0

I am trying to rearrange a dataset to create a line graph with two y-variables that will use the same scale, meaning that there will only be one y-axis. One of my variables has significantly higher values than the other so I am hoping to create a broken y-axis.

I think the first step to being able to graph this data set is rearranging my table to go from this:

Current format: (https://i.sstatic.net/pzHHRyUf.png)

To something like this: Desired format: (https://i.sstatic.net/y2YH6e0w.png)

I am pretty new to R so I am not sure how to do this. Can anyone provide some guidance?

Thanks!

4
  • 1
    Perform a search here for "pivot_longer" in the dplyr package. That will allow you to reshape the data. Maybe this: stackoverflow.com/questions/61367186/…. The broken y axis is a different question.
    – Dave2e
    Commented Jun 29 at 19:43
  • 1
    I like to use tidyr::pivot_longer() for this task. Here's a chapter on reshaping data like you're describing. r4ds.had.co.nz/tidy-data.html
    – Jon Spring
    Commented Jun 29 at 19:44
  • 2
    @Dave2e I think you meant to say in the tidyr package, or in the tidyverse meta-package that includes both tidyr and dplyr.
    – Jon Spring
    Commented Jun 29 at 19:54
  • Thanks Jon! That chapter was super helpful and I was able to successfully rearrange my table. Commented Jul 2 at 14:33

0

Browse other questions tagged or ask your own question.