[18667] in s-news-athena

home help back first fref pref prev next nref lref last post

[S] Bug in merge() with timeDate, Splus 5.1

daemon@ATHENA.MIT.EDU (Don MacQueen)
Mon Jul 19 12:55:10 1999

Message-Id: <v03130305b3b905511fbb@[128.115.153.6]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date: Mon, 19 Jul 1999 09:49:37 -0700
To: support@statsci.com
From: Don MacQueen <macq@llnl.gov>
Cc: s-news@wubios.wustl.edu


Here is an example of a bug in the merge() function.
It fails when one of the common variables is of class timeDate.

> version
Version 5.1 Release 1 for Sun SPARC, SunOS 5.5 : 1999


> source('showbug.sp')
source('showbug.sp')
> n <- 10
> date <- as(trunc(seq(3000, 4000, len = n)), "timeDate")
> x <- 1:10
> y <- 2 * x
> df1 <- data.frame(date = date, x = x)
> df2 <- data.frame(date = date, y = y)
> dfc1 <- df1
> dfc1$date <- format(dfc1$date)
> dfc2 <- df2
> dfc2$date <- format(dfc2$date)
> cat("\nMerging with dates as character strings\n")

Merging with dates as character strings
> print(class(dfc1$date))
[1] "character"
> print(class(dfc2$date))
[1] "character"
> foo <- merge(dfc1, dfc2)
> print(foo)
       date  x  y
 1   5-4-70  8 16
 2   6-5-69  5 10
 3   7-7-68  2  4
 4  1-13-70  7 14
 5  2-14-69  4  8
 6  3-18-68  1  2
 7  8-23-70  9 18
 8  9-24-69  6 12
 9 10-26-68  3  6
10 12-13-70 10 20
> cat("\nMerging with dates as timeDate variables\n")

Merging with dates as timeDate variables
> print(class(df1$date))
[1] "timeDate"
> print(class(df2$date))
[1] "timeDate"
> bah <- merge(df1, df2)
Problem in duplicated(x, incomparables): mode "list" not valid for matching
Use traceback() to see the call stack
>

-Don

--------------------------------
Don MacQueen
Environmental Protection Dept.
Lawrence Livermore National Lab
macq@llnl.gov    (925) 423-1062
--------------------------------


-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

home help back first fref pref prev next nref lref last post