0
votes

I want to show change in biomass within certain time period. In each graph there will be two lines i.e of wet biomass and dry biomass. I want to make three separate graphs for each treatment.

The weeding0, 1 and 2 are the treatments. The date refers to the time they were placed in the research site. So June-July means that the samples were installed on June and was retrieved in July. I tried to plot a simple ggplot graph but didnt get any lines in the graph.

ggplot(data=data) + geom_line(aes(y = Weeding1, x = Date_1, colour = State))

Example data

Weeding1    State   Date    Weeding2    State   Date    Weeding0    State   Date
5.65         Wet    June-July   5.4     Wet   June-July 5.5         Wet June-July
4.88         Dry    June-July   4.73    Dry   June-July 4.7         Dry June-July
5.38         Wet    June-sept   5.25    Wet   June-sept 5.05        Wet June-sept
3.93         Dry    June-sept   3.9     Dry   June-sept 3.78        Dry June-sept
5.5          Wet    July-sept   5.5     Wet   July-sept 5.33        Wet July-sept 
4.43         Dry    July-sept   4.35    Dry   July-sept 4.13       Dry  July-sept
7.03         Wet    July-oct    6.46    Wet   July-oct  6.77       Wet  July-oct  
5.06         Dry    July-oct    5.27    Dry   July-oct  5.2         Dry July-oct
6.31         Wet    June-oct    4       Wet   June-oct  4.86        Wet June-oct
3.24         Dry    June-oct    3.07    Dry   June-oct  3.11        Dry June-oct

Thank you for your time

Edit

I rearranged my data

Date(weeding1)  Wet Dry
July        5.65    4.88
June        20      7.11
September   5.38    3.93
October     6.31    3.24


ggplot(Litter1, aes(x = Date))+ geom_point(aes(y = Wet, colour = "Wet"))+ geom_point(aes(y = Dry, colour = "Dry"))

With this I got point but even if I add +geom_line() in the end I am not getting the line. Thanks

I got it with this.

 ggplot(Litter1, aes(x = Date,group=1))+ geom_point(aes(y = Wet, colour = "Wet"))+ geom_point(aes(y = Dry, colour = "Dry"))

My code for DUMBELL

df <- structure(list(State = structure(c(2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L), .Label = c("Dry", "Wet"), class = "factor"), Date = structure(c(3L, 3L, 5L, 5L, 4L, 4L, 3L, 3L, 5L, 5L, 4L, 4L, 3L, 3L, 5L, 5L, 4L, 4L), .Label = c("July-oct", "July-sept", "June-July", "June-oct", "June-sept"), class = "factor"),treatment = c("Weeding1", "Weeding1", "Weeding1", "Weeding1", "Weeding1", "Weeding1", "Weeding2", "Weeding2", "Weeding2", "Weeding2", "Weeding2",  "Weeding2", "Weeding0", "Weeding0", "Weeding0", "Weeding0",  "Weeding0", "Weeding0"), value = c(5.65, 4.88, 5.38, 3.93, 6.31, 3.24, 5.4, 4.73, 5.25, 3.9, 4, 3.07, 5.5, 4.7, 5.05, 3.78,4.86, 3.11),row.names = c(NA, -30L), .Names = c("State", "Date", "treatment", "value"), class = "data.frame"))
1

1 Answers

0
votes

Reshaping your data as proper tidy data:

data = structure(list(Weeding = c(5.65, 4.88, 5.38, 3.93, 5.5, 4.43, 
7.03, 5.06, 6.31, 3.24, 5.4, 4.73, 5.25, 3.9, 5.5, 4.35, 6.46, 
5.27, 4, 3.07, 5.5, 4.7, 5.05, 3.78, 5.33, 4.13, 6.77, 5.2, 4.86, 
3.11), State = structure(c(2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 
1L, 2L, 1L, 2L, 1L), .Label = c("Dry", "Wet"), class = "factor"), 
    Date = structure(c(3L, 3L, 5L, 5L, 2L, 2L, 1L, 1L, 4L, 4L, 
    3L, 3L, 5L, 5L, 2L, 2L, 1L, 1L, 4L, 4L, 3L, 3L, 5L, 5L, 2L, 
    2L, 1L, 1L, 4L, 4L), .Label = c("July-oct", "July-sept", 
    "June-July", "June-oct", "June-sept"), class = "factor"), 
    group = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
    0L, 0L, 0L)), .Names = c("Weeding", "State", "Date", "group"
), class = "data.frame", row.names = c("1", "2", "3", "4", "5", 
"6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", 
"17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", 
"28", "29", "30"))

Then I force ggplot to consider the date as number.

ggplot(data) + aes(y = Weeding, x = as.numeric(Date), col = State) + geom_line() + facet_wrap(~group) + 
  scale_x_continuous(labels=c("1" = "July-oct", "2" = "July-sept","3" = "June-July", "4" = "June-oct", "5" = "June-sept"))

enter image description here

But to be honnest that sound weird and wrong to me to do so. But this what you asked