apply

    6熱度

    1回答

    這裏有一個數據幀: A B C 0 6 2 -5 1 2 5 2 2 10 3 1 3 -5 2 8 4 3 6 2 我可以檢索一列基本上是從原來的df使用df.apply列的元組: out = df.apply(tuple, 1) print(out) 0 (6, 2, -5) 1 (2, 5, 2) 2 (10, 3, 1) 3 (-5, 2, 8) 4 (3,

    1熱度

    2回答

    我寫了下面的代碼來每天從門戶網站中取消招標信息。 packages <- c('rvest', 'stringi', 'tidyverse','lubridate','dplyr') purrr::walk(packages, library, character.only = TRUE, warn.conflicts = FALSE) start_time <- proc.time()

    2熱度

    1回答

    通過R,我可以很容易地從字符串列表中創建一個包含某些字符串模式的頻率的數據幀。 library(stringr) library(tm) library(dplyr) text = c('i am so hhappy happy now','you look ssad','sad day today','noway') dat = sapply(c('happy', 'sad'), fu

    1熱度

    1回答

    我有一個data.frame有2個因素;一個叫做kernel_type(有三個級別:b,e和p)和一個叫做group_by_var(有三個級別:tw,fif,sev)。數據集的第一列稱爲levels_together幷包含數字。 我有第二個data.frame具有相同的結構,在levels_together列中有不同的數字。 他們看起來像這樣: levels_together group_by_v

    0熱度

    1回答

    我有類似這樣的很多tibbles的: dftest_tw <- structure(list(text = c("RT @BitMEXdotcom: A new high: US$500M turnover in the last 24 hours, over 80% of it on $XBTUSD. Congrats to the team and thank you to our u…",

    0熱度

    1回答

    我可以理解爲什麼要使用呼叫,並在下面的例子適用: myObject = { name: "shafizzle", sayName: function() { console.log(this.name) } }; myObject.sayName(); anotherObject = { name: "not me" } myObject.sayName.call (anotherO

    0熱度

    2回答

    我有一個文本向量與已註冊的藥物名稱,另一個與新葯名稱。我想知道新葯是否看起​​來像現有的藥物。 例如,如果supercure是可以由firm1或firm2生產的藥物,並且supercure firm1 1000mg和supercure firm2 500mg已經註冊,那麼supercure firm1 500 mg應該與它們兩者相關聯。 agrep允許R中做這樣的匹配,並sapply允許這樣做對每

    0熱度

    8回答

    我有HTML頁面,其中div和按鈕從JavaScript動態生成,如下所示。 <div style="background: rgb(247, 247, 247);"> <button class ="xyz" disabled="disabled">Button1</button> </div> <div style="background: rgb(247, 247, 247);

    0熱度

    1回答

    我使用lapply函數調用Spotify的API。我有一列albumids,我想從每個albumid中檢索曲目名稱。我這樣做的方式是將albumid分隔成一個字符向量,然後運行並使用lapply函數調用字符向量中的每個值。這個問題是我不能把它放回原始數據框。 下面是一個例子: 我有一個數據幀,看起來像這樣: spotify<-df$`Album IDs` : df Artist

    -1熱度

    1回答

    我有一個DF,看起來像這樣 COL1 COL2 COL3 0 ABC N [{u'PERF_PCT': 0.2,u'PERF_DATE': 12},{u'PERF_PCT': 0.3,u'PERF_DATE': 13}] 1 XYZ N [{u'PERF_PCT': 0.6,u'PERF_DATE': 12},{u'PERF_PCT': 0.2,u'PERF_