I have a csv file containing trainee names and a csv file containing a list of publications, including a variable defining the author's name. I'd like for R to add a variable to the publications dataframe containing a dummy variable if the author name in the publication matches any of the trainee names ("peeps") contained in the trainee file. The following code isn't working for me, and I can't figure out why. The error I receive is "object 'i' not found. Am I going about this all wrong? Thanks!
publications <- read.csv("publications.csv", header = TRUE, stringsAsFactors = FALSE)
trainees <- read.csv("TraineeRoster.csv", header = TRUE, stringsAsFactors = FALSE)
peeps <- trainee$LastName
publications["TraineePub"]
for (i in 1:nrow(publications)) {
if (publications$AuthorLast[i] == peeps) {
publications$TraineePub[i]
} else {
publications$TraineePub[i]
}
}