Advertisement
Guest User

EDA codes

a guest
Jan 28th, 2020
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5.39 KB | None | 0 0
  1. attach(studentsurvey_2)
  2. table (Smoke)
  3.  
  4. attach(studentsurvey_2)
  5. table(Height)
  6. height_factor= cut(Height, breaks= c(0, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200))
  7. table(height_factor)
  8. height_factor1= cut(Height, breaks= c(0, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200),
  9.                     labels= c("below 150 centimeters", "151 to 155 centimeters", "156 to 160 centimeters", "161 to 165 centimeters", "166 to 170 centimeters", "171 to 175 centimeters", "176 to 180 centimeters", "181 to 185 centimeters", "186 to 190 centimeters", "191 to 195 centimeters", "196 centimeters and above"))
  10. table(height_factor1)    
  11.  
  12. attach(studentsurvey_2)
  13. table(Fold)
  14.  
  15.  
  16. attach(studentsurvey_2)
  17. table(Pulse)
  18. pulse_factor= cut(Pulse, breaks= c(0, 30, 40, 50, 60, 70, 80, 90, 100, 110))
  19. table(pulse_factor)
  20. pulse_factor2= cut(Pulse, breaks= c(0, 30, 40, 50, 60, 70, 80, 90, 100, 110),
  21.                    labels= c("30 bpm and below", "31 to 40 bpm", "41 to 50 bpm","51 to 60 bpm","61 to 70 bpm","71 to 80 bpm","81 to 90 bpm","91 to 100 bpm","101 bpm and above"))
  22. table(pulse_factor2)
  23.  
  24. attach(length_of_service2)
  25. table(`Length of Service`)
  26. length_of_service_factor= cut(`Length of Service`, breaks = c(0, 5, 10, 15, 20, 30))
  27. table(length_of_service_factor)
  28. length_of_service_factor1= cut(`Length of Service`, breaks = c(0, 5, 10, 15, 20, 30), labels = c("1 to 5 years", "6 to 10 years", "11 to 15 years", "16 to 20 years", "21 years and above"))
  29. table(length_of_service_factor1)
  30.  
  31. attach(age_variable)
  32. table(Age)
  33. Age_factor= cut(Age, breaks = c(0, 25, 30, 35, 40, 60))
  34. table(Age_factor)
  35. Age_factor1= cut(Age, breaks = c(0, 25, 30, 35, 40, 60), labels = c("25 years old and below", "26 to 30 years old", "31 to 35 years old", "36 to 40 years old", "41 years old and above"))
  36. table(Age_factor1)
  37.  
  38. my_list=list(a=1:10, name="Mike", gender="Female", TRUE)
  39. my_list
  40. lists=list(a=1:30, seq(1,10,by=0.5), fav_subj=factor(c("EDA","Route_Surveying","Ethics"),ordered=TRUE,levels=c("EDA","Route_Surveying","Ethics")), TRUE)
  41. lists
  42. test=list(seq(1,50,length.out=10),seq(11,21,by=0.3),song=factor(c("Yesterday","Imagine","Into the Unknown","Lover","Let it go"),ordered=TRUE,levels=c("Yesterday","Imagine","Into the Unknown","Lover","Let it go")))
  43. test
  44.  
  45. j=1:6
  46. xmatrix=matrix(j, nrow=2, ncol=3, byrow = T, dimnames=NULL)
  47. xmatrix
  48. xmatrix1=matrix(c(1,2,3,4,5,6), nrow=2, ncol=3, byrow = TRUE, dimnames=list(c("a","b"),c("c","d","e")))
  49. xmatrix1
  50.  
  51. x=1:30
  52. sixfive=matrix(x,nrow=6,ncol=5,byrow=TRUE,dimnames=list(c("A","B","C","D","E","F"),c("Blue","Red","White","Green","Yellow")))
  53. sixfive
  54. sixfive[c("A", "F"),]
  55. sixfive[,c("White", "Yellow")]
  56.  
  57. name = c("Jhancel","Avemae", "Maricel", "Josiephine", "Leslie", "Leandro", "Gabriel", "Mark Jayson", "Keano", "Aira")
  58. favoritemovie = c("Deadpool", "Can't Help Falling in Love", "Anak", "The hows of Us", "The Notebook", "Guardians Of the Galaxy", "Black Panther", "Five Feet Apart", "Olympus Has Fallen", "HIgh School Musical")
  59. sports = c("Basketball", "Badminton", "N/A", "Volleyball", "Volleyball", "Basketball", "Basketball", "Basketball", "Tennis", "N/A")
  60. status = c("Married", "Married", "Widowed", "Single", "Single", "Single", "Single", "Single", "Single", "Single")
  61. age = c (26, 22, 43, 19, 20, 20, 20, 20, 20, 20)
  62. celebritycrush = c("Anne Curtis", "Coco Martin", "Brad Pitt", "Daniel Padilla", "Liam Hemsworth", "Dahyun", "Scarlett Johansson", "Mina", "Kendall Jenner", "Enrique Gil")
  63. Description = data.frame(name, favoritemovie, sports, status, age, celebritycrush)
  64.  
  65.  
  66. str(Description)
  67.  
  68. Description$name
  69. Description$favoritemovie
  70. Description$name
  71. Description$status
  72.  
  73. name = c("Jhancel","Avemae", "Maricel", "Josiephine", "Leslie", "Leandro", "Gabriel", "Mark Jayson", "Keano", "Aira")
  74. favoritemovie = c("Deadpool", "Can't Help Falling in Love", "Anak", "The hows of Us", "The Notebook", "Guardians Of the Galaxy", "Black Panther", "Five Feet Apart", "Olympus Has Fallen", "HIgh School Musical")
  75. sports = c("Basketball", "Badminton", "N/A", "Volleyball", "Volleyball", "Basketball", "Basketball", "Basketball", "Tennis", "N/A")
  76. status = c("Married", "Married", "Widowed", "Single", "Single", "Single", "Single", "Single", "Single", "Single")
  77. age = c (26, 22, 43, 19, 20, 20, 20, 20, 20, 20)
  78. celebritycrush = c("Anne Curtis", "Coco Martin", "Brad Pitt", "Daniel Padilla", "Liam Hemsworth", "Dahyun", "Scarlett Johansson", "Mina", "Kendall Jenner", "Enrique Gil")
  79. Description = data.frame(name, favoritemovie, sports, status, age, celebritycrush)
  80. zxc= subset(Description, status!= "Single"& age<20)
  81. zxc
  82.  
  83. Name=c("Sam","Kim","Jeff","Ley","Ann","Jim","Steph","Mimi","Ana","Reg")
  84. Gender=c("Male","Male","Male","Male","Female","Male","Female","NA","Female","Female")
  85. Age=c(23,26,32,20,31,32,40,39,20,20)
  86. Marital_Status=c("Single","Single","Single","Married","Widow","Separated","Single","Married","Single","Single")
  87. Highest_Educational_Attainment=c(4,3,2,5,6,4,1,4,4,5)
  88. DF=data.frame(Name,Gender,Age,Marital_Status,Highest_Educational_Attainment)
  89. DF
  90. SD=subset(DF,Gender=="Male" & Marital_Status=="Single" & Age>=30 & Age<=40 & Highest_Educational_Attainment>=4)
  91. SD
  92.  
  93. final_scores= c(40, 78, 80, 90, 92, 56, 72, 55, 88, 81, 81, 79, 93)
  94. ifelse(final_scores>=60, "PASS", "FAILED")
  95.  
  96. final_scores= c(40, 78, 80, 90, 92, 56, 72, 55, 88, 81, 81, 79, 93)
  97. ifelse(final_scores<=60, "E", ifelse(final_scores<=70, "D", ifelse(final_scores<=80, "C", ifelse(final_scores<=90, "B", ifelse(final_scores<=100, "A")))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement