Not sure why R won't calculate the means of my data correctly. I do have a lot of NA values but R keeps telling me that the mean is NA. Here's an example:
data1=read_excel"pepper.xlsx"
data1$cultivar = as.factor(data1$cultivar)
mean = aggregate(data1[,3:4], list(data1$cultivar), mean)
| cultivar | replication | width | height |
|---|---|---|---|
| BOF | 1 | 12 | 14 |
| BOF | 2 | 10 | NA |
| BOF | 3 | NA | 15 |
| BOF | 4 | NA | NA |
Instead of computing the mean width of BOF being 11 and the mean height being 14.5, it computes the means of the height and width as NA. This is an over-simplification of my data. I have several cultivars in my study and calculated the means of each variable of each cultivar using the aggregate function.