holki659@student.otago.ac.nz
2002-May-29 05:17 UTC
[R] Coercion/conversion of logical index to integer index
Hi all, This question has significant potential to be a stupid one, but as I could find no hints in the manual or previous posts: If you have a logical index X:>X[1] TRUE FALSE TRUE TRUE FALSE And you want an equivalent integer index Y:>Y[1] 1 3 4 Is there no easy way? (I'm thinking of the equivalent of FIND in Matlab) Kieran -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian D Ripley
2002-May-29 06:47 UTC
[R] Coercion/conversion of logical index to integer index
On Wed, 29 May 2002 holki659 at student.otago.ac.nz wrote:> > Hi all, > > This question has significant potential to be a stupid one, but as I could find no hints in > the manual or previous posts: > > If you have a logical index X: > > >X > [1] TRUE FALSE TRUE TRUE FALSE > > And you want an equivalent integer index Y: > > >Y > [1] 1 3 4 > > Is there no easy way? (I'm thinking of the equivalent of FIND in Matlab)seq(along=X)[X] is easy enough, and which(X) is even easier (to use, if unnecessarily complex here). -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, I used the lm() function to fit a linear model to a set of items that I got from a file using the read.table() function. The response variable in this case is non-numeric. When I used some of the data in the same file and tried to predict the response variable for the first 5 rows by doing:> pred <- predict(model, newdata) > pred1 2 3 4 5 37.890006 82.584161 30.794062 3.796456 41.568923 The predictions should have been those non-numeric values that were in the response variable field when I fitted the model. Now I want to compare and see if the predictions are correct. Can someone tell me how to extract those non-numeric values from this. Thanks in advance. -Saket. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._