Thank you so much Josh, that's exactly what i needed!
Cheers
alb
--
View this message in context:
http://r.789695.n4.nabble.com/conditional-mean-between-two-data-frames-with-different-levels-tp3049010p3049980.html
Sent from the R help mailing list archive at Nabble.com.
Hi Alberto,
This should do it. 'x' is equivalent to your alfa vector.
Cheers,
Josh
## your example data, in a form R can read
dat1 <- data.frame(score = c(1, 2, 0, 2, 1, 1, 3, 2, 1, 0),
teams = c("a", "b", "c", "d", "e", "a", "b", "c", "d", "e"))
dat2 <- data.frame(score = c(2, 3, 1, 0, 0,
Thank you very much Josh, I guess you`re right.
So this is an example:
data frame 1 has 2 columns and 10 rows. The first column is "score" a
variable indicating the number of goals scored by a football team
score<-c(1,2,0,2,1,1,3,2,1,0), column 2 contains the football "teams " where
teams<-c(a,b,c
Hi Alberto,
It would help if you could provide a small example. I might break the
problem down into three parts: 1) create a vector that has the final
subgroupings you want 2) find the conditional means by subgroup 3)
replicate the means as needed. My first guess would be start with:
"==" or
Hi guys, I have two data frames: one referred to 2008 and one to 2009. Their
structure is identical except for the different data in them.
I need to create a vector alfa of the same length of the dataframe 2009 and
fill each element with the mean of 2008$var1 conditional to the subgroup
indicated
5 matches
Mail list logo