#' Computes all the chosen transformations to the input data frame in the chosen
#' parameters.
#'
#' @param data A data frame
#' @param subset a specification of the rows to be used: defaults to all rows.
#' This can be any valid indexing vector (see \link{[.data.frame}) for the
#' rows of data or if that is not supplied, a data frame made up of the
#' variables used in \code{formula}.
#' @param select expression, indicating columns to select from a data frame.
#' Defaults for all the variables in data. See \link{subset}.
#' @param transf The chosen transformations to be applied to the data
#' @return A list with all data transformed according to the arguments
#' passed.help
#' @export
#' @examples
#' library(appraiseR)
#' library(sf)
#' data(centro_2015)
#' vars <- c("area_total", "dist_b_mar")
#' alltransf(centro_2015, select = vars)
#' alltransf(centro_2015, subset = 1:10, select = c("valor", "area_total"))
#'
alltransf <- function(data, subset = NULL, select = colnames(data),
transf = c('rsqrt', 'log', 'sqrt')){
DF <- as.data.frame(data)
if (is.null(subset)) subset <- seq_len(nrow(DF))
select <- setdiff(select, "geometry")
DF <- DF[subset, colnames(DF) %in% select, drop = FALSE]
DF <- stats::na.omit(DF)
for (i in colnames(DF)) if (is.character(DF[,i])) DF[,i] <- as.factor(DF[,i])
factors <- sapply(DF, is.factor)
transformations <- list("rsqr" = rsqr,
"rec" = rec,
"rsqrt" = rsqrt,
"log" = log,
"sqrt" = sqrt,
"identity" = identity,
"sqr" = sqr)
transfers <- c("identity", transf)
transfs <- transformations[transfers]
t_list <- lapply(transfs, function(f) f(DF[,factors == FALSE, drop = FALSE]))
return(t_list)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.