Switch to English Site

Little Things

Little Things

29 de Junio de 2020

I recently became a Certified R Trainer. The process was fantastic and I recommend it to anyone who enjoys teaching this stuff, even if just informally.

If you can get through the online text R for Data Science, you will have no problem with the technical assessment. I’d read it years ago, but doing it a second time was really helpful. There are so many ways to solve a given problem in programming. By re-reading examples in a text like that, you always uncover little things that might end up saving you a lot of time.

 

library(tidyverse)

starwars %>% 
  group_by(species) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n))
## # A tibble: 38 x 2
##    species      n
##    <chr>    <int>
##  1 Human       35
##  2 Droid        6
##  3 <NA>         4
##  4 Gungan       3
##  5 Kaminoan     2
##  6 Mirialan     2
##  7 Twi'lek      2
##  8 Wookiee      2
##  9 Zabrak       2
## 10 Aleena       1
## # … with 28 more rows

For instance, I’ve spent several years running code like this to get basic counts.There is nothing wrong with that approach. It works and gets the results you’d expect. Going throughR for Data Science again, however, revealed a more concise way.

starwars %>% 
  group_by(species) %>% 
  count(sort = T) 
## # A tibble: 38 x 2
## # Groups:   species [38]
##    species      n
##    <chr>    <int>
##  1 Human       35
##  2 Droid        6
##  3 <NA>         4
##  4 Gungan       3
##  5 Kaminoan     2
##  6 Mirialan     2
##  7 Twi'lek      2
##  8 Wookiee      2
##  9 Zabrak       2
## 10 Aleena       1
## # … with 28 more rows

Small wins aren’t life changing, but if you find enough of them, things start to feel a lot easier.

Suscríbete para recibir actualizaciones

search
Or create a free DataKwery.com account

Cursos relacionados

Rutas de aprendizaje relacionadas

Coursera
Johns Hopkins University