Sandeep.Sampara at ril.com
2013-Oct-18 11:37 UTC
[R] Need to merge multiple data frames with time stamp
Hi, I'm trying to combine 15 different data frames but all have time field as common. But the thing is time intervals are different (like min's and sec's). So I have to check the common time from all the 15 data frames and merge it to a single data frame and then export it to excel or csv. I tried with below query but it's not giving exact output. It's almost 5 year of data, but its giving output for 3months only. Please help with your query to get my output. a <- merge(MA2DHPA,MA2DHPB,by="IP_Trend_Time") b <- merge(MA2UCPA,MA2UCPB,by="IP_Trend_Time") c <- merge(MA2DCPA,MA2DCPB,by="IP_Trend_Time") d <- merge(MA2DHTA,MA2DHTB,by="IP_Trend_Time") e <- merge(MA2UCTA,MA2UCTB,by="IP_Trend_Time") f <- merge(MA2DCTA,MA2DCTB,by="IP_Trend_Time") g <- merge(MA2CP,MA2CPS,by="IP_Trend_Time") h <- MA2AP x <- merge(a,b,by="IP_Trend_Time") y <- merge(c,d,by="IP_Trend_Time") z <- merge(e,f,by="IP_Trend_Time") w <- merge(g,h,by="IP_Trend_Time") x1 <- merge(x,y,by="IP_Trend_Time") y1 <- merge(z,w,by="IP_Trend_Time") MA2 <- merge(x1,y1,by="IP_Trend_Time") Regards, Sandeep S|IT&C, Reliance Industries Limited (E&P) | Onshore Terminal | Gadimoga * +91 884 2977066 / 9908130749 Please consider the environment before printing this email. -------------- next part -------------- "Confidentiality Warning: This message and any attachments are intended only for the use of the intended recipient(s). are confidential and may be privileged. If you are not the intended recipient. you are hereby notified that any review. re-transmission. conversion to hard copy. copying. circulation or other use of this message and any attachments is strictly prohibited. If you are not the intended recipient. please notify the sender immediately by return email. and delete this message and any attachments from your system. Virus Warning: Although the company has taken reasonable precautions to ensure no viruses are present in this email. The company cannot accept responsibility for any loss or damage arising from the use of this email or attachment."
You at least need to provide a subset of what the data looks likes. Since you are merging on 'time', if there are not the same times in each set, then you will have missing values. For example, in the merges that you are doing, have you looked at the size of the resulting object compared to the two that you are merging? That would give you and idea as to how much you might be missing. Also is your time as POSIXct? If so, are there fractional seconds in the data? If you had provided some data, some of these questions would be answered. Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Fri, Oct 18, 2013 at 7:37 AM, <Sandeep.Sampara at ril.com> wrote:> Hi, > > > > I'm trying to combine 15 different data frames but all have time field as > common. But the thing is time intervals are different (like min's and > sec's). > > So I have to check the common time from all the 15 data frames and merge it > to a single data frame and then export it to excel or csv. > > I tried with below query but it's not giving exact output. It's almost 5 > year of data, but its giving output for 3months only. > > Please help with your query to get my output. > > > > a <- merge(MA2DHPA,MA2DHPB,by="IP_Trend_Time") > > b <- merge(MA2UCPA,MA2UCPB,by="IP_Trend_Time") > > c <- merge(MA2DCPA,MA2DCPB,by="IP_Trend_Time") > > d <- merge(MA2DHTA,MA2DHTB,by="IP_Trend_Time") > > e <- merge(MA2UCTA,MA2UCTB,by="IP_Trend_Time") > > f <- merge(MA2DCTA,MA2DCTB,by="IP_Trend_Time") > > g <- merge(MA2CP,MA2CPS,by="IP_Trend_Time") > > h <- MA2AP > > > > x <- merge(a,b,by="IP_Trend_Time") > > y <- merge(c,d,by="IP_Trend_Time") > > z <- merge(e,f,by="IP_Trend_Time") > > w <- merge(g,h,by="IP_Trend_Time") > > > > x1 <- merge(x,y,by="IP_Trend_Time") > > y1 <- merge(z,w,by="IP_Trend_Time") > > > > MA2 <- merge(x1,y1,by="IP_Trend_Time") > > > > Regards, > > Sandeep S|IT&C, > Reliance Industries Limited (E&P) | Onshore Terminal | Gadimoga > * +91 884 2977066 / 9908130749 > > > > Please consider the environment before printing this email. > > > > > "Confidentiality Warning: This message and any attachments are intended only for the use of the intended recipient(s). > are confidential and may be privileged. If you are not the intended recipient. you are hereby notified that any > review. re-transmission. conversion to hard copy. copying. circulation or other use of this message and any attachments is > strictly prohibited. If you are not the intended recipient. please notify the sender immediately by return email. > and delete this message and any attachments from your system. > > Virus Warning: Although the company has taken reasonable precautions to ensure no viruses are present in this email. > The company cannot accept responsibility for any loss or damage arising from the use of this email or attachment." > ______________________________________________ > 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. >
Kevin Schiesser
2013-Oct-18 17:52 UTC
[R] Need to merge multiple data frames with time stamp
Merge has an option 'all', when set to 'TRUE' merge will return a data.frame of every row in both data.frames. You can also specify all.x, and all.y. I do not suggest taking this path. Rather, standardize time columns for all 15 data.frames with as.POSIXct()/as.POSIXlt() depending on the input time format. -Kevin On 10/18/13 04:37 , "Sandeep.Sampara at ril.com" <Sandeep.Sampara at ril.com> wrote: Hi, I'm trying to combine 15 different data frames but all have time field as common. But the thing is time intervals are different (like min's and sec's). So I have to check the common time from all the 15 data frames and merge it to a single data frame and then export it to excel or csv. I tried with below query but it's not giving exact output. It's almost 5 year of data, but its giving output for 3months only. Please help with your query to get my output. a <- merge(MA2DHPA,MA2DHPB,by="IP_Trend_Time") b <- merge(MA2UCPA,MA2UCPB,by="IP_Trend_Time") c <- merge(MA2DCPA,MA2DCPB,by="IP_Trend_Time") d <- merge(MA2DHTA,MA2DHTB,by="IP_Trend_Time") e <- merge(MA2UCTA,MA2UCTB,by="IP_Trend_Time") f <- merge(MA2DCTA,MA2DCTB,by="IP_Trend_Time") g <- merge(MA2CP,MA2CPS,by="IP_Trend_Time") h <- MA2AP x <- merge(a,b,by="IP_Trend_Time") y <- merge(c,d,by="IP_Trend_Time") z <- merge(e,f,by="IP_Trend_Time") w <- merge(g,h,by="IP_Trend_Time") x1 <- merge(x,y,by="IP_Trend_Time") y1 <- merge(z,w,by="IP_Trend_Time") MA2 <- merge(x1,y1,by="IP_Trend_Time") Regards, Sandeep S|IT&C, Reliance Industries Limited (E&P) | Onshore Terminal | Gadimoga * +91 884 2977066 / 9908130749 Please consider the environment before printing this email. --------------------------------------------------------------------------------- The information transmitted in this email is intended on...{{dropped:9}}