Getting unexpected extra rows (continued)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting unexpected extra rows (continued)

PaulJr
Hello everyone,

So I have  created a date sequence with the following code:

>x<-seq(as.Date("1985-10-01"), as.Date(Sys.Date()), "months")

>x["Transits"]<-NA

>xFrame<-data.frame(x)


> str(xFrame)

'data.frame':   379 obs. of  1 variable:
 $ x: Date, format: "1985-10-01" "1985-11-01" "1985-12-01" "1986-01-01" ...

How can I make this a dataframe with two columns (date and transits) and
378 observations with value NA?

Any help will be greatly appreciated,

Regards,

Paul

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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 | Threaded
Open this post in threaded view
|

Re: Getting unexpected extra rows (continued)

Nordlund, Dan (DSHS/RDA)
This is pretty basic stuff which suggests you need to (re)read the intro to R that comes with your R installation.  One approach would be :

xFrame <- data.frame(x=x, Transits=NA)


hope this is helpful,

Dan

Daniel Nordlund, PhD
Research and Data Analysis Division
Services & Enterprise Support Administration
Washington State Department of Social and Health Services


> -----Original Message-----
> From: R-help [mailto:[hidden email]] On Behalf Of Paul
> Bernal
> Sent: Thursday, March 30, 2017 2:31 PM
> To: [hidden email]
> Subject: [R] Getting unexpected extra rows (continued)
>
> Hello everyone,
>
> So I have  created a date sequence with the following code:
>
> >x<-seq(as.Date("1985-10-01"), as.Date(Sys.Date()), "months")
>
> >x["Transits"]<-NA
>
> >xFrame<-data.frame(x)
>
>
> > str(xFrame)
>
> 'data.frame':   379 obs. of  1 variable:
>  $ x: Date, format: "1985-10-01" "1985-11-01" "1985-12-01" "1986-01-01" ...
>
> How can I make this a dataframe with two columns (date and transits) and
> 378 observations with value NA?
>
> Any help will be greatly appreciated,
>
> Regards,
>
> Paul
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.