R/ds.corm.R

Defines functions ds.corm

Documented in ds.corm

###############################################################################################
##### Correlation Matrix
###############################################################################################

#' @name ds.corm
#' @aliases ds.corm
#' @title Correlation matrix
#' @description Calculating the correlation matrix of a data frame and return in a data frame object
#' @usage ds.corm(x,n)
#' @param x :a data frame
#' @param n :number of decimal points
#' @examples ds.corm(mtcars,3)


ds.corm <- function(x,n){

  typeofvar <- sapply(x,class)
  ha <- names(typeofvar[typeofvar == "numeric" | typeofvar == "integer" | typeofvar == "double"])
  x <- x[,c(ha)]

  cormatirx <-data.frame(round(cor(x, use = "na.or.complete"), n))
  return(cormatirx)

}

Try the PMmisc package in your browser

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

PMmisc documentation built on May 1, 2019, 9:57 p.m.