You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# compare this to the dplyr method ============================================facility<- mutate(york, key=1) |>
rename(lat_facility=lat,
long_facility=long) |># create an ID for each row
mutate(facility_id=1:n()) |>
slice(1:100)
user<- mutate(york_crime, key=1) |>
rename(lat_user=lat,
long_user=long) |>
mutate(user_id=1:n()) |>
slice(1:100)
my_dist_dplyr<-user|>
left_join(facility,
by="key",
relationship="many-to-many") |>
mutate(distance= spherical_distance(lat1=lat_user,
long1=long_user,
lat2=lat_facility,
long2=long_facility)) |># drop key
select(-key) |>
select(user_id,
facility_id,
distance) |>
spread(key="facility_id",
value="distance",
sep="_") |># drop the ID column (for proper comparison)
select(-user_id) |>
as.matrix()
test_that("cpp distance matrix produces same numeric result as using dplyr",{
# I still need to make a method that gives the big matrix names
expect_equal(my_dist_cpp,my_dist_dplyr)
})
Which involve hand copying relevant code over - this is not a very robust way to test the dplyr/underlying methods in the software
The text was updated successfully, but these errors were encountered:
Currently there are tests like
Which involve hand copying relevant code over - this is not a very robust way to test the dplyr/underlying methods in the software
The text was updated successfully, but these errors were encountered: