I have a dataframe and the head() looks like this:
CEMETERY SEX CONTEXT RaHD L RaHD R DIRECTIONAL ASYMMETRY
1 Medieval-St. Mary Graces FEMALE 7172 21.2 21.6 NA
2 Medieval-St. Mary Graces MALE 6225 23.9 25.2 NA
3 Medieval-St. Mary Graces MALE 9987 23.9 23.5 NA
4 Medieval-St. Mary Graces MALE 11475 22.4 22.3 NA
5 Medieval-St. Mary Graces MALE 12356 25.8 25.4 NA
6 Medieval-St. Mary Graces MALE 12525 22.4 22.3 NA
(RaHD L and RaHD R are bone measurements). I have just created the 'DIRECTIONAL ASYMMETRY' column by doing:
MRaHDTABLE["DIRECTIONAL ASYMMETRY"]=NA
and I now need to input data into that column. The formula for directional asymmetry is '%DA = (right - left) / (average of left and right) x 100' so would be (RaHD R - RaHD L) / (average of RaHD R and RaHD L) x 100. I'm not sure how to input this into my table as I tried:
MRaHDTABLE$'DIRECTIONAL ASYMMETRY'=(MRaHDTABLE$`RaHD R`-
MRaHDTABLE$`RaHDL`)/mean(MRaHDTABLE$`RaHD L`,MRaHDTABLE$`RaHD R`)*100
but got the error:
Error in mean.default(MRaHDTABLE$`RaHD L`, MRaHDTABLE$`RaHD R`) :
'trim' must be numeric of length one
RaHD.LandRaHD_Lare both good alternatives.(21.6 -21.2)/((21.6-21.2)/2)*100or do you take the average of the whole column?DA <- function(x, y) {(x-y)/mean(x,y)*100}, and thenmapply(DA, x= MRaHDTABLE$'RaHD L', y= MRaHDTABLE$'RaHD R')