SEEG-Oxford / movement

R package containing useful functions for the analysis of movement data in disease modelling and mapping
20 stars 16 forks source link

as.location_dataframe.dataframe should take fewer arguments #88

Closed goldingn closed 9 years ago

goldingn commented 9 years ago

Currently the user has to format their locations data into pairs of to-from locations, just so that as.location_dataframe.dataframe can flatten them back to one location per row.

Instead, as.location_dataframe.dataframe should take a correctly formatted dataframe with location IDs, populations and x and y coordinates, and just apply the class label. The docs should be updated accordingly

KathrinTessella commented 9 years ago

@goldingn : it looks like the R as.location_dataframe.dataframe also removed duplicated locations (origins); see the unit tests:

test_that("as.location_dataframe removes duplicate origins", {
    testdata <- data.frame(origin=c(1,1,2,3,4), pop_origin=c(10,10,20,30,40), lat_origin=c(-1,-1,0,1,2), long_origin=c(-5,-5,-4,-3,-2))
    expect_equal(nrow(as.location_dataframe(testdata)), 4)
})

Should this functionality stay in place?

goldingn commented 9 years ago

Yes please, preferably with a warning telling the usr which duplicates are removed.

KathrinTessella commented 9 years ago

Task completed after merging the changes