Зміст курсу
R Introduction: Part II
R Introduction: Part II
Columns Accessors
Since data frames have names on their columns, you should be able to extract necessary data using them.
There are several ways in R to refer to a particular column using naming. One of them is the same as in vectors and matrices: column name within square brackets (for example, data[, "col_name"]
). The second way is unique for data frames - using the dollar $
sign. The syntax is data$col_name
(yes, without quotation marks). For example, you can extract the column "Age"
from the data frame created in the last chapter.
Завдання
Let's work with the mtcars
dataset. Your tasks are:
- Extract the
cyl
column values using square brackets. - Extract the
disp
column values using the dollar$
sign.
Завдання
Let's work with the mtcars
dataset. Your tasks are:
- Extract the
cyl
column values using square brackets. - Extract the
disp
column values using the dollar$
sign.
Все було зрозуміло?
Columns Accessors
Since data frames have names on their columns, you should be able to extract necessary data using them.
There are several ways in R to refer to a particular column using naming. One of them is the same as in vectors and matrices: column name within square brackets (for example, data[, "col_name"]
). The second way is unique for data frames - using the dollar $
sign. The syntax is data$col_name
(yes, without quotation marks). For example, you can extract the column "Age"
from the data frame created in the last chapter.
Завдання
Let's work with the mtcars
dataset. Your tasks are:
- Extract the
cyl
column values using square brackets. - Extract the
disp
column values using the dollar$
sign.
Завдання
Let's work with the mtcars
dataset. Your tasks are:
- Extract the
cyl
column values using square brackets. - Extract the
disp
column values using the dollar$
sign.
Все було зрозуміло?
Since data frames have names on their columns, you should be able to extract necessary data using them.
There are several ways in R to refer to a particular column using naming. One of them is the same as in vectors and matrices: column name within square brackets (for example, data[, "col_name"]
). The second way is unique for data frames - using the dollar $
sign. The syntax is data$col_name
(yes, without quotation marks). For example, you can extract the column "Age"
from the data frame created in the last chapter.
Завдання
Let's work with the mtcars
dataset. Your tasks are:
- Extract the
cyl
column values using square brackets. - Extract the
disp
column values using the dollar$
sign.
Columns Accessors
Since data frames have names on their columns, you should be able to extract necessary data using them.
There are several ways in R to refer to a particular column using naming. One of them is the same as in vectors and matrices: column name within square brackets (for example, data[, "col_name"]
). The second way is unique for data frames - using the dollar $
sign. The syntax is data$col_name
(yes, without quotation marks). For example, you can extract the column "Age"
from the data frame created in the last chapter.
Завдання
Let's work with the mtcars
dataset. Your tasks are:
- Extract the
cyl
column values using square brackets. - Extract the
disp
column values using the dollar$
sign.