r - Manipulate a data frame - amending the last row name -


i'm building set of coordinates plot on ggmap code below.

coords <- rbind(as.matrix(rte[,7:8]),as.matrix(rte[nrow(rte),9:10])) %>%      as.data.frame() 

this generates data below. issue have end point (last point/row).

i'm getting error there duplicate value (9.3) - need rename +0.1 of previous value i.e. 9.4.

structure(list(startlon = c(-2.8812933, -2.8836377, -2.8846959,  -2.883528, -2.8867415, -2.8878325, -2.8880098, -2.8895748, -2.8935501,  -2.8971835, -2.8987187, -2.8989829, -2.8986408, -2.8989038, -2.897305,  -2.8939165, -2.8932886, -2.8932332, -2.8932886, -2.891303, -2.8904392,  -2.8896841, -2.8900902, -2.8896841, -2.8916631, -2.8908963, -2.889908,  -2.889908, -2.8897949, -2.8877892, -2.8879832), startlat = c(53.1935042,  53.1934807, 53.1962441, 53.1968895, 53.1943495, 53.1938296, 53.1936907,  53.1943944, 53.1942666, 53.1939625, 53.1931411, 53.1930795, 53.1928816,  53.1926769, 53.1893671, 53.1898796, 53.1899857, 53.1899088, 53.1899857,  53.1903599, 53.1905145, 53.1906626, 53.1912708, 53.1906626, 53.1902482,  53.1884563, 53.1868239, 53.1868239, 53.1866933, 53.1877751, 53.1884169 )), .names = c("startlon", "startlat"), row.names = c("1.1",  "1.2", "1.3", "2.1", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7",  "3.1", "3.2", "3.3", "3.4", "3.5", "4.1", "4.2", "5.1", "5.2",  "5.3", "6.1", "6.2", "7.1", "7.2", "7.3", "7.4", "8", "9.1",  "9.2", "9.3", "9.3"), class = "data.frame") 

what's best way of doing this?

here generic solution:

mx1 <- matrix(1:10, 5, dimnames=list(c("1", "1", "1", "2", "2"), null)) mx1 %>% `row.names<-`(make.unique(row.names(.))) %>% as.data.frame 

produces:

    v1 v2 1    1  6 1.1  2  7 1.2  3  8 2    4  9 2.1  5 10 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -