I struggle with a seemingly simple issue which I could not find an answer to here.
I analyze a data set represented as a data frame with some questionnaire results represented as factors (called A1-A13, approx 100 rows). Each row has some additional information, such as Gender (Factor) and Age (Numerical). An example for this data set would be:
library(palmerpenguins)
penguins
# A tibble: 344 × 8
   species island    bill_length_mm bill_depth_mm flipper_length_mm body_mass_g sex     year
   <fct>   <fct>              <dbl>         <dbl>             <int>       <int> <fct>  <int>
 1 Adelie  Torgersen           39.1          18.7               181        3750 male    2007
 2 Adelie  Torgersen           39.5          17.4               186        3800 female  2007
 3 Adelie  Torgersen           40.3          18                 195        3250 female  2007
The columns "species" and "island" are examples for columns I am interested in.
I now perform the following analysis for each columns:
# Histogram
histogram( ~ species , data=penguins, ylim = c(0,100), drop.unused.levels = FALSE)
# Ordinal regression
mod<-polr(**species** ~ sex + yea, data=penguins,Hess=T)
# Summary
summary(mod)
# Get p values
tidy(mod, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, p.values = TRUE)
# Draw histogram
histogram( ~ **species** | sex, data=dta, drop.unused.levels = FALSE, layout=c(1,2), ylim=c(0,100))
As output, I want to have the histograms, the output from summary and tidy as well as the second histogram.
For the example data, I would have this done for species and island columns. However, my data has 13 colums I want to repeat this process for. Is there any other elegant way to program this to be repeated for columns A1-A13?
Thank you!
