# NOT RUN {
# Finding the MAP model with maximum depth <= 10
# for the SP500 dataset (with default value beta):
BCT(SP500, 10)
# For custom beta (e.g. 0.7):
BCT(SP500, 10, 0.7)
# The type of the input dataset is "character"
# If the dataset is contained within a vector:
q <- c(1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0)
# Convert a vector to a "character" object:
s <- paste(q, collapse = "")
BCT(s, 2)
# Reading a file using the readChar function
# Example 1: The dataset is stored in a .txt file
# fileName <- '~/example_data.txt' # fileName stores the path to the dataset
# s<-readChar(fileName, file.info(fileName)$size)
# Make sure that s does not contain any "\n" at the end of the string
# To remove last entry:
# s<-gsub('.$', '', s)
# To remove any unwanted characters (e.g. "\n"):
# s<-gsub('\n', '', s)
# Example 2: The dataset is stored in a .csv file
# fileName <- '~/example_data.csv' # fileName stores the path to the dataset
# s<-readChar(fileName, file.info(fileName)$size)
# Depending on the running environment,
# s might contain unwanted characters such as: "\n" or "\r\n".
# Remove any unwanted characters (e.g. "\r\n"):
# s<-gsub('\r\n', '', s)
# Always make sure that s does not contain any unwanted characters
# }
Run the code above in your browser using DataLab