I’m trying to add a Row to my data.frame to spit out the average of the column.
This is my data frame:
Weight Response
1 Control 59 0.0
2 Treatment 90 0.8
3 Treatment 47 0.1
4 Treamment 106 0.1
5 Control 85 0.7
6 Treatment 73 0.6
7 Control 61 0.2
I’d like it to become:
Weight Response
1 Control 59 0.0
2 Treatment 90 0.8
3 Treatment 47 0.1
4 Treamment 106 0.1
5 Control 85 0.7
6 Treatment 73 0.6
7 Control 61 0.2
8 AVERAGES 74 0.3
Thanks!
Simple one:
[Edit] If your
data.framecontains other types thannumeric(likefactororcharacter) then you could use more complicated but safer method:Simple example:
logicalcolumn is converted to numeric, and for non-numeric columns there areNA‘s