Re: [R] Adding in Missing Data

From: Jeff08 <jefferyding_at_gmail.com>
Date: Mon, 07 Jun 2010 23:35:29 -0700 (PDT)

Thanks,

That thread talks about adding values to NA. However, the problem with my data is that the missing data points aren't even in the data.frame.

The method I think of is using a loop to check ID by ID, if the date column contains all elements of unique(Returns.names$date_), and if not add those rows in, setting totret equal to the previous date.

Problem is loops are so slow.

Jeff

"See this thread...

http://www.opensubscriber.com/message/r-help@.../6986471.html

specifically the last post by Gabor. "

"Sample Data.Frame format

Name is Returns.names

            X id ticker date_ adjClose totret RankStk 427225 427225 00174410 AHS 2001-11-13 21.66 100 1235
"id" uniquely defines a row

What I am trying to do is add missing data for each ID.

Important Information: Date is not continuous, the data points are for trading days, so weekends/certain holidays are off

x<-unique(Returns.names$date_) gives me the list of all the possible trading days.

For days that are missing, I would like to add a row for that date & the same totret as the previous day.

I cant think of an easy way to do this"

-- 
View this message in context: http://r.789695.n4.nabble.com/Adding-in-Missing-Data-tp2246825p2246921.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_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.
Received on Tue 08 Jun 2010 - 08:48:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Jun 2010 - 09:00:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive