I have a few correlation matrices. I want to see how many values fall in 6 bins as follows; bin 1: 0 to 0.1, 0.1 to 0.2, 0.2 to 0.3, 0.3 to 0.4, 0.4 to 0.5 and 0.5 to 1.
My matrix:
dput(head(x3,n=1))
structure("1 0.0118056267220191 0.0698430295769578 0.147675160526577 -0.240526687986192 -0.240526687986192 NA -0.0864263397068391 0.0472030857452077 0.144075169217511 -0.169335298346717 -0.136657358184974 0.0997757565385112 0.0318247578607896 -0.121466138394709 0.0698430295769578 0.0372342961702855 0.162822402256459 0.0698430295769578 -0.228614978429606 -0.00325644804512918 -0.0864263397068391 0.128784183243357 0.0698430295769578 0.0772194756468332 -0.0850262968762965 -0.0850262968762965 -0.0850262968762965 -0.35016924446602 0.0440944056879946 -0.171996312074949 0.144075169217511 0.150114837624665 0.0698430295769578 0.0698430295769578 0.0772194756468332 -0.0238936680131698 -0.0900497873763463 0.0997757565385112 -0.0465278278289626 0.0117475463077051 0.0824568591955934 -0.0900497873763463 -0.0257843138721356 0.0723951333229052 -0.286356421265527 0.0698430295769578 0.119512195121951 0.027050089040023 -0.0753353976483616 0.123466199581199 -0.0864263397068391 0.0997757565385112 -0.0396206715348156 0.123466199581199 0.144075169217511 0.180333926933486 0.288860360879251 -0.286356421265527 -0.030022967524933 -0.100304414707211 0.128045554224423 0.292369332798234 0.0997757565385112 -0.0401597420067507 0.0698430295769578 0.0698430295769578 0.0341553188670066 0.0997757565385112 ", .Dim = c(1L,
1L))
I currently do not have a working example. Not sure how to approach this.
Any help would be greatly appreciated.
Thanks.
?cut
or?findInterval
. Looks like your dput is a single string. Usescan
to get the individual elements. – akrunxNew <- scan(text=x3, what=numeric(), quiet=TRUE);cut(xNew, breaks=c(-Inf,0,0.1,0.2, 0.3, 0.4, 0.5,1))
– akruntable
, as intable(cut(xNew, breaks=c(-Inf,0,0.1,0.2, 0.3, 0.4, 0.5,1)))
. – eipi10