append_id: Distinguish between Things Published in Same Year

Description Usage Arguments Details Value

View source: R/reading.R

Description

Given a dataframe with an identifier variable, returns the same dataframe with a different letter appended to repeat values of that variable.

Usage

1
append_id(my_df, my_id_col)

Arguments

my_df

a dataframe with an identifier that needs to be made unique.

my_id_col

a character column in that dataframe to be altered so that all values in it are unique.

Details

Some authors will produce more than one book (or other bibliography item) in a particular year. When two or more such items are present, this function will add a letter to the end of the date, starting at 'a' and cycling through the (English) alphabet. It'll do this to any character variable, but this will result in silly outcomes unless the last part of the string is a year.

Value

a dataframe identical to the one supplied to the function but with the identifier variable altered so that repeats of a given value are now distinguished by a letter appended to the string (e.g. if 'Smith 2010' appears twice in the original, there will now be a 'Smith 2010a' and a 'Smith 2010b'.


AGDunn/nehnar documentation built on Nov. 15, 2020, 4:08 a.m.