ggplot2 - Plot summarized data using qplot in R -


i cross-classify , plot bal using qplot facets:

> str(bal) 'data.frame':   2096 obs. of  6 variables:  $ fips     : chr  "24510" "24510" "24510" "24510" ...  $ scc      : chr  "10100601" "10200601" "10200602" "30100699" ...  $ pollutant: chr  "pm25-pri" "pm25-pri" "pm25-pri" "pm25-pri" ...  $ emissions: num  6.53 78.88 0.92 10.38 10.86 ...  $ type     : chr  "point" "point" "point" "point" ...  $ year     : int  1999 1999 1999 1999 1999 1999 1999 1999 1999 1999 ... 

i'm interested in 2 classifiers year , type:

> levels(factor(bal$year)) [1] "1999" "2002" "2005" "2008" > levels(factor(bal$type)) [1] "non-road" "nonpoint" "on-road"  "point"    

i far, can plot distribution of emissions cross-classified year , type: enter image description here i'm unable plot sum of distributions of each year, able compute:

> tapply(bal$emissions, list(bal$year, bal$type), sum)       non-road nonpoint   on-road     point 1999 522.94000 2107.625 346.82000  296.7950 2002 240.84692 1509.500 134.30882  569.2600 2005 248.93369 1509.500 130.43038 1202.4900 2008  55.82356 1373.207  88.27546  344.9752 

my guess along lines of

> qplot(bal$year, tapply(bal$emissions, list(bal$year, bal$type), sum),          data=bal, facets= . ~ type) error: aesthetics must either length one, or same length dataproblems:tapply(bal$emissions, list(bal$year, bal$type), sum) 

but dont r telling me there.

how can plot matrix using qplot?

you dan using ggplot either

qplot(year, emissions, data=bal,      stat="summary", fun.y="sum",     facets= .~type ) 

or

ggplot(bal) +     aes(year, emissions) +     stat_summary(fun.y="sum",geom="point") +      facet_grid(.~type) 

both should give following plot seems match summary data.

plot summarized data


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -