[Rd] inconsistent behaviour of c(...)

Peter Langfelder peter@|@ng|e|der @end|ng |rom gm@||@com
Fri Jul 19 09:19:39 CEST 2019


I think your character vector got converted to a factor. See ?options,
section stringsAsFactors:

     ‘stringsAsFactors’: The default setting for arguments of
          ‘data.frame’ and ‘read.table’.
The default is TRUE, so strings get converted to factors when building
data frames.

Set options(stringsAsFactors=FALSE) and try again.

Peter

On Fri, Jul 19, 2019 at 12:15 AM Michael Meyer via R-devel
<r-devel using r-project.org> wrote:
>
>
>
> Greetings,
>
> Running R 3.5.0 under Windows 7
>
> typeof(c(1,"2")) yields "character" as expected. But in
>
> d.f <- data.frame(C=c(1,"2"))
>
> typeof(d.f$C) yields "integer".
>
> Is this a bug?
>
> Michael Meyer
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list