[R] Matrix Manipulation
Alex Kim
alexkim205 at yahoo.com
Sat Jul 4 12:05:04 CEST 2015
Hi guys,
Suppose I have an extremely large data frame with 2 columns and .5 mil
rows. For example, the last 6 rows may look like this:
.
..
...
89 100
93 120
95 125
101 NA
115 NA
123 NA
124 NA
I would like to manipulate this data frame to output a data frame that
looks like:,
100 89, 93, 95
120 101, 115
125 123, 124
What would be the absolute quickest way to do this, given that there are
many rows? Currently I have this:
# m is the large two column data frame
end <- na.omit(m[,'V2']);
out <- data.frame(End=end,
Start=unname(sapply(split(m[,'V1'],findInterval(m[,'V1'],end))[as.character(0:c(length(end)-1))],paste,collapse='.')))
However this is taking a little bit too long.
Thank you for your help!
[[alternative HTML version deleted]]
More information about the R-help
mailing list