[R] stdev error

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri Mar 11 15:30:16 CET 2022


В Fri, 11 Mar 2022 08:14:52 -0600
"Jeff Reichman" <reichmanj using sbcglobal.net> пишет:

> I get the following error:
> 
>> Error: `stdev` refers to a variable created earlier in this
>> summarise().
>> 
>> Do you need an extra mutate() step?
> 
> I suspect it is because the standard deviation of a length-one vector
> is NA and R is errorerrors out on the standard deviation  of 1.

My interpretation of the error message is that summarise() thinks that
you're creating a variable (Bse_ftv = mean(Bse_ftv)) and then asking
summarise() to compute its standard deviation (stdev = sd(Bse_ftv)) in
the same call. This is apparently not always supported, according
to ?summarise [1].

You know that you meant the previously available Bse_ftv column, not
the newly created Bse_ftv = mean(Bse_ftv), but this is not how the call
is interpreted. Try setting a different name for the result of
mean(Bse_ftv).

-- 
Best regards,
Ivan

[1] https://search.r-project.org/CRAN/refmans/dplyr/html/summarise.html



More information about the R-help mailing list