[R] Help summarizing R data frame

2010-12-02 Thread chris99

I am trying to aggregate data in column 2 to identifiers in col 1

eg..

take this>

identifier   quantity
1 10
1 20
2 30
1 15
2 10
3 20

and make this>

identifier quantity
145
240
320


Thanks in advance for your help!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Help-summarizing-R-data-frame-tp3069624p3069624.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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] Reorganizing Data Frame

2011-01-18 Thread chris99

Hi I need some help trying to restructure a data frame:

I have:
foodtransaction quantity
pizza BUY  5
pizza SELL  3
apple BUY  2
orange   SELL  1
pizza BUY   2


And the data frame I want to make is:

foodBUY  SELL
pizza 7 3
apple 2 0
orange   0 1



I can't figure out the commands to use. Can anyone help?
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Reorganizing-Data-Frame-tp3223863p3223863.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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] Reorganize data frame

2011-03-16 Thread chris99
Hi group,

I am trying to convert the organization of a data frame so I can do some
correlations between stocks,

I have something like this:

stock.returns <-
data.frame(rbind(c("MSFT","20110301",0.05),c("MSFT","20110302",0.01),c("GOOG","20110301",-0.01),c("GOOG","20110302",0.04)))
colnames(stock.returns) <- c("Ticker","Date","Return")
stock.returns
  Ticker Date Return
1   MSFT 20110301   0.05
2   MSFT 20110302   0.01
3   GOOG 20110301  -0.01
4   GOOG 20110302   0.04


And want to convert it to this:

stock.returns <-
data.frame(rbind(c("20110301",0.05,-0.01),c("20110302",0.01,0.04)))
colnames(stock.returns) <- c("Date","MSFT","GOOG")
stock.returns
  Date MSFT  GOOG
1 20110301 0.05 -0.01
2 20110302 0.01  0.04


Can anyone offer any suggestions?

Thanks,
Chris

--
View this message in context: 
http://r.789695.n4.nabble.com/Reorganize-data-frame-tp3381929p3381929.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.