+2 votes
in Programming Languages by (14.6k points)
My input file does not have column names. I want to put column names (header) after reading the file as a DataFrame. How can I add a header to an R DataFrame?

1 Answer

+2 votes
by (48.9k points)

You can use the names() function to set the header of a DataFrame.

Here is an example:

names(your_dataframe) <- c("col1", "col2", "col3")

The above example adds a header to the DataFrame with 3 columns: "col1", "col2", "col3".

Related questions

+5 votes
1 answer
+4 votes
1 answer
+5 votes
1 answer
+5 votes
1 answer
asked Jul 6, 2021 in Programming Languages by kush (14.6k points)

...