Make multiple plots in one graph in R

#1
Hi

I have a data-file in excel as you can se in the picture :)
I have tried several codes to plot a graph with the time on x-axis and the temperature on the y-axis for mesh0-mesh5.

1.How is it possible inside R?
2. Is it fine to use excel format or should it be csv?


allmeshes.PNG
 

hlsmith

Less is more. Stay pure. Stay poor.
#3
I don't use ggplot so much but in baseplot you typically just add some option like add=TRUE and it will add additional line plots.
 
#5
Thank you!

Why is my values being considered as 'characters' inside R? I want to plot with ggplot but it wont work because they are not numerical.
 
#6
I haven't worked with time series data much. But, maybe instead of wide format you could try long format. Look at gather and spread functions in R. I'm envisioning you facet/color by the mesh (I don't know what mesh is). I don't really know what you're going after. But, it's usually a matter of structuring the data so that ggplot syntax will work. There is an as.numeric() function for converting to numeric values. I simulated some data to show what I mean.

i.e.

time temp mesh
1 4.12 0
2 5.34 0
1 6.56 1
2 4.78 1
1 6.12 2

1614813893665.png
 
Last edited:
#7
I haven't worked with time series data much. But, maybe instead of wide format you could try long format. Look at gather and spread functions in R. I'm envisioning you facet/color by the mesh (I don't know what mesh is). I don't really know what you're going after. But, it's usually a matter of structuring the data so that ggplot syntax will work. There is an as.numeric() function for converting to numeric values. I simulated some data to show what I mean.

i.e.

time temp mesh
1 4.12 0
2 5.34 0
1 6.56 1
2 4.78 1
1 6.12 2

View attachment 3116
Thank you! I figured it out and solved the problem :)