Displaying 1 result from an estimated 1 matches for "x1_cut".
2009 Aug 03
1
apply cut function on various values (factor constrained)
...y a
combination of tapply and cut...but
example
------------------------------------------------------------------------------------------------------------
# data
# data
set.seed(100)
n<-30
X1 <- rnorm(n, mean=0.7, sd=10)
X2 <- rnorm(n, mean=0.3, sd=25)
# code X1 values by using cut
X1_cut <- factor(cut(X1,quantile(X1),include.lowest=TRUE))
# calculate quantiles given X1_cut
X2QuantilesForX1_cut <-tapply(X2,X1_cut,quantile)
# display quantiles
X2QuantilesForX1_cut
# now i want to code X2 values; taking as breaks X2QuantilesForX1_cut;
code does not work, just for showing my i...