Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rbootcamp202003_Day2_p8.pdf

sakaue
March 20, 2020
67

 Rbootcamp202003_Day2_p8.pdf

sakaue

March 20, 2020
Tweet

Transcript

  1. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  2. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  3. • ΫϩεूܭදΛϞβΠΫϓϩοτͱͯ͠ඳը 1. > cross.tab <- matrix(c(96, 54, 52, 48),

    nrow=2, ncol=2, byrow=TRUE) #ΫϩεूܭදΛ࡞੒ 2. > rownames(cross.tab) <- c("Male", "Female") 3. > colnames(cross.tab) <- c("Jotai", "Keitai") 4. > cross.tab #Ϋϩεूܭදͷ֬ೝ 5. > mosaicplot(cross.tab) #ϞβΠΫϓϩοτͷඳը 1. ϞβΠΫϓϩοτΛඳ͘
  4. • ߦ΍ྻ͕3ͭҎ্͋Δ৔߹ͷΫϩεूܭදΛϞβΠΫϓϩοτ ͱͯ͠ඳը 1. install.packages("textometry", dependencies = TRUE) 2. library(textometry)

    3. data(robespierre); robespierre #σʔληοτͷ֬ೝ 4. robespierre.2 <- robespierre[-6, ]; robespierre.2 # σʔλ࠷ ऴߦʢothers ͷߦʣͷ࡟আ 5. mosaicplot(robespierre.2) 6. mosaicplot(robespierre.2, las=2) #ϥϕϧͷ޲͖Λม͑Δ 1. ϞβΠΫϓϩοτΛඳ͘
  5. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  6. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  7. • 2࣍ݩσʔλʢ2มྔσʔλʣΛՄࢹԽ͢Δࢄ෍ਤΛඳը 1. FPP <- read.csv(file(file.choose(), encoding = "cp932"), header

    = TRUE, row.names = 1) 1. # CSVϑΝΠϧ͔ΒͷσʔλಡΈࠐΈʢFPP.csvΛબ୒ʣ 2. head(FPP, 5 )#σʔλͷ๯಄ͷ5ߦͷΈΛදࣔ 3. plot(FPP[, 1], FPP[, 4]) # ࢄ෍ਤΛඳը 4. plot(FPP[, 1], FPP[, 4], main = "FPP", xlab = "Google", ylab = "BCCWJ") 1. # ࢄ෍ਤͷҾ਺Λࢦఆ 5. plot(FPP[, 1], FPP[, 4], main = "FPP", xlab = "Google", ylab = "BCCWJ", cex = 1.2, pch = 16, col = "grey") 1. # ఺ͷେ͖͞ͱλΠϓͱ৭Λࢦఆ 2. ࢄ෍ਤΛඳ͘: جૅฤ
  8. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  9. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  10. • ߦ΍ྻ͕3ͭҎ্͋Δ৔߹ʹࢄ෍ਤߦྻΛඳը 1. install.packages("car", dependencies = TRUE) 2. library(car) 3.

    scatterplot(FPP[, 1], FPP[, 4], xlab = "Google", ylab = "BCCWJ", smoother = FALSE, reg.line = FALSE) # ࢄ෍ਤͱശͻ͛ਤΛಉ࣌ʹඳը 4. pairs(FPP) # ࢄ෍ਤߦྻΛඳը 3. ࢄ෍ਤΛඳ͘: ൃల൛
  11. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  12. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  13. ·ͱΊ • ࢴഔମͳΒݱ࣮తʹ… • boxplot + beeswarm / violin plot

    • Web (HTML) Ͱͷެ։͕ OK ͳΒ… • explosion boxplot ͸͍͍͔΋!
  14. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  15. Agenda 1. ϞβΠΫϓϩοτΛඳ͘ (20) 2. ࢄ෍ਤΛඳ͘: جૅฤ (20) 3. ࢄ෍ਤΛඳ͘:

    ൃలฤ (10) 4. ಈతͳਤΛඳ͘ (10) 5. ԋशʹ͙࣍ԋश (30)
  16. 5. ԋशʹ͙࣍ԋश 1. http://sakaue.info ͷ RBC ಛઃαΠτ͔Βຊԋश༻ σʔλΛऔͬͯ͘Δ 2. μ΢ϯϩʔυͨ͠σʔλΛ

    RStudio Server ʹҠಈ 3. ϑΝΠϧͷத਎Λ֬ೝ͠ɼ֤ྻͷཁ໿౷ܭྔΛٻΊΔ 4. Pre testɼPost test ͷࢄ෍ਤΛඳ͘ 1. ϓϩοτͷҹͷछྨΛม͑Δ 2. X ࣠ͱY ࣠ͷൣғΛ 0͔Β100·Ͱʹࢦఆ 3. ର֯ઢͷิॿઢΛՃ͑ΔʢάάΔʣ
  17. 5. ԋशʹ͙࣍ԋशʢώϯτʣ 1. http://sakaue.info ͷ RBC ಛઃαΠτ͔Βຊԋश༻σʔ λΛऔͬͯ͘Δ 2. RStudio

    Server ͷ Upload ϘλϯΛԡ͠·͠ΐ͏ 3. apply() ؔ਺ͱ summary() ؔ਺Λ࢖͍·͠ΐ͏ 4. 6ݶͰ࢖ͬͨม਺Λ࢖͍ɼboxplot() ؔ਺Λ࢖͍·͠ΐ͏ 1. Ҿ਺ pch Λ࢖͍·͠ΐ͏ 2. Ҿ਺ xlimɼylim Λ࢖͍·͠ΐ͏ 3. lines(par()$usr[1:2], par()$usr[3:4], lty = 2) Ͱඳ͚·͢
  18. 0 20 40 60 80 100 0 20 40 60

    80 100 pretest posttest
  19. •And/and, But/but ͷݕࡧ݁ՌΛϞβΠΫϓϩοτͰՄࢹԽ 1. http://sakaue.info ͷ RBC ಛઃαΠτ͔Βຊԋश༻σʔ λΛऔͬͯ͘Δ •TXT

    σʔλΛՃ޻͠୯ޠʹ੾Γ෼͚Δ •੾Γ෼͚ͨ΋ͷʹର͠ݕࡧΛ͔͚Δʢਖ਼نදݱʣ •ॲཧʹ࢖͏ओͳؔ਺ʢσʔλಡΈࠐΈ΋͓๨Εͳ͘ʣ •strsplit(), unlist(), grep(), length(), mosaicplot() •ม਺ͷத਎Λਵ࣌֬ೝ͢Δ 5. ԋशʹ͙࣍ԋश
  20. •And/and, But/but ͷݕࡧ݁ՌΛϞβΠΫϓϩοτͰՄࢹԽ 1. http://sakaue.info ͷ RBC ಛઃαΠτ͔Βԋश༻σʔλΛऔͬͯ͘Δ •୯ޠʹ੾Γ෼͚Δʹ͸ strsplit

    ͱ unlist Λ࢖͍·͢ʢҾ਺ʹ༻৺ʣ •ݕࡧʹ͸ grep() ؔ਺Λ࢖͍ɼ਺͑Δʹ͸ length() ؔ਺Λ࢖͍·͢ •ॲཧʹ࢖͏ओͳؔ਺ʢσʔλಡΈࠐΈ΋͓๨Εͳ͘ʣ •strsplit(), unlist(), grep(), length(), mosaicplot() •ݕࡧ਺ΛٻΊͨΒɼߦྻΛ࡞ΓɼϞβΠΫϓϩοτΛඳ͖·͢ •จࣈྻॲཧܥ͸ओʹୈ4ݶͱୈ6ݶͷࢿྉΛݟ௚ͯ͠Έ·͠ΐ͏ 5. ԋशʹ͙࣍ԋशʢώϯτʣ
  21. • R Ͱجຊతͳݕࡧɾ෼ੳͳΒ͹... 1) σʔλΛ strsplit() ʴ unlist() ͯ͠ 2)

    grep() ͱ length() ͰΧ΢ϯτ 3) plot() ΍ mosaicplot() ͳͲͰՄࢹԽ 4) chisq.test() ͳͲͰݕఆ ݴޠσʔλॲཧͷ·ͱΊ