Grokbase Groups R r-help March 2002
FAQ

On Sat, Mar 16, 2002 at 11:58:51PM -0500, ggrothendieck at yifan.net wrote:
data(iris)
# iris3 is first 3 rows of iris
iris3 <- iris[1:3,]
# z compares row 1 to each row of iris3 and is correctly
computed
z <- c(F,F,F)
for(i in seq(z)) z[i] <- identical(iris3[1,],iris3[i,])
z
[1] TRUE FALSE FALSE

# this should do the same but is incorrect
apply(iris3,1,function(x)identical(x,iris3[1,]))
1 2 3
FALSE FALSE FALSE

What's wrong here?

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Could this be because 'apply' expects an 'array' as input (try 'help(apply)') ?



Hopin' it helps,





Laurent





--
--------------------------------------------------------------
Laurent Gautier CBS, Building 208, DTU
PhD. Student D-2800 Lyngby,Denmark
tel: +45 45 25 24 85 http://www.cbs.dtu.dk/laurent
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 7 | next ›
Discussion Overview
groupr-help @
categoriesr
postedMar 17, '02 at 4:58a
activeMar 18, '02 at 6:57p
posts7
users4
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase