I have a data frame in R that looks like this:
var | name | value |
---|---|---|
A | John | 1 |
A | Mary | 2 |
A | George | 3 |
B | Nick | 4 |
B | Jonas | 5 |
B | Helen | 6 |
C | Lary | 7 |
C | Paul | 8 |
I want to transform it in gt to look like this :
var | name | value |
---|---|---|
John | 1 | |
A | Mary | 2 |
George | 3 | |
Nick | 4 | |
B | Jonas | 5 |
Helen | 6 | |
C | Lary | 7 |
Paul | 8 |
How ca I do it using gt in R ?
library(tidyverse)
library(gt)
var = c(rep("A",3),rep("B",3),rep("C",2))
name = c("John","Mary",
"George",
"Nick" , "Jonas",
"Helen","Lary","Paul")
value = c(seq(1,8,1))
data_=tibble(var,name,value);data_
You can use the arguments on the gt() function. this should work
data_ |> gt(groupname_col="var", row_group_as_column = TRUE)