0

I have a big problem that I have spent a lot of time trying to solve Through the code below I obtained a tibble with 1 row and 22 columns:

  median_income = survey_median(VD5008, na.rm = TRUE),
    sd_income = survey_sd(VD5008, na.rm = TRUE),
    mean_age = survey_mean(V2009, na.rm = TRUE),
    median_age = survey_median(V2009, na.rm = TRUE),
    sd_age = survey_sd(V2009, na.rm = TRUE),
    mean_study = survey_mean(VD3005, na.rm = TRUE),
    median_study = survey_median(VD3005, na.rm = TRUE),
    sd_study = survey_sd(VD3005, na.rm = TRUE),
    mean_hmembers = survey_mean(n_household_members, na.rm = TRUE),
    median_hmembers = survey_median(n_household_members, na.rm = TRUE),
    sd_hmembers = survey_sd(n_household_members, na.rm = TRUE),
    number_observations = survey_total(na.rm = TRUE)
  ) %>% 
  mutate_if(is.numeric, round, 2)

Output of code

What I want is to transform that tibble like that: Table that I want

I use some tools of tidyr, but unsuccessfully.

Is possible through tidyr tools? I would appreciate it if someone could help me with the code to transform this table

  • Do you want to generate a table or a dataframe of descriptive stats? If a table, you should use [describe()](https://www.rdocumentation.org/packages/psych/versions/1.0-17/topics/describe), and then either [tab_df()](https://www.rdocumentation.org/packages/sjPlot/versions/2.8.4/topics/tab_df) or [stargazer()](https://cran.r-project.org/web/packages/stargazer/vignettes/stargazer.pdf) to make the table look nice. If you want a dataframe, you will need to make your post [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and provide your data. – jrcalabrese Nov 21 '22 at 01:50

0 Answers0