On Apr 8, 2010, at 9:47 AM, Jun Shen wrote:
Dear David, Erik and Charles,
Thank you for your input. Both mapply() and which() can do the job.
Just one
exception. If there is a missing value as NA in the data frame "a"
and a
data point (either numerical or character) in the corresponding
position of
"b", then mapply() only returns NA for that position rather than
"FALSE",
and which() cannot pick up that position either. Thanks again.
You seem to have changed the programming challenge from identification
to replicating identical(). If so then you can get closer with
wrapping isTRUE(all() around the mapply("==" , attributes( ...), ...)
step, and wrap the "==" call in isTRUE(all(.))
> isTRUE(all(mapply("==", df1, df2)) )
[1] FALSE since all(c(NA, TRUE, TRUE)) == NA and isTRUE(NA) == FALSE
--
David.
Jun
On Wed, Apr 7, 2010 at 10:46 PM, Charles C. Berry <cbe...@tajo.ucsd.edu
>wrote:
On Wed, 7 Apr 2010, Jun Shen wrote:
Dear all,
I understand identical (a,b) will tell me if a and b are exactly
the same
or
not. But what if they are different, is there anyway to tell which
element(s) are different? Thanks.
which( a != b, arr.ind = TRUE)
HTH,
Chuck
Jun
[[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.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive
Medicine
E mailto:cbe...@tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego
92093-0901
[[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.
David Winsemius, MD
West Hartford, CT
______________________________________________
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.