I am working with a dataframe of enzyme activities by different components. The table lists the components in the description column. There are multiple entries for for each different component. I want the mean activity of each of the different components. I've been unable to discern why I cannot gent an answer other than NA for the table produced using group_by and summarise.
Here is the Table:
structure(list(lot = c("CLS-X X030118", "CLS-X X030118", "CLS-X X030118",
"CLS-X X030118", "CLS-X X030118", "CLS-X X030118", "CLS-X X030118",
"CLS-X X030118", "CLS-X X030118", "CLS-X X030118"), COLLAGENASE = c(736,
1029, 958, 1017, 468, 468, 579, 597, 759, 668), Description = c("Pharmatone 25b",
"Pharmatone 25b", "Pharmatone 25b", "Pharmatone 25b", "Primatone HS",
"Primatone HS", "Primatone HS", "Primatone HS", "Primatone RL",
"Primatone RL")), row.names = c(NA, -10L), class = c("tbl_df",
"tbl", "data.frame"))
# A tibble: 10 x 3
lot COLLAGENASE Description
<chr> <dbl> <chr>
1 CLS-X X030118 736 Pharmatone 25b
2 CLS-X X030118 1029 Pharmatone 25b
3 CLS-X X030118 958 Pharmatone 25b
4 CLS-X X030118 1017 Pharmatone 25b
5 CLS-X X030118 468 Primatone HS
6 CLS-X X030118 468 Primatone HS
7 CLS-X X030118 579 Primatone HS
8 CLS-X X030118 597 Primatone HS
9 CLS-X X030118 759 Primatone RL
10 CLS-X X030118 668 Primatone RL
The df is called peptest. Here is the code:
testgrpby<- peptest %>%
group_by(Description) %>% summarise(
mean("COLLAGENASE" , na.rm=TRUE ))
I have tried to make the COLLAGENASE column numeric. I still get NA's
Here is the problem on Stackoverflow.
https://stackoverflow.com/questions/74237485/mean-from-multiple-columns-using-group-by-and-summarize-returns-na
I have been stuck on this for days.