K Fernandes
2005-Jan-19 23:14 UTC
[R] How to filter information from a table into a new table
Hello, Say I have a table T as follows A b 1 2 1 3 2 2 2 3 ...etc. And I would like create a table C from this existing table T, but only including rows where A=1. How might I do this? Thanks, K - please reply to kafernan@uwaterloo.ca as well as I am on the digest version :) [[alternative HTML version deleted]]
Mulholland, Tom
2005-Jan-20 01:06 UTC
[R] How to filter information from a table into a new table
temp <- table(rpois(100,5),rpois(100,1)) temp temp[temp[,1] > 1,] temp[temp[,1] == 1,] temp[temp[,1] == 2,] temp[temp[,1] == 3,] Of course you have not made it obvious if you are using the term table to mean any output that looks like a table, but in general terms you will find information in the documentation that comes with R, such as "An Introduction to R." In your case anything.you.like <- T[T[,1] == 1,] Tom> -----Original Message----- > From: K Fernandes [mailto:kafernan at uwaterloo.ca] > Sent: Thursday, 20 January 2005 7:15 AM > To: r-help at stat.math.ethz.ch > Subject: [R] How to filter information from a table into a new table > > > Hello, > > > > Say I have a table T as follows > > > > A b > > 1 2 > > 1 3 > > 2 2 > > 2 3 > > ...etc. > > > > And I would like create a table C from this existing table T, but only > including rows where A=1. > > > > How might I do this? > > > > Thanks, > > > > K - please reply to kafernan at uwaterloo.ca as well as I am on > the digest > version :) > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
Hello, I would like to use lm to model the equation y=x^2. However, when I use z<-lm(formula=y~x^2) summary(z) I obtain results that are equivalent to when I use z<-lm(formula=y~x) summary(z) That is, using x instead of x^2. However, I do get different results when I use z<-lm(formula=y~log(x)) summary(z) Does anyone know why this might be the case? Any ideas are appreciated. Thank you, K
On Wed, 19 Jan 2005 21:20:22 -0500 K Fernandes wrote:> Hello, > I would like to use lm to model the equation y=x^2. > > However, when I use > > z<-lm(formula=y~x^2) > summary(z) > > I obtain results that are equivalent to when I use > > z<-lm(formula=y~x) > summary(z)In formulas "^" specifies interactions. "^2" selects all second order interactions from the preceeding term. If you want the arithmetic function "^" you have to insulate the term in I(), i.e., try to fit lm(y ~ I(x^2)) See ?formula for more details. Z> That is, using x instead of x^2. > > However, I do get different results when I use > > z<-lm(formula=y~log(x)) > summary(z) > > Does anyone know why this might be the case? Any ideas are > appreciated. > > Thank you, > K > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >
K Fernandes
2005-Jan-21 01:51 UTC
[R] Plotting points from two vectors onto the same graph
Hello, I have three vectors defined as follows:> x<-c(10,20,30,40,50) > y1<-c(154,143,147,140,148) > y2<-c(178,178,171,188,180)I would like to plot y1 vs x and y2 vs x on the same graph. How might I do this? I have looked through a help file on plots but could not find the answer to plotting multiple plots on the same graph. Thank you for your help, K