economics_long
is a data frame with four variables. The code above maps x to date
, y to value01
, and linetype to the variable called variable
.
For your data, you might need to map linetype to p
, but I'm not sure.
It will be much easier to give you concrete suggestions if you can share reproducible code that we can run. As part of that, it would be nice to have some sample data with the same structure you're working with. (Your code goes in that direction, but it's not explicit which libraries you're relying on or where the traj
function comes from.)
It's often easiest to share data using R's dput()
function, which creates a "recipe" to make an exact copy of an R object, such as a data frame. For instance dput(head(YOUR_DATA), 100)
would create code that, when run by others, will reproduce the first 100 rows of your data.
economics_long
# A tibble: 2,870 x 4
date variable value value01
<date> <chr> <dbl> <dbl>
1 1967-07-01 pce 507. 0
2 1967-08-01 pce 510. 0.000265
3 1967-09-01 pce 516. 0.000762
4 1967-10-01 pce 512. 0.000471
5 1967-11-01 pce 517. 0.000916
6 1967-12-01 pce 525. 0.00157
7 1968-01-01 pce 531. 0.00207
8 1968-02-01 pce 534. 0.00230
9 1968-03-01 pce 544. 0.00322
10 1968-04-01 pce 544 0.00319
# … with 2,860 more rows