R/others.R

wh_dict <- function(x, attr, value){
  if(missing(attr) || missing(value))stop('Please supply attr and value')
  lv <- unique(x[, attr])
  dictionary <- data.frame(lv)
  colnames(dictionary) <- attr
  dictionary$Keys <- NA
  for(i in 1:length(lv))dictionary[i, 'Keys'] <- as.character(x[x[,attr]==lv[i], value][1])
  return(dictionary)
}

Try the cleandata package in your browser

Any scripts or data that you put into this service are public.

cleandata documentation built on May 1, 2019, 10:25 p.m.