Try this:

df <- data.frame(a=character(0),b=character(0), stringsAsFactors = FALSE)
df[1,] <- c('a', 'a')


On Wed, Oct 6, 2010 at 2:00 PM, N David Brown <hubd...@gmail.com> wrote:

> Does anyone know why a data frame created with empty character columns
> converts them to integer columns?
>
> > df<-data.frame(a=character(0),b=character(0))
> > df<-rbind(df,c("a","a"))
> > typeof(df[1,1])
> [1] "integer"
>
> AsIs doesn't help:
>
> > df<-data.frame(a=I(character(0)),b=I(character(0)))
> > df<-rbind(df,I(c("a","a")))
> > typeof(df[1,1])
> [1] "integer"
>
> Any suggestions on how to overcome this would be appreciated.
>
> Best wishes,
>
> David
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to