Displaying 2 results from an estimated 2 matches for "db10_means".
2024 Sep 16
2
(no subject)
...win dataset in which the mean of the group is replaced instead of
individual values.
So for example, groupid 3, I calculate the mean (12+18)/2 and then I
replace in the new dataframe, but in the same positions, instead of 12 and
18, the values of the corresponding mean.
I found this solution, where db10_means is the output dataset, db10 is my
initial data.
db10_means<-db10 %>%
group_by(groupid) %>%
mutate(across(starts_with("cp"), list(mean = mean)))
It works perfectly, except that for NA values, where it replaces to all
group members the NA, while in some cases, the group is ma...
2024 Sep 17
1
(no subject)
...for example, groupid 3, I calculate the mean (12+18)/2 and then I
> > >>> replace in the new dataframe, but in the same positions, instead of 12
> > >> and
> > >>> 18, the values of the corresponding mean.
> > >>> I found this solution, where db10_means is the output dataset, db10 is
> > my
> > >>> initial data.
> > >>>
> > >>> db10_means<-db10 %>%
> > >>> group_by(groupid) %>%
> > >>> mutate(across(starts_with("cp"), list(mean = mean)))
>...