rowwise

    0熱度

    1回答

    行假設你有這樣的data.frame: df <- data.frame(matrix(1:12, 4)) df X1 X2 X3 1 1 5 9 2 2 6 10 3 3 7 11 4 4 8 12 必須由這些列索引被過濾行方式: b=c(2,1,3,2) 所以期望輸出應該是這樣的: c(5, 2, 11, 8) 顯然,使用下面的方法並不是解決方案。 df[ 1:

    -1熱度

    1回答

    我在做矩陣計算時遇到了問題,請您注意一下。 非常感謝您提前! 我有一個數據幀genderLocation和矩陣測試,它們彼此對應與索引 genderLocation [1:6] scanner_gender cmall_gender wechat_gender scanner_location cmall_location wechat_location 156043 3

    0熱度

    1回答

    我想使用dplyr的rowwise()和管道將函數(返回一個列表)應用到數據框中的每一行。 測試數據集分爲兩行: test_tbl <- tibble(a=c(2, 4), b=c(0, 8), c=c(5, -3)) 定義一個簡單的函數(它是關於函數返回一個列表,顯然不是增加8): simple_function <- function(input) { list(input +