Advertisement
Ashenk97

PS - LAB 07

Sep 10th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.15 KB | None | 0 0
  1. #Extra
  2.  
  3. #.xlsx --> .csv
  4.  
  5. #Opening csv file
  6. #data{#variable name} <- read.csv('filename.csv', header=TRUE)
  7.  
  8. #Opening text file
  9. #data{#variable name} <- read.table('filename.txt', header=TRUE,sep=","{#Because data is seperated by ','s})
  10.  
  11. #To clear console
  12. #Ctrl + L
  13.  
  14. #LAB 07
  15. #Set Path
  16. setwd("C:\\Users\\it18011012\\Desktop\\IT18011012")
  17. getwd()
  18.  
  19. #1
  20.  
  21. #read data from the text file
  22. data<-read.table("Forest.txt",header=TRUE,sep=",")
  23. attach(data)
  24. fix(data)
  25.  
  26.  
  27. #2
  28. #Summary/Strucure of data variable
  29. str(data)
  30.  
  31.  
  32. #3
  33. #str - Used to count obesrvations
  34. #Observations = 517
  35.  
  36. #4
  37. min(wind)
  38. max(wind)
  39.  
  40. #5
  41. summary(temp)
  42.  
  43. #6
  44. boxplot(wind, horizontal = TRUE, outline = TRUE, pch=16)
  45. #pch = Symbols for representing outliers. ex:-8,16,24
  46.  
  47. #7
  48. #Negative
  49.  
  50. #8
  51. median(temp)
  52.  
  53. #9
  54. mean(wind)
  55. sd(wind)
  56.  
  57. sapply(data,sd)
  58.  
  59. #10
  60. IQR(wind)
  61.  
  62. #11
  63. #Create a frequency table with day &month count
  64. freq<-table(day, month)
  65. freq
  66. #Answer = 21
  67.  
  68. #12
  69. #Average = Mean
  70. mean(temp[month=='sep'])
  71.  
  72. #13
  73. barplot(freq,beside = TRUE,xlab = "Month",ylab="Frequency",legend=rownames(freq))
  74. #Beside = TRUE --> Bars in seperate
  75. #Beside = FALSE --> Bars in one
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement