0

I have a tibble where the first two columns are the combinations of two variables. I want to transform this into a two-variable tibble (or data frame). From this:

> b<-tibble(LET=rep(LETTERS[1:4],each=2),let=rep(letters[1:2],times=4),value=c(1,6,7,4,2,5,8,3))
> b
# A tibble: 8 x 3
  LET   let   value
  <chr> <chr> <dbl>
1 A     a         1
2 A     b         6
3 B     a         7
4 B     b         4
5 C     a         2
6 C     b         5
7 D     a         8
8 D     b         3

To this:

# A tibble: 4 x 3
  LET   value.a value.b
  <chr>   <dbl>   <dbl>
1 A           1       6
2 B           7       4
3 C           2       5
4 D           8       3
paulgr
  • 89
  • 6

0 Answers0