That's not right in general, is it? I'd think that should be
x[!is.na(x1)] <- 0
x2 <- x1
I left out a '1' on the first line - it should have been
x1[!is.na(x1)] <- 0
In the following examples the value of the assignment
expression is the right hand side of the assignment.
Thank you so much Jim!
On Sat, Feb 24, 2018 at 6:38 PM, Jim Lemon wrote:
> Hi Val,
> My fault - I assumed that the NA would be first in the result produced
> by "unique":
>
> mydat <- read.table(textConnection("Col1 Col2 col3
> Z1 K1 K2
> Z2 NA NA
> Z3 X1 NA
> Z4 Y1 W1"),header = TRUE,stringsAsF
Hi Val,
My fault - I assumed that the NA would be first in the result produced
by "unique":
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
val23<-unique(unlist(mydat[,c("Col2","col3")]))
napos<-which(is.na(val23))
prev
Thank you Jim,
I read the data as you suggested but I could not find K1 in col1.
rbind(preval,mydat) Col1 Col2 col3
1
2 X1
3 Y1
4 K2
5 W1
6 Z1 K1 K2
7 Z2
8 Z3 X1
9 Z4 Y1 W1
On Sat, Feb 24, 2018 at 6:18 PM, Jim Lemon wrote:
> hi Val,
> Your problem s
hi Val,
Your problem seems to be that the data are read in as a factor. The
simplest way I can think of to get around this is:
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1 NA
Z4 Y1 W1"),header = TRUE,stringsAsFactors=FALSE)
preval<-data.frame(Col1=unique(unlist(mydat[
Sorry , I hit the send key accidentally here is my complete message.
Thank you Jim and all, I got it.
I have one more question on the original question
What does this "[-1] " do?
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
myd
Thank you Jim and all, I got it.
I have one more question on the original question
What does this "[-1] " do?
preval<-data.frame(Col1=unique(unlist(mydat[,c("Col2","col3")]))[-1],
Col2=NA,col3=NA)
mydat <- read.table(textConnection("Col1 Col2 col3
Z1 K1 K2
Z2 NA NA
Z3 X1
On 24/02/2018 1:53 PM, William Dunlap via R-help wrote:
x1 = rbind(unique(preval),mydat)
x2 <- x1[is.na(x1)] <- 0
x2 # gives 0
Why introduce the 'x2'? x1[...] <- 0 alters x1 in place and I think that
altered x1 is what you want.
You asked why x2 was zero. The value of the express
As Bert implies, you may be getting ahead of yourself. An 8 may be a number, or
it may be the character 8, or it could be a factor, and you don't seem to know
the difference yet (thus suggesting tutorials). If you go to the trouble of
making a reproducible example [1][2][3] then you may find the
But note that converting it e.g. via as.numeric() would be disastrous:
> as.numeric(factor(c(3,5,7)))
[1] 1 2 3
The OP may need to do some homework with R tutorials to learn about basic R
data structures; or if he has already done this, he may need to be more
explicit about how the data were crea
On Sat, Feb 24, 2018 at 01:16:27PM -0600, Gary Black wrote:
> Hi All,
>
> I'm a newbie and have two questions. Please pardon me if they are very basic.
>
>
> 1. I'm using a regression tree to predict the selling prices of 10 new
> records (homes). The following code is resulting in an error
Hi All,
I'm a newbie and have two questions. Please pardon me if they are very basic.
1. I'm using a regression tree to predict the selling prices of 10 new records
(homes). The following code is resulting in an error message: pred <-
predict(model, newdata = outOfSample[, -6])
The error
x1 = rbind(unique(preval),mydat)
x2 <- x1[is.na(x1)] <- 0
x2 # gives 0
Why introduce the 'x2'? x1[...] <- 0 alters x1 in place and I think that
altered x1 is what you want.
You asked why x2 was zero. The value of the expression
f(a) <- b
and assignments are processed right to left
Thank you Jim
I wanted a final data frame after replacing the NA's to "0"
x1 = rbind(unique(preval),mydat)
x2 <- x1[is.na(x1)] <- 0
x2
but I got this,
[1] 0
why I am getting this?
On Sat, Feb 24, 2018 at 12:17 AM, Jim Lemon wrote:
> Hi Val,
> Try this:
>
> preval<-data.frame(Col1=unique(
14 matches
Mail list logo