Your comment on this question:

Email me at this address if a comment is added after mine:Email me if a comment is added after mine

Privacy: Your email address will only be used for sending these notifications.

1 answer to this question.

Your answer

Your name to display (optional):

Email me at this address if my answer is selected or commented on:Email me if my answer is selected or commented on

Privacy: Your email address will only be used for sending these notifications.

0 votes

For df1 plot

# Group data by when and site
grouped_df1<-group_by(df1,site)#summarise grouped data and calculate mean and standard error using function mean and std.error(from plotrix)
summarised_df1<-summarise_each(grouped_df1,funs(mean=mean,std_error=std.error))# Define the top and bottom of the errorbars
limits <- aes(ymax = mean + std_error, ymin=mean-std_error)#Begin your ggplot#Here we are plotting site vs mean and filling by another factor variable when
g<-ggplot(summarised_df1,aes(site,mean))#Creating bar to show the factor variable position_dodge #ensures side by side creation of factor bars
g<-g+geom_bar(stat ="identity",position = position_dodge())#creation of error bar
g<-g+geom_errorbar(limits,width=0.25,position = position_dodge(width =0.9))#print graph
g

For df2 plot

# Group data by when and site
grouped_df2<-group_by(df2,when,site)#summarise grouped data and calculate mean and standard error using function mean and std.error
summarised_df2<-summarise_each(grouped_df2,funs(mean=mean,std_error=std.error))# Define the top and bottom of the errorbars
limits <- aes(ymax = mean + std_error, ymin=mean-std_error)#Begin your ggplot#Here we are plotting site vs mean and filling by another factor variable when
g<-ggplot(summarised_df2,aes(site,mean,fill=when))#Creating bar to show the factor variable position_dodge #ensures side by side creation of factor bars
g<-g+geom_bar(stat ="identity",position = position_dodge())#creation of error bar
g<-g+geom_errorbar(limits,width=0.25,position = position_dodge(width =0.9))#print graph
g