logical(0) in table headers

Hello,

I am trying to set up a proper dataframe, and has problem setting the headers of my dataframe (df).

I am loading the headers from a .csv file:

headers <- read.csv("headers", header = TRUE, sep = " ")

Then using this command to set the headers:

names(df) <- headers

As a result, the headers are now "locical(0)" in all the columns of the dataframe.
Would anyone know why?
Thanks for the help!

Hi there,

First of all I would use the colnames() function instead of the names to set new headers to a data frame.

But to your question: you are trying to assign a dataframe to column names whereas the names function requires a vector of strings. So make sure that if you are reading a dataframe you only use the column that has the header names

Hope this helps,
PJ

1 Like

This topic was automatically closed 7 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.