[R] lapply and list indexing basics (after realizing I wasn't previously subscribed...sorry)

2010-03-07 Thread Simon Knapp
library(MASS) dat <- data.frame( col1=as.factor(sample(1:4, 100, T)), col2=as.factor(sample(1:4, 100, T)), col3=as.factor(sample(1:4, 100, T)), isi=rnorm(100) ) dat <- split(dat, as.factor(sample(1:3, 100, T))) lapply(dat, function(x, densfun) fitdistr(x$isi, densfun), 'normal')

Re: [R] lapply and list indexing basics

2010-03-07 Thread jim holtman
It would have been nice if you had at least posted what the structure of myList is. Assuming that this is the list of your data frames, then the following might work: lapply(myList, function(x) fitdistr(x$isi, densfun='gamma',start=list(scale=1, shape=2))) On Sun, Mar 7, 2010 at 7:30 PM, Dgnn

[R] lapply and list indexing basics

2010-03-07 Thread Dgnn
I have split my original dataframe to generate a list of dataframes each of which has 3 columns of factors and a 4th column of numeric data. I would like to use lapply to apply the fitdistr() function to only the 4th column (x$isi) of the dataframes in the list. Is there a way to do this or am I

[R] lapply and list indexing basics (after realizing I wasn't previously subscribed...sorry)

2010-03-07 Thread Dgnn
I have split my original dataframe to generate a list of dataframes each of which has 3 columns of factors and a 4th column of numeric data. I would like to use lapply to apply the fitdistr() function to only the 4th column (x$isi) of the dataframes in the list. Is there a way to do this or am