Caveat: This document provides a convenient, worry-free format for writing up homework. Of course you must modify it properly. In particular you must delete any instructional material (such as this paragraph, for instance). Also, don't forget to provide your own name and title in the YAML front matter.
# You should also load any packages that you need, for example: # library(ggplot2) # This is a good place for global chunk options; # we'll get you started with a few sensible ones. # Don't try to modify them until you have more experience. knitr::opts_chunk$set( error = TRUE, # document will knit even if code-chunk contains error fig.align = 'center', # center graphs on the page out.width = "90%", # graphs take up 90% of available width warning = FALSE, # prevent warnings and messages in the message = FALSE, # console from getting into the knitted # document size = "small", # slightly smaller LaTeX output tidy = FALSE # show code like you wrote it )
Describe the problem briefly here. (It may help to copy, paste and modify the problem as stated in the online textbook.)
Here's the code for my solution:
manyCat <- function(word, n) { wordWithNewLine <- paste(word, "\n") message <- rep(wordWithNewLine, times = n) cat(message) }
Let's test the function on a couple of examples. To cat out the string "Hello"
four times, we try:
manyCat(word = "Hello", n = 4)
To cat out "Goodbye!"
twice, we try:
manyCat(word = "Goodbye!", n = 2)
The problem statement goes here ...
Your solution goes here ...
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.