dataframe - Matching and Adding Factor Counts in R Data Frames -


Exits my question and the question already asked and is different from them. I think imagine that I have a There is a minimum dataset (bird) where each row shows the bird's observation at a given time and place: id, obs, country A, 4, United States of America, B, 3, Can A, 5, United States C, 4, MEX C, 1, USA A, 3, Can D, 1, Blank

What do I ideally prefer Conversion of a dataset, removing the tap from a dataset like this:

  id, tot_obs, country_tot A, 12,2 b, 3,1c, 5,2   

I know that I can get by using the number of factors:

  table (bird $ country)   

However, Is there a clever, perhaps, a way to remove the tap, connecting the total numbers, finding the numbers of countries and then reconfiguring them in this form? If there is a package that does this, then I am also open for that suggestion!

Load the data with stringsacters = FALSE :

  df < - read.csv (header = TRUE, text = "id, obs, country A, 4, USA B, 3, CAN A, 5, USA C, 4, MEX C, 1, USA A, A, 3, CAN D , 1, blank ", stringsfactors = FALSE) # Check to check that column are the factors (DF, class) # ID Obs Country #" Character "" Integer "" Character "  

All Rows to country = null

  df < - df [df $ country! After that you can use the  plyr  package  abbreviation  to get the desired code:   

/ P>

  ddply (df, (id), summarized, total-sum = sum (abus), total republic = length (unique (country)) # Calculator of # id total totals # 1 a2 2 # 2B3 1 # 3C5 2    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -