TheAceHome

Untitled

Apr 29th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. setwd("C:\\Users\\nikit\\Downloads")
  2. # Вектор
  3. c(1,2,3,4,5)
  4. fakedata <- c(1,2,3,4,5) # Назначить переменной
  5.  
  6. fakedata[1]
  7.  
  8. # Фрейм данных
  9. morefake <- c("a", "a", "a", "a", "a")
  10. cbind(fakedata, morefake) # Матрица, значения преобразуются в символы
  11. fake.df <- data.frame(cbind(fakedata, morefake))
  12. fake.df$morefake <- as.character(fake.df$morefake)
  13. colnames(fake.df)
  14.  
  15. # Загрузка данных в фрейм данных
  16. education <- read.csv("2009education.csv", header=TRUE, sep=",", as.is=TRUE)
  17. education[1,] # Первый ряд
  18. education[1:10,] # Первые десять рядов
  19. education$state # Первый столбец
  20. education[,1] # Первый столбец
  21. education[1,1] # Первая ячейка
  22.  
  23. # Сортировать от наименьшего к наибольшему
  24. high.order <- order(education$high)
  25. education.high <- education[high.order,]
  26.  
  27. ## основные графики
  28.  
  29. plot(fakedata)
  30. plot(education.high$high)
  31. plot(education$high, education$bs)
  32. plot(education[,2:4])
  33.  
  34. # Виды графиков
  35. plot(education.high$high, type="l")
  36. plot(education.high$high, type="h")
  37. plot(education.high$high, type="s")
  38.  
  39.  
  40.  
  41.  
  42. # Остальные графики
  43. par(mfrow=c(3,3), mar=c(2,5,2,1), las=1, bty="n")
  44. plot(education.high$high)
  45. plot(education$high, education$bs)
  46. plot(education.high$high, type="l")
  47. plot(education.high$high, type="h")
  48. plot(education.high$high, type="s")
  49. barplot(education$high)
  50. barplot(education$high, names.arg=education$state, horiz=TRUE, las=1, cex.names=0.5, border=NA)
Advertisement
Add Comment
Please, Sign In to add comment