Withdraw NA in a Data Frame

3

I import a file containing more than 30 columns. Some blank lines that I imported the R recognize as "NA". When exporting these same columns, the lines that should be blank (empty) appear with "NA". How do I export by changing the "NA" for empty? I do not want to delete the data, just that it appears empty.

    
asked by anonymous 14.08.2018 / 17:10

2 answers

6

Assuming the dataset is named dados , run the following command:

write.csv(dados, file="NomeDoArquivo.csv", na=" ", row.names=FALSE, quote=FALSE)

where

  • na=" " says that all NA in dados will be replaced by whitespace
  • row.names=FALSE takes quotes from column names and categorical variables

14.08.2018 / 17:25
5

In the write.table functions. write.csv and write.csv2 , there is an option ( na ) where you define how you want the missing data to be exported.

Try write.table(x, ..., na = "")

    
14.08.2018 / 17:23