llpg
                
              
                
                
              
                  
                  
              1
              
             
            
              Hi,
I don't know why but my columns "annee" where I use the groupby is rename in a bad version :
df <- data.frame(subset(data))[,c("nb_aaa", "nb_bbb")] %>%
  group_by(data[,c("annee")]) %>%
  summarise_each(funs = sum)
It works but my output is :

how can I have only "annee" ?? and not data[,c("annee")]
Thanks
             
            
              
              
              
            
           
          
            
              
                FJCC
                
              
              
                  
                  
              2
              
             
            
              You at least want to write
group_by(annee)
I am not sure what you intend to do with
data.frame(subset(data))[,c("nb_aaa", "nb_bbb")]
Is data a data frame and you want just the columns nb_aaa and nb_bbb? If so, where will the column annee come from ?
             
            
              
              
              
            
           
          
            
              
                FJCC
                
              
              
                  
                  
              3
              
             
            
              Maybe you mean sommething like this?
library(dplyr)
DF <- data.frame(annee = rep(2012:2014, each = 3), Dummy = 0:8, nb_aaa = 1:9, nb_bbb = 11:19)
DF %>% select(annee, nb_aaa, nb_bbb) %>%  group_by(annee) %>% 
  summarize_each( funs =sum)
             
            
              
              
              
            
           
          
            
              
                llpg
                
              
                
              
                  
                  
              4
              
             
            
              when I try I have that :

while my table data have the column "annee" :

             
            
              
              
              
            
           
          
            
              
                llpg
                
              
              
                  
                  
              5
              
             
            
              My output is good but it's just the name of the column that is not, and i don't know how to change it..
             
            
              
              
              
            
           
          
            
              
                llpg
                
              
              
                  
                  
              6
              
             
            
              OK it works 
I have to had "annee" in my subset(data), like this :
df <- data.frame(subset(data))[,c("annee","nb_lgt_aut_ind", "nb_lgt_aut_coll_res")] %>%
  group_by(annee) %>%
  summarise_each(funs = sum)
Thanks you 
             
            
              
              
              
            
           
          
            
              
                system
                
                  Closed 
              
              
                  
                  
              7
              
             
            
              This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
 If you have a query related to it or one of the replies, start a new topic and refer back with a link.