Re: [R] bug?

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Fri 16 Dec 2005 - 04:45:45 EST

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@r-project.org>
> Author: R-core members, Saikat DebRoy <saikat@stat.wisc.edu>, Roger
> Bivand <Roger.Bivand@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@gmail.com
> Blog:http://sociology.yculblog.com
>
>

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

______________________________________________

R-help@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 Received on Fri Dec 16 05:10:45 2005

This archive was generated by hypermail 2.1.8 : Fri 16 Dec 2005 - 09:45:34 EST