diff --git a/a4.r b/a4.r index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a50a9d1120ea8f2863e9f08e94c530620692d8e2 100644 --- a/a4.r +++ b/a4.r @@ -0,0 +1,30 @@ +### + # R code for assignment 4. + ## + + +# Clear console. +cat('\014') + + +# Install and import packages. +install.packages('rpart', dependencies=TRUE) +install.packages('randomForest', dependencies=TRUE) +library(rpart) +library (randomForest) + + +### + # The "cat" function seems to be an all around better alternative to "print". + # ("print" has a tendency to add extra, frivilous output that makes it look dirty and difficult to read.) + # + # This wrapper for "cat" then automatically adds a newline to the end of the message, effectively accomplishing + # what you would intuitively expect "print" to do. + # + # See references.md file for source of idea. + ## +catn <- function(message, trailing='\n') { + cat(message) + cat(trailing) +} + diff --git a/documents/references.md b/documents/references.md index ad9ca4ac802d2b4bbedd71b50f46f4ef56121480..33b73923cc9ff19abe3892ef3f3297c6353eec32 100644 --- a/documents/references.md +++ b/documents/references.md @@ -3,3 +3,10 @@ ## Description All references to external logic. Includes anything from stack overflow links to notes about logic from previous works. + + +## R + +### Alternative to the "Print" Function +Because it doesn't always behave how I expect, and tends to give additional, "dirty" output that I don't want. +<https://stackoverflow.com/questions/11230957/alternative-to-print-and-cat>