There are multiple functions in R with the purpose of providing textual output.
- print("text to be printed") is the most common way to print value out. This function treats provided text as an array and doesn't provide any formatting.
- cat("text\n", file="path", append= TRUE) this function provides great formatting + if you provide optional argument file, text from the first argument is going to be printed to selected file, else text is going to be printed to the screen. If you set optional argument append to TRUE, text from the first argument is not going to replace content of the file.
- printf("%s", "hey") this function works in the same way like in c programming language, and I will talk about it in upcoming episodes. For this function package R.utils must be imported.
- message("text") the best solution for most of cases when you need user output. Provides formatting.
- warning("text") same as message but it states that this message is actual warning.
- stop("text") same as message but unlike warning, this function is going to print text to the screen and then to terminate script.
For the video tutorial, check the link below.
No comments:
Post a Comment