R is doing a very strange thing where it is not giving me an error message and instead just not computing what I've told it to compute. I'm attempting to find the standard error of a variable and the command is producing NAs instead and I cannot figure out why. Here's my code for getting the mean and standard error:
ReHo_mean_Esc_1 <- ReHo_Group_Esc_1 %>% group_by(Group) %>% summarise(Value=mean(Value), se=sd(Value)/sqrt(n()))
My variable of interest is called Value. Here's my dataframe:
ID Clu Group Value Esc Nal
422 1 LgA 3.26090 94 7.50
501 1 LgA 3.32376 139 15.25
503 1 LgA 2.76855 24 31.50
521 1 LgA 1.81475 -28 6.75
522 1 LgA 1.80966 58 13.00
523 1 LgA 3.97502 76 10.25
603 1 LgA 1.78573 76 18.00
604 1 LgA 3.70577 54 10.00
605 1 LgA 2.93304 51 18.00
613 1 LgA 3.68118 116 17.00
429 1 ShA 2.61634 -33 5.75
430 1 ShA 3.39848 13 12.75
431 1 ShA 3.40785 -33 9.75
432 1 ShA 4.38024 50 4.75
513 1 ShA 4.14605 8 10.50
514 1 ShA 3.86332 0 10.75
518 1 ShA 2.96312 0 13.00
519 1 ShA 2.82937 -33 7.50
610 1 ShA 5.07850 13 26.00
612 1 ShA 4.14895 56 4.00
614 1 ShA 3.83926 42 8.25
My summarize command has no issues producing the mean for each group but it gives me NAs for the standard error and I have no idea why. Any ideas?
Thanks!
Don't name your new variable Value
. dplyr is different to base R in that it allows newly created variables to be immediately available within the same function.
ReHo_Group_Esc_1 %>%
group_by(Group) %>%
summarise(mValue=mean(Value), se=sd(Value)/sqrt(n()))
# A tibble: 2 x 3
Group mValue se
<chr> <dbl> <dbl>
1 LgA 2.91 0.266
2 ShA 3.70 0.223
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments