I am trying to estimate the mean value of a lab test reading igg1_norm across different categories of a variable type (5 categories).
db <- forg %>%
group_by(forg$type)%>%
summarise(mean=mean(forg$igg1_norm, na.rm=TRUE),sd=sd(forg$igg1_norm, na.rm=TRUE),lower = mean(forg$igg1_norm, na.rm=TRUE) - sd(forg$igg1_norm, na.rm=TRUE), upper = mean(forg$igg1_norm, na.rm=TRUE) + sd(forg$igg1_norm, na.rm=TRUE))
My data looks like as per below
cowidfarm type time_num igg1_norm igg2_norm
<chr> <fct> <fct> <labelled> <labelled>
1 LM1047 3 1 0.1080482 0.4526854
2 LM1047 3 2 0.1833975 0.6029548
3 LM1047 3 3 0.1704118 0.5394913
4 LM1050 1 1 0.2883397 0.4347826
5 LM1050 1 2 0.1453905 0.5655340
6 LM1050 1 3 0.3302948 0.4962779
7 LM1134 3 1 0.4498922 0.6672078
8 LM1134 3 2 0.2641302 0.6204986
9 LM1134 3 3 0.3207913 0.5074442
10 LM1221 3 1 1.2184955 0.8653846
I get no errors when running the code but the output is odd as I get only one value when I was expecting 5 values (one for each category).
mean sd lower upper
1 0.4046562 0.3239133 0.08074287 0.7285695
Does anyone have an idea of what I am doing wrong? Any help is dearly appreciated
question from:
https://stackoverflow.com/questions/66068409/getting-the-same-value-when-estimating-the-mean-across-different-categories 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…