knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) # Set WD to Root library(tidyverse)
n = 20; M = matrix(NA, ncol = 2, nrow = 10); #check the help file so that you know what this does! for (i in 1:n){ # your code here M[i] <- i } M
m = matrix(NA, nrow = 2, ncol = 1) for (i in 1:2){ # your code here m[i] <- print(mean(M[ ,i])) } m colMeans(M)
mmm <- matrix(1:20, nrow = 10) mmm[ ,2]
mmm[1:5]
f1 = function(){ s = sample(c("H", "T"), size = 4, replace = TRUE) return(s) } f1()
foo <- matrix(NA, 10, 4) for (i in 1:nrow(foo)) { foo[i, ]<- f1() } foo
replicate(10, f1())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.