How to find Decile in R if the data set has NA values -



How to find Decile in R if the data set has NA values -

i trying rank info using decile using r. here code.

x<-c(1,6,2,4,3,5,12,9,8,10,11,7)

newvar<-cut(x,quantile(x,(0:10)/10),include.lowest=true)

cbind(x,newvar)

x newvar

[1,] 1 1

[2,] 6 5

[3,] 2 1

[4,] 4 3

[5,] 3 2

[6,] 5 4

[7,] 12 10

[8,] 9 8

[9,] 8 7

[10,] 10 9

[11,] 11 10

[12,] 7 6

for above info set giving right values.

but if info set has na values givin error shown below.

x<-c(1,6,2,4,3,5,12,9,8,10,na,11,7,na)

newvar<-cut(x,quantile(x,(0:10)/10),include.lowest=true, na.rm=false)

error "error in quantile.default(x, (0:10)/10) :missing values , nan's not allowed if 'na.rm' false"

r

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -