On Tue, 2009-08-04 at 23:42 +0530, Meenu Sahi wrote: > Dear R Users > > I'm writing my first simulation in R. > I've put across my problems with a smaller example in the attachment along > with the questions.
Q1 - mydat4[, 1:2] is not a matrix! It is a data.frame. > class(mydat4[, 1:2]) [1] "data.frame" > is.matrix(mydat4[, 1:2]) [1] FALSE ?diff is explicit about 'x' needing to be a numeric vector or a matrix. Cast mydat4[, 1:2] as a matrix and it will work: > diff(as.matrix(mydat4[,1:2]),1) Level spread 3 0.27 2.27 6 0.15 0.01 8 0.58 -2.15 9 0.48 1.43 81 -0.48 -1.43 91 0.48 1.43 2 0.17 0.26 10 0.95 -2.38 1 -0.83 1.94 11 0.32 -1.36 HTH G > > Please help. > > Best regards > Meenu > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
signature.asc
Description: This is a digitally signed message part
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.