Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
dplyr
romain@r-enthusiasts.com
Romain François
...
$ wc -l R/*.R | tail -n1
3576 total
$ wc -l src/*.cpp | tail -n1
4908 total
$ wc -l **/*.h | tail -n1
8908 total
dis playa
DEEP LIAR
%>%(païpe)
verbe( sujet, complement )
sujet %>% verbe( complement )
enjoy(cool(bake(shape(beat(append(bowl(rep("flour",
2), "yeast", "water", "milk", "oil"), "flour", until
= "soft"), durati...
Vocabulary
filter
x y
purple 2
purple 3
red 4
red 5
purple 6
yellow 7
yellow 8
x y
purple 2
purple 3
purple 6
data %>% filter( x == "...
mutate
x y
purple 2
purple 3
red 4
red 5
purple 6
yellow 7
yellow 8
data %>% mutate( y = y*2, z = nchar(x) )
x y z
purple ...
select
x y
purple 2
purple 3
red 4
red 5
purple 6
yellow 7
yellow 8
data %>% select( x )
x
purple
purple
red
red
purple
ye...
arrange
x y
purple 2
purple 3
red 4
red 5
purple 6
yellow 7
yellow 8
data %>% arrange( desc(x) )
x y
yellow 8
yellow 7
pur...
group_by
x y
purple 2
purple 3
red 4
red 5
purple 6
yellow 7
yellow 8
x y
purple 2
purple 3
purple 6
data %>% group_by( x ...
summarise
x y
purple 2
purple 3
red 4
red 5
purple 6
yellow 7
yellow 8
summarise( data, z = min(y) )
z
2
group_by + summarise
x y
purple 2
purple 3
red 4
red 5
purple 6
yellow 7
yellow 8
x y
purple 2
purple 3
purple 6
data %>% ...
Mise en garde :
comme son nom
l'indique ...
install_github( "romainfrancois/cpasbien" )
library("cpasbien")
movies <- get_all_movies( pages = 1:20 )
episodes <- get_a...
> glimpse( movies )
Observations: 600
Variables: 11
$ type <chr> "policiers-thrillers", "policiers-thrillers", "policiers-...
Les comédies les plus
téléchargées en ce moment
en qualité dvdrip
Les comédies les plus
téléchargées en ce moment
en qualité dvdrip
movies %>%
filter(
grepl( "comedies", type ),
quality ==...
Les films d'animation
en meilleure qualité possible
(mais pas dvdscr)
en français
movies %>%
filter(
grepl("animation", type),
lang == "french",
quality != "dvdscr"
) %>%
select(-type, -lang) %>%
group_by...
Le dernier episode disponible de
chaque série en VO
episodes %>%
filter( lang == "vostfr" ) %>%
group_by( show ) %>%
filter( season == max(season) ) %>%
filter( episode == ma...
episodes %>%
filter( lang == "vostfr" ) %>%
group_by( show ) %>%
filter( season == max(season) ) %>%
filter( episode == ma...
Questions ?
romain@r-enthusiasts.com
Demo
library("cpasbien")
library("shiny")
runApp( system.file("app", package = "cpasbien") )
dplyr and torrents from cpasbien
dplyr and torrents from cpasbien
dplyr and torrents from cpasbien
dplyr and torrents from cpasbien
dplyr and torrents from cpasbien
Upcoming SlideShare
Loading in …5
×

dplyr and torrents from cpasbien

dplyr presentation at the Paris meetup Raddicts.
using data from the package cpasbien that scraps information from the website of the same name.

  • Be the first to comment

dplyr and torrents from cpasbien

  1. 1. dplyr romain@r-enthusiasts.com Romain François
  2. 2. ... $ wc -l R/*.R | tail -n1 3576 total $ wc -l src/*.cpp | tail -n1 4908 total $ wc -l **/*.h | tail -n1 8908 total
  3. 3. dis playa
  4. 4. DEEP LIAR
  5. 5. %>%(païpe)
  6. 6. verbe( sujet, complement ) sujet %>% verbe( complement )
  7. 7. enjoy(cool(bake(shape(beat(append(bowl(rep("flour", 2), "yeast", "water", "milk", "oil"), "flour", until = "soft"), duration = "3mins"), as = "balls", style = "slightly-flat"), degrees = 200, duration = "15mins"), duration = "5mins")) bowl(rep("flour", 2), "yeast", "water", "milk", "oil") %>% append("flour", until = "soft") %>%
 beat(duration = "3mins") %>%
 shape(as = "balls", style = "slightly-flat") %>%
 bake(degrees = 200, duration = "15mins") %>%
 cool(buns, duration = "5mins") %>% enjoy()
  8. 8. Vocabulary
  9. 9. filter x y purple 2 purple 3 red 4 red 5 purple 6 yellow 7 yellow 8 x y purple 2 purple 3 purple 6 data %>% filter( x == "purple" )
  10. 10. mutate x y purple 2 purple 3 red 4 red 5 purple 6 yellow 7 yellow 8 data %>% mutate( y = y*2, z = nchar(x) ) x y z purple 4 6 purple 6 6 red 8 3 red 10 3 purple 12 6 yellow 14 6 yellow 16 6
  11. 11. select x y purple 2 purple 3 red 4 red 5 purple 6 yellow 7 yellow 8 data %>% select( x ) x purple purple red red purple yellow yellow
  12. 12. arrange x y purple 2 purple 3 red 4 red 5 purple 6 yellow 7 yellow 8 data %>% arrange( desc(x) ) x y yellow 8 yellow 7 purple 6 red 5 red 4 purple 3 purple 2
  13. 13. group_by x y purple 2 purple 3 red 4 red 5 purple 6 yellow 7 yellow 8 x y purple 2 purple 3 purple 6 data %>% group_by( x ) x y red 4 red 5 x y yellow 7 yellow 8
  14. 14. summarise x y purple 2 purple 3 red 4 red 5 purple 6 yellow 7 yellow 8 summarise( data, z = min(y) ) z 2
  15. 15. group_by + summarise x y purple 2 purple 3 red 4 red 5 purple 6 yellow 7 yellow 8 x y purple 2 purple 3 purple 6 data %>% group_by( x )%>% summarise( z = max(y) ) x y red 4 red 5 x y yellow 7 yellow 8 x z purple 6 red 5 yellow 8
  16. 16. Mise en garde : comme son nom l'indique ...
  17. 17. install_github( "romainfrancois/cpasbien" ) library("cpasbien") movies <- get_all_movies( pages = 1:20 ) episodes <- get_all_episodes( pages = 1:20 )
  18. 18. > glimpse( movies ) Observations: 600 Variables: 11 $ type <chr> "policiers-thrillers", "policiers-thrillers", "policiers-thr... $ title <chr> "Oppression", "Oppression", "Oppression", "Oppression", "Ret... $ year <chr> "2016", "2016", "2016", "2016", "2016", "2016", "2016", "201... $ lang <chr> "french", "french", "french", "french", "french", "french", ... $ quality <chr> "dvdrip", "dvdrip-x264", "bluray-1080p", "bluray-720p", "dvd... $ size <dbl> 710, 345, 7885, 4506, 701, 632, 696, 701, 1434, 4710, 1434, ... $ up <dbl> 2928, 285, 223, 330, 5541, 522, 2329, 8362, 4835, 1157, 261,... $ down <dbl> 188, 18, 62, 54, 236, 17, 90, 400, 452, 159, 27, 29, 126, 66... $ torrent <chr> "http://www.cpasbien.cm/telechargement/oppression-french-dvd... $ poster <chr> "http://www.cpasbien.cm/_pictures/oppression-french-dvdrip-2... $ href <chr> "http://www.cpasbien.cm/dl-torrent/films/policiers-thrillers... > glimpse( episodes ) Observations: 569 Variables: 11 $ show <chr> "NCIS New Orleans ", "Hawaii 5-0 (2010) ", "Van Helsing ", "... $ season <dbl> 2, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 27, 27, 1, 2, 4, 1, 3, 3... $ episode <dbl> 17, 1, 2, 12, 11, 10, 2, 6, 5, 1, 4, 2, 3, 2, 1, 2, 1, 1, 1,... $ lang <chr> "french", "vostfr", "vostfr", "french", "french", "french", ... $ quality <chr> "hdtv", "hdtv", "hdtv", "hdtv", "hdtv", "hdtv", "hdtv", "hdt... $ size <dbl> 351, 367, 356, 344, 348, 336, 230, 346, 346, 368, 347, 347, ... $ up <dbl> 131, 204, 717, 1143, 1081, 1222, 235, 700, 658, 295, 648, 38... $ down <dbl> 22, 20, 45, 144, 132, 154, 14, 49, 61, 20, 48, 18, 4, 5, 32,... $ torrent <chr> "http://www.cpasbien.cm/telechargement/l-m-n/ncis-new-orlean... $ poster <chr> "http://www.cpasbien.cm/_pictures/l-m-n/ncis-new-orleans-s02... $ href <chr> "http://www.cpasbien.cm/dl-torrent/series/l-m-n/ncis-new-orl...
  19. 19. Les comédies les plus téléchargées en ce moment en qualité dvdrip
  20. 20. Les comédies les plus téléchargées en ce moment en qualité dvdrip movies %>% filter( grepl( "comedies", type ), quality == "dvdrip" ) %>% arrange( desc(down) )
  21. 21. Les films d'animation en meilleure qualité possible (mais pas dvdscr) en français
  22. 22. movies %>% filter( grepl("animation", type), lang == "french", quality != "dvdscr" ) %>% select(-type, -lang) %>% group_by(title) %>% filter(size == max(size))
  23. 23. Le dernier episode disponible de chaque série en VO
  24. 24. episodes %>% filter( lang == "vostfr" ) %>% group_by( show ) %>% filter( season == max(season) ) %>% filter( episode == max(episode) ) %>% arrange(desc(up)) Le dernier episode disponible de chaque série en VO
  25. 25. episodes %>% filter( lang == "vostfr" ) %>% group_by( show ) %>% filter( season == max(season) ) %>% filter( episode == max(episode) ) %>% filter( episode == 1 ) %>% arrange( desc(up) ) ... les séries d'automne ...
  26. 26. Questions ? romain@r-enthusiasts.com
  27. 27. Demo library("cpasbien") library("shiny") runApp( system.file("app", package = "cpasbien") )

×