Re: [R] Setting NA to blank

From: Dat Mai <dat.d.mai_at_gmail.com>
Date: Mon, 09 May 2011 18:28:03 -0400

I asked because I thought it'd solve an issue I had. I was actually being quite rash in asking this question and for that, I apologize.

I wanted to know because I was attempting to create a heatmap where the NA values would not be shown while all the outputs with actual numerical value will be shown. I had assumed that setting the NA's to blanks would fix the issue, but it hadn't. I refrained from immediately asking another question so I that I can look further into this.

I hope that answers your question.

On Mon, May 9, 2011 at 4:21 PM, Ted Harding <ted.harding_at_wlandres.net>wrote:

> John Kane's reply sums it up! (Though you could use "",
> instead of " ", which would give you an "empty string"
> instead of the "space" character; but the resulting
> matrix would still consist entirely of "character"
> elements).
>
> However, the real reason I am following up is to ask
> why you want the blank instead of the NA.
>
> If it is just for printing out or display, then the
> fact that the matrix has been converted to character
> probably does not matter.
>
> But if it is for compatibility with some other
> computational software that (e.g.) expects missing
> values to be represented by a blank, or some "null"
> representation, then it may not be so straightforward.
>
> So, if that might be an issue, please describe for us
> how you intend to use the result.
>
> Ted.
>
> On 09-May-11 19:56:39, Dat Mai wrote:
> > Thank you kind sir!
> >
> > On Mon, May 9, 2011 at 3:25 PM, John Kane <jrkrideau_at_yahoo.ca> wrote:
> >
> >>
> >> (mat <- matrix(c(1,2,3,NA),2))
> >> mat[is.na(mat)] <- " "
> >> mat
> >>
> >> But if you have a numerical matrix it coverts the matrix to character.
> >>
> >> --- On Mon, 5/9/11, Dat Mai <dat.d.mai_at_gmail.com> wrote:
> >>
> >> > From: Dat Mai <dat.d.mai_at_gmail.com>
> >> > Subject: [R] Setting NA to blank
> >> > To: r-help_at_r-project.org
> >> > Received: Monday, May 9, 2011, 2:46 PM
> >> > Hey All,
> >> >
> >> > I have a matrix m, and I wish to set all the NA values to
> >> > blank. How would I
> >> > do so?
> >> >
> >> > --
> >> > Best,
> >> > Dat Mai
> >> > PhD Rotation Student
> >> > Albert Einstein College of Medicine
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <ted.harding_at_wlandres.net>
> Fax-to-email: +44 (0)870 094 0861
> Date: 09-May-11 Time: 21:21:07
> ------------------------------ XFMail ------------------------------
>

-- 
Best,
Dat Mai
PhD Rotation Student
Albert Einstein College of Medicine

	[[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.
Received on Mon 09 May 2011 - 22:40:23 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 May 2011 - 07:10:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive