4-7 總結資料資訊
阿新 • • 發佈:2018-11-11
> head(airquality,10) Ozone Solar.R Wind Temp Month Day 1 41 190 7.4 67 5 1 2 36 118 8.0 72 5 2 3 12 149 12.6 74 5 3 4 18 313 11.5 62 5 4 5 NA NA 14.3 56 5 5 6 28 NA 14.9 66 5 6 7 23 299 8.6 65 5 7 8 19 99 13.8 59 5 8 9 8 19 20.1 61 5 9 10 NA 194 8.6 69 5 10 > tail(airquality) Ozone Solar.R Wind Temp Month Day 148 14 20 16.6 63 9 25 149 30 193 6.9 70 9 26 150 NA 145 13.2 77 9 27 151 14 191 14.3 75 9 28 152 18 131 8.0 76 9 29 153 20 223 11.5 68 9 30 > summary(airquality) Ozone Solar.R Wind Temp Month Min. : 1.00 Min. : 7.0 Min. : 1.700 Min. :56.00 Min. :5.000 1st Qu.: 18.00 1st Qu.:115.8 1st Qu.: 7.400 1st Qu.:72.00 1st Qu.:6.000 Median : 31.50 Median :205.0 Median : 9.700 Median :79.00 Median :7.000 Mean : 42.13 Mean :185.9 Mean : 9.958 Mean :77.88 Mean :6.993 3rd Qu.: 63.25 3rd Qu.:258.8 3rd Qu.:11.500 3rd Qu.:85.00 3rd Qu.:8.000 Max. :168.00 Max. :334.0 Max. :20.700 Max. :97.00 Max. :9.000 NA's :37 NA's :7 Day Min. : 1.0 1st Qu.: 8.0 Median :16.0 Mean :15.8 3rd Qu.:23.0 Max. :31.0 > str(airquality) 'data.frame': 153 obs. of 6 variables: $ Ozone : int 41 36 12 18 NA 28 23 19 8 NA ... $ Solar.R: int 190 118 149 313 NA NA 299 99 19 194 ... $ Wind : num 7.4 8 12.6 11.5 14.3 14.9 8.6 13.8 20.1 8.6 ... $ Temp : int 67 72 74 62 56 66 65 59 61 69 ... $ Month : int 5 5 5 5 5 5 5 5 5 5 ... $ Day : int 1 2 3 4 5 6 7 8 9 10 ... > table(airquality$Month) 5 6 7 8 9 31 30 31 31 30 > table(airquality$Ozone,useNA = "ifany") 1 4 6 7 8 9 10 11 12 13 14 16 18 19 20 21 22 1 1 1 3 1 3 1 3 2 4 4 4 4 1 4 4 1 23 24 27 28 29 30 31 32 34 35 36 37 39 40 41 44 45 6 2 1 3 1 2 1 3 1 2 2 2 2 1 1 3 2 46 47 48 49 50 52 59 61 63 64 65 66 71 73 76 77 78 1 1 1 1 1 1 2 1 1 2 1 1 1 2 1 1 2 79 80 82 84 85 89 91 96 97 108 110 115 118 122 135 168 <NA> 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 37 > table(airquality$Month,airquality$Day) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 31 5 1 6 0 7 1 8 1 9 0 > any(is.na(airquality)) [1] TRUE > sum(is.na(airquality)) [1] 44 > all(airquality$Month<12) [1] TRUE > titanic <- as.data.frame(Titanic) > head(titanic) Class Sex Age Survived Freq 1 1st Male Child No 0 2 2nd Male Child No 0 3 3rd Male Child No 35 4 Crew Male Child No 0 5 1st Female Child No 0 6 2nd Female Child No 0 > dim(titanic) [1] 32 5 > summary(titanic) Class Sex Age Survived Freq 1st :8 Male :16 Child:16 No :16 Min. : 0.00 2nd :8 Female:16 Adult:16 Yes:16 1st Qu.: 0.75 3rd :8 Median : 13.50 Crew:8 Mean : 68.78 3rd Qu.: 77.00 Max. :670.00 > x <- xtabs(Freq ~ Class + Age,data=titanic) > x Age Class Child Adult 1st 6 319 2nd 24 261 3rd 79 627 Crew 0 885 > ftable(x) Age Child Adult Class 1st 6 319 2nd 24 261 3rd 79 627 Crew 0 885 > object.size(airquality) 5632 bytes > print(object.size(airquality),units = "KB") 5.5 Kb