0

Say I have the following two columns A, B per screen grab. Col1 values are repeated.

I am trying to move col2 values to new adjacent columns, when a new cycle of numbers in col1 begins.

I have been pouring over tidyr - separate in particular, but have had no luck.

Is probably something very easy that I am missing.

Thxenter image description here

Screamh
  • 39
  • 5
  • 1
    Images are not the right way to share data/code. Add them in a reproducible format which is easier to copy. Read about [how to give a reproducible example](http://stackoverflow.com/questions/5963269). – Ronak Shah Jun 25 '21 at 11:19
  • Using `tidyverse` you can do `df %>% group_by(Col1) %>% mutate(row = row_number()) %>%pivot_wider(names_from = row, values_from = col2, names_prefix = 'col')` – Ronak Shah Jun 25 '21 at 11:22
  • Thx Ronak for sharing expertise – Screamh Jun 25 '21 at 13:06
  • Ronak, I have road tested your session, and am getting a strange error. There are no issues in generating up to 15 new columns of data, but when I go beyond that, the first entry in line 1 (from say col17, 18, 19, .... col 50) is NA. The original column 1 and 2 have no NAs. I can omit NA using na.omit(file). Unable to find anything using google - have you seen this issue before? – Screamh Jun 26 '21 at 09:42
  • That is strange. We would need more information about the data and the error that you are facing. Maybe you can ask that as a new question since this question is closed by sharing data in a reproducible format and the expected output. – Ronak Shah Jun 26 '21 at 10:09
  • Ok, will do, thx – Screamh Jun 26 '21 at 10:14
  • Ronak, I looked at the abscissa ranges, all were not equal. Again, thx for sharing insights. – Screamh Jul 02 '21 at 10:01

0 Answers0