R1 Flashcards
assign the variable “h” the value 2
h
r workspace
place where variables and information is stored in R.
list all variables in workspace
ls()
remove variable named “a”
rm(a)
clear workspace
rm( list = ls() )
code to multiply 3 and 5
3 * 5
code to calculate 2 to the power of 5
2 ^ 5
code to calculate 28 modulo 6
28 %% 6
WRITE R CODE TO:
Combine the variables MY_APPLES and MY_ORANGES into a new variable MY_FRUIT, which is the total amount of fruits in your fruit basket
MY_FRUIT
what is the result of ls() on an empty work space?
character(0)
what is the r variable for pi?
pi
remove variables ‘p’ and ‘q’ from the workspace
rm(p, q)
what are R’s fundamental data types called?
atomic vectors
4 ways to determine object’s type?
typeof() -type of an R object
class() - object oriented programming in R answer
mode()
3 booleans in R
TRUE or T, FALSE or F, NA
class( 2L) returns?
integer
class(2) returns
numeric
is.numeric(2)
TRUE
is.integer(2)
FALSE
class(“string of stuff”)
character
6 Basic Atomic Data Types in R:
logical, integer, double, complex, character, raw
define a vector in R
a vector is an INDEXED SET of values that are all of the same type
in R, data elements are ____, not scalar
vectors
what is the rule for types in vectors?
can only contain one type, can’t mix types