208  Question

Schlüsselwörter

Aufgaben, Statistik, Prognose, Modellierung, R, Datenanalyse, Regression

Erstellen Sie für jede Variable aus mtcars ein Histogramm!

Hinweise:

209 Solution

has_two_levels <- function(vec){
  
  # input: vector of any type
  # value: number of unique values (double)
  
  tmp <- length(unique(vec))
  tmp == 2
}
mtcars_hist <- function(col){
  mtcars %>% 
    ggplot(aes(x = col)) +
    geom_histogram()
}
mtcars %>% 
  select(where(is.numeric)) %>% 
  select(where(negate(has_two_levels))) %>%   # `!` zum Negieren geht leider nicht
  map(mtcars_hist)
## $mpg
## 
## $cyl
## 
## $disp
## 
## $hp
## 
## $drat
## 
## $wt
## 
## $qsec
## 
## $gear
## 
## $carb

210 Meta-information

extype: string exsolution: NA exname: ggplot-prog expoints: 1