Answers for "how to print the column names of a dataframe in r"

1

r get name of column in data frame

colnames(<dataframe>)
#or
names(<dataframe>)
Posted by: Guest on February-26-2021
1

create a dataframe with column names in r

# This works well if you need an empty dataframe with n known columns
df <- data.frame(matrix(ncol = 3, nrow = 0))
x <- c("name", "age", "gender")
colnames(df) <- x
Posted by: Guest on February-23-2021
0

r set dataframe column names

R> colnames(X)[2] <- "superduper"
Posted by: Guest on May-06-2020

Code answers related to "how to print the column names of a dataframe in r"

Browse Popular Code Answers by Language