Hi i am trying to do this but in a vast data frame with hundreds of columns is there a more concise was of doing this method: df[,c(1,2,3,4,etc)] i need to write code for column 1-413 then 413- something else so it is just a range and not an assortment like [,c(1,2,5)] thanks
We can use :
instead of -
subdf <- df[2:414]
If we need the rowwise median
apply(subdf, 1, median, na.rm = TRUE)
Or with matrixStats
library(matrixStats)
rowMedians(as.matrix(subdf), na.rm = TRUE)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.