Using which() improves my code, but now I'm receiving some data.frame error
and still does not convert the values to negative.
#TAKE PART OF MATRIX
CEM1_PARTIAL <- CEM1[1:10,1:10]
#CEM1_PARTIAL=apply(CEM1_PARTIAL,2,as.character)
#CEM1_PARTIAL <- as.numeric(as.character(CEM1_PARTIAL))
#CEM1_PART
That just converts my values in V3 to NA
--
View this message in context:
http://r.789695.n4.nabble.com/matrix-looping-accessing-previous-column-tp3165308p3165340.html
Sent from the R help mailing list archive at Nabble.com.
__
R-help@r-project.or
Thank you for the quick response :-). I've applied your suggestion to my
code, but I still receive an error:
> CEM1_PARTIAL$V3[which(CEM1_PARTIAL$V4 == "DOWN") - 1] <-
> CEM1_PARTIAL$V3[which(CEM1_PARTIAL$V4 == "DOWN") - 1] * -1
Warning message:
In Ops.factor(CEM1_PARTIAL$V3[which(CEM1_PARTIAL$V4
Hi,
I have a matrix with numbers and character. I want to evaluate each cell and
change the value of the cell before it depending on the evaluation. My
evaluation: if a cell had the word "down" change the cell preceding it to a
negative number by multiplying that value by a -1. I am have trouble
4 matches
Mail list logo