[R] dplyr : row total for all groups in dplyr summarise

David Winsemius dwinsemius at comcast.net
Wed Jul 6 20:42:06 CEST 2016


> On Jul 6, 2016, at 9:45 AM, rmendelss gmail <rmendelss at gmail.com> wrote:
> 
> 
>> On Jul 6, 2016, at 9:36 AM, David Winsemius <dwinsemius at comcast.net> wrote:
>> 
>> n this case the text was cut from the R session console text and pasted without modification into Mail.app version 8.2. In replicating this action, I see now that hitting "return" then unfortunately converts the final double-quote to a "smart-quote”.
> 
> Speaking of this, this happens to me a lot when I post, so any example code can not be copied and paste to be reproducible.  Does anyone know of a workaround for this?

Google search: Mail.app changes quotes

https://discussions.apple.com/thread/7065405?tstart=0

If this is on a Mac then the answer it to change setting on the Keyboard/text Control Panel: uncheck the Use smart quotes and dashes:




Test:

mtcars %>%
   group_by (am, gear) %>%
   summarise (n=n()) %>%
   mutate(rel.freq = paste0(round(100 * n/sum(n), 0), "%")) %>%
   ungroup() %>% plyr::rbind.fill(data.frame( n=nrow(mtcars),rel.freq="100%"))


Seems to work.
-- 
David
> 
> Thanks,
> 
> -Roy
> 
> 



More information about the R-help mailing list