grain y ields and u nit con v ersion
play

Grain y ields and u nit con v ersion IN TR OD U C TION TO W R ITIN - PowerPoint PPT Presentation

Grain y ields and u nit con v ersion IN TR OD U C TION TO W R ITIN G FU N C TION S IN R Richie Co on C u rric u l u m Architect at DataCamp USDA NASS INTRODUCTION TO WRITING FUNCTIONS IN R Corn and w heat Soon these w ill be food Hmm ,


  1. Grain y ields and u nit con v ersion IN TR OD U C TION TO W R ITIN G FU N C TION S IN R Richie Co � on C u rric u l u m Architect at DataCamp

  2. USDA NASS INTRODUCTION TO WRITING FUNCTIONS IN R

  3. Corn and w heat Soon these w ill be food Hmm , delicio u s INTRODUCTION TO WRITING FUNCTIONS IN R

  4. 1 acre = area of land 2 o x en can plo u gh in a da y INTRODUCTION TO WRITING FUNCTIONS IN R

  5. Not the 100 Acre Wood INTRODUCTION TO WRITING FUNCTIONS IN R

  6. 1 hectare = 2 football fields INTRODUCTION TO WRITING FUNCTIONS IN R

  7. 1 hectare = 150 Ne w York apartments INTRODUCTION TO WRITING FUNCTIONS IN R

  8. 1 b u shel = 2 baskets of peaches INTRODUCTION TO WRITING FUNCTIONS IN R

  9. 1 kilogram = 1 sq u irrel monke y INTRODUCTION TO WRITING FUNCTIONS IN R

  10. magrittr ' s pipeable operator replacements operator f u nctional alternati v e x * y x %>% multiply_by(y) x ^ y x %>% raise_to_power(y) x[y] x %>% extract(y) INTRODUCTION TO WRITING FUNCTIONS IN R

  11. Let ' s practice ! IN TR OD U C TION TO W R ITIN G FU N C TION S IN R

  12. Vis u ali z ing grain y ields IN TR OD U C TION TO W R ITIN G FU N C TION S IN R Richie Co � on C u rric u l u m Architect at DataCamp

  13. The corn dataset glimpse(corn) Observations: 6,381 Variables: 6 $ year <int> 1866, 1866, 1866, 1866, 1866, 1866... $ state <chr> "Alabama", "Arkansas", "California... $ farmed_area_acres <dbl> 1050000, 280000, 42000, 57000, 200... $ yield_bushels_per_acre <dbl> 9.0, 18.0, 28.0, 34.0, 23.0, 9.0, ... $ farmed_area_ha <dbl> 424919.92, 113311.98, 16996.80, 23... $ yield_kg_per_ha <dbl> 79.29892, 158.59784, 246.70776, 29... INTRODUCTION TO WRITING FUNCTIONS IN R

  14. ggplot 2: dra w ing m u ltiple lines ggplot(dataset, aes(x, y)) + geom_line(aes(group = group)) INTRODUCTION TO WRITING FUNCTIONS IN R

  15. ggplot 2: smooth trends ggplot(dataset, aes(x, y)) + geom_line(aes(group = group)) + geom_smooth() INTRODUCTION TO WRITING FUNCTIONS IN R

  16. ggplot 2: facetting ggplot(dataset, aes(x, y)) + geom_line(aes(group = group)) + geom_smooth() + facet_wrap(vars(facet)) INTRODUCTION TO WRITING FUNCTIONS IN R

  17. USA Cens u s regions INTRODUCTION TO WRITING FUNCTIONS IN R

  18. dpl y r inner joins dataset1 %>% inner_join(dataset2, by = "column_to_join_on") INTRODUCTION TO WRITING FUNCTIONS IN R

  19. Let ' s practice ! IN TR OD U C TION TO W R ITIN G FU N C TION S IN R

  20. Modeling grain y ields IN TR OD U C TION TO W R ITIN G FU N C TION S IN R Richie Co � on C u rric u l u m Architect at DataCamp

  21. INTRODUCTION TO WRITING FUNCTIONS IN R

  22. Linear models v s . generali z ed additi v e models A linear model A generali z ed additi v e model library(mgcv) lm( gam( response_var ~ explanatory_var1 + explanatory_var2, response_var ~ s(explanatory_var1) + explanatory_var2, data = dataset data = dataset ) ) INTRODUCTION TO WRITING FUNCTIONS IN R

  23. Predicting GAMs predict_this <- data.frame( explanatory_var1 = c("some", "values"), explanatory_var2 = c("more", "values") ) predicted_responses <- predict(model, predict_this, type = "response") predict_this %>% mutate(predicted_responses = predicted_responses) INTRODUCTION TO WRITING FUNCTIONS IN R

  24. Let ' s practice ! IN TR OD U C TION TO W R ITIN G FU N C TION S IN R

  25. Congrat u lations IN TR OD U C TION TO W R ITIN G FU N C TION S IN R Richie Co � on C u rric u l u m Architect at DataCamp

  26. In Chapter 1 y o u learned Writing y o u r o w n f u nctions lets y o u re u se code . There is a simple process for t u rning scripts into f u nctions . Data arg u ments come before detail arg u ments . INTRODUCTION TO WRITING FUNCTIONS IN R

  27. In Chapter 2 y o u learned Defa u lts can be set u sing name = value s y nta x. Arg u ments can be passed bet w een f u nctions u sing their name or ... . Checking u ser inp u ts can be done u sing assertive . INTRODUCTION TO WRITING FUNCTIONS IN R

  28. In Chapter 3 y o u learned Yo u can ret u rn earl y from a f u nction u sing return() . Yo u can pre v ent ret u rn v al u es being printed w ith invisible() . F u nctions can ret u rn m u ltiple v al u es u sing lists or a � rib u tes . R has r u les abo u t scope that determine w hich v ariables can be seen . INTRODUCTION TO WRITING FUNCTIONS IN R

  29. In Chapter 4 y o u learned Writing y o u r o w n f u nctions can be u sef u l for y o u r data anal y ses . E v en simple , one - line f u nctions can be helpf u l . INTRODUCTION TO WRITING FUNCTIONS IN R

  30. More modeling INTRODUCTION TO WRITING FUNCTIONS IN R

  31. Tid y ing models INTRODUCTION TO WRITING FUNCTIONS IN R

  32. Unit testing INTRODUCTION TO WRITING FUNCTIONS IN R

  33. En v ironments Object - Oriented Programming w ith S 3 and R 6 in R INTRODUCTION TO WRITING FUNCTIONS IN R

  34. Thanks for taking the co u rse ! IN TR OD U C TION TO W R ITIN G FU N C TION S IN R

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend