aboutsummaryrefslogtreecommitdiff
path: root/lab2/intro.r
diff options
context:
space:
mode:
Diffstat (limited to 'lab2/intro.r')
-rwxr-xr-xlab2/intro.r48
1 files changed, 48 insertions, 0 deletions
diff --git a/lab2/intro.r b/lab2/intro.r
new file mode 100755
index 0000000..037210e
--- /dev/null
+++ b/lab2/intro.r
@@ -0,0 +1,48 @@
+#!/usr/bin/env Rscript
+
+v <- c(1:10, seq(11, 20, by = 2))
+
+typeof(1)
+typeof(1L)
+typeof(v)
+typeof(as.integer(v))
+head(v)
+str(v)
+plot(v)
+
+
+save.image(file = "abc.Rdata")
+
+v <- seq(1, 10, by = 0.5)
+v
+
+load("abc.Rdata")
+
+v
+
+
+v <- c("a", "b", "c", "b", "a")
+
+f <- factor(v)
+
+func <- function(x, y = 0) {
+ return((x * x) + y)
+}
+
+func(y = 3, 5)
+
+
+m <- matrix(c(1:6, 11:13), nrow = 3, ncol = 3, byrow = TRUE)
+m
+
+m[2:3, 1:2]
+
+df <- data.frame(a = c(1:5), b = c("a", "b", "c", "d", "e"))
+
+df$a
+df$b
+
+df[df$a > 2, ]
+
+
+q("no") \ No newline at end of file