I The Story of Vector V: an R markdown example
This is an example of R markdown text that can be cut and pasted in a new R markdown document (section 13.2.2) and then knitted into an HTML or other type of document. This illustrates the use of R
code in chunks (shown or hidden) and as inline commands.
Note: Depending on the format (HTML/PDF) of this document some elements might have a background color. However, ALL these apparent parts constitute the .Rmd
file.
---
: "The story of vector **V**"
title: html_document
output---
# `V` learns numbers
`V` that was feeling empty
Once upon a time there was a vector named `0` through `9`. One day `V` met
and was trying to learn numbers from *magical* combine function `c()` that was able to add the
the ***inside*** `V`, like this: numbers
```{r}
V <- c(1,2,3,4,5,6,7,8,9)
```
`V` was very happy, and `V` was now spending its time enumerating
: `r V`. Sometimes it would pick one at random: `r sample(V, 1)`
the numbers
and it was pleased that it was not always the same number coming up.
## `V` wonders about itself
`V` asked:
Wanting to know itself better
* what is my class? And the answer was: ``r class(V)``
* how long am I? And the answer came as ``r length(V)``
# `V` wants more
`V` wanted more: it wanted to add these numbersbut not in
But then "in its head" so it could be
the open like this, it wanted to do that : **`r sum(V)`** (*and the value will be printed
done like this`R`.*)
here directly as calculate by
## `V` meets the Math Wizard
*Math Wizards*?
But how to describe that to *fairy* friend *Equation* who gave `V` the *magic* codes:
He asked his
$$\sum_{n=1}^{9} n = sum(V)$$
**`r sum(V)`**.
which is still
## `V` in the land of vectorization
`V` wanted to be 10 times more.
But it wanted more again... `V` went on a journey across the land to know what to do.
So `V` ended in the
It was a long and arduous journey, but "Land of Vectorization* and there, he was augmented 100 times
to be like this: `r 100*V`. But it was cumbersome to feel
these big numbers and *division* helped one more time to
make it just 1o times smaller to be `r 10*(V)`
# `V` and the mental picture
This time it wanted to have a mental "picture" of the numbers
and it could think of 2 ways but it had to keep the `R` code
*secret* so that it would not be stolen:
```{r echo=FALSE, fig.height=3}
par(mfrow = c(1,2))
plot(V)
boxplot(V)
par(mfrow = c(1,1))
```
# Conclusion
It is useful to have friends that help you, and `V` is very grateful
of its magical encounter with `c()` and other friends along the way.