r - extracting specific columns from a data frame

# Assuming 'your_data' is your data frame
selected_columns <- your_data[, c("Column1", "Column2", "Column3")]

# Alternatively, you can use column indices
# selected_columns <- your_data[, c(1, 2, 3)]

Explanation: 1. your_data[, c("Column1", "Column2", "Column3")]: This extracts specific columns named "Column1", "Column2", and "Column3" from the data frame 'your_data'. The comma before the column selection indicates that we want to subset the data frame by columns.

  1. your_data[, c(1, 2, 3)]: This is an alternative way to select columns by index. Here, we use the column indices (1, 2, 3) instead of column names to extract the desired columns from the data frame.