Challenge: I have a column in which there are several rows. For eg., the first row is "Fruit name" and second row is "Fruit Color" and it repeats for another fruit. I want to grab the every second row (Fruit color) and create a new column. In the original column only the fruit names remain.
I would like to go from df_before to df_after.
I'm sure there is a easier way to do this using functions from tidyverse (dplyr?) but couldn't find any info with a good deal of search. Would appreciate any pointers. Thanks in advance!
library(tidyverse)
df_before <- tribble(~Singlecolumn,"Apple","Red","Banana","Yellow","Kiwi","Grey","Grapes","Green")
df_before
Singlecolumn
Apple
Red
Banana
Yellow
Kiwi
Grey
Grapes
Green
df_after <- tribble(~Column1, ~Column2, "Apple","Red","Banana","Yellow","Kiwi","Grey","Grapes","Green")
df_after
Column1 Column2
Apple Red
Banana Yellow
Kiwi Grey
Grapes Green