#' Given an entry of a scanned line of a PDF, returns the full name
#' @param person A scanned line of content from a PDF
#' @return name The name contained within the entry
#' @export
get_name <- function(person){
if(get_prof_year(person) %in% 2009:2013){
name = stringr::str_split(person, ",")[[1]][1] #isolate everything before the first comma
name = stringr::str_trim(name) #remove trailing and leading spaces
}else{
name = stringr::str_split(person, "\\s{4}")[[1]][1] #many spaces
}
name = gsub("[^a-zA-z ]", "", name) #remove any non-letters from the entry
return(name)
}
#' Returns a list of names of all people on the person-list
#' @param person_list a list of people
#' @return a list of names on person_list
names <- function(person_list){
return(sapply(person_list, get_name))
}
#' returns a list of names of all staff that occur on two concurrent years
#' @param list1 a faculty list
#' @param list2 a faculty list
#' @return names a list of names that appear on both faculty lists
#' @export
overlap <- function(list1, list2){
return(intersect(names(list1), names(list2)))
}
#' Looks for a name in a faculty list
#' @param name the needle
#' @param faculty the haystack
#' @return the index of the needle in the haystack
#' @export
search_name_in_list <- function(name, faculty){
modified <- gsub("[^a-zA-z0-9 ]", "", faculty)
return(grep(name, modified))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.