#' A method to collect relevant professor information in a neat data.frame
#' @param faculty A list of faculty
#' @param age Include ages in the dataframe?
#' @param gender Include gender in the dataframe?
#' @param has_ba include ba information in dataframe?
#' @param has_ma include ma information in dataframe?
#' @param has_phd include phd information in dataframe?
#' @return df A dataframe containing the faculty list and potential more computations thereupon
#' @export
df_description <- function(faculty, age = TRUE, gender = TRUE, has_ba = FALSE, has_ma = FALSE, has_phd = FALSE){
df <- data.frame(original = faculty)
if(age){
all_ages <- sapply(faculty, function(x) as.integer(calculate_age(x)[[1]]))
df["age"] <- all_ages
}
if(gender){
all_genders <- sapply(faculty, function(person) determine_genders(person))
df["gender"] <- all_genders
}
if(has_ba){
ba_list <- sapply(faculty, function(person) has_degree(person, "BA"))
df["ba"] <- ba_list
}
if(has_ma){
ma_list <- sapply(faculty, function(person) has_degree(person, "MA"))
df["ma"] <- ma_list
}
if(has_phd){
phd_list <- sapply(faculty, function(person) has_degree(person, "PHD"))
df["phd"] <- phd_list
}
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.