An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100427/f2a70533/attachment.pl>
data frame
2 messages · n.vialma at libero.it, Ista Zahn
Here is one way, using the reshape package:
library(reshape)
Dat <- read.table(textConnection("variable YEAR VAR
EC01 2006 100
EC01 2007 200
EC02 2006 500
EC02 2007 450
PROD 2006 567
PROD 2007 543"), header=TRUE)
closeAllConnections()
c.Dat1 <- as.data.frame(cast(Dat, YEAR ~ variable, value = "VAR"))
m.Dat <- melt(c.Dat1, measure.vars = c("EC01", "EC02"))
m.Dat$value/m.Dat$PROD
-Ista
On Tue, Apr 27, 2010 at 8:04 AM, n.vialma at libero.it <n.vialma at libero.it> wrote:
Dear list, I have a big data frame which looks like this: variable ? ? ? ? ? ? ? ? YEAR ? ? ? ? ? ? ? ? ? ? ? ? ?VAR EC01 ? ? ? ? ? ? ? ? ? ? ?2006 ? ? ? ? ? ? ? ? ? ? ? ? ? ? 100 EC01 ? ? ? ? ? ? ? ? ? ? ?2007 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?200 EC02 ? ? ? ? ? ? ? ? ? ? ? 2006 ? ? ? ? ? ? ? ? ? ? ? ? ? ? 500 EC02 ? ? ? ? ? ? ? ? ? ? ? 2007 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?450 PROD ? ? ? ? ? ? ? ? ? ? ? 2006 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?567 PROD ? ? ? ? ? ? ? ? ? ? ? 2007 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?543 What I would like to do is to divide each variables by PROD,namely: EC01(2006)/PROD(2006) EC01(2007)/PROD(2007) EC02(2006)/PROD(2006) EC02(2007)/PROD(2007) Anyone knows how to do it?? THANKS!!! ? ? ? ?[[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.
Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org