0

I'm a relatively new user of R I have a data frame "Lossl" as follows:

'data.frame':   100 obs. of  18 variables:
 $ plot      : chr  "3" "1" "5" "1" ...
 $ day       : Factor w/ 3 levels "0","218","365": 1 1 1 1 1 1 1 1 2 2 ...
 $ ID        : chr  "A014" "A047" "A110" "A125" ...
 $ type      : chr  "litter" "litter" "litter" "litter" ...
 $ species   : Factor w/ 4 levels "birch leaves",..: 2 3 1 3 4 1 4 2 2 2 ...
 $ treat     : Factor w/ 2 levels "char","control": 2 2 2 1 2 1 1 1 2 2 ...
 $ inimass   : num  4.02 4 4.02 4 4.02 4 4.02 4 4.01 4.02 ...
 $ inichar   : num  0 0 0 0 0 0 0 0 0 0 ...
 $ fresh.mass: num  4.02 4 4.02 4 4.02 4 4.02 4 4.62 4.46 ...
 $ rem_g     : num  4.02 4 4.02 4 4.02 4 4.02 4 3.45 3.55 ...
 $ rem       : num  100 100 100 100 100 ...
 $ W         : num  0 0 0 0 0 ...
 $ Cot       : num  NA NA NA NA NA ... 

I'm trying to create barplot with facets by factor 'day.'

ggplot(data=Lossr, aes(x=species, y=W)) +coord_cartesian(ylim=c(0,80)) +
 scale_colour_manual(values=c("black", "3"))+
 stat_summary(fun = mean, geom = 'bar', aes(fill=treat), colour='black', width=0.5, position=position_dodge(0.6)) + 
scale_fill_manual(values=c("grey", "green")) +
 stat_summary(fun.data = mean_se, geom = 'errorbar', width=0.5, position=position_dodge(0.6), aes(fill=treat)) + 
facet_wrap(. ~day) + theme_bw()

The result is

barplot with facets

So I wish to exclude "0" which is level 1 from factor "day", if I do as follows:

ggplot(data=Lossr, aes(x=species, y=W)) +coord_cartesian(ylim=c(0,80)) + scale_colour_manual(values=c("black", "3"))+ 
stat_summary(fun = mean, geom = 'bar', aes(fill=treat), colour='black', width=0.5, position=position_dodge(0.6)) + 
scale_fill_manual(values=c("grey", "green")) + 
stat_summary(fun.data = mean_se, geom = 'errorbar', width=0.5, position=position_dodge(0.6), aes(fill=treat)) + 
facet_wrap(~day==c("218", "365")) + theme_bw()

barplot with facets but lables

This is levels of factor which I need, but labels turned to logical true and false rather than days I had on the previous figure. Could someone help me to fix this problem with labels? Thank you.

teunbrand
  • 33,645
  • 4
  • 37
  • 63

0 Answers0