R Entering Input

There are ways to enter input variable on R environment. Assign a variable must follow specific syntax. The assignment is follow specific symbol “<-“. Left side of the symbol is a variable and right is value to be assign to variable.

Entering Input
> x_value <- 80
> my_msg <- "hello R"

Extract variable value to screen can be demonstrated by use syntax “print(variabel_name).

> print(x_value)
> [1] 80
> print(my_msg)
[1] "hello R"
>

Clear Screen
Ctrl-L

Commands

Commands is write after # string will ignore by R.

"
> x_value <- 80 # Hello this is command 1
> my_msg <- "hello R" # Hello this is command 2
> print (x_value)
[1] 80
> print (my_msg)
[1] "hello R"
>

Assign and Print Sequence
> x_seq <- 0:100  # assign sequence number from 0 to 100
> print(x_seq)
  [1]   0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17
 [19]  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35
 [37]  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53
 [55]  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71
 [73]  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89
 [91]  90  91  92  93  94  95  96  97  98  99 100
>
Assign List of value

To assign list of value in R by using prefix ‘c’ or combine. Let say we want to assign list of number 1,2,3 to variable ‘list_of_number’:

list_of_number <- c(1,2,3)

To print out value of variable you can just type ‘list_of_number’ follow by enter of use ‘print’ command:

print(list_of_number)
Video