[R] Lists and functions in data.frame?
Rainer M Krug
r.m.krug at gmail.com
Wed Dec 8 11:08:34 CET 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi
I would like to have a data.frame, where one column contains functions,
and another one lists. i.e.:
FUN <- function(l) {return(l$a+l$b+l$c}
LIST <- list(a=1, b=2, c=3)
d <- data.frame(fun=FUN, no=LIST, value=2, b=TRUE)
FUN <- function(l) {return(l$a*l$b*l$c}
LIST <- list(a=4, b=5, c=6)
d <- rbind(d, data.frame(fun=FUN, no=LIST, value=2, b=FALSE)
I would like
d$FUN[1](d$l[1] == 6
to be TRUE
I want to use it to save a parameterset for a simulation model, which
consists of functions, lists, and vectors of different length.
Is this possible?
Cheers,
Rainer
- --
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Natural Sciences Building
Office Suite 2039
Stellenbosch University
Main Campus, Merriman Avenue
Stellenbosch
South Africa
Tel: +33 - (0)9 53 10 27 44
Cell: +27 - (0)8 39 47 90 42
Fax (SA): +27 - (0)8 65 16 27 82
Fax (D) : +49 - (0)3 21 21 25 22 44
Fax (FR): +33 - (0)9 58 10 27 44
email: Rainer at krugs.de
Skype: RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkz/WSIACgkQoYgNqgF2egocEwCeIErcuxDxVa8RFs1SlWiY/hQp
T84An1XAtE3tFNKajBnGQngTig4srlIb
=6AG3
-----END PGP SIGNATURE-----
More information about the R-help
mailing list