R/ML_support_functions.R

Defines functions dataPartitions CsvRead

# This .R file requires "data.table" and "caret" packages to run

# Read the .csv file
CsvRead<-function(CsvData){
  if (inherits(CsvData,"data.table")==TRUE){
    return(CsvData)
  }
  else if (inherits(CsvData,"data.table")==FALSE)
  {
    CsvData<-data.table::as.data.table(CsvData)
    return(CsvData)
  }
  else{
    stop("The data you entered is not a correct format.")
  }

}

# Create partitions from your .csv file extracted data table
dataPartitions<-function(Data,partition){
  i<-caret::createDataPartition(Data$LDLd,p=partition,list=FALSE)
  trainData<-Data[i,]
  validationData <- Data[-i,]
  return(list("trainData" = trainData,"validationData" = validationData))
}

Try the LDLcalc package in your browser

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

LDLcalc documentation built on May 31, 2022, 5:07 p.m.