dataFrames :: Filtering :: subset(), [], sqldf(), transform(), split()
Filtering을 통한, 새로운 data.frame 생성
[]
airquality[airquality$Month==8 & airquality$Temp>90, ] with(airquality, airquality[Month==8 & Temp>90, ])
Subset()
subset(airquality, # data.frame select=Ozone:Wind, # 포함 Column select=-c(Temp) # 제외 Column Month==8 & Temp>90) # Condition
http://stackoverflow.com/questions/9860090/in-r-why-is-better-than-subset
Hadley Wickham 의 글 subset
의 위험성 [here].
sqldf()
library(sqldf) sqldf("SELECT Ozone, Solar.R, Wind FROM airquality WHERE Month==8 and Temp>90")
열추가 :: cbind(), trainform()
cbind(airquality, comp=airquality$Temp/airquality$Wind ) with(airquality, cbind(airquality, comp=Temp/Wind )) transform(airquality, comp=Temp/Wind)
그룹화 :: split()
2nd 인자 기준(grouping factor)으로, 1st 인자를 그룹화시켜 List 생성
split(airquality$Temp, airquality$Month) # 월(Month)별 온도(temp)
$`5` [1] 67 72 74 62 56 66 65 59 61 69 74 69 66 68 58 64 66 57 68 62 59 73 61 61 57 58 57 67 81 79 76 $`6` [1] 78 74 67 84 85 79 82 87 90 87 93 92 82 80 79 77 72 65 73 76 77 76 76 76 75 78 73 80 77 83 $`7` [1] 84 85 81 84 83 83 88 92 92 89 82 73 81 91 80 81 82 84 87 85 74 81 82 86 85 82 86 88 86 83 81 $`8` [1] 81 81 82 86 85 87 89 90 90 92 86 86 82 80 79 77 79 76 78 78 77 72 75 79 81 86 88 97 94 96 94 $`9` [1] 91 92 93 93 87 84 80 78 75 73 81 76 77 71 71 78 67 76 68 82 64 71 81 69 63 70 77 75 76 68