Hi R users, I have a dataframe, where there is a column 'time' represents time series but is not complete. How to expand the dataframe so this column will become complete, where other columns with the newly added rows have NA values? Thanks. df A B C time 10 5 3.3 1990-01-01 11 5 4 1990-02-07 12 4 3 1990-02-14 ... [[alternative HTML version deleted]]
Look at the zoo or data.table packages. -- Sent from my phone. Please excuse my brevity. On July 20, 2016 1:31:26 PM PDT, lily li <chocold12 at gmail.com> wrote:>Hi R users, > >I have a dataframe, where there is a column 'time' represents time >series >but is not complete. How to expand the dataframe so this column will >become >complete, where other columns with the newly added rows have NA values? >Thanks. > >df >A B C time >10 5 3.3 1990-01-01 >11 5 4 1990-02-07 >12 4 3 1990-02-14 >... > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org 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.
> On Jul 20, 2016, at 1:31 PM, lily li <chocold12 at gmail.com> wrote: > > Hi R users, > > I have a dataframe, where there is a column 'time' represents time series > but is not complete. How to expand the dataframe so this column will become > complete, where other columns with the newly added rows have NA values? > Thanks. > > df > A B C time > 10 5 3.3 1990-01-01 > 11 5 4 1990-02-07 > 12 4 3 1990-02-14 > ...Make a dataframe with a 'time' column using seq.Date and merge that dataframe with your df dataframe.> > [[alternative HTML version deleted]]Really .... isn't it time you learned how to send plain text. You've posted many questions on Rhelp. It's really not that difficult on gmail. I also have a gmail account and have had no difficulty finding instructions on how to do it.> > ______________________________________________ > R-help at r-project.org 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.David Winsemius Alameda, CA, USA
Yes, I tried to create a dataframe and merge it with the shortened dataframe. The resulting dataframe goes with the short one and truncates the complete date column, so it does not work. On Wed, Jul 20, 2016 at 6:38 PM, David Winsemius <dwinsemius at comcast.net> wrote:> > > On Jul 20, 2016, at 1:31 PM, lily li <chocold12 at gmail.com> wrote: > > > > Hi R users, > > > > I have a dataframe, where there is a column 'time' represents time series > > but is not complete. How to expand the dataframe so this column will > become > > complete, where other columns with the newly added rows have NA values? > > Thanks. > > > > df > > A B C time > > 10 5 3.3 1990-01-01 > > 11 5 4 1990-02-07 > > 12 4 3 1990-02-14 > > ... > > Make a dataframe with a 'time' column using seq.Date and merge that > dataframe with your df dataframe. > > > > > [[alternative HTML version deleted]] > > Really .... isn't it time you learned how to send plain text. You've > posted many questions on Rhelp. It's really not that difficult on gmail. I > also have a gmail account and have had no difficulty finding instructions > on how to do it. > > > > > ______________________________________________ > > R-help at r-project.org 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. > > David Winsemius > Alameda, CA, USA > >[[alternative HTML version deleted]]