0

I want to make a line graph that plots Elapsed column as x-axis and and the rest as different samples.

So far I have tried this with ggplot() but saw no graph:

 merged %>% 
    pivot_longer(!Elapsed) %>%
    ggplot(aes(x = Elapsed, y= value, color = name)) +
       geom_point()

Alternatively, could you please help specify the appropriate syntax for plot_ly()

plot_ly(x = merged$Elapsed, y= ??, type = 'scatter', 
        mode = 'lines', name = 'Relative Wound Density')
DaveArmstrong
  • 18,377
  • 2
  • 13
  • 25
  • 1
    Welcome to SO! You will be most likely to get your question answered if you follow the [helpful advice](https://stackoverflow.com/help/how-to-ask) about asking questions and create a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – DaveArmstrong May 31 '23 at 22:46
  • 1
    Example using standard data works, so the issue probably lies with your data. Can you put the output of `dput(head(merged))` into the body of your question? Example: `mtcars |> tidyr::pivot_longer(!gear) |> ggplot(aes(x = gear, y= value, color = name)) + geom_point()` – Jon Spring May 31 '23 at 23:41
  • Maybe you don't have a column called `Elapsed`. Maybe your other columns don't have the same type (which would cause an error at the pivot_longer step, but you haven't noted any errors. Maybe your values are NAs. Maybe your column names are invalid. Maybe the code is fine but you've done something to hide or redirect your plot output. Hard to guess without sample data. – Jon Spring May 31 '23 at 23:43

0 Answers0