Hi all, hope you having a nice day, I ahve this weird results with identical (probably I am not understanding correctly what it does ...) I have these two data frames and I issue :> identical(temp, temp1)[1] FALSE However, these data frames are Nx2 and when I issue:> identical(temp[,2], temp1[,2])[1] TRUE> identical(temp[,1], temp1[,1])[1] TRUE and the results from str> str(temp)`data.frame': 7072 obs. of 2 variables: $ pub_id : int 10000 1000 10001 10002 10003 10004 10005 10006 10007 $ faminc90: int -2 5998 19900 43000 35000 40000 56538 61000 36000 39105> str(temp1)`data.frame': 7072 obs. of 2 variables: $ pub_id: int 10000 1000 10001 10002 10003 10004 10005 10006 10007 10008 $ faminc: int -2 5998 19900 43000 35000 40000 56538 61000 36000 39105 The question is why are the objects different. How else can I tell what is the difference Thank You Jean
> d1 <- data.frame(x=1:3, y=4:6) > d2 <- data.frame(x=1:3, z=4:6) > d3 <- data.frame(x=1:3, y=4:6) > identical(d1, d2)[1] FALSE> identical(d1, d3)[1] TRUE Andy> From: Jean Eid > > Hi all, hope you having a nice day, > > I ahve this weird results with identical (probably I am not > understanding > correctly what it does ...) > > I have these two data frames and I issue : > > identical(temp, temp1) > [1] FALSE > > > However, these data frames are Nx2 and when I issue: > > identical(temp[,2], temp1[,2]) > [1] TRUE > > identical(temp[,1], temp1[,1]) > [1] TRUE > > and the results from str > > > > str(temp) > `data.frame': 7072 obs. of 2 variables: > $ pub_id : int 10000 1000 10001 10002 10003 10004 10005 10006 10007 > $ faminc90: int -2 5998 19900 43000 35000 40000 56538 61000 > 36000 39105 > > str(temp1) > `data.frame': 7072 obs. of 2 variables: > $ pub_id: int 10000 1000 10001 10002 10003 10004 10005 > 10006 10007 10008 > $ faminc: int -2 5998 19900 43000 35000 40000 56538 61000 > 36000 39105 > > The question is why are the objects different. How else can I > tell what is > the difference > > > Thank You > > Jean > > ______________________________________________ > 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 > > >
Jean Eid wrote:> Hi all, hope you having a nice day, > > I ahve this weird results with identical (probably I am not understanding > correctly what it does ...) > > I have these two data frames and I issue : > >>identical(temp, temp1) > > [1] FALSE > > > However, these data frames are Nx2 and when I issue: > >>identical(temp[,2], temp1[,2]) > > [1] TRUE > >>identical(temp[,1], temp1[,1]) > > [1] TRUE > > and the results from str > > > >>str(temp) > > `data.frame': 7072 obs. of 2 variables: > $ pub_id : int 10000 1000 10001 10002 10003 10004 10005 10006 10007 > $ faminc90: int -2 5998 19900 43000 35000 40000 56538 61000 36000 39105 > >>str(temp1) > > `data.frame': 7072 obs. of 2 variables: > $ pub_id: int 10000 1000 10001 10002 10003 10004 10005 10006 10007 10008 > $ faminc: int -2 5998 19900 43000 35000 40000 56538 61000 36000 39105 > > The question is why are the objects different. How else can I tell what is > the differenceThere could be a difference in the attributes (e.g. rownames of the dataframe, or names of one of the columns). One thing that might turn up the difference is to use dump() to write out the objects to a file, and use some text-based compare on those files. Duncan Murdoch
Jean Eid <jeaneid at chass.utoronto.ca> writes:> > str(temp) > `data.frame': 7072 obs. of 2 variables: > $ pub_id : int 10000 1000 10001 10002 10003 10004 10005 10006 10007 > $ faminc90: int -2 5998 19900 43000 35000 40000 56538 61000 36000 39105 > > str(temp1) > `data.frame': 7072 obs. of 2 variables: > $ pub_id: int 10000 1000 10001 10002 10003 10004 10005 10006 10007 10008 > $ faminc: int -2 5998 19900 43000 35000 40000 56538 61000 36000 39105 > > The question is why are the objects different. How else can I tell what is > the differenceJust look more carefully. The _names_ differ. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
On Fri, 20 May 2005, Jean Eid wrote:> Hi all, hope you having a nice day, > > I ahve this weird results with identical (probably I am not understanding > correctly what it does ...)Why should a data frame with colunns pub_id faminc90 a data frame with colunns pub_id faminc be considered identical()? Its description is The safe and reliable way to test two objects for being _exactly_ equal. and those are not equal in a critical way.> I have these two data frames and I issue : >> identical(temp, temp1) > [1] FALSE > > > However, these data frames are Nx2 and when I issue: >> identical(temp[,2], temp1[,2]) > [1] TRUE >> identical(temp[,1], temp1[,1]) > [1] TRUE > > and the results from str > > >> str(temp) > `data.frame': 7072 obs. of 2 variables: > $ pub_id : int 10000 1000 10001 10002 10003 10004 10005 10006 10007 > $ faminc90: int -2 5998 19900 43000 35000 40000 56538 61000 36000 39105 >> str(temp1) > `data.frame': 7072 obs. of 2 variables: > $ pub_id: int 10000 1000 10001 10002 10003 10004 10005 10006 10007 10008 > $ faminc: int -2 5998 19900 43000 35000 40000 56538 61000 36000 39105 > > The question is why are the objects different. How else can I tell what is > the difference-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595