I want to do a line plot with R similar to the way Excel is plotting it:
Can somebody help me how I can do this with ggplot?
This is the code to have the same dataset as in the picture:
id = c(1,2,3,4)
Na = c(600,1100,2500,400)
Ca = c(53,106,932,8)
Mg = c(18,32,975,2)
Cl = c(463,1960,13330,590)
HCO3 = c(698,165,189,640)
SO4 = c(25,62,1068,2)
unit = c("Series 1", "Series 2","Series 3","Series 4" )
data = data.frame(cbind(id,Na,Ca,Mg,Cl,HCO3,SO4,unit))
data
I know that I can fill graphs with ggplot with a factor. I have a bigger data set with those 4 series. Each ID is assigned to one of the series, so this are just the averages. At the end I want to do a plot of several lines (not just this 4) and colour the lines regarding their unit (Series).
It would be great if someone even can give me a hint how I can plot this with the different variables on the x-axis and their value [mg/L] on the y-axis. I prefer the y-axis being in logarithmic scale, if possible.
Thanks in advance for helping a R-Beginner in ggplot2!