如何在R中按列添加数据帧子集中的所有记录?
如何在数据帧中保留所有未使用的列的同时,获得test1到test57行中所有列的值之和 它将仅使用数值对所有行求和如何在R中按列添加数据帧子集中的所有记录?,r,dataframe,R,Dataframe,如何在数据帧中保留所有未使用的列的同时,获得test1到test57行中所有列的值之和 它将仅使用数值对所有行求和 Participant ID Test1 Test2 Test3 Test4 Test5 Test6 Test7 ... Test57 ParticipantA asd 2 4 2 3 2 3 4 7 ParticipantB sxa 1 3 2 2
Participant ID Test1 Test2 Test3 Test4 Test5 Test6 Test7 ... Test57
ParticipantA asd 2 4 2 3 2 3 4 7
ParticipantB sxa 1 3 2 2 3 3 3 8
ParticipantC agff 1 4 4 2 3 4 2 9
ParticipantD asx 2 4 2 3 2 4 4 4
ParticipantE axp 3 2 2 2 2 2 3 96
df$Sum使用rowSums
df$Sum <- rowSums(df[sapply(df, is.numeric)], na.rm = TRUE)