Plotting a line graph in R studio that has an x axis that goes down and then up

  Kiến thức lập trình

I am new to R studio so please bear that in mind. I have an assignment at uni to make a line graph of the mean with standard error bars from some data we collected. The experiment was measuring beats per minute of brine shrimp when changing temperature. We took temperature measurements in increments of 2 degrees celcius from 20C down to 6C and then back up to 20C. I ideally would like to have a graph where the x axis reads from 20->6->20 but can’t figure out how to do this.

My data:

temperature= 20,18,16,14,12,10,8,10,12,14,16,18,20
mean=104.50,113.89,103.16,89.57,82.63,77.95,74.41,71.29,76.10,83.71,86.58,100.40,104.39,130.31,111.00
se=6.85,6.22,4.10,3.82,4.39,2.85,2.94,3.50,7.56,4.87,4.13,5.36,5.22,9.49,13.38

Here’s what I’ve tried so far:

i saw online that i could write out my data points like this
x=c(20,18,16,14,12,10,8,6,8,10,12,14,16,18,20) y=c(104.5,113.89,103.16,89.57,82.63,77.95,74.41,71.29,76.1,83.71,86.58,100.4,104.39,130.31,111)
ggplot(data.frame(x=1:length(x),y))+ geom_point(aes(x=x, y=y)) ggplot(x,y)
this plots my data correctly but the x axis goes from 1->15 as I have 15 observations which isn’t what i want. and also theres no standard error bars obviously

i then tried this
ggplot(starved2_0,aes(x=temp,y=mean))+ geom_errorbar(aes(ymin=mean-se, ymax=mean+se),width=.1)+ geom_line()+ geom_point()
i then tried this but this just puts both my values for each temperature together and so isn’t what i want

Any ideas as to how to solve this would be greatly appreciated! 🙂

New contributor

user24308944 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT