graph - Graphing in R - combining factors -


this odd request, don't know if function exist, hoping there might be. basically, have number of variables i'm looking @ give outcome , typical data below

sample   daylength  expt   line    protein  1            ld      l      k        100 2            sd      s      r        150 3            ld      l      r        200 4            sd      s      k        120 5            ld      l      k        95 6            sd      s      r        160 7            ld      l      r        195 8            sd      s      k        130 

so have 3 dependant variables (daylength, expt, line) , 1 outcome variable of protein. however, i'd looking @ in graph comparing protein levels showing bars l , s experiments

an example of code use draw bar graph ggplot2 is:

ggplot(data=results, aes(x=daylength, y=protein, fill=line)) + geom_bar(stat="identity", position=position_dodge()) 

and give me graph showing results ld , sd experiments lines offering separate series. however, not account third factor, expt.

ordinarily in excel able manipulate table give results ld/l, ld/s, sd/l , sd/s being separate headings , create graph using them x factors, can arduous, if i'm going rewrite table, save , run in r each time. looking see if there simple enough method either manipulate table in r group below few commands or combine 2 factors draw graph directly each time, because in cases may interested in combining different factors.

sample   daylength/expt   line    protein  1            ld/l          k        100 2            sd/s          r        150 3            ld/l          r        200 4            sd/s          k        120 5            ld/l          k        95 6            sd/s          r        160 7            ld/l          r        195 8            sd/s          k        130 

you can use interaction operator : on factors:

library(ggplot2) head(co2) # using builtin data #  plant   type  treatment conc uptake #1   qn1 quebec nonchilled   95   16.0 #2   qn1 quebec nonchilled  175   30.4 #3   qn1 quebec nonchilled  250   34.8 #4   qn1 quebec nonchilled  350   37.2 #5   qn1 quebec nonchilled  500   35.3 #6   qn1 quebec nonchilled  675   39.2 qplot(conc, uptake, color=type:treatment, data=co2) 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -