You can add the argument na.print=" " to print() to make
the missing values print as " " instead of as NA. Some,
but not all print methods support this. E.g.,
> print(c(1,2,NA,4,5,NA), na.print="-")
[1] 1 2 - 4 5 -
> print(matrix(c(1,2,NA,4,5,NA),2), na.print="-")
[,1] [,2] [,3]
[1,] 1 - 5
[2,] 2 4 -
> # print.data.frame use na.print for factor/character data only
> print(data.frame(X=c(1,NA,3), Y=LETTERS[c(NA,2,3)]), na.print="-")
> print(data.frame(X=c(1,NA,3), Y=LETTERS[c(NA,2,3)], Z=c(NA,TRUE,FALSE)),
na.print="-")
X Y Z
1 1 - NA
2 NA B TRUE
3 3 C FALSE
In write.table (& write.csv) the argument na=" " does the trick.
> write.csv(data.frame(X=c(1,NA,3), Y=LETTERS[c(NA,2,3)],
Z=c(NA,TRUE,FALSE)), na="-")
"","X","Y","Z"
"1",1,-,-
"2",-,"B",TRUE
"3",3,"C",FALSE
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Wed, Feb 17, 2016 at 2:04 AM, Jan Kacaba <[email protected]> wrote:
> In my original data a csv file I have missing values. If I use read.table
> the missing values are replaced by NAs.
>
> Is it possible to get object where missing values aren't replaced with NAs?
> Is it possible to replace NAs with empty space?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.