Skip to content
Prev 75809 / 398502 Next

do glm with two data sets

Thanks for your help.

# read the two data sets
e <- as.matrix(read.table("file1.txt", header=TRUE,row.names=1))
g <- as.matrix(read.table("file2.txt", header=TRUE,row.names=1))

# solution 
d1<-data.frame(g[1,], e[1,])
fit<-glm(e[1,] ~ g[1,], data=d1)
summary(fit)

I am not sure that is the best solution.

Thanks again,

Ying
 

-----Original Message-----
From: Gavin Simpson [mailto:gavin.simpson at ucl.ac.uk] 
Sent: Wednesday, August 17, 2005 7:01 PM
To: Sundar Dorai-Raj
Cc: Hu, Ying (NIH/NCI); r-help at stat.math.ethz.ch
Subject: Re: [R] do glm with two data sets
On Wed, 2005-08-17 at 17:22 -0500, Sundar Dorai-Raj wrote:
Hi Ying,

That error message is likely caused by having a data.frame on the right
hand side (rhs) of the formula. You can't have a data.frame on the rhs
of a formula and g1 is still a data frame even if you only choose the
first row, e.g.:

dat <- as.data.frame(matrix(100, 10, 10))
class(dat[1, ])
[1] "data.frame"

You could try:

glm(e1 ~ ., data=g1[1, ])

and see if that works, but as Sundar notes, your post is a little
difficult to follow, so this may not do what you were trying to achieve.

HTH

Gav
http://www.R-project.org/posting-guide.html