Hi, Sorry for the question, I know it should be basic knowledge but I'm struggling for two hours now. How do I select only the first entry of each list member and ignore the rest? So for> $"121_at"> -113691170> $"1255_g_at"> 42231151> $"1316_at"> 35472685 35472588> $"1320_at"> -88003869I only want to select -113691170, 42231151, 35472685 and -88003869 .? Regards Benjamin -- Benjamin Otto Universitaetsklinikum Eppendorf Hamburg Institut fuer Klinische Chemie Martinistrasse 52 20246 Hamburg [[alternative HTML version deleted]]
Is this what you want?> x <- list(a=1:3, b=30:34, c=40:35) > x$a [1] 1 2 3 $b [1] 30 31 32 33 34 $c [1] 40 39 38 37 36 35> lapply(x,'[', 1)$a [1] 1 $b [1] 30 $c [1] 40> unlist(lapply(x,'[', 1))a b c 1 30 40>On 9/29/06, Benjamin Otto <b.otto at uke.uni-hamburg.de> wrote:> Hi, > > > > Sorry for the question, I know it should be basic knowledge but I'm > struggling for two hours now. > > > > How do I select only the first entry of each list member and ignore the > rest? > > > > So for > > > > > $"121_at" > > > -113691170 > > > > > $"1255_g_at" > > > 42231151 > > > > > $"1316_at" > > > 35472685 35472588 > > > > > $"1320_at" > > > -88003869 > > > > I only want to select > > > > -113691170, 42231151, 35472685 and -88003869 .? > > > > Regards > > Benjamin > > -- > Benjamin Otto > Universitaetsklinikum Eppendorf Hamburg > Institut fuer Klinische Chemie > Martinistrasse 52 > 20246 Hamburg > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
You need one of the apply family of functions. ?sapply> tmp <- list(a=1:2, b=3:5, c=5, dd=numeric(0), e=1:8) > sapply(tmp, function(x) x[1])a b c dd e 1 3 5 NA 1
Does this do what you want? > x <- list(1,2,3:7,8,9:10) > sapply(x, function(xx) xx[1]) [1] 1 2 3 8 9 > -- Tony Plate Benjamin Otto wrote:> Hi, > > > > Sorry for the question, I know it should be basic knowledge but I'm > struggling for two hours now. > > > > How do I select only the first entry of each list member and ignore the > rest? > > > > So for > > > > >>$"121_at" > > >>-113691170 > > > > > >>$"1255_g_at" > > >>42231151 > > > > > >>$"1316_at" > > >>35472685 35472588 > > > > > >>$"1320_at" > > >>-88003869 > > > > > I only want to select > > > > -113691170, 42231151, 35472685 and -88003869 .? > > > > Regards > > Benjamin > > -- > Benjamin Otto > Universitaetsklinikum Eppendorf Hamburg > Institut fuer Klinische Chemie > Martinistrasse 52 > 20246 Hamburg > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >
Is there any heteroskedasticity test in the package? Something that would flag a sample like x <- c(rnorm(1000), rnorm(1000, 0, 1.2)) Alberto Monteiro
On Fri, 29 Sep 2006, Alberto Monteiro wrote:> Is there any heteroskedasticity test in the package? Something > that would flag a sample like > > x <- c(rnorm(1000), rnorm(1000, 0, 1.2))The package lmtest contains several tests for heteroskedasticity, in particular the Breusch-Pagan test (and also the Goldfeld-Quandt test for known change point). Furthermore, some of the structural change tests in strucchange can be used to test for non-constant variances, e.g, the Nyblom-Hansen test. Z> Alberto Monteiro > > ______________________________________________ > R-help at stat.math.ethz.ch 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 may also try to levene test. Once again i think it is for a known change point. http://finzi.psych.upenn.edu/R/library/car/html/levene.test.html On 9/30/06, Achim Zeileis <Achim.Zeileis at wu-wien.ac.at> wrote:> On Fri, 29 Sep 2006, Alberto Monteiro wrote: > > > Is there any heteroskedasticity test in the package? Something > > that would flag a sample like > > > > x <- c(rnorm(1000), rnorm(1000, 0, 1.2)) > > The package lmtest contains several tests for heteroskedasticity, in > particular the Breusch-Pagan test (and also the Goldfeld-Quandt test for > known change point). Furthermore, some of the structural change tests in > strucchange can be used to test for non-constant variances, e.g, the > Nyblom-Hansen test. > Z > > > Alberto Monteiro > > > > ______________________________________________ > > R-help at stat.math.ethz.ch 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. > > > > > > ______________________________________________ > R-help at stat.math.ethz.ch 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. >-- Ritwik Sinha Graduate Student Epidemiology and Biostatistics Case Western Reserve University ritwik.sinha at gmail.com | +12163682366 | http://darwin.cwru.edu/~rsinha