Advertisement
Guest User

lab2 R

a guest
Mar 31st, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. #ZAD. 1
  2. library(ggplot2)
  3. library(PogromcyDanych)
  4. setLang(lang = 'eng')
  5. ggplot(cats_birds, aes(x = length,
  6. y = speed,
  7. shape = group,
  8. color = group)) +
  9. geom_point(size = 5) +
  10. geom_line()
  11. #tutaj nie jestem pewien tej linii
  12. #ZAD. 2
  13. ggplot(pearson, aes(x = son,
  14. y = father,
  15. color = son)) +
  16. geom_point(size = 1)+
  17. geom_smooth(color = 'red')
  18.  
  19. #ZAD. 3
  20. ggplot(seriesIMDB, aes(x = series,
  21. y = note)) +
  22. geom_boxplot()
  23. #brakuje sortowania
  24.  
  25. #ZAD. 4
  26. ggplot(diagnosis, aes(x = eduk4_2013,
  27. fill = gp29)) +
  28. geom_bar()
  29.  
  30. #ZAD. 5
  31.  
  32. auta2012 %>%
  33. filter(Brand == 'Volkswagen',
  34. Model == 'Passat') %>%
  35. select(Brand, Model, Year, Price) -> data.paseratti
  36.  
  37. figure<-ggplot(data.paseratti, aes(x = Year, y = Price)) +
  38. geom_smooth()+
  39. ylim(0, 20000)
  40.  
  41. figure + theme_bw()
  42. figure + theme_gray()
  43. figure + theme_dark()
  44. figure + theme_classic()
  45. figure + theme_light()
  46. figure + theme_linedraw()
  47. figure + theme_void()
  48. figure + theme_excel_new()
  49. figure + theme_minimal()
  50. figure + theme_economist()
  51. figure + theme_fivethirtyeight()
  52. figure + theme_foundation()
  53.  
  54. #ZAD. 6
  55. auta2012 %>%
  56. filter(Brand == 'Toyota') %>%
  57. select(Brand,Model) %>% group_by(Model) %>% summarise(counter = n()) ->data.toyki
  58. data.toyki[order(data.toyki$counter,decreasing = TRUE),] %>% top_n(5)->najtoyki
  59.  
  60. area<- ggplot(najtoyki, aes(x="", y=counter, fill=Model))+
  61. geom_bar(width = 1, stat = "identity")
  62. area
  63.  
  64. pie <- area + coord_polar("y", start=0)
  65. pie
  66.  
  67. auta2012 %>%
  68. filter(Brand == 'Toyota') %>%
  69. select(Brand,Model)->bartoyki
  70.  
  71. #brakuje barplota
  72. ggplot(bartoyki , aes(x = najtoyki$Model)) +
  73. geom_bar()+
  74. ylim(0, 1750)
  75.  
  76. #ZAD. 7
  77. #tego zadania ani ja ani Ola nie kumamy xD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement