Nothing
See if chunk options like tidy
, prompt
and echo
, etc work as expected.
1 + 1
## [1] 2
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
## [1] 10
# two blank lines below
dnorm(0)
## [1] 0.3989
1 + 1
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
# two blank lines below
dnorm(0)
> 1 + 1
## [1] 2
> for (i in 1:10) {
+ # nothing before 10
+ if (i >= 10)
+ print(i)
+ }
## [1] 10
> # two blank lines below
>
>
> dnorm(0)
## [1] 0.3989
1+1
for (i in 1:10) {
# nothing before 10
if(i>=10)print(i)
}
# two blank lines below
dnorm(0)
1+1
## [1] 2
for (i in 1:10) {
# nothing before 10
if(i>=10)print(i)
}
## [1] 10
# two blank lines below
dnorm(0)
## [1] 0.3989
## [1] 2
## [1] 10
## [1] 0.3989
1 + 1
[1] 2
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
[1] 10
# two blank lines below
dnorm(0)
[1] 0.3989
1 + 1
## [1] 2
## [1] 10
# two blank lines below
dnorm(0)
## [1] 0.3989
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
1 + 1
## [1] 2
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
## [1] 10
## # two blank lines below
##
##
## dnorm(0)
> 1+1
## [1] 2
> for (i in 1:10) {
+ # nothing before 10
+ if(i>=10)print(i)
+ }
## [1] 10
> # two blank lines below
>
>
> dnorm(0)
## [1] 0.3989
> 1+1
> for (i in 1:10) {
+ # nothing before 10
+ if(i>=10)print(i)
+ }
> # two blank lines below
>
>
> dnorm(0)
options(prompt = "R> ", continue = "+ ")
R> 1 + 1
## [1] 2
R> for (i in 1:10) {
+ # nothing before 10
+ if (i >= 10)
+ print(i)
+ }
## [1] 10
R> # two blank lines below
R>
R>
R> dnorm(0)
## [1] 0.3989
{
# can you deal with \code{foo} or \n, \a?
gsub("\\.", "\\\\", "a.b.c") # \link{bar}
}
## [1] "a\\b\\c"
cat("a\tb\nc")
## a b
## c
We can set formatR options globally:
options(formatR.blank = FALSE)
1 + 1
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
# two blank lines below
dnorm(0)
Or locally in one chunk via tidy.opts
. Do not keep comments:
1 + 1
for (i in 1:10) {
if (i >= 10)
print(i)
}
dnorm(0)
Move left braces to the next line:
for (i in 1:10)
{
# nothing before 10
if (i >= 10)
print(i)
}
## [1] 10
Indent by 2 spaces:
1 + 1
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
# two blank lines below
dnorm(0)
See http://yihui.org/formatR for details.
Do not include messages:
1 + 1
## [1] 2
message("helloooo!")
No warnings:
1:2 + 1:3
## [1] 2 4 4
warning("no no no")
Select warnings using numeric indices:
1:2 + 1:3
## [1] 2 4 4
warning("no no no")
## Warning: no no no
Invalid indices will select nothing:
1:2 + 1:3
## [1] 2 4 4
warning("no no no")
Do not show text results:
1 + 1
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
# two blank lines below
dnorm(0)
Flush all results to the end of a chunk:
1 + 1
for (i in 1:10) {
# nothing before 10
if (i >= 10)
print(i)
}
# two blank lines below
dnorm(0)
## [1] 2
## [1] 10
## [1] 0.3989
Output as is:
cat("_Markdown_,", "oh yeah, **Markdown**")
Markdown, oh yeah, Markdown
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.