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: What do I ideally prefer Conversion of a dataset, removing the tap from a dataset like this: I know that I can get by using the number of factors: 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 All Rows to / P>
id, tot_obs, country_tot A, 12,2 b, 3,1c, 5,2
table (bird $ country)
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 "
country = null
df < - df [df $ country! After that you can use the
plyr package
abbreviation to get the desired code:
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
Post a Comment