Hi, Jim:
I tried your code and get the following error:
trn1-read.table('trn1.svm', header=F, na.string='.', sep='|')
Med-apply(trn1, 2, median, na.rm=T)
Ind-which(is.na(trn1), arr.ind=T)
trn1[Ind]-Med[Ind[,'col']]
Error in [-.data.frame(`*tmp*`, Ind, value = c(1.00802124455,
1.00802124455, :
only
On Tue, 4 Oct 2005, Weiwei Shi wrote:
Hi, Jim:
I tried your code and get the following error:
trn1-read.table('trn1.svm', header=F, na.string='.', sep='|')
Med-apply(trn1, 2, median, na.rm=T)
Ind-which(is.na(trn1), arr.ind=T)
trn1[Ind]-Med[Ind[,'col']]
Error in [-.data.frame(`*tmp*`, Ind,
At 8:35 PM +0100 10/4/05, Prof Brian Ripley wrote:
On Tue, 4 Oct 2005, Weiwei Shi wrote:
Hi, Jim:
I tried your code and get the following error:
trn1-read.table('trn1.svm', header=F, na.string='.', sep='|')
Med-apply(trn1, 2, median, na.rm=T)
Ind-which(is.na(trn1), arr.ind=T)
Hi,
I have the following codes to replace missing using median, assuming missing
only occurs on continuous variables:
trn1-read.table('trn1.fv', header=F, na.string='.', sep='|')
# median
m.trn1-sapply(1:ncol(trn1), function(i) median(trn1[,i], na.rm=T))
#replace
trn2-trn1
for (each in
Use 'which(...arr.ind=T)'
x.1
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 6 10 3 4 10 7 9 8 4 10
[2,] 8 7 4 7 4 8 3 NA 3 4
[3,] 7 7 10 10 3 5 3 2 2 2
[4,] 3 4 5 10 10 2 6 9 4 5
[5,] 3 5 9 5 6 NA 3 NA 6 7
[6,] 9 6 10 5 10 4 2 10 NA 5
[7,] 5 2 5 10 3 7 6 4 6 8
[8,] 2 6 1 8 9 2 7 8 3 8