#' Modify column names of data frame
#'
#' @param names names to be changed
#' @param data data frame from which
#'
#' @return
#' @export
#'
#'
modifyNames <- function(names, data) {
if(!hasArg(names)) {
if(!hasArg(data)) {
data <- getDataFrame()
}
names <- getNames(data)
}
message("Names: ")
print(names)
again <- TRUE
while(again) {
what <- whatToDo("What to do with names?", c("nothing", "shorten", "substitute", "add"))
#nothing
if(what == "nothing") {
again <- FALSE
}
#Shorten names
else if(what == "shorten") {
prefix <- readline("Please provide prefix or number: ")
if(length(unique(regexpr(prefix, names))) && unique(regexpr(prefix, names)) == 1) {
names2 <- substring(names, nchar(prefix) + 1)
}
else if(is.numeric(as.numeric(prefix))) {
names2 <- substring(names, as.numeric(prefix))
}
}
#Substitute names
else if(what == "substitute") {
message("Provide named vector with new names.")
names2 <- unname(getData()[names])
}
#ToDo
else if(what == "add") {
message("Not implemented yet.")
}
if(what != "nothing") {
print(names2)
if(ok("Accept changes?")) {
names <- names2
}
again <- ok("Additional changes?")
}
}
names
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.