Hello there, would you please look into my codes? Here I have following:> set.seed(100) > samp <- sample(c(1,-1,0), 20, replace=T); samp[1] 1 1 -1 1 -1 -1 0 -1 -1 1 -1 0 1 -1 0 0 1 -1 -1 0 Here I want to calculate the length of each unique number for above vector. How can I do that? Thanks in advance [[alternative HTML version deleted]]
How about: table(samp) -- Robert Tirrell | rpt@stanford.edu | (607) 437-6532 Program in Biomedical Informatics | Butte Lab | Stanford University On Thu, Feb 10, 2011 at 13:54, Nipesh Bajaj <bajaj141003@gmail.com> wrote:> > set.seed(100) > > samp <- sample(c(1,-1,0), 20, replace=T); samp >[[alternative HTML version deleted]]
Hi, does table(samp) do what you want? Am 10.02.2011 22:54, schrieb Nipesh Bajaj:> Hello there, would you please look into my codes? Here I have following: > >> set.seed(100) >> samp <- sample(c(1,-1,0), 20, replace=T); samp > [1] 1 1 -1 1 -1 -1 0 -1 -1 1 -1 0 1 -1 0 0 1 -1 -1 0 > > Here I want to calculate the length of each unique number for above vector. > How can I do that? > > Thanks in advance > > [[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.-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/7410-58243 F ++49/40/7410-57790
?rle -- Clint Bowman INTERNET: clint at ecy.wa.gov Air Quality Modeler INTERNET: clint at math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600 FAX: (360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels: 300 Desmond Drive, Lacey, WA 98503-1274 On Fri, 11 Feb 2011, Nipesh Bajaj wrote:> Hello there, would you please look into my codes? Here I have following: > >> set.seed(100) >> samp <- sample(c(1,-1,0), 20, replace=T); samp > [1] 1 1 -1 1 -1 -1 0 -1 -1 1 -1 0 1 -1 0 0 1 -1 -1 0 > > Here I want to calculate the length of each unique number for above vector. > How can I do that? > > Thanks in advance > > [[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. >