Hello, I have 2 vectors of the same mode and the same contents but I still get FALSE. Any ideas ?> reference <- c(11, 14, 16, 5, 4, 2, 0, 15, 9, 0) > reference[1] 11 14 16 5 4 2 0 15 9 0> cpgDensity[1] 11 14 16 5 4 2 0 15 9 0> identical(cpgDensity, reference)[1] FALSE> mode(cpgDensity)[1] "numeric"> mode(reference)[1] "numeric"> cpgDensity == reference[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE Thanyou, Dario.
It might have to do with the storage.mode():> reference <- c(11, 14, 16, 5, 4, 2, 0, 15, 9, 0) > storage.mode(reference)[1] "double"> cpgDensity <- as.integer(reference) > storage.mode(cpgDensity)[1] "integer"> identical(reference,cpgDensity)[1] FALSE regards S?ren ________________________________________ Fra: r-help-bounces at r-project.org [r-help-bounces at r-project.org] På vegne af Dario Strbenac [D.Strbenac at garvan.org.au] Sendt: 1. marts 2010 07:24 Til: r-help at r-project.org Emne: [R] identical() mystery Hello, I have 2 vectors of the same mode and the same contents but I still get FALSE. Any ideas ?> reference <- c(11, 14, 16, 5, 4, 2, 0, 15, 9, 0) > reference[1] 11 14 16 5 4 2 0 15 9 0> cpgDensity[1] 11 14 16 5 4 2 0 15 9 0> identical(cpgDensity, reference)[1] FALSE> mode(cpgDensity)[1] "numeric"> mode(reference)[1] "numeric"> cpgDensity == reference[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE Thanyou, Dario. ______________________________________________ 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.
Dario Strbenac wrote:> Hello, > > I have 2 vectors of the same mode and the same contents but I still get FALSE. Any ideas ? > > >> reference <- c(11, 14, 16, 5, 4, 2, 0, 15, 9, 0) >> reference >> > [1] 11 14 16 5 4 2 0 15 9 0 > >> cpgDensity >> > [1] 11 14 16 5 4 2 0 15 9 0 > >> identical(cpgDensity, reference) >> > [1] FALSE > >> mode(cpgDensity) >> > [1] "numeric" > >> mode(reference) >> > [1] "numeric" >The typeof() function is more informative than mode(). str() might also give some information, e.g. if one of those objects has a class: > x <- 1:10 > y <- noquote(x) > y [1] 1 2 3 4 5 6 7 8 9 10 > x [1] 1 2 3 4 5 6 7 8 9 10 > typeof(x) [1] "integer" > typeof(x) [1] "integer" > identical(x,y) [1] FALSE > str(x) int [1:10] 1 2 3 4 5 6 7 8 9 10 > str(y) Class 'noquote' int [1:10] 1 2 3 4 5 6 7 8 9 10 Duncan Murdoch
If you use 'dput' you could provide a reproducible example, plus it would probably explain what was happening. On Mon, Mar 1, 2010 at 1:24 AM, Dario Strbenac <D.Strbenac at garvan.org.au> wrote:> Hello, > > I have 2 vectors of the same mode and the same contents but I still get FALSE. Any ideas ? > >> reference <- c(11, 14, 16, 5, 4, 2, ?0, 15, 9, 0) >> reference > ?[1] 11 14 16 ?5 ?4 ?2 ?0 15 ?9 ?0 >> cpgDensity > ?[1] 11 14 16 ?5 ?4 ?2 ?0 15 ?9 ?0 >> identical(cpgDensity, reference) > [1] FALSE >> mode(cpgDensity) > [1] "numeric" >> mode(reference) > [1] "numeric" >> cpgDensity == reference > ?[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE > > Thanyou, > ? ? ? ? Dario. > > ______________________________________________ > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?