Re: [R] lapply with data frame

2010-02-28 Thread Bill.Venables
below! From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of bill.venab...@csiro.au [bill.venab...@csiro.au] Sent: 01 March 2010 17:18 To: n...@smartmediacorp.com; r-help@r-project.org Subject: [ExternalEmail] Re: [R] lapply with data frame Data frames are

Re: [R] lapply with data frame

2010-02-28 Thread Bill.Venables
Data frames are lists. Each column of the data frame is a component of the list. So in, e.g. lapply(data, function(x) x) the function would receive each column of the data frame in turn. To apply a function to each row of the data frame (which may need some care) one tool you can use is ap

Re: [R] lapply with data frame

2010-02-27 Thread jim holtman
> x <- read.table(textConnection("idgroupvalue + 1A3.2 + 2A3.0 + 3A3.1 + 4B5.5 + 5B6.0 + 6B6.2"), header=TRUE) > # dataframe is processed by column by lapply > lapply(x, c) $id [1] 1 2 3 4 5 6 $

Re: [R] lapply with data frame

2010-02-27 Thread David Winsemius
On Feb 27, 2010, at 9:49 PM, Noah Silverman wrote: I'm a bit confused on how to use lapply with a data.frame. For example. lapply(data, function(x) print(x)) WHAT exactly is passed to the function. Is it each ROW in the data frame, No. one by one, or each column, Yes. Dataframes are