0 votes
1 view
in R Programming by (5.3k points)

Commands:

t <- data.frame(v = 5:1, v2 = 9:5)

write.csv(t, "t.csv")

Resulting file:

# "","v","v2"

# "1",5,9

# "2",4,8

# "3",3,7

# "4",2,6

# "5",1,5

How do I prevent the first column with row index from being written to the file?

1 Answer

0 votes
by (25.3k points)

To prevent row names to be written to file while using write.csv, you can set the row.names argument to FALSE.

Where,

row.names:- Either a logical value indicating whether the row names of x are to be written along with x, or a character vector of row names to be written.

In your case:

write.csv(t, "t.csv", row.names=FALSE)

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...