[R] bug?

Thomas Lumley tlumley at u.washington.edu
Thu Dec 15 18:45:45 CET 2005


I suppose it is a bug in the documentation that it doesn't say it doesn't 
work with dates (or Surv objects, or ....)

It works with factors and numbers.

 	-thomas


On Thu, 15 Dec 2005, ronggui wrote:

>> library(foreign)
>> da<-read.dta(file.choose())
>> da
>    startdat starttim    enddate endtime days hoursmin secused
> 1 2005-01-11        2 2005-12-15   20.19   NA       NA       9
>
>> attributes(da)
> $datalabel
> [1] "Example of use of date and time functions"
>
> $time.stamp
> [1] "15 Ê®¶þÔ 2005 20"
>
> $names
> [1] "startdat" "starttim" "enddate"  "endtime"  "days"     "hoursmin" "secused"
>
> $formats
> [1] "%d"    "%5.2f" "%d"    "%5.2f" "%3.0f" "%5.2f" "%4.0f"
>
> $types
> [1] 253 255 253 255 252 255 252
>
>> write.foreign(da,"c:\\da.sps","da.txt","SPSS")
> then I try to run the da.sps,some errors come.I think the write.foreign function needs some improvement.
> It seems SPSS does not have such date/time data format as yyyy-mm-dd.
> Here is some information about the spss date/time format.
>
> "Date/Time. Valid values include dates of the general format dd-mm-yyyy, mm/dd/yyyy, dd.mm.yyyy, yyyy/mm/dd, hh:mm:ss, and a variety of other date and time formats. Months can be represented in digits, Roman numerals, or three-letter abbreviations, or they can be fully spelled out."
>
>
>
>> Warning # 1102
>> An invalid numeric field has been found.  The result has been set to the
>> system-missing value.
>
>> Command line: 7  Current case: 1  Current splitfile group: 1
>> Field contents: '2005-01-11'
>> Record number: 1  Starting column: 1  Record length: 37
>
>
>> Warning # 1102
>> An invalid numeric field has been found.  The result has been set to the
>> system-missing value.
>
>> Command line: 7  Current case: 1  Current splitfile group: 1
>> Field contents: '2005-12-15'
>> Record number: 1  Starting column: 14  Record length: 37
>
>
>> Warning # 1102
>> An invalid numeric field has been found.  The result has been set to the
>> system-missing value.
>
>> Command line: 7  Current case: 1  Current splitfile group: 1
>> Field contents: 'NA'
>> Record number: 1  Starting column: 31  Record length: 37
>
>
>> Warning # 1102
>> An invalid numeric field has been found.  The result has been set to the
>> system-missing value.
>
>> Command line: 7  Current case: 1  Current splitfile group: 1
>> Field contents: 'NA'
>> Record number: 1  Starting column: 34  Record length: 37
>
>> packageDescription("foreign")
> Package: foreign
> Priority: recommended
> Version: 0.8-11
> Date: 2005-12-08
> Title: Read Data Stored by Minitab, S, SAS, SPSS, Stata, Systat, dBase,
>        ...
> Depends: R (>= 2.2.0)
> Imports: stats, methods
> Maintainer: R-core <R-core at r-project.org>
> Author: R-core members, Saikat DebRoy <saikat at stat.wisc.edu>, Roger
>        Bivand <Roger.Bivand at nhh.no> and others: see COPYRIGHTS file in
>        the sources.
> Description: Functions for reading and writing data stored by
>        statistical packages such as Minitab, S, SAS, SPSS, Stata,
>        Systat, ..., and for reading and writing .dbf (dBase) files.
> License: GPL version 2 or later
> Packaged: Fri Dec 9 14:46:20 2005; ripley
> Built: R 2.2.0; i386-pc-mingw32; 2005-12-10 14:23:19; windows
>
>
>
>
> 2005-12-15
>
> ------
> Deparment of Sociology
> Fudan University
>
> My new mail addres is ronggui.huang at gmail.com
> Blog:http://sociology.yculblog.com
>
>

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle


More information about the R-help mailing list