context("Testing vb_flow_data content: this is not not shipped by `read_vp_flow_data()`")
pkg_data <-
system.file("extdata", "virtual-pollinators-flow.qs", package = "vbpflow")
vp_flow_data <-
qread(pkg_data)
# xpectr::gxs_selection("vp_flow_data")
## Testing 'vp_flow_data' ####
## Initially generated by xpectr
xpectr::set_test_seed(42)
# Testing class
expect_equal(
class(vp_flow_data),
c("tbl_df", "tbl", "data.frame"),
fixed = TRUE
)
# Testing column values
expect_equal(
xpectr::smpl(vp_flow_data[["reporter_countries"]], n = 30),
c(
"Belgium", "Bulgaria", "Canada", "Canada", "Estonia", "France",
"Hungary", "Israel", "Italy", "Italy", "Italy", "Kyrgyzstan",
"Latvia", "Mexico", "New Zealand", "Oman", "Portugal", "Russia",
"Singapore", "Sri Lanka", "Sweden", "Ukraine", "Ukraine", "United Arab Emirates",
"United Kingdom", "United Kingdom", "United Republic of Tanzania",
"United States of America", "United States of America", "United States of America"
),
fixed = TRUE
)
expect_equal(
xpectr::smpl(vp_flow_data[["partner_countries"]], n = 30),
c(
"Czech Republic", "Belgium", "Malaysia", "Thailand", "Finland",
"Japan", "Croatia", "Netherlands", "China", "Bosnia and Herzegovina",
"Estonia", "Kazakhstan", "Ireland", "Singapore", "Australia",
"Jordan", "Saudi Arabia", "Armenia", "Japan", "Mauritius", "Italy",
"Turkey", "Latvia", "Bangladesh", "Austria", "Ireland", "India",
"Uzbekistan", "Sri Lanka", "Bahrain"
),
fixed = TRUE
)
expect_equal(
xpectr::smpl(vp_flow_data[["year"]], n = 30),
c(
2010, 2004, 2007, 2011, 2002, 2008, 2011, 2007, 2003, 2005, 2009,
2007, 2015, 2001, 2004, 2004, 2015, 2008, 2001, 2001, 2003,
2008, 2011, 2014, 2013, 2014, 2002, 2001, 2012, 2015
),
tolerance = 1e-4
)
expect_equal(
xpectr::smpl(vp_flow_data[["vp_flow"]], n = 30),
c(
3.46403, 8.6929, 0.89591, 298.02233, 0.23644, 0.53436, 1.33311,
1589.43411, 1.86089, 436.36968, 205.43444, 211.3227, 0.22825,
7.44056, 42.06786, 0.37836, 336.59893, 17.28454, 42.71998, 213.41512,
10.36452, 0.10228, 106.80759, 0.02307, 41.41943, 47.55081, 30.07488,
8464.85804, 0.11613, 2.61789
),
tolerance = 1e-4
)
expect_equal(
xpectr::smpl(vp_flow_data[["reporter_long"]], n = 30),
c(
4.64065, 25.21553, -98.30777, -98.30777, 25.54249, -2.76173, 19.39559,
35.00445, 12.07001, 12.07001, 12.07001, 74.54166, 24.91236,
-102.52345, 171.48492, 56.09166, -8.50104, 96.68656, 103.81726,
80.70108, 16.74558, 31.38326, 31.38326, 54.30017, -2.86563,
-2.86563, 34.8131, -112.46167, -112.46167, -112.46167
),
tolerance = 1e-4
)
expect_equal(
xpectr::smpl(vp_flow_data[["reporter_lat"]], n = 30),
c(
50.63982, 42.7689, 61.36206, 61.36206, 58.67193, 42.17344, 47.16278,
31.4611, 42.79663, 42.79663, 42.79663, 41.46222, 56.85085, 23.94754,
-41.81114, 20.60515, 39.59551, 61.98052, 1.35876, 7.61267, 62.77967,
48.99657, 48.99657, 23.90528, 54.12387, 54.12387, -6.27565,
45.67955, 45.67955, 45.67955
),
tolerance = 1e-4
)
expect_equal(
xpectr::smpl(vp_flow_data[["partner_long"]], n = 30),
c(
15.3124, 4.64065, 109.69762, 101.00288, 26.27467, 138.0309, 16.40413,
5.28145, 103.81907, 17.76877, 25.54249, 67.29149, -8.13794,
103.81726, 134.491, 36.77136, 44.53686, 44.92993, 138.0309,
57.57121, 12.07001, 35.16895, 24.91236, 90.23813, 14.12648,
-8.13794, 79.61198, 63.14002, 80.70108, 50.54197
),
tolerance = 1e-4
)
expect_equal(
xpectr::smpl(vp_flow_data[["partner_lat"]], n = 30),
c(
49.73341, 50.63982, 3.78987, 15.11816, 64.49885, 37.5923, 45.08048,
52.10079, 36.56177, 44.1745, 58.67193, 48.15688, 53.17545, 1.35876,
-25.73289, 31.24579, 24.12246, 40.28953, 37.5923, -20.27769,
42.79663, 39.0616, 56.85085, 23.86731, 47.58549, 53.17545, 22.88578,
41.75554, 7.61267, 26.04205
),
tolerance = 1e-4
)
expect_equal(
xpectr::smpl(vp_flow_data[["reporter_hdi"]], n = 30),
c(
0.8964, 0.76613, 0.8976, 0.8976, 0.8356, 0.87527, 0.81293, 0.8806,
0.86293, 0.86293, 0.86293, 0.63167, 0.8072, 0.7386, 0.89507,
0.773, 0.81427, 0.7706, 0.8828, 0.733, 0.90613, 0.72333, 0.72333,
0.83293, 0.89533, 0.89533, 0.47053, 0.90607, 0.90607, 0.90607
),
tolerance = 1e-4
)
expect_equal(
xpectr::smpl(vp_flow_data[["partner_hdi"]], n = 30),
c(
0.8488, 0.8964, 0.7572, 0.70667, 0.8966, 0.88153, 0.79773, 0.90367,
0.679, 0.7152, 0.8356, 0.75687, 0.8994, 0.8828, 0.91773, 0.7268,
0.79653, 0.7112, 0.88153, 0.73427, 0.86293, 0.72027, 0.8072,
0.5308, 0.8758, 0.8994, 0.5626, 0.65147, 0.733, 0.79873
),
tolerance = 1e-4
)
# Testing column names
expect_equal(
names(vp_flow_data),
c(
"reporter_countries", "partner_countries", "year", "vp_flow",
"reporter_long", "reporter_lat", "partner_long", "partner_lat",
"reporter_hdi", "partner_hdi"
),
fixed = TRUE
)
# Testing column classes
expect_equal(
xpectr::element_classes(vp_flow_data),
c(
"character", "character", "numeric", "numeric", "numeric", "numeric",
"numeric", "numeric", "numeric", "numeric"
),
fixed = TRUE
)
# Testing column types
expect_equal(
xpectr::element_types(vp_flow_data),
c(
"character", "character", "double", "double", "double", "double",
"double", "double", "double", "double"
),
fixed = TRUE
)
# Testing dimensions
expect_equal(
dim(vp_flow_data),
c(556627L, 10L)
)
# Testing group keys
expect_equal(
colnames(dplyr::group_keys(vp_flow_data)),
character(0),
fixed = TRUE
)
## Finished testing 'vp_flow_data' ####
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.