Reputation: 3
I have two data.frames with a common column dates
that I construct by dropping time from original timestamps. I want to combine both data.frames and sort the result upon dates:
tbl <- rbind(tabf, tabi)
tblo <- tbl[order(dates), ]
The problem is that dates
has the nrow of the 2nd data.frame, and the result of sorting has that nrow, not nrow of combined data.frames.
Upvotes: 0
Views: 75
Reputation: 17432
You have another object named dates
in your environment if this isn't returning the message: error: object "dates" not found
. Specify that it's the column dates
inside of tbl
:
tblo <- tbl[order(tbl$dates),]
And don't be afraid to use spaces in your code! You'll run into problems with things like 2<-3
vs. 2 < -3
Upvotes: 2