R Apply() function on specific dataframe columns

后端 未结 4 1356
有刺的猬
有刺的猬 2020-11-28 03:00

I want to use the apply function on a dataframe, but only apply the function to the last 5 columns.

B<- by(wifi,(wifi$Room),FUN=function(y){apply(y, 2, A)         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-11-28 03:18

    I think what you want is mapply. You could apply the function to all columns, and then just drop the columns you don't want. However, if you are applying different functions to different columns, it seems likely what you want is mutate, from the dplyr package.

提交回复
热议问题