How do I export table in R in txt or csv?

Asked

Viewed 22,729 times

6

I wonder how I do to export a generated data table within the R to format txt or csv?

  • 1

    I don’t want to be boring, but you could take a look at the R documentation first, besides being extremely simple the answer is instant.

1 answer

8

You can use the function write.csv or write.table (documentation), as in the example below.

nomes <- c("Scooby", "Salsicha", "Fred", "Velma", "Daphne")
idades <- c(10, 18, 20, 21, 19)
tabela <- data.frame(nome = nomes, idade = idades)
write.csv(tabela, "ScoobyDoo.csv", row.names = FALSE)
  • 7

    Remember that to be automatically compatible with Microsoft Office in English, you can use write.csv2(), that automatically puts sep=";" and dec=",". Similarly, read.csv2() can be used to read these files.

  • 1

    Thank you for your reply. I am not aware of IT. I am Grateful!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.