Your first replacement in kx changed it to a character vector and
comparisons
of character strings given different results than comparisons of numbers
> kx <- 1:10
> qt <- quantile(kx)
> kx[kx <= qt[2]] <- "DN"
> kx
[1] "DN" "DN" "DN" "4" "5" "6" "7" "8" "9" "10"
> "10" < "6"
[1] TRUE
>
> #
Your goal is fundamentally flawed, since all elements of a vector must be if
the same type.
Create another vector to hold your character information.
kc <- rep( 'NC', length( kx ) )
kc[ kx <= qt[[2]] ] <- 'DN'
kc[ kx >=qt [[4]] ] <- 'UP'
--
Sent from my phone. Please excuse my brevity.
On N
2 matches
Mail list logo