Nice! Exactly what I was looking for. I just needed to call the rows in both
vector arguments.
Thanks,
MVS
--
View this message in context:
http://r.789695.n4.nabble.com/Changing-NA-to-0-in-selected-columns-of-a-dataframe-tp4645917p4645949.html
Sent from the R help mailing list archive at Nabb
Hello,
Try the following.
data[ , 2:3][is.na(data[ , 2:3] ) ] = 0
You have to tell the interpreter which columns you want to change.
Hope this helps,
Rui Barradas
Em 11-10-2012 23:05, scoyoc escreveu:
I've been beating my head on the table for hours now and don't understand why
this doesn't
2 2 7 0 17 NA
#3 3 0 13 18 NA
#4 4 0 14 19 NA
#5 5 0 15 20 25
A.K.
- Original Message -
From: R. Michael Weylandt
To: arun
Cc: scoyoc ; R help
Sent: Thursday, October 11, 2012 7:04 PM
Subject: Re: [R] Changing NA to 0 in selected columns of a dataframe
On Thu, Oct 11, 2012 at 11:5
On Thu, Oct 11, 2012 at 11:58 PM, arun wrote:
> Hi,
> Try this:
> dat1 = as.data.frame ( cbind ( A, B, C, D, E ) )
No. Do not try this. It is a Very Bad Thing to use
as.data.frame(cbind(...))
instead of
data.frame(...)
for reasons I've mentioned before on this list. In short, cbind()
forces
org
Cc:
Sent: Thursday, October 11, 2012 6:05 PM
Subject: [R] Changing NA to 0 in selected columns of a dataframe
I've been beating my head on the table for hours now and don't understand why
this doesn't work. I have a dataframe that I want to change NAs to 0 for
some of the c
Actually what does "only logical matrix subscripts are allowed in
replacement" mean. I can designate columns using is.na.
--
View this message in context:
http://r.789695.n4.nabble.com/Changing-NA-to-0-in-selected-columns-of-a-dataframe-tp4645917p4645918.html
Sent from the R help mailing list a
I've been beating my head on the table for hours now and don't understand why
this doesn't work. I have a dataframe that I want to change NAs to 0 for
some of the columns and not others. Consider this...
>#create dataframe
> A = c(1:5)
> B = c(6, 7, NA, NA, NA)
> C = c(NA, NA, 13, 14, 15)
> D = c(
7 matches
Mail list logo