Try this: DF <- data.frame(start=1:5,end=10:6) # apply(DF,1,function(row){ return(row$start + row$end) })
DF$start + DF$end apply(DF, 1, function(row) row[["start"]] + row[["end"]]) apply(DF, 1, function(row) row["start"] + row["end"]) On 8/9/07, Ido M. Tamir <[EMAIL PROTECTED]> wrote: > Dear All, > > I would like to know why $ was deprecated for atomic vectors and > what I can use instead. > > I got used to the following idiom for working with > data frames: > > df <- data.frame(start=1:5,end=10:6) > apply(df,1,function(row){ return(row$start + row$end) }) > > I have a data.frame with named columns and > use each row to do something. I would like the > named index ($) because the column position > in the data frame changes from time to time. > The data frame is read from files. > > thank you very much, > > ido > > > > > '$' returns 'NULL' (with a warning) except for recursive > objects, and is only discussed in the section below on recursive > objects. Its use on non-recursive objects was deprecated in R > 2.5.0. > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.