Dear Rxperts, is there way to identify intervals from continuous data (having some kind of a pattern) and then pick the value of most frequency? a1 <- round(rnorm(50,mean=0,0.1),2) a2 <- round(rnorm(50,mean=1,0.2),1) a3 <- round(rnorm(50,mean=5,1),0) a4 <- round(rnorm(50,mean=14,4),0) a5 <- round(rnorm(50,mean=30,8),0) b1 <- rbind(a1,a2,a3,a4,a5) hist(b1,brea=100) # shows intervals and values with varying frequency. unlike the mean values of a1.... a5 above, I don't know the nominal values. I would like an algorithm to identify intervals and pick the value with most frequency. I tried "cut", "split" and was not successful. Any suggestions/tips are highly welcome. Thanks and regards, Santosh [[alternative HTML version deleted]]
Hello, I'm not sure I ubderstand but, h <- hist(b1,brea=100) which.max(h$counts) # max frequency findInterval(b1, h$breaks) Hope this helps, Rui Barradas Em 27-11-2012 14:59, Santosh escreveu:> Dear Rxperts, > > is there way to identify intervals from continuous data (having some kind > of a pattern) and then pick the value of most frequency? > > > a1 <- round(rnorm(50,mean=0,0.1),2) > a2 <- round(rnorm(50,mean=1,0.2),1) > a3 <- round(rnorm(50,mean=5,1),0) > a4 <- round(rnorm(50,mean=14,4),0) > a5 <- round(rnorm(50,mean=30,8),0) > > b1 <- rbind(a1,a2,a3,a4,a5) > > hist(b1,brea=100) # shows intervals and values with varying frequency. > > unlike the mean values of a1.... a5 above, I don't know the nominal values. > I would like an algorithm to identify intervals and pick the value with > most frequency. > > I tried "cut", "split" and was not successful. > Any suggestions/tips are highly welcome. > Thanks and regards, > Santosh > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
You might find the binning function in the sm package helpful here. --Mark Lamias ________________________________ From: Santosh <santosh2005@gmail.com> To: r-help <r-help@r-project.org> Sent: Tuesday, November 27, 2012 9:59 AM Subject: [R] binning by frequency Dear Rxperts, is there way to identify intervals from continuous data (having some kind of a pattern) and then pick the value of most frequency? a1 <- round(rnorm(50,mean=0,0.1),2) a2 <- round(rnorm(50,mean=1,0.2),1) a3 <- round(rnorm(50,mean=5,1),0) a4 <- round(rnorm(50,mean=14,4),0) a5 <- round(rnorm(50,mean=30,8),0) b1 <- rbind(a1,a2,a3,a4,a5) hist(b1,brea=100) # shows intervals and values with varying frequency. unlike the mean values of a1.... a5 above, I don't know the nominal values. I would like an algorithm to identify intervals and pick the value with most frequency. I tried "cut", "split" and was not successful. Any suggestions/tips are highly welcome. Thanks and regards, Santosh [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]