S******y 发帖数: 1123 | 1 > library(gtools)
> x <- rnorm(1000)
> quartiles <- quantcut( x )
> table(quartiles)
quartiles
[-3.41,-0.704] (-0.704,0.0272] (0.0272,0.732] (0.732,2.94]
250 250 250 250 |
|
l*g 发帖数: 46 | 2 您是说要改quantcut这个function里面的东西?
我改了一下,又有别的error...还要加na.rm=T?
Error in if (pairs[1, i] == pairs[1, i - 1] && pairs[1, i] == pairs[2, :
missing value where TRUE/FALSE needed
我的data太skewed了,所以两个cutoff points是一样的。。。
谢谢!
na. |
|
|
i*******c 发帖数: 113 | 4 How to input time series concept into multiple linear regression model by R? |
|
S******y 发帖数: 1123 | 5 Thanks. unclass - works well. |
|
o****o 发帖数: 8077 | 6 use upper and lower triaggle matrix, and sum over the rows to obtain the
cumulative weights, from beginning or from tail
then use the quantcut function
a |
|
l*g 发帖数: 46 | 7 出来这么一个error
Error in if (sum(flag) == 0) return(cut) else return(min(x[flag], na.rm = na
.rm)) :
missing value where TRUE/FALSE needed
我之前用过这个function没有问题的,也加了na.rm,不知道现在跑不过去。。。
谢谢! |
|
a*******7 发帖数: 772 | 8 sum(flag, na.rm = T) == 0
na |
|
l*g 发帖数: 46 | 9
呃。。。抹油看懂。。。这个是什么?要加在什么地方?谢谢! |
|
a*******7 发帖数: 772 | 10 把这句:if (sum(flag) == 0) return(cut) else return(min(x[flag], na.rm = na.
rm))
里面的: (sum(flag) == 0)
换成:(sum(flag, na.rm = T) == 0) |
|
k*******a 发帖数: 772 | 11 建议你用这个函数前先把 数据里面的missing value去掉 试试看 |
|
l*g 发帖数: 46 | 12 不容易去啊。。。而且dimension较多,指望能用na。rm去掉呢。。。 |
|
c***z 发帖数: 6348 | 13 maybe do
if(is.na(your.var)) {do something}
else (do what you are doing} |
|
|