R/gen_droites.R

Defines functions gen_droites

#' @import ggplot2
#' @import reshape2
#' @import tidyr
gen_droites <- function(points){

  points %>%
    left_join(points,by=c("destination" = "depart"),suffix=c("_depart","_destination")) %>%
    filter(depart != nrow(.)) %>%
    select(x_depart,y_depart,x_destination,y_destination) %>%
    mutate(group = seq_len(nrow(.)),
           group =as.factor(group)
    ) %>% melt(id="group") %>%
    separate(variable,into=c("coord","type"),sep="_") %>%
    dcast(group +type ~ coord,value.var = "value")

}

Try the rusk package in your browser

Any scripts or data that you put into this service are public.

rusk documentation built on May 1, 2019, 7:49 p.m.