Hi,
Try:
dat <- read.table(text="ID ONE TWO THREE
1 2 5 7
2 6 NA NA
3 5 7 NA
4 1 NA NA",sep="",header=TRUE)
dat1 <- dat
#Either:
dat$MAX <- apply(dat[,-1],1,max,na.rm=TRUE)
#or
dat1$MAX <- do.call('pmax',c(dat1[,2:4],list(na.rm=TRUE))
Thanks for the help.
problem is solved. :-)
--
View this message in context:
http://r.789695.n4.nabble.com/find-max-value-in-different-columns-tp4685905p4685912.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.org ma
February 27, 2014 8:06 AM
> To: r-help@r-project.org
> Subject: [R] find max value in different columns
>
> Hello together,
>
> i have a data.frame like this one:
>
> IDONE TWO THREE
> 1 2 57
> 2 6 NA NA
> 3 5 7
Hello together,
i have a data.frame like this one:
IDONE TWO THREE
1 2 57
2 6 NA NA
3 5 7NA
4 1 NA NA
Now i want a new column with the max-Value of "ONE", "TWO" and THREE. The
result look like this one:
IDONE TWO
4 matches
Mail list logo