[R] lapply and list indexing basics (after realizing I wasn't previously subscribed...sorry)
Dgnn
sharkbrainpdx at gmail.com
Mon Mar 8 03:29:06 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-after-realizing-I-wasn-t-previously-subscribed-sorry-tp1584053p1584053.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list