Answers for "R create dataframe with column and row names"

R
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 make column of rownames

library(dplyr)
df <- tibble::rownames_to_column(df, "VALUE")
Posted by: Guest on July-27-2020

Code answers related to "R create dataframe with column and row names"

Browse Popular Code Answers by Language