#' takes a vector of marks and converts missing to zero and EX to NA
#'
#' @param x marks
#'
#' @return vector of marks
#' @export
#'
#' @examples
#' library(examMarking)
#' data(marks)
#' clean_marks(marks$A1_20)
clean_marks <- function(x){
x[is.na(x)] <- 0
x[x=="EX"] <- NA
x <- as.numeric(x)
return(x)
}
#' Takes a data frame of marks and regular expression and converts
#' the columns whose names match regular expression
#'
#' @param df data frame of marks
#' @param RE regular expression used to identify the columns
#'
#' @return data frame with exemptions converted to value.
#' @export
#'
#' @examples
#' library(examMarking)
#' library(examMarking)
#' data("SMI_2018_marks")
#' SMI_2018_marks
#' clean_marks_df(SMI_2018_marks, "^A")
clean_marks_df <- function(df, assess_RE){
df <- dplyr::mutate_at(df, dplyr::vars(dplyr::matches(assess_RE)), clean_marks)
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.