Plot multiple line graph over time

Greetings,
Am looking at the recovery time of arthropods after a disturbance and finding it difficult to plot Multiple lines on count data over sampling time.
My response variable is number of insect sampled and explanatory variable is sampling time.
Treatments for comparison are spatial scale; 35m, 15m, 20m and 6m
Then am thinking of correlating it with environmental variables (Temp and Rainfall).
Eg of how my data looks like;; B is before harvest and A is after harvest, Gb, Rvb and Sp are count data from the sampling

date blk Trt harv Temp Rain Gb Rvb Sp
7 May 1 15m B 9.5 1.25 1 0 0
7 May 1 20m B 9.5 1.25 0 0 1
7 May 1 8m B 9.5 1.25 2 1 1
7 May 2 20m B 9.5 1.25 0 1 1
7 May 2 15m B 9.5 1.25 0 1 0
7 May 2 8m B 9.5 1.25 1 3 0
7 May 3 35m B 9.5 1.25 2 1 1
7 May 3 8m B 9.5 1.25 1 4 1

10 May 1 15m B 9.5 1.25 1 7 0
10 May 1 20m B 9.5 1.25 1 4 1
10 May 1 8m B 9.5 1.25 1 5 1
10 May 2 20m B 9.5 1.25 0 4 2
10 May 2 15m B 9.5 1.25 0 1 0
10 May 2 8m B 9.5 1.25 0 0 2
10 May 3 35m B 9.5 1.25 0 2 0
10 May 3 8m B 9.5 1.25 1 4 1

15 May 1 15m B 9.5 1.25 3 0 1
15 May 1 20m B 9.5 1.25 2 3 1
15 May 1 8m B 9.5 1.25 2 1 1
15 May 2 20m B 9.5 1.25 0 2 0
15 May 2 15m B 9.5 1.25 1 1 1
15 May 2 8m B 9.5 1.25 1 3 0
15 May 3 35m B 9.5 1.25 2 1 1
15 May 3 8m B 9.5 1.25 0 4 2

Hi @benosei! Welcome!

I think it will help if you supply some more info in order for helpers to be sure they understand your problem (this is pretty common — when you're new to this stuff, it's hard to know how much information is enough!).

The best thing would be if you can take a look at the advice here: FAQ: Tips for writing R-related questions, and make your question into a reproducible example. A concrete, self-contained example of the sort of thing you’re trying to do lets helpers see exactly where you’re running into trouble.

If you try the instructions in the above links and get stuck, here's a fallback option...
  1. Edit your post and add in some of the code you have tried. It's OK it doesn't work! It's really helpful to see what you've been attempting. Be sure to format your code as code (it's hard to read unformatted code, and it can get garbled by the forum software)
  2. Include sample data:
    • If your data set is OK to share, run the following line and paste the output into your post. Again, be sure to format it as code :sparkles:
    dput(head(your_dataframe_name, 10))
    
    • If your data set can't be shared, run this line instead and paste the output into your post (and yes, format as code!) This will still share some information about your data. If it's truly confidential, I'm afraid you'll need to make a fake sample dataset to share.
    str(your_dataframe_name)
    
1 Like

Essentially, you have a time series, in which interval, not just sequence, is important. This calls for an look at the CRAN topical index of the available time series packages, how well they play with ggplot or your favorite visualization tool, and refactoring your data. You'll want time objects to go with each set of classified organizations, and then it is pretty straightfoward to to multiple plots on the same intervals of each of the object. And, as an added bonus, it opens up tools to investigate temporal autocorrelation and other interesting characteristics of your data sets. Shumway and Stoffer have a comprehensive text Time Series Analysisand its Applcations with R Examples (4th ed). Early free versions may still be available online,

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.