Programming/R

From Dev Wiki
< Programming
Revision as of 21:38, 29 May 2020 by Brodriguez (talk | contribs) (Expand page)
Jump to navigation Jump to search

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)