Programming/R: Difference between revisions
Jump to navigation
Jump to search
Brodriguez (talk | contribs) m (Brodriguez moved page R to R (Language)) |
Brodriguez (talk | contribs) (Expand page) |
||
Line 4: | Line 4: | ||
== Comments == | == Comments == | ||
# This is an inline comment. | # This is an inline comment. | ||
== Variables == | |||
Variables R are loosely typed in R. That means that the type (bool, int, string, etc) is implicitly declared by the value provided. | |||
{{ Todo | Link to variable typing. }} | |||
=== Variable Definition === | |||
a_bool <- TRUE | |||
b_bool <- FALSE | |||
my_var_1 <- "This is " | |||
my_var_2 <- "a string." | |||
=== Variable Usage === | |||
# We can print our variables by retyping the variable name with no further syntax. | |||
a_bool | |||
b_bool | |||
my_var_1 | |||
my_var_2 | |||
=== Variable Types === | |||
Variable types in R are called the following: | |||
* '''Booleans''' are called {{ ic | Logicals }}. | |||
* '''Text''' is called {{ ic | characters }}. | |||
* '''Numbers''' are called {{ ic | numerics }}. | |||
If ever unsure you can check the typing of a variable with {{ ic |class() }}. For example: | |||
# This will print out the typing for "my_variable". | |||
class(my_variable) |
Revision as of 21:38, 29 May 2020
R is a language used for statistics.
Comments
# This is an inline comment.
Variables
Variables R are loosely typed in R. That means that the type (bool, int, string, etc) is implicitly declared by the value provided.
ToDo: Link to variable typing.
Variable Definition
a_bool <- TRUE b_bool <- FALSE my_var_1 <- "This is " my_var_2 <- "a string."
Variable Usage
# We can print our variables by retyping the variable name with no further syntax. a_bool b_bool my_var_1 my_var_2
Variable Types
Variable types in R are called the following:
- Booleans are called
Logicals
. - Text is called
characters
. - Numbers are called
numerics
.
If ever unsure you can check the typing of a variable with class()
. For example:
# This will print out the typing for "my_variable". class(my_variable)