Problem with creation an empty table with column names

I have a code:
#reading a file
table <- readxl::read_excel("name.xlsx", sheet = "sheetname", skip = 10, col_names = TRUE)

#creating column names
col_n <- na.omit(AE_table[" Column Name"])

create an empty table

df <- data.frame(matrix(ncol=length(col_n),nrow=0))
colnames(df) <- col_n
print(df)

I obtained one column containing: c("name1", "name2", "name3"......)
Any ideas how to resolve this ??
Thanks a lot for some clues.

Hi @BeWu ,

Am I right to assume that you want an empty copy of your table object?

library(dplyr)
df <- table %>% slice(0)

Let me know if you're looking for something else, but column names and classes will be retained.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.