Skip to content
Prev 360133 / 398503 Next

Unequal column lengths

Many basic summary stats in R will not work (i.e. usually return an NA) if there are NAs in the data unless you explicitylauthorize it to do so.

With your data set df
with(df, mean(Dat2, na.rm = TRUE))
[1] 5

This by the way is functionally the same as 
mean(df$Dat2, na.rm = TRUE) 
It's just easier to type the first one 


In other cases R will do not object to the NA's

summary(df)
     Dat1          Dat2        Dat3     
 Min.   :1.0   Min.   :3   Min.   :4.00  
 1st Qu.:2.0   1st Qu.:4   1st Qu.:4.75  
 Median :3.0   Median :5   Median :5.00  
 Mean   :4.4   Mean   :5   Mean   :5.75  
 3rd Qu.:7.0   3rd Qu.:6   3rd Qu.:6.00  
 Max.   :9.0   Max.   :7   Max.   :9.00  
               NA's   :2   NA's   :1     


John Kane
Kingston ON Canada
____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!