[Rd] read.table with option dec=',' (PR#3532)
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Tue Jul 22 17:58:51 MEST 2003
lucas at toulouse.inra.fr writes:
> Full_Name: Antoine Lucas
> Version: 1.7.0 (2003-04-16)
> OS: Linux
> Submission from: (NULL) (193.51.197.253)
>
>
> I have a problem using read.table:
????
> If in a dataframe, we have a string containing a dot, write.table
> will not write any file while using option "dec=','".
>
> Example
>
> > m <- "1.5"
> > write.table(m,dec=',')
> Error in if (n%%nrowv == 0) value <- value[rep(1:nrowv, length = n), , :
> missing value where TRUE/FALSE needed
> In addition: Warning messages:
> 1: no finite arguments to min; returning Inf
> 2: no finite arguments to max; returning -Inf
>
> Whereas the contrary write the table:
> > m <- "1,5"
> > write.table(m,dec='.')
> "x"
> "1" "1,5"
Wrong diagnosis:
> m <- data.frame(1.5,"1.5")
> write.table(m,dec=',')
"X1.5" "X.1.5."
"1" 1,5 "1.5"
> m <- data.frame("a","b")
> write.table(m,dec=',')
Error in if (n%%nrowv == 0) value <- value[rep(1:nrowv, length = n), ,
:
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: no finite arguments to min; returning Inf
2: no finite arguments to max; returning -Inf
The problem is unrelated to whether or not there are strings with dots
in. The real reason is that you have no numeric columns. If you don't
have any numeric colums, then you can just leave out the dec argument
since it is not supposed to do anything with character columns. The
code in write.table is conditional on dec != "."; that's why the thing
is unsymmetric in dot and comma.
We should probably treat these borderline cases more gracefully
though. Possibly even at the data frame indexing level: it boils down
to
> x[numeric(0)] <- list()
Error in if (n%%nrowv == 0) value <- value[rep(1:nrowv, length = n), ,
:
missing value where TRUE/FALSE needed
In addition: Warning messages:
1: no finite arguments to min; returning Inf
2: no finite arguments to max; returning -Inf
and I suppose we might just treat this as a no-op.
--
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
More information about the R-devel
mailing list