[R] Convert NA to '.'

David_D david.dabin at gmail.com
Mon Jun 22 15:22:28 CEST 2009


Jorge,

Thanks a lot for your reply. It's indeed working in this case. However, with
data frames mixing numeric and character is not working anymore. Morever I
am working with many variables and I don't want to modify them. What I would
really appreciate is a global option (in the Rprofile?) that allow to change
the display nd printing of NA by any symbol?

Does it exist?

Best regards,
David


Jorge Ivan Velez wrote:
> 
> Dear David,
> Try this:
> 
> x <- c("A", "B", "C", NA)
> x[is.na(x)] <- "."
> x
> 
> HTH,
> 
> Jorge
> 
> On Mon, Jun 22, 2009 at 2:11 AM, David_D <david.dabin at gmail.com> wrote:
> 
>>
>> Dear R-users,
>>
>> For reporting purpose (using Sweave and LaTeX), I am creating complex
>> tables
>> with the cat function such as
>>
>> > x<-c("A", "B", "C", NA)
>> > cat(x, '\n')
>> A B C NA
>>
>> For convenience, I would like to change all my NA value to something else
>> like '.' (as in SAS for example). Is there a global option which allows
>> this
>> change? Or should I change all my code to work with the print function
>> and
>> the na.print argument?
>>
>> Best regards,
>> David
>> --
>> View this message in context:
>> http://www.nabble.com/Convert-NA-to-%27.%27-tp24142187p24142187.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> 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]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Convert-NA-to-%27.%27-tp24142187p24147157.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list