Re: [R] stdev error

2022-03-11 Thread Chris Evans
Can't see your data but perhaps: my_tbl %>% mutate(Bse_bwt = round(Bse_bwt * 2) / 2) %>% group_by(Cat, Bse_bwt) %>% summarize(count = n(), Bse_ftv = mean(Bse_ftv), stdev = if_else(count > 1, sd(Bse_ftv), NA_real_)) - Original Messa

Re: [R] stdev error

2022-03-11 Thread Eric Berger
try changing Bse_ftv = mean(Bse_ftv) to Bse_ftv_mean = mean(Bse_ftv) On Fri, Mar 11, 2022 at 4:15 PM Jeff Reichman wrote: > r-help forum > > > > When I run the following code > > > > my_tbl %>% > > mutate(Bse_bwt = round(Bse_bwt * 2) / 2) %>% > > group_by(Cat, Bse_bwt) %>% > > summarize(co

Re: [R] conditional filling of data.frame - improve code

2022-03-11 Thread Rui Barradas
Heello, I hadn't posted an answer because my mapply is more complicated that the original and much more complicated than Jeff's merge but here it is. But if there's a problem with the output of merge, maybe the mapply can be of use, only the column expressly named is created. The result is eq

Re: [R] conditional filling of data.frame - improve code

2022-03-11 Thread Ivan Calandra
In my first trials, I made a typo, which resulted in more columns than needed in the output of merge, which is why I needed more formatting. But now, it is indeed done all in one line and it is, as I said already, nicer anyway! -- Dr. Ivan Calandra Imaging lab RGZM - MONREPOS Archaeological Re