-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 11-04-02 10:39 PM, Jane Shevtsov wrote: > I have data in matrix form from a parameter scan of a food web > simulation. (The matrix entry M[i,j] gives the variable of interest > for a web size i and connectance j.) How would I find an equation > expressing the variable of interest to web size and connectance? Can > lm() do it? > > Thanks, > Jane Shevtsov >
suppose your size and connectance vectors were sizevec and connvec. Then something like dimnames(M) <- list(sizevec,connvec) library(reshape) X <- melt(M) lm(value~X1+X2) will do it. Mini example: > z <- matrix(1:9,nrow=3,dimnames=list(1:3,4:6)) > library(reshape) Loading required package: plyr Attaching package: 'reshape' The following object(s) are masked from 'package:plyr': round_any > str(melt(z)) 'data.frame': 9 obs. of 3 variables: $ X1 : int 1 2 3 1 2 3 1 2 3 $ X2 : int 4 4 4 5 5 5 6 6 6 $ value: int 1 2 3 4 5 6 7 8 9 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2Y90MACgkQc5UpGjwzenOmPQCdFAOGcxnzADXZNv9ikgDzJcPQ 3/IAn1ayn1HVOQOdlqFDPoq+Et6rR5nt =cfIQ -----END PGP SIGNATURE----- _______________________________________________ R-sig-ecology mailing list R-sig-ecology@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology