[R] lapply and list indexing basics

Dgnn sharkbrainpdx at gmail.com
Mon Mar 8 01:30:10 CET 2010


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 misusing lapply?

As a second solution I tried splitting only the numeric data column to yield
a list of vectors and then using
lapply(myList, fitdistr, densfun='gamma',start=list(scale=1, shape=2)) 
returns the error:
Error in optim(x = c(305, 290, 283, 363, 331, 293, 304, 312, 286, 339,  : 
non-finite finite-difference value [2]
In addition: Warning message:
In dgamma(x, shape, scale, log) : NaNs produced

However, if I use fitdistr(myList[[i]]) on each element of the list, there
are no errors.

Thanks in advance for any comments.

-jason
-- 
View this message in context: http://n4.nabble.com/lapply-and-list-indexing-basics-tp1584006p1584006.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list