Dear r-help reader,
I have some problems with the aggregate function.
My datframe looks like
frame
Day Time V1 V2
1 M0 3 NA
2 M0 4 NA
3 M0 5 2
4 M1 NA 4
5 M1 10 6
6 T0 4 45
7 T1 4 3
8 T1 3 2
9 T1 6 1
I used the aggegate
Frank [EMAIL PROTECTED] writes:
aggregate(frame[,c(-1)],list(frame$Day,frame$Time),mean)
My problem is now that I do not obtain a 'mean' for Day=M/Time=0 and
Day=M/Time=1,
because aggregate ignores all values for a grouping variable if NA
occurs.
No. But mean() will give an NA
aggregate(frame[,c(-1)],list(frame$Day,frame$Time),mean, na.rm=T)
2006/10/1, Frank [EMAIL PROTECTED]:
Dear r-help reader,
I have some problems with the aggregate function.
My datframe looks like
frame
Day Time V1 V2
1 M0 3 NA
2 M0 4 NA
3 M0 5 2
4 M1 NA
See ?mean and note the na.rm= argument:
aggregate(frame[-1], frame[1:2], mean, na.rm = TRUE)
On 10/1/06, Frank [EMAIL PROTECTED] wrote:
Dear r-help reader,
I have some problems with the aggregate function.
My datframe looks like
frame
Day Time V1 V2
1 M0 3 NA
2 M0 4