Re: [R] empty data frame and POSIXct data types

2021-06-24 Thread Rui Barradas
iugno 2021 15.46 A: r-help@r-project.org; Stefano Sofia; r-help mailing list Oggetto: Re: [R] empty data frame and POSIXct data types 1) It _is_ a vector. Why do you think it is not a vector? 2) Your data frame has one row, with an NA in the date_POSIX column. You cannot fit a vector of length 2 a

Re: [R] empty data frame and POSIXct data types

2021-06-24 Thread Stefano Sofia
w...@dcn.davis.ca.us] Inviato: giovedì 24 giugno 2021 15.46 A: r-help@r-project.org; Stefano Sofia; r-help mailing list Oggetto: Re: [R] empty data frame and POSIXct data types 1) It _is_ a vector. Why do you think it is not a vector? 2) Your data frame has one row, with an NA in the date_POSI

Re: [R] empty data frame and POSIXct data types

2021-06-24 Thread Olivier Crouzet
Hi Stefano, my guess is that you're expecting data recycling to apply but your data frame is only one row long... therefore you can't insert a 2-row vector into a 1-row vector. Recycling won't help. You should specify the number of rows that will be required in your data frame using (e.g) rep().

Re: [R] empty data frame and POSIXct data types

2021-06-24 Thread Jeff Newmiller
1) It _is_ a vector. Why do you think it is not a vector? 2) Your data frame has one row, with an NA in the date_POSIX column. You cannot fit a vector of length 2 as a column into a data frame with only 1 row. What are you trying to do? Do you really want to end up with a 2-row data frame or a

Re: [R] Empty Data Frame

2011-04-27 Thread Hadley Wickham
On Wed, Apr 27, 2011 at 4:58 AM, Dennis Murphy wrote: > Hi: > > You could try something like > > df <- data.frame( expand.grid( Week = 1:52, Year = 2002:2011 )) expand.grid already returns a data frame... You might want KEEP.OUT.ATTRS = F though. Even it feels like you are yelling at R. Hadley

Re: [R] Empty Data Frame

2011-04-27 Thread Dennis Murphy
Hi: You could try something like df <- data.frame( expand.grid( Week = 1:52, Year = 2002:2011 )) dim(df) head(df) The first variable changes faster than the second. HTH, Dennis On Wed, Apr 27, 2011 at 1:03 AM, Santosh Srinivas wrote: > Dear Group, > > Is there a more efficient way to create a

Re: [R] Empty data frame does not maintain column type

2010-10-06 Thread N David Brown
Thanks to all three of you for responding. Brilliant answer there, David - using the options() function as exemplified to set stringsAsFactors=FALSE universally solved the issue. Much appreciated, guys. On 6 October 2010 18:27, David Winsemius wrote: > > On Oct 6, 2010, at 1:00 PM, N David Brow

Re: [R] Empty data frame does not maintain column type

2010-10-06 Thread David Winsemius
On Oct 6, 2010, at 1:00 PM, N David Brown wrote: Does anyone know why a data frame created with empty character columns converts them to integer columns? Quick answer: it's the strngsAsFactors demon but you have invoked that demon twice, Once with data.frame and the second rime with rbind.

Re: [R] Empty data frame does not maintain column type

2010-10-06 Thread Jeffrey Spies
This should do it: df <- data.frame(a=character(0), b=character(0), stringsAsFactors=F) because: typeof(factor(0)) is "integer" while: typeof(character(0)) is "character". Cheers, Jeff. On Wed, Oct 6, 2010 at 1:00 PM, N David Brown wrote: > Does anyone know why a data frame created with

Re: [R] Empty data frame does not maintain column type

2010-10-06 Thread Henrique Dallazuanna
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 wrote: > Does anyone know why a data frame created with empty character columns > converts them to integer columns? > > > df<-data.frame(a=cha

Re: [R] Empty data frame

2008-02-07 Thread Paul Hiemstra
Jarosław Jasiewicz wrote: > Hi > Sorry for banal question > How to create empty data frame with for example 30 variables without > typying: data.frame(x=1,y=1) > Jarek > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinf

Re: [R] Empty data frame

2008-02-07 Thread Gabor Grothendieck
Try this assuming the first 15 are double and the next 15 are factor: as.data.frame(rep(list(num = double(0), char = character(0)), each = 15)) 2008/2/7 Jarosław Jasiewicz <[EMAIL PROTECTED]>: > Gabor Grothendieck pisze: > > >> data.frame(a = character(0), b = double(0)) > >> > > [1] a b > > <0

Re: [R] Empty data frame

2008-02-07 Thread Jarosław Jasiewicz
Gabor Grothendieck pisze: >> data.frame(a = character(0), b = double(0)) >> > [1] a b > <0 rows> (or 0-length row.names) > > > On Feb 7, 2008 5:48 AM, Jarosław Jasiewicz <[EMAIL PROTECTED]> wrote: > >> Hi >> Sorry for banal question >> How to create empty data frame with for example 30 var

Re: [R] Empty data frame

2008-02-07 Thread Henrique Dallazuanna
Try this: do.call(data.frame, as.list(paste("var", 1:30, sep="."))) On 07/02/2008, Jarosław Jasiewicz <[EMAIL PROTECTED]> wrote: > Hi > Sorry for banal question > How to create empty data frame with for example 30 variables without > typying: data.frame(x=1,y=1) > Jarek > > _

Re: [R] Empty data frame

2008-02-07 Thread Gabor Grothendieck
> data.frame(a = character(0), b = double(0)) [1] a b <0 rows> (or 0-length row.names) On Feb 7, 2008 5:48 AM, Jarosław Jasiewicz <[EMAIL PROTECTED]> wrote: > Hi > Sorry for banal question > How to create empty data frame with for example 30 variables without > typying: data.frame(x=1,y=1) >