I want to discover pattern in my data by plotting two variables (just choosing any two) against time to see their change over time. my dataset include 4 environmental variables (temperature, CO2, light intensity, RH) and plant growth variables (height, yield, number of leaves, ....). the experiment is repeated in 5 environmental locations. how can I plot for example " Change of plant height(PH) and RH (relative humidity) according to time (WAT)? the time is recorded as number of weeks after transplanting (WAT). I used this code but it is not giving me the results I am looking for
ggplot(farms, na.omit = TRUE, aes(x=WAT)) +
geom_line(aes(y = RH), color = "darkred") +
geom_line(aes(y = PH), color="darkblue") + facet_wrap(~location)
For example there is no legend. and on Y axis it showing only RH.
I tried to reshape as farms_long <-melt(farms, id = "WAT") and then plotted again using this code :
ggplot(farms_long,
aes(x = WAT,
y = value,
color = variable)) +
geom_line()
I tried to used this then it plotted everything and become more messy. I couldn't figure out how to pick the two variables to show as Y.
here is the head() of my dataset
l
ocation WAT week.of.the.year Temp RH CO2 LI PH PL TC LL LW FLN FRN LN fl_area
1 farm1 1 37 24.35572 89.68531 336.0974 31793.33 32.35 19.38 11.525 9.21 16.46 NA NA NA NA
2 farm1 2 38 23.19145 84.69412 352.1406 28855.71 NA NA NA NA NA NA NA NA NA
3 farm1 3 39 23.24108 88.76812 369.5249 23868.71 31.19 17.63 21.345 7.81 5.43 NA NA 7.0 NA
4 farm1 4 40 23.28016 89.15208 386.2302 23906.14 33.83 16.45 16.544 9.11 6.35 NA NA 7.4 NA
5 farm1 5 41 18.24180 90.49593 353.2946 16811.43 30.77 14.25 16.636 12.33 8.41 1 NA 5.3 NA
6 farm1 6 42 15.72282 87.56171 402.4722 25462.14 31.70 14.55 19.778 13.47 9.14 2 NA 6.1 NA
kindly help. I am a new R learner. Thank you for the consideration and time.