forked from rll307/WorkshopTwitter2022_PTBR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
03_basics.R
84 lines (66 loc) · 1.97 KB
/
03_basics.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
writeLines("It is part of my CNPq-funded project and seeks to make corpus tools and R accessible. If you have any doubts or wish to make any research contact please send me an email. Rodrigo de Lima-Lopes [email protected]")
#' # Introduction
#' In this tutorial we will try to do get some introductory concepts on R language, mostly getting some basic conventions.
#'
#' # Some very basic stuff
#'
#' R is a good arithmetic tool. If we type the following lines in our script and run each at a time:
#'
#'
## --------------------------------------
1+5
5-4
100/33
5^2
5**2
9/4
9*4
(300 * 9) + (500 / 2)
x <- 2L
x
typeof(x)
y <- 2.5
y
typeof(y)
z <- 3+2i
z
typeof(z)
h <- "h"
typeof(h)
h
q1 <- TRUE
typeof(q1)
q1
q2 <- FALSE
q2
typeof(q2)
a <- seq(0,100, 2)
a
typeof(a)
repetition <- rep("repetition",100)
repetition
typeof(repetition)
#'
#'
#' # In a nutshell
#'
#' These commands taught us a couple of things:
#'
#' 1. R can make some basic calculations
#' 1. R can store values in its memory
#' - But be aware that data is not saved until you tell R to do so
#' 1. We use "<-" for variable attribution
#' - "=" is also possible, but "<-" is a better choice because
#' 1. "=" is already present inside some commands, so "<-" is exclusive of variable attribution
#' 1. "<-" brings us some direction regarding the attribution
#' 1. There are some kinds of data in R, the basic ones are:
#' - **Integer**: whole numbers, without decimals
#' - **Double**: numbers with decimals
#' - **Complex**: numbers with scientific notation
#' - **Character**: words or letters
#' - **Logical** (or Boolean): meaning *TRUE* or *FALSE*
#' - **Dates**: numbers representing dates
#' - **Vector**: ordered sequence of numbers or characters
#' 1. Commands in R are always a sequence of letters followed by "()" like `seq()`
#' 1. The way to tell R a value ought to be understood as a character is to write between quotations marks
#' 1. Each command might get a set of arguments