I have a long data frame that I want to pivot wider.
f.tenuretot <- f.tenure_tmp %>% filter(grepl("TOT", tenure)) %>% select(NAME, tenure, value) %>%
pivot_wider(names_from=c(NAME, tenure), values_from= value)
I want the final data set to have the NAME values as column names, and for the first row to contain the values of the "tenure" variable.
Is there a way to do this?
TIA
Could you supply some sample data?
A handy way to supply data is to use the dput() function. Do dput(mydata) where "mydata" is the name of your dataset. For really large datasets probably dput(head(mydata, 100) will do. Paste it here between
```
```
adambickford:
f.tenuretot <- f.tenure_tmp %>% filter(grepl("TOT", tenure)) %>% select(NAME, tenure, value) %>%
pivot_wider(names_from=c(NAME, tenure), values_from= value)
does
pivot_wider(names_from=c(NAME), values_from= value)
not do that?