Hi,
I hope someone can help here. I have been scratching my head for many hours, trying to find out how to merge two datasets that were created by different means. The initial miniMarket contains dates without discontinuities (weekends). This matrix was created using seq and has a character nature right now. > miniMarket [1] "2011-07-22" "2011-07-21" "2011-07-20" "2011-07-19" "2011-07-18" "2011-07-17" "2011-07-16" "2011-07-15" [9] "2011-07-14" "2011-07-13" "2011-07-12" "2011-07-11" "2011-07-10" "2011-07-09" "2011-07-08" "2011-07-07" [17] "2011-07-06" "2011-07-05" "2011-07-04" "2011-07-03" > typeof(miniMarket) [1] "character" The miniTechies dataframe was the resulted of a sql query and had a double nature (typeof), despite of being presented as a date > miniTechies Date AdjClose 67191 2011-07-22 41.09 67192 2011-07-21 40.93 67193 2011-07-20 40.46 67194 2011-07-19 40.67 67195 2011-07-18 39.90 > typeof(miniTechies$Date) [1] "double" I tried to compare them using this casting protocol and they seemed to match > as.double(as.Date(miniMarket[1])) [1] 15177 > as.double(miniTechies$Date[1]) [1] 15177 When I try to merge them by the dates, I fail > mergedM <- as.matrix(merge(miniMarket,miniTechies[,2],by=1,all=TRUE)) Warning message: In `[<-.factor`(`*tmp*`, ri, value = c(20L, 19L, 18L, 17L, 16L, : invalid factor level, NAs generated > mergedM x [1,] "2011-07-03" [2,] "2011-07-04" [3,] "2011-07-05" [4,] "2011-07-06" [5,] "2011-07-07" [6,] "2011-07-08" [7,] "2011-07-09" [8,] "2011-07-10" [9,] "2011-07-11" [10,] "2011-07-12" [11,] "2011-07-13" [12,] "2011-07-14" [13,] "2011-07-15" [14,] "2011-07-16" [15,] "2011-07-17" [16,] "2011-07-18" [17,] "2011-07-19" [18,] "2011-07-20" [19,] "2011-07-21" [20,] "2011-07-22" [21,] NA [22,] NA [23,] NA [24,] NA [25,] NA I didn't try to reproduce the means to create these datasets because I don't really understand how the Date is being represented in the miniTechies dataframe. Could anyone provide me some hint on how to merge these datasets. What I want is a dataset with all dates and not only dates for which there is data on the miniTechies dataframe. Thanks, Marco [[alternative HTML version deleted]] ______________________________________________ R-help@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.