** Objects **
Objects are simply a definition for a type of data to be stored
e.g., vector, matrix, array, data frame, list, function
A perticular way of organizing data
* Atomic vectors (basic data types in R and is pretty much the workhorse of R)
* Recursive lists (List is a special vector. Each element can be a different class)
You can create vectors by concatenating them using the c()
function.
Various examples:
x <- c(1, 2, 3)
x is a numeric vector. These are the most common kind. They are numeric objects and are treated as double precision real numbers. To explicitly create integers, add a L at the end.
x1 <- c(1L, 2L, 3L)
You can also have logical vectors.
y <- c(TRUE, TRUE, FALSE, FALSE)
Finally you can have character vectors:
z <- c("Alec", "Dan", "Rob", "Rich")
{r}
#The general pattern is vector(class of object, length).
Create an empty vector with vector()
x <- vector() # will get default logical(0) values
# with a specified type and pre-defined length
x <- vector(length = 10) # will get default 10 FALSE values
# with a length and type
vector(mode = "character", length = 10) # is equalent to character(10)
vector("numeric", length = 5) # is equalent to numeric(5)
vector("integer", 10)
vector(mode = "logical", 8)
vector("complex", 5)
Vectors may only have one type
Some Function for Vectors
Functions | Description |
---|---|
c() |
combines values, vectors, and/or lists to create new objects |
unique() |
returns a vector containing one element for each unique value in the vector |
duplicated() |
returns a logical vector which tells if elements of a vector are duplicated with regard to previous one |
rev() |
reverse the order of element in a vector |
sort() |
sorts the elements in a vector |
append() |
append or insert elements in a vector. |
sum() |
sum of the elements of a vector |
min() |
minimum value in a vector |
max() |
maximum value in a vector |
cumsum |
cumulative sum |
diff |
x[i+1] - x[i] |
prod |
product |
cumprod |
cumulative product |
mean |
average |
median |
median |
range |
range (minimum and maximum) |
order |
order |
rank |
rank |
sample |
random sample |
quartile |
percentile |
var |
variance, covariance |
sd |
standard deviation |
Other Functions
{r}
(x <- c(sort(sample(1:20, 9)), NA))
(y <- c(sort(sample(3:23, 7)), NA))
union(x, y)
intersect(x, y)
setdiff(x, y)
setdiff(y, x)
setequal(x, y)
which.min(x)
which.max(x)
match(x,y)
** Create a ists using list function**
x <- list(1, "a", TRUE, 1+4i)
R also has many data structures. These include * matrix and arrays * data frame
m <- matrix(c(47,48,52,36,89,45,1,2,-25), nrow = 3, ncol = 3)
m
# this code creates a 3 by 3 matrix
47 | 36 | 1 |
48 | 89 | 2 |
52 | 45 | -25 |
(to create a matrix)
# 3 column matrix with column dimnames
m <- cbind(Index = c(1:3), Age = c(30, 45, 34), Salary = c(500, 600, 550))
class(m)
m
Index | Age | Salary |
---|---|---|
1 | 30 | 500 |
2 | 45 | 600 |
3 | 34 | 550 |
a <- array(1:27, dim=c(3,3,3))
print(a)
, , 1 [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 , , 2 [,1] [,2] [,3] [1,] 10 13 16 [2,] 11 14 17 [3,] 12 15 18 , , 3 [,1] [,2] [,3] [1,] 19 22 25 [2,] 20 23 26 [3,] 21 24 27
To check the dimensions
of array or matrix
dim()
will give you the number of rows, columns and slices
length(dim())
will give actual dimension as a single number
# for matrix
dim(m)
length(dim(m))
# for array
dim(a)
length(dim(a))
Creating more than 3 dimensions like 4, 5 and etc
ar <- array(1:36, dim = c(3,2,2,3)) # 4 dimensional array
dim(ar)
length(dim(ar))
arr <- array(1:36, dim = c(3,2,2,3,1)) # 5 dimensional array
dim(arr)
length(dim(arr))
Name <- c("a1", "a2", "b3")
Value1 <- c(23, 4, 12)
Value2 <- c(1,45,5)
dat <- data.frame(Name, Value1, Value2)
dat
Name | Value1 | Value2 |
---|---|---|
a1 | 23 | 1 |
a2 | 4 | 45 |
b3 | 12 | 5 |
(to use for a data frame)
df <- data.frame(x = 1:3, y = c("a", "b", "c"))
df
df1 <- cbind(1, df)
class(df1)
x | y |
---|---|
1 | a |
2 | b |
3 | c |
df <- data.frame(a = c(1:5), b = (1:5)^2)
df
rbind(df, c(2, 3), c(5, 6))
a | b |
---|---|
1 | 1 |
2 | 4 |
3 | 9 |
4 | 16 |
5 | 25 |
a | b |
---|---|
1 | 1 |
2 | 4 |
3 | 9 |
4 | 16 |
5 | 25 |
2 | 3 |
5 | 6 |
(to create a data frame)
expand.grid
gives us all the combinations of entries of two vectors.For example:
all combinations of blue and black pants
and white, grey and plaid shirts
eg <- expand.grid(pants = c("blue", "black"), shirt = c("white", "grey", "plaid"))
class(eg)
#generate a deck of cards
suits <- c("Diamonds", "Clubs", "Hearts", "Spades")
numbers <- c("Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")
deck <- expand.grid(number=numbers, suit=suits)
class(deck)
print(deck)
deck <- paste(deck$number, deck$suit)
class(deck)
print(deck)
number suit 1 Ace Diamonds 2 Deuce Diamonds 3 Three Diamonds 4 Four Diamonds 5 Five Diamonds 6 Six Diamonds 7 Seven Diamonds 8 Eight Diamonds 9 Nine Diamonds 10 Ten Diamonds 11 Jack Diamonds 12 Queen Diamonds 13 King Diamonds 14 Ace Clubs 15 Deuce Clubs 16 Three Clubs 17 Four Clubs 18 Five Clubs 19 Six Clubs 20 Seven Clubs 21 Eight Clubs 22 Nine Clubs 23 Ten Clubs 24 Jack Clubs 25 Queen Clubs 26 King Clubs 27 Ace Hearts 28 Deuce Hearts 29 Three Hearts 30 Four Hearts 31 Five Hearts 32 Six Hearts 33 Seven Hearts 34 Eight Hearts 35 Nine Hearts 36 Ten Hearts 37 Jack Hearts 38 Queen Hearts 39 King Hearts 40 Ace Spades 41 Deuce Spades 42 Three Spades 43 Four Spades 44 Five Spades 45 Six Spades 46 Seven Spades 47 Eight Spades 48 Nine Spades 49 Ten Spades 50 Jack Spades 51 Queen Spades 52 King Spades
[1] "Ace Diamonds" "Deuce Diamonds" "Three Diamonds" "Four Diamonds" [5] "Five Diamonds" "Six Diamonds" "Seven Diamonds" "Eight Diamonds" [9] "Nine Diamonds" "Ten Diamonds" "Jack Diamonds" "Queen Diamonds" [13] "King Diamonds" "Ace Clubs" "Deuce Clubs" "Three Clubs" [17] "Four Clubs" "Five Clubs" "Six Clubs" "Seven Clubs" [21] "Eight Clubs" "Nine Clubs" "Ten Clubs" "Jack Clubs" [25] "Queen Clubs" "King Clubs" "Ace Hearts" "Deuce Hearts" [29] "Three Hearts" "Four Hearts" "Five Hearts" "Six Hearts" [33] "Seven Hearts" "Eight Hearts" "Nine Hearts" "Ten Hearts" [37] "Jack Hearts" "Queen Hearts" "King Hearts" "Ace Spades" [41] "Deuce Spades" "Three Spades" "Four Spades" "Five Spades" [45] "Six Spades" "Seven Spades" "Eight Spades" "Nine Spades" [49] "Ten Spades" "Jack Spades" "Queen Spades" "King Spades"
R contains five classes of objects. That is:
1). Numeric- real numbers
2). Character
3). Integer- whole numbers
4). Logical
5). Complex
These objects can have attributes (contain metadata) such as:
1). Dimensions
2). Class
3). Names
4). Length
These attributes are accessed with attribute()
function.
NA, NULL, ±Inf and NaN
NA + 2
sum(c(NA, 4, 6))
median(c(NA, 4, 8, 4), na.rm = TRUE)
length(c(NA, 2, 3, 4))
5 == NA
NA == NA
TRUE | NA
x <- c(2,NA,5,4.89,10,TRUE,6/7)
is.na(x)
is.null()
can be used to detect NULL variables.length(c(3, 4, NULL, 1))
sum(c(5, 1, NULL, 4))
x <- NULL
c(x, 5)
numeric
that results from calculations like division of a number by zero.32/0
5 * Inf
Inf - 2e+10
Inf + Inf
8 < -Inf
Inf == Inf
0/0, Inf-Inf
and Inf/Inf
result in NaNNaN + 1
exp(NaN)
Guess what the following do without running them first
{r}
xx <- c(1.7, "a")
xx <- c(TRUE, 2)
xx <- c("a", TRUE)
This is called implicit coercion.
If the two arguments are atomic vectors of different types, one is coerced to the type of the other, the (decreasing) order of precedence being character, complex, numeric, integer, logical
c(1, FALSE)
numeric 1, 0
c("a", 1)
character "a", "1"
c(list(1), "a")
list 1, "a"
c(TRUE, 1L)
numeric 1, 1
vec <- c(5,7,8,9,45,-87)
print(vec)
mode(vec)
vec <- append(vec, "hello")
print(vec)
mode(vec)
[1] 5 7 8 9 45 -87
[1] "5" "7" "8" "9" "45" "-87" "hello"
Similarly
1 == "1"
# returns TRUE
here 1 will get coerced into char "1" since the more flexible type here is character
-1 < FALSE
# returns TRUE
here FALSE will get coerced into int 0 since the more flexible type here is integer.
"one" < 2
# returns FALSE
here 2 will get coerced into char "2" since the more flexible type here is character.
while testing the objects
Use is.atomic()
to test if an object is either atomic vector or is.recursive()
|| is.list()
for recursive list.
note: is.vector()
does not test if an object is a vector. Instead it returns TRUE only if the object is a vector with no attributes apart from names.
is.atomic()
is more suitable for testing if an object is a vector.
is.list()
tests whether an object is truly a list.
is.numeric()
, similarly, is TRUE for either integer or double vectors, but not for lists.
# Ex:
# create a string of double-precision values
dbl_var <- c(1, 2.5, 4.5)
dbl_var
## [1] 1.0 2.5 4.5
# placing an L after the values creates a string of integers
int_var <- c(1L, 6L, 10L)
int_var
## [1] 1 6 10
#To check whether a vector is made up of integer or double values:
# identifies the vector type (double, integer, logical, or character)
typeof(dbl_var)
## [1] "double"
typeof(int_var)
## [1] "integer"
vec <- 1:12 # a vector
print(vec)
[1] 1 2 3 4 5 6 7 8 9 10 11 12
mat <- matrix( vec, nrow=2) # a matrix
print(mat)
[,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 3 5 7 9 11 [2,] 2 4 6 8 10 12
dim(mat) <- NULL
print(mat) # back to vector
[1] 1 2 3 4 5 6 7 8 9 10 11 12
print(mtcars)
mpg cyl disp hp drat wt qsec vs am gear carb Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4 Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4 Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1 Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1 Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2 Valiant 18.1 6 225.0 105 2.76 3.460 20.22 1 0 3 1 Duster 360 14.3 8 360.0 245 3.21 3.570 15.84 0 0 3 4 Merc 240D 24.4 4 146.7 62 3.69 3.190 20.00 1 0 4 2 Merc 230 22.8 4 140.8 95 3.92 3.150 22.90 1 0 4 2 Merc 280 19.2 6 167.6 123 3.92 3.440 18.30 1 0 4 4 Merc 280C 17.8 6 167.6 123 3.92 3.440 18.90 1 0 4 4 Merc 450SE 16.4 8 275.8 180 3.07 4.070 17.40 0 0 3 3 Merc 450SL 17.3 8 275.8 180 3.07 3.730 17.60 0 0 3 3 Merc 450SLC 15.2 8 275.8 180 3.07 3.780 18.00 0 0 3 3 Cadillac Fleetwood 10.4 8 472.0 205 2.93 5.250 17.98 0 0 3 4 Lincoln Continental 10.4 8 460.0 215 3.00 5.424 17.82 0 0 3 4 Chrysler Imperial 14.7 8 440.0 230 3.23 5.345 17.42 0 0 3 4 Fiat 128 32.4 4 78.7 66 4.08 2.200 19.47 1 1 4 1 Honda Civic 30.4 4 75.7 52 4.93 1.615 18.52 1 1 4 2 Toyota Corolla 33.9 4 71.1 65 4.22 1.835 19.90 1 1 4 1 Toyota Corona 21.5 4 120.1 97 3.70 2.465 20.01 1 0 3 1 Dodge Challenger 15.5 8 318.0 150 2.76 3.520 16.87 0 0 3 2 AMC Javelin 15.2 8 304.0 150 3.15 3.435 17.30 0 0 3 2 Camaro Z28 13.3 8 350.0 245 3.73 3.840 15.41 0 0 3 4 Pontiac Firebird 19.2 8 400.0 175 3.08 3.845 17.05 0 0 3 2 Fiat X1-9 27.3 4 79.0 66 4.08 1.935 18.90 1 1 4 1 Porsche 914-2 26.0 4 120.3 91 4.43 2.140 16.70 0 1 5 2 Lotus Europa 30.4 4 95.1 113 3.77 1.513 16.90 1 1 5 2 Ford Pantera L 15.8 8 351.0 264 4.22 3.170 14.50 0 1 5 4 Ferrari Dino 19.7 6 145.0 175 3.62 2.770 15.50 0 1 5 6 Maserati Bora 15.0 8 301.0 335 3.54 3.570 14.60 0 1 5 8 Volvo 142E 21.4 4 121.0 109 4.11 2.780 18.60 1 1 4 2
ULmtcars <- unlist(mtcars) # produces a vector from the dataframe
# the atomic type of a dataframe is a list
print(ULmtcars)
mpg1 mpg2 mpg3 mpg4 mpg5 mpg6 mpg7 mpg8 mpg9 mpg10 21.000 21.000 22.800 21.400 18.700 18.100 14.300 24.400 22.800 19.200 mpg11 mpg12 mpg13 mpg14 mpg15 mpg16 mpg17 mpg18 mpg19 mpg20 17.800 16.400 17.300 15.200 10.400 10.400 14.700 32.400 30.400 33.900 mpg21 mpg22 mpg23 mpg24 mpg25 mpg26 mpg27 mpg28 mpg29 mpg30 21.500 15.500 15.200 13.300 19.200 27.300 26.000 30.400 15.800 19.700 mpg31 mpg32 cyl1 cyl2 cyl3 cyl4 cyl5 cyl6 cyl7 cyl8 15.000 21.400 6.000 6.000 4.000 6.000 8.000 6.000 8.000 4.000 cyl9 cyl10 cyl11 cyl12 cyl13 cyl14 cyl15 cyl16 cyl17 cyl18 4.000 6.000 6.000 8.000 8.000 8.000 8.000 8.000 8.000 4.000 cyl19 cyl20 cyl21 cyl22 cyl23 cyl24 cyl25 cyl26 cyl27 cyl28 4.000 4.000 4.000 8.000 8.000 8.000 8.000 4.000 4.000 4.000 cyl29 cyl30 cyl31 cyl32 disp1 disp2 disp3 disp4 disp5 disp6 8.000 6.000 8.000 4.000 160.000 160.000 108.000 258.000 360.000 225.000 disp7 disp8 disp9 disp10 disp11 disp12 disp13 disp14 disp15 disp16 360.000 146.700 140.800 167.600 167.600 275.800 275.800 275.800 472.000 460.000 disp17 disp18 disp19 disp20 disp21 disp22 disp23 disp24 disp25 disp26 440.000 78.700 75.700 71.100 120.100 318.000 304.000 350.000 400.000 79.000 disp27 disp28 disp29 disp30 disp31 disp32 hp1 hp2 hp3 hp4 120.300 95.100 351.000 145.000 301.000 121.000 110.000 110.000 93.000 110.000 hp5 hp6 hp7 hp8 hp9 hp10 hp11 hp12 hp13 hp14 175.000 105.000 245.000 62.000 95.000 123.000 123.000 180.000 180.000 180.000 hp15 hp16 hp17 hp18 hp19 hp20 hp21 hp22 hp23 hp24 205.000 215.000 230.000 66.000 52.000 65.000 97.000 150.000 150.000 245.000 hp25 hp26 hp27 hp28 hp29 hp30 hp31 hp32 drat1 drat2 175.000 66.000 91.000 113.000 264.000 175.000 335.000 109.000 3.900 3.900 drat3 drat4 drat5 drat6 drat7 drat8 drat9 drat10 drat11 drat12 3.850 3.080 3.150 2.760 3.210 3.690 3.920 3.920 3.920 3.070 drat13 drat14 drat15 drat16 drat17 drat18 drat19 drat20 drat21 drat22 3.070 3.070 2.930 3.000 3.230 4.080 4.930 4.220 3.700 2.760 drat23 drat24 drat25 drat26 drat27 drat28 drat29 drat30 drat31 drat32 3.150 3.730 3.080 4.080 4.430 3.770 4.220 3.620 3.540 4.110 wt1 wt2 wt3 wt4 wt5 wt6 wt7 wt8 wt9 wt10 2.620 2.875 2.320 3.215 3.440 3.460 3.570 3.190 3.150 3.440 wt11 wt12 wt13 wt14 wt15 wt16 wt17 wt18 wt19 wt20 3.440 4.070 3.730 3.780 5.250 5.424 5.345 2.200 1.615 1.835 wt21 wt22 wt23 wt24 wt25 wt26 wt27 wt28 wt29 wt30 2.465 3.520 3.435 3.840 3.845 1.935 2.140 1.513 3.170 2.770 wt31 wt32 qsec1 qsec2 qsec3 qsec4 qsec5 qsec6 qsec7 qsec8 3.570 2.780 16.460 17.020 18.610 19.440 17.020 20.220 15.840 20.000 qsec9 qsec10 qsec11 qsec12 qsec13 qsec14 qsec15 qsec16 qsec17 qsec18 22.900 18.300 18.900 17.400 17.600 18.000 17.980 17.820 17.420 19.470 qsec19 qsec20 qsec21 qsec22 qsec23 qsec24 qsec25 qsec26 qsec27 qsec28 18.520 19.900 20.010 16.870 17.300 15.410 17.050 18.900 16.700 16.900 qsec29 qsec30 qsec31 qsec32 vs1 vs2 vs3 vs4 vs5 vs6 14.500 15.500 14.600 18.600 0.000 0.000 1.000 1.000 0.000 1.000 vs7 vs8 vs9 vs10 vs11 vs12 vs13 vs14 vs15 vs16 0.000 1.000 1.000 1.000 1.000 0.000 0.000 0.000 0.000 0.000 vs17 vs18 vs19 vs20 vs21 vs22 vs23 vs24 vs25 vs26 0.000 1.000 1.000 1.000 1.000 0.000 0.000 0.000 0.000 1.000 vs27 vs28 vs29 vs30 vs31 vs32 am1 am2 am3 am4 0.000 1.000 0.000 0.000 0.000 1.000 1.000 1.000 1.000 0.000 am5 am6 am7 am8 am9 am10 am11 am12 am13 am14 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 am15 am16 am17 am18 am19 am20 am21 am22 am23 am24 0.000 0.000 0.000 1.000 1.000 1.000 0.000 0.000 0.000 0.000 am25 am26 am27 am28 am29 am30 am31 am32 gear1 gear2 0.000 1.000 1.000 1.000 1.000 1.000 1.000 1.000 4.000 4.000 gear3 gear4 gear5 gear6 gear7 gear8 gear9 gear10 gear11 gear12 4.000 3.000 3.000 3.000 3.000 4.000 4.000 4.000 4.000 3.000 gear13 gear14 gear15 gear16 gear17 gear18 gear19 gear20 gear21 gear22 3.000 3.000 3.000 3.000 3.000 4.000 4.000 4.000 3.000 3.000 gear23 gear24 gear25 gear26 gear27 gear28 gear29 gear30 gear31 gear32 3.000 3.000 3.000 4.000 5.000 5.000 5.000 5.000 5.000 4.000 carb1 carb2 carb3 carb4 carb5 carb6 carb7 carb8 carb9 carb10 4.000 4.000 1.000 1.000 2.000 1.000 4.000 2.000 2.000 4.000 carb11 carb12 carb13 carb14 carb15 carb16 carb17 carb18 carb19 carb20 4.000 3.000 3.000 3.000 4.000 4.000 4.000 1.000 2.000 1.000 carb21 carb22 carb23 carb24 carb25 carb26 carb27 carb28 carb29 carb30 1.000 2.000 2.000 4.000 2.000 1.000 2.000 2.000 4.000 6.000 carb31 carb32 8.000 2.000
UCmtcars <- unclass(mtcars) # removes the class attribute, turning the dataframe into a
# series of vectors plus any names attributes, same as setting
# class(mtcars) <- NULL
print(UCmtcars)
$mpg [1] 21.0 21.0 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 17.8 16.4 17.3 15.2 10.4 [16] 10.4 14.7 32.4 30.4 33.9 21.5 15.5 15.2 13.3 19.2 27.3 26.0 30.4 15.8 19.7 [31] 15.0 21.4 $cyl [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4 $disp [1] 160.0 160.0 108.0 258.0 360.0 225.0 360.0 146.7 140.8 167.6 167.6 275.8 [13] 275.8 275.8 472.0 460.0 440.0 78.7 75.7 71.1 120.1 318.0 304.0 350.0 [25] 400.0 79.0 120.3 95.1 351.0 145.0 301.0 121.0 $hp [1] 110 110 93 110 175 105 245 62 95 123 123 180 180 180 205 215 230 66 52 [20] 65 97 150 150 245 175 66 91 113 264 175 335 109 $drat [1] 3.90 3.90 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 3.92 3.07 3.07 3.07 2.93 [16] 3.00 3.23 4.08 4.93 4.22 3.70 2.76 3.15 3.73 3.08 4.08 4.43 3.77 4.22 3.62 [31] 3.54 4.11 $wt [1] 2.620 2.875 2.320 3.215 3.440 3.460 3.570 3.190 3.150 3.440 3.440 4.070 [13] 3.730 3.780 5.250 5.424 5.345 2.200 1.615 1.835 2.465 3.520 3.435 3.840 [25] 3.845 1.935 2.140 1.513 3.170 2.770 3.570 2.780 $qsec [1] 16.46 17.02 18.61 19.44 17.02 20.22 15.84 20.00 22.90 18.30 18.90 17.40 [13] 17.60 18.00 17.98 17.82 17.42 19.47 18.52 19.90 20.01 16.87 17.30 15.41 [25] 17.05 18.90 16.70 16.90 14.50 15.50 14.60 18.60 $vs [1] 0 0 1 1 0 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 0 1 0 0 0 1 $am [1] 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 $gear [1] 4 4 4 3 3 3 3 4 4 4 4 3 3 3 3 3 3 4 4 4 3 3 3 3 3 4 5 5 5 5 5 4 $carb [1] 4 4 1 1 2 1 4 2 2 4 4 3 3 3 4 4 4 1 2 1 1 2 2 4 2 1 2 2 4 6 8 2 attr(,"row.names") [1] "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" [4] "Hornet 4 Drive" "Hornet Sportabout" "Valiant" [7] "Duster 360" "Merc 240D" "Merc 230" [10] "Merc 280" "Merc 280C" "Merc 450SE" [13] "Merc 450SL" "Merc 450SLC" "Cadillac Fleetwood" [16] "Lincoln Continental" "Chrysler Imperial" "Fiat 128" [19] "Honda Civic" "Toyota Corolla" "Toyota Corona" [22] "Dodge Challenger" "AMC Javelin" "Camaro Z28" [25] "Pontiac Firebird" "Fiat X1-9" "Porsche 914-2" [28] "Lotus Europa" "Ford Pantera L" "Ferrari Dino" [31] "Maserati Bora" "Volvo 142E"
c(mtcars) # similar to unclass but without the attributes
install.packages("swirl")
also installing the dependencies 'bitops', 'RCurl'
There is a binary version available but the source version is later: binary source needs_compilation RCurl 1.98-1.3 1.98-1.5 TRUE Binaries will be installed package 'bitops' successfully unpacked and MD5 sums checked package 'RCurl' successfully unpacked and MD5 sums checked package 'swirl' successfully unpacked and MD5 sums checked The downloaded binary packages are in C:\Users\Administrator\AppData\Local\Temp\Rtmp44AWmj\downloaded_packages
library(swirl)
Warning message: "package 'swirl' was built under R version 3.6.3" | Hi! I see that you have some variables saved in your workspace. To keep | things running smoothly, I recommend you clean up before starting swirl. | Type ls() to see a list of the variables in your workspace. Then, type | rm(list=ls()) to clear your workspace. | Type swirl() when you are ready to begin.