#' Give numbers as column names
#'
#' Assigns numbers as names to columns of a data frame.
#'
#' We use string concatentation and coercion of integers to
#' character type.
#'
#' @param x a data frame
#' @param prefix template pattern character string
#' @export
#' @examples
#' ## rename the columns in an in-built R data set
#' give_col_numbers(zooper)
give_col_numbers <- function(x, prefix = "COL."){
# all code here
names(x) <- paste0(prefix, seq(1,ncol(x), 1))
return(x)
}
#' Integer to bits
#'
#' Convert integers into bit format
#'
#' 32 bit integers and raw vector type
#' @param x vector of numbers
#' @param bit.type type of bits to create, default is 8
#' @export
#' @examples
#' int_2_bit(1:10)
#'
#' ## or, more complicated
int_2_bit <- function(x, bit.type = 8) {
x <- list(x)
## zooperdanke
l <- lapply(x, function(y) as.integer(intToBits(y)[bit.type:1]))
return(l)
}
# function to calculate Mean Square Error
mse <- function(predicted, observed) {
mean((predicted - observed)**2, na.rm = T)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.