[R] Add function to each row excluding certain columns

laro l_rohner at gmx.ch
Thu Oct 10 00:31:52 CEST 2013


Thank you again! But somehow the which(function) didn't work...
The problem is, that the columns I want to drop in further calculations will
not have the same name, that's why I'm looking for a solution to make a
vector of the columns that should be omitted, like

omit<-c("Restriction 1","Restriction 2")

and then simple add the function max to the rows, withour the listed columns
in omit (I know this doesn't work, but something like this)

example1New <- cbind(example1, `MAX without
Restriction`=apply(example1[,-omit],1,max,na.rm=TRUE))

Is there any way?

Kind regards



--
View this message in context: http://r.789695.n4.nabble.com/Add-function-to-each-row-excluding-certain-columns-tp4677914p4677934.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list