Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Columns Accessors | Data Frames
R Introduction: Part II
course content

Contenido del Curso

R Introduction: Part II

R Introduction: Part II

1. Matrices
2. Data Frames
3. Lists

bookColumns 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.

12345678910
# Data name <- c("Alex", "Julia", "Finn") age <- c(24, 43, 32) gender <- c("M", "F", "M") # Creating a data frame test <- data.frame(name, age, gender) # Extracting the name column using two ways test[,"name"] test$name
copy

Tarea

Let's work with the mtcars dataset. Your tasks are:

  1. Extract the cyl column values using square brackets.
  2. Extract the disp column values using the dollar $ sign.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3
toggle bottom row

bookColumns 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.

12345678910
# Data name <- c("Alex", "Julia", "Finn") age <- c(24, 43, 32) gender <- c("M", "F", "M") # Creating a data frame test <- data.frame(name, age, gender) # Extracting the name column using two ways test[,"name"] test$name
copy

Tarea

Let's work with the mtcars dataset. Your tasks are:

  1. Extract the cyl column values using square brackets.
  2. Extract the disp column values using the dollar $ sign.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 3
toggle bottom row

bookColumns 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.

12345678910
# Data name <- c("Alex", "Julia", "Finn") age <- c(24, 43, 32) gender <- c("M", "F", "M") # Creating a data frame test <- data.frame(name, age, gender) # Extracting the name column using two ways test[,"name"] test$name
copy

Tarea

Let's work with the mtcars dataset. Your tasks are:

  1. Extract the cyl column values using square brackets.
  2. Extract the disp column values using the dollar $ sign.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

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.

12345678910
# Data name <- c("Alex", "Julia", "Finn") age <- c(24, 43, 32) gender <- c("M", "F", "M") # Creating a data frame test <- data.frame(name, age, gender) # Extracting the name column using two ways test[,"name"] test$name
copy

Tarea

Let's work with the mtcars dataset. Your tasks are:

  1. Extract the cyl column values using square brackets.
  2. Extract the disp column values using the dollar $ sign.

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 3
Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
some-alt