Re: [R] how to read data from table based a condition

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Thu, 10 Apr 2008 11:23:13 +0200

Xin wrote:
> Dear All:
>
> I imported a table into R. But I want to read a variable (y) from this table conditional on another variable (x=1) in the table.
>
> y<-data[,7]
> x<-data[,3]
>
> I want to know the mean of y if corresponding x=1.
>
> I tried
>
> if (x==1) y3<-y
>
> It does not work.
>
> Anyone can give a help?

Is this homework?
Please do read the posting guide and An Introduction to R!

Uwe Ligges

 > Thanks!
>
>
> Xin
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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.



R-help_at_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. Received on Thu 10 Apr 2008 - 09:29:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Apr 2008 - 09:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive