[Rd] read.table with option dec=',' (PR#3532)
tplate at blackmesacapital.com
tplate at blackmesacapital.com
Tue Jul 22 18:27:01 MEST 2003
The problem appears to occur in the following expression from write.table():
x[num] <- lapply(x[num], function(z) gsub("\\.", ",",as.character(z)))
which gives an error when 'num' has length zero (for what it's worth, the
RHS evaluated to list()).
The error reported occurs when dec= is supplied to write.table() and the
table has no numeric columns.
Data frame column assignment does not appear able to handle the case where
the index has zero length, as in the following example
> x <- data.frame(x="1.5")
> num <- numeric(0)
> x[num] <- 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
> traceback()
2: "[<-.data.frame"(*tmp*, num, value = list())
1: "[<-"(*tmp*, num, value = list())
>
Possible fixes are to either guard the expression in write.table() with 'if
(length(num))' or to change "[<-.data.frame"() to handle this case.
(I note that S-plus 6.1 under Windows and R1.6.2 under Windows also
generate an error with this type of data frame assignment, so it does not
appear to be a new bug with data frame assignment, and is probably best
fixed with the simple change to write.table())
-- Tony Plate
At Tuesday 03:29 PM 7/22/2003 +0200, lucas at toulouse.inra.fr wrote:
>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"
>
>
>Best regards
>
>Antoine Lucas
>
>--
>Antoine Lucas
>INRA, Unité de biométrie et | Tel 05 61 28 53 34
>intelligence artificielle | Fax 05 61 28 53 35
>http://genopole.toulouse.inra.fr/~lucas
>
>______________________________________________
>R-devel at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list