From ddccd4b975b93ad227ae789c3736a5d11a9e848d Mon Sep 17 00:00:00 2001 From: zee-zhijun Date: Thu, 22 Sep 2016 11:44:01 -0400 Subject: [PATCH] Lesson1 --- .gitignore | 3 +++ Class 4 - Swirl.Rproj | 13 +++++++++++++ lesson1.csv | 1 + 3 files changed, 17 insertions(+) create mode 100644 .gitignore create mode 100644 Class 4 - Swirl.Rproj create mode 100644 lesson1.csv diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..807ea25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.Rproj.user +.Rhistory +.RData diff --git a/Class 4 - Swirl.Rproj b/Class 4 - Swirl.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/Class 4 - Swirl.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/lesson1.csv b/lesson1.csv new file mode 100644 index 0000000..a588fb0 --- /dev/null +++ b/lesson1.csv @@ -0,0 +1 @@ +"time,""answer"",""id""" "1473958317215,""* **Day/Time"",""YOUR NAME""" "** Tuesdays/Thursdays, 11,""00am - 12"",""YOUR NAME""" "40pm,"""",""YOUR NAME""" "1474487121947,""install.packages(swirl)"",""YOUR NAME""" "1474487158147,""library(swirl)"",""YOUR NAME""" "1474487177956,""swirl()"",""YOUR NAME""" "1474487282102,""5+7"",""YOUR NAME""" "1474487314117,""x<-5+7"",""YOUR NAME""" "1474487319629,""x"",""YOUR NAME""" "1474487327381,""y<-x-3"",""YOUR NAME""" "1474487330086,""y"",""YOUR NAME""" "1474487352013,""z<-c(1.1,9,3.14)"",""YOUR NAME""" "1474487373797,""?c"",""YOUR NAME""" "1474487395647,""z"",""YOUR NAME""" "1474487411731,""c(z,555)"",""YOUR NAME""" "1474487423931,""c(z,555,z)"",""YOUR NAME""" "1474487434745,""z*2+100"",""YOUR NAME""" "1474487610213,""my_sqrt<-sqrt(z-1)"",""YOUR NAME""" "1474487657797,""my_sqrt"",""YOUR NAME""" "1474487677506,""my_div<-z/my_sqrt"",""YOUR NAME""" "1474487699915,""my_div"",""YOUR NAME""" "1474487743809,""c(1,2,3,4)+c(0,10)"",""YOUR NAME""" "1474487766800,""c(1,2,3,4)+c(0,10,100)"",""YOUR NAME""" "1474487794144,""z*2+100"",""YOUR NAME""" "1474487808415,""z*2+1000"",""YOUR NAME""" "1474487825055,""my_div"",""YOUR NAME""" "1474487891358,""getwd()"",""YOUR NAME""" "1474487899908,""ls()"",""YOUR NAME""" "1474487913675,""x <-9"",""YOUR NAME""" "1474487917284,""ls"",""YOUR NAME""" "1474487923484,""ls()"",""YOUR NAME""" "1474487932907,""dir()"",""YOUR NAME""" "1474487945150,""list.files()"",""YOUR NAME""" "1474487958538,""?list.files"",""YOUR NAME""" "1474488044513,""args(list.files())"",""YOUR NAME""" "1474488049749,""args(list.files)"",""YOUR NAME""" "1474488126685,""old.dir<-dir()"",""YOUR NAME""" "1474488139139,""old.dir<-getwd()"",""YOUR NAME""" "1474488174856,""dir.create(testdir)"",""YOUR NAME""" "1474488188749,""?dir.create()"",""YOUR NAME""" "1474488226060,""testdir<-dir.create()"",""YOUR NAME""" "1474488249021,""testdir<-dir.create(getwd())"",""YOUR NAME""" "1474488276260,""dir.create(testdir)"",""YOUR NAME""" "1474488307332,""setwd(testdir)"",""YOUR NAME""" "1474488316881,""setwd(testdir)"",""YOUR NAME""" "1474488346505,""file.create(mytest.R)"",""YOUR NAME""" "1474488360671,""testdir()"",""YOUR NAME""" "1474488378815,""list.files(testdir)"",""YOUR NAME""" "1474488391591,""list.files()"",""YOUR NAME""" "1474488407927,""file.exists(mytest.R)"",""YOUR NAME""" "1474488429047,""file.info(mytest.R)"",""YOUR NAME""" "1474488481173,""file.rename(mytest.R,mytest2.R)"",""YOUR NAME""" "1474488527988,""file.copy(mytest2.R,mytest3.R)"",""YOUR NAME""" "1474488564115,""file.path(mytest3.R)"",""YOUR NAME""" "1474488599627,""file.path(folder1,folder2)"",""YOUR NAME""" "1474488618688,""file.path(folder1)"",""YOUR NAME""" "1474488629392,""file.path(folder1,folder2)"",""YOUR NAME""" "1474488646527,""?dir.create"",""YOUR NAME""" "1474488723750,""dir.create(file.path(testdir2,testdir3))"",""YOUR NAME""" "1474488746342,""dir.create(file.path(testdir2,testdir3),recursive = TRUE)"",""YOUR NAME""" "1474556085870,""setwd()"",""YOUR NAME""" "1474556094959,""setwd(dir)"",""YOUR NAME""" "1474556106947,""setwd()"",""YOUR NAME""" "1474556162363,""getwd()"",""YOUR NAME""" "1474556174936,""setwd(old.dir)"",""YOUR NAME""" "1474556230122,""unlink(testdir,recursive = TRUE)"",""YOUR NAME""" "1474556290529,""1"",""YOUR NAME""" "20,"""",""YOUR NAME""" "1474556302369,""pi"",""YOUR NAME""" "10,"""",""YOUR NAME""" "1474556327839,""15"",""YOUR NAME""" "1,"""",""YOUR NAME""" "1474556369304,""`"",""YOUR NAME""" "`,"""",""YOUR NAME""" "1474556912230,""?`"",""YOUR NAME""" "`,"""",""YOUR NAME""" "1474556946302,""seq(1,20)"",""YOUR NAME""" "1474556970550,""seq(0,10,by=0.5)"",""YOUR NAME""" "1474556989445,""seq(5,10,length=30)"",""YOUR NAME""" "1474557030412,""my_seq <- seq(5, 10, length=30)"",""YOUR NAME""" "1474557042845,""length(my_seq)"",""YOUR NAME""" "1474557083113,""1"",""YOUR NAME""" "length(my_seq),"""",""YOUR NAME""" "1474557097969,""seq(along.with = my_seq)"",""YOUR NAME""" "1474557119097,""seq_along(my_seq)"",""YOUR NAME""" "1474557232788,""rep(0, times=40)"",""YOUR NAME""" "1474557265418,""rep(c(0, 1, 2), times=10)"",""YOUR NAME""" "1474557295266,""rep(c(0, 1, 2), each = 10)"",""YOUR NAME""" "1474557362766,""x <- c(44, NA, 5, NA)"",""YOUR NAME""" "1474557368318,""3x"",""YOUR NAME""" "1474557371819,""3*x"",""YOUR NAME""" "1474557388480,""y <- rnorm(1000)"",""YOUR NAME""" "1474557402886,""z <- rep(NA, 1000)"",""YOUR NAME""" "1474557481284,""my_data <- sample(c(y,z), 100)"",""YOUR NAME""" "1474557499459,""is.na(my_data)"",""YOUR NAME""" "1474557523220,""my_na <- is.na(my_data)"",""YOUR NAME""" "1474557530289,""print(my_na)"",""YOUR NAME""" "1474557543714,""my_na"",""YOUR NAME""" "1474557568581,""my_data == NA"",""YOUR NAME""" "1474557619372,""sum(my_na)"",""YOUR NAME""" "1474557644090,""my_data"",""YOUR NAME""" "1474557667205,""0/0"",""YOUR NAME""" "1474557685834,""Inf - Inf"",""YOUR NAME""" "1474557778931,""?sample"",""YOUR NAME""" "1474557801767,""sample(1"",""YOUR NAME""" "6, 4, replace = TRUE),"""",""YOUR NAME""" "1474557841239,""sample(1"",""YOUR NAME""" "6, 4, replace = TRUE),"""",""YOUR NAME""" "1474558007271,""sample(1"",""YOUR NAME""" "20, 10),"""",""YOUR NAME""" "1474558025414,""LETTERS"",""YOUR NAME""" "1474558033865,""sample(LETTERS)"",""YOUR NAME""" "1474558101573,""sample(c(0,1), 100, prob = c(0.3, 0.7))"",""YOUR NAME""" "1474558126061,""sample(c(0,1), 100, replace= TRUE, prob = c(0.3, 0.7))"",""YOUR NAME""" "1474558152378,""flips <- sample(c(0,1), 100, replace= TRUE, prob = c(0.3, 0.7))"",""YOUR NAME""" "1474558225259,""flips"",""YOUR NAME""" "1474558237566,""sum(flips)"",""YOUR NAME""" "1474558253856,""?rbinom"",""YOUR NAME""" "1474558401242,""rbinom(1, size = 100, prob = 0.7)"",""YOUR NAME""" "1474558439671,""flips2 <- rbinom(1, size = 100, prob = 0.7)"",""YOUR NAME""" "1474558475258,""flips2 <- rbinom(n = 100, size = 1, prob = 0.7)"",""YOUR NAME""" "1474558523829,""flips2"",""YOUR NAME""" "1474558548015,""sum(flips2)"",""YOUR NAME""" "1474558566476,""?rnorm"",""YOUR NAME""" "1474558592949,""rnorm(10)"",""YOUR NAME""" "1474558634667,""rnorm(10, mean = 100, sd = 25)"",""YOUR NAME""" "1474558671188,""rpois(5, lambda = 10)"",""YOUR NAME""" "1474558692809,""my_pois <- replicate(100, rpois(5, 10))"",""YOUR NAME""" "1474558700522,""my_pois"",""YOUR NAME""" "1474558739057,""cm <- colMeans(my_pois)"",""YOUR NAME""" "1474558747241,""hist(cm)"",""YOUR NAME""" "1474558810520,""H <-read.table(~/.rstudio-desktop/history_database, sep=:, fill=T, stringsAsFactors=F)"",""YOUR NAME""" \ No newline at end of file