I use the dataset airqualityavailable in R and try to count the number of rows in the data that do not contain any NAs, but aggregating by Month.
The data is as follows:
head(airquality)
As you can see, I have NAin the columns Ozoneand Solar.R. I used the function complete.casesas follows:
x <- airquality[,1]
y <- airquality[,2]
ok <- complete.cases(x,y)
And then to check:
nrow(airquality)
sum(!ok)
sum(ok)
which is great.
But now I would like to allocate this data for sorting Month(Column5), and in this I ran into problems - when trying aggregateor the sortvalue in column5 ( Month).
, Month ( , ):
aggregate(x = sum(complete.cases(airquality)), by= list(nrow(airquality)), FUN = sum)
... , . by . 5 airquality.
- airquality[,5]
- airquality[,"Month"]
:
aggregate(x = sum(complete.cases(airquality)), by= list(airquality[,5]), FUN = sum)
aggregate(x = sum(complete.cases(airquality)), by=
list(sum(complete.cases(airquality)),airquality[,5]), FUN = sum)
?aggregate(x, ...). by...
by - , , x. .
?factor, , , , ( ). break =, .
", ", , , # SQL.
:
Count Month
24 5
9 6
26 7
23 8
29 9