Some example Python code:
import re
for test_string in ['555-1212', 'ILL-EGAL']:
if re.match(r'^\d{3}-\d{4}$', test_string):
print test_string, 'is a valid US local phone number'
else:
print test_string, 'rejected'
β¦ and R code:
cube <- function(x) {
if (!is.numeric(x))
stop("'x' must be numeric")
return(x^3)
}
# Use this function
cube(1:10)
R Chunks:
R Markdown
Test of an R Markdown post, see http://rmarkdown.rstudio.com. You can embed an R code chunk like this:
cars_lm <- lm(dist ~ speed, data = cars)
cars_lm
##
## Call:
## lm(formula = dist ~ speed, data = cars)
##
## Coefficients:
## (Intercept) speed
## -17.579 3.932
Including Plots
You can also embed plots. See Figure 1 for example:
par(mar = c(0, 1, 0, 1))
pie(
c(280, 60, 20),
c('Sky', 'Sunny side of pyramid', 'Shady side of pyramid'),
col = c('#0292D8', '#F7EA39', '#C4B632'),
init.angle = -50, border = NA
)
You can use an alert note
to stand out a section.
Hugo shortcodes
In R Markdown, you should not use the {{< tweet 936232450006704128 >}}
syntax. Instead, you should use:
Excited about the new R Release? #rstats
— ππΎπ¬π::maternity_leaveπ€± (@LucyStats) November 30, 2017
ππ Welcome "Kite-Eating Tree"!
ππ₯ gif courtesy of @pdalgd!
π€π Curious about the other R release name origins? Check out our post!
π https://t.co/b7XkQKwHpM pic.twitter.com/J1UNks276A
Other examples
Youtube
Vimeo
Github Gist
Speakerdeck
Figure