Rmd Note Sample Using both R, Python, and C

Roh

2020/10/15

Note: This document is to provide a sample template for the lecture notes in .Rmd

Memo: test

horizontal line ***

Usage of singe quote

x = 5  # radius of a circle

For a circle with the radius 5, its area is 78.5398163.

1 Head 1

Add link like this. Link

Description

Footnote example1 Footnote example22

2 Head 2

Refer to the other lecture note in this blog

2.1 R example

Description

Below chunk is a simple R code and its output

# R code example
dat <- iris

# remove one level to have only two groups
dat <- subset(dat, Species != "setosa")
dat$Species <- factor(dat$Species)

dim(dat)
## [1] 100   5

boxplot(dat[, 1] ~ dat$Species, # draw boxplots by group
    ylab = names(dat[1]), # rename y-axis with variable's name
    xlab = "Species"
  )
title('R example')

Regarding the option whether to show output or not as well as running the code when knitting, here are the options.

  • eval: whether to evaluate the code
  • echo: whether to show the code or not
  • result: whether to show the result output
  • collapse: Whether to merge text output and source code into a single code block in the output
  • warning, message, error: wether to display warning, message, and error
  • include: whether to include anything from a code chunk in the output document

2.2 Python Example

To run python code in R, we simply need install the package called reticulate.

#install.packages('reticulate')
library(reticulate)
#py_install(packages = "matplotlib")
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0,3,0.1)
y = 1 + np.sin(2*np.pi*x)
plt.plot(x,y)
plt.title('python example')

3 Latex Example

We observe an \(iid\) sample of size \(n\), \({[X_i]}_{i=1}^{n}\stackrel{iid}{\sim}F\). Each observation is real-values. We wish to estimate some parameter of the distribution \(F\) that can be written as a functional of \(F, T(F)\). Examples include the following.

3.0.0.1 References (Example)

McDonald, J.H. 2014. Handbook of Biological Statistics (3rd ed.). Sparky House Publishing, Baltimore, Maryland.


  1. this part will be displaed in the footnote part↩︎

  2. hello↩︎