[R] Select a group of data from a file
Jeremy Baxter
J.Baxter at ru.ac.za
Fri Jan 18 09:53:35 CET 2008
Try subset.
help(subset)
Subset returns a subsets of vectors, matrices or data frames which meet
conditions. There are some excellent examples in the help. Here is an example
similar to your email.
Create some data:
Var1<-sample(1:10,20,replace=TRUE)
Var2<-sample(1:10,20,replace=TRUE)
the.old.data<-cbind(Var1,Var2)
head(the.old.data)
Var1 Var2
[1,] 8 10
[2,] 1 10
the.new.data <- subset(the.old.data, Var2==1)
the.new.data
HTH,
Jeremy
On Friday 18 January 2008 10:33:51 LA SPINA, MICHELANGELO wrote:
> I've a file with several data six variables, three quantitative and three
> qualitative, I would like to select a group of data from the file to
> analyze then, i.e: my file is like that (but with 6 variables):
>
> Var1 Var2
> 2 1
> 5 1
> 8 1
> 7 2
> 3 2
> 8 2
>
> I want to use only the data where var2 is "1"
--
Jeremy Baxter, Statistics Department, Rhodes University, South Africa.
Views expressed above, no matter how badly spelt, are my own... I think?
More information about the R-help
mailing list