Making sense of an interaction overlaying city shapefiles and country shapefiles from maps.

Motivation

I have some data describing the shape of cities in Mexico and wish to overlay these on a map of the country (taken from maps through ggplot2::map_data()). While I managed to a graph, I cannot wrap my head around why my first attempt failed.
I hoped someone could explain why the first call fails.

The example below should provide sufficient context to reproduce the error.
Please note that the maps library is required to run this chunk.

Reprex

Unfortunately as a new user I can only add one embedded content to the post. I manually edited the reprex to provide links instead.

Libraries and a small extract of the data I am working with

library(ggplot2)
library(dplyr)
#> 
#> Attachement du package : 'dplyr'
#> Les objets suivants sont masqués depuis 'package:stats':
#> 
#>     filter, lag
#> Les objets suivants sont masqués depuis 'package:base':
#> 
#>     intersect, setdiff, setequal, union

sample_tbl <- dplyr::tribble(
  ~x, ~y, ~fid,
  -99.23124, 19.73848, 154,
  -99.20016, 19.73848, 154,
  -99.19698, 19.73021, 154,
  -99.16591, 19.73021, 154,
  -99.16909, 19.73848, 154,
  -99.15873, 19.73848, 154,
  -99.15555, 19.73021, 154,
  -99.14519, 19.73021, 154,
  -99.14201, 19.72193, 154,
  -99.12130, 19.72193, 154,
  -99.11812, 19.71365, 154,
  -99.10777, 19.71365, 154,
  -99.10142, 19.69710, 154,
  -99.09106, 19.69710, 154,
  -99.08789, 19.68882, 154,
  -99.05682, 19.68882, 154,
  -99.05999, 19.69710, 154,
  -99.04964, 19.69710, 154,
  -99.04647, 19.68882, 154,
  -99.00504, 19.68882, 154,
  -99.00821, 19.69710, 154,
  -98.99785, 19.69710, 154,
  -98.98750, 19.69710, 154,
  -98.99067, 19.70538, 154,
  -98.98031, 19.70538, 154,
  -98.98665, 19.72193, 154,
  -98.95558, 19.72193, 154,
  -98.95241, 19.71365, 154,
  -98.96277, 19.71365, 154,
  -98.95643, 19.69710, 154,
  -98.96678, 19.69710, 154,
  -98.96045, 19.68055, 154,
  -98.95010, 19.68055, 154,
  -98.94693, 19.67227, 154,
  -98.95729, 19.67227, 154,
  -98.95413, 19.66400, 154,
  -98.96448, 19.66400, 154,
  -98.97484, 19.66400, 154,
  -98.97168, 19.65572, 154,
  -98.98203, 19.65572, 154,
  -98.97256, 19.63089, 154,
  -98.9622, 19.63089, 154,
  -98.95905, 19.62262, 154,
  -98.93834, 19.62262, 154,
  -98.9415, 19.63089, 154,
  -98.93114, 19.63089, 154,
  -98.9343, 19.63917, 154,
  -98.92394, 19.63917, 154,
  -98.91359, 19.63917, 154,
  -98.91675, 19.64744, 154,
  -98.90639, 19.64744, 154,
  -98.90008, 19.63089, 154,
  -98.91043, 19.63089, 154,
  -98.90413, 19.61435, 154,
  -98.89378, 19.61435, 154,
  -98.88748, 19.5978, 154,
  -98.89783, 19.5978, 154,
  -98.89154, 19.58125, 154,
  -98.90189, 19.58125, 154,
  -98.9226, 19.58125, 154,
  -98.91945, 19.57297, 154,
  -98.94016, 19.57297, 154,
  -98.9433, 19.58125, 154,
  -99.00541, 19.58125, 154,
  -99.00227, 19.57297, 154,
  -99.01262, 19.57297, 154,
  -99.00319, 19.54815, 154,
  -99.01354, 19.54815, 154,
  -99.00412, 19.52334, 154,
  -99.01447, 19.52334, 154,
  -99.00506, 19.49852, 154,
  -99.01541, 19.49852, 154,
  -99.00915, 19.48197, 154,
  -99.0195, 19.48197, 154,
  -99.02985, 19.48197, 154,
  -99.02672, 19.4737, 154,
  -99.03707, 19.4737, 154,
  -99.03081, 19.45716, 154,
  -99.04116, 19.45716, 154,
  -99.03491, 19.44062, 154,
  -99.02456, 19.44062, 154,
  -99.02144, 19.43234, 154,
  -98.9904, 19.43234, 154,
  -98.99352, 19.44062, 154,
  -98.98318, 19.44062, 154,
  -98.9863, 19.44889, 154,
  -98.97595, 19.44889, 154,
  -98.96561, 19.44889, 154,
  -98.96873, 19.45716, 154,
  -98.92734, 19.45716, 154,
  -98.91699, 19.45716, 154,
  -98.92012, 19.46543, 154,
  -98.89942, 19.46543, 154,
  -98.88694, 19.43234, 154,
  -98.8766, 19.43234, 154,
  -98.86414, 19.39926, 154,
  -98.87449, 19.39926, 154,
  -98.88483, 19.39926, 154,
  -98.88172, 19.39099, 154,
  -98.89207, 19.39099, 154,
  -98.88896, 19.38272, 154,
  -98.8993, 19.38272, 154,
  -98.8962, 19.37445, 154,
  -98.90654, 19.37445, 154,
  -98.91688, 19.37445, 154,
  -98.91378, 19.36618, 154,
  -98.92412, 19.36618, 154,
  -98.91791, 19.34964, 154,
  -98.90757, 19.34964, 154,
  -98.90447, 19.34137, 154,
  -98.89413, 19.34137, 154,
  -98.89103, 19.3331, 154,
  -98.87034, 19.3331, 154,
  -98.87344, 19.34137, 154,
  -98.8631, 19.34137, 154,
  -98.8662, 19.34964, 154,
  -98.85586, 19.34964, 154,
  -98.85896, 19.35791, 154,
  -98.83827, 19.35791, 154,
  -98.83517, 19.34964, 154,
  -98.84551, 19.34964, 154,
  -98.83932, 19.3331, 154,
  -98.84966, 19.3331, 154,
  -98.83728, 19.30003, 154,
  -98.82694, 19.30003, 154,
  -98.80842, 19.25042, 154,
  -98.81876, 19.25042, 154,
  -98.8291, 19.25042, 154,
  -98.82602, 19.24215, 154,
  -98.83636, 19.24215, 154,
  -98.83328, 19.23389, 154,
  -98.85396, 19.23389, 154,
  -98.85704, 19.24215, 154,
  -98.88805, 19.24215, 154,
  -98.88497, 19.23389, 154,
  -98.89531, 19.23389, 154,
  -98.89223, 19.22562, 154,
  -98.90257, 19.22562, 154,
  -98.89641, 19.20909, 154,
  -98.90675, 19.20909, 154,
  -98.91709, 19.20909, 154,
  -98.91401, 19.20082, 154,
  -98.92435, 19.20082, 154,
  -98.98637, 19.20082, 154,
  -98.98329, 19.19255, 154,
  -98.99363, 19.19255, 154,
  -98.98441, 19.16775, 154,
  -99.00508, 19.16775, 154,
  -99.00815, 19.17602, 154,
  -99.01849, 19.17602, 154,
  -99.02156, 19.18429, 154,
  -99.0319, 19.18429, 154,
  -99.03805, 19.20082, 154,
  -99.02772, 19.20082, 154,
  -99.01738, 19.20082, 154,
  -99.02046, 19.20909, 154,
  -99.01012, 19.20909, 154,
  -99.0132, 19.21735, 154,
  -99.00286, 19.21735, 154,
  -99.00903, 19.23389, 154,
  -99.01937, 19.23389, 154,
  -99.02245, 19.24215, 154,
  -99.06381, 19.24215, 154,
  -99.06072, 19.23389, 154,
  -99.07106, 19.23389, 154,
  -99.0814, 19.23389, 154,
  -99.07831, 19.22562, 154,
  -99.08865, 19.22562, 154,
  -99.08556, 19.21735, 154,
  -99.0959, 19.21735, 154,
  -99.08974, 19.20082, 154,
  -99.0794, 19.20082, 154,
  -99.07632, 19.19255, 154,
  -99.06598, 19.19255, 154,
  -99.05983, 19.17602, 154,
  -99.0805, 19.17602, 154,
  -99.08358, 19.18429, 154,
  -99.09391, 19.18429, 154,
  -99.09699, 19.19255, 154,
  -99.10733, 19.19255, 154,
  -99.11658, 19.21735, 154,
  -99.12691, 19.21735, 154,
  -99.13, 19.22562, 154,
  -99.14034, 19.22562, 154,
  -99.14343, 19.23389, 154,
  -99.1641, 19.23389, 154,
  -99.16101, 19.22562, 154,
  -99.18169, 19.22562, 154,
  -99.19096, 19.25042, 154,
  -99.2013, 19.25042, 154,
  -99.2044, 19.25869, 154,
  -99.21473, 19.25869, 154,
  -99.21783, 19.26696, 154,
  -99.24885, 19.26696, 154,
  -99.25815, 19.29176, 154,
  -99.26849, 19.29176, 154,
  -99.2747, 19.3083, 154,
  -99.28504, 19.3083, 154,
  -99.28815, 19.31657, 154,
  -99.29849, 19.31657, 154,
  -99.30471, 19.3331, 154,
  -99.31505, 19.3331, 154,
  -99.31817, 19.34137, 154,
  -99.34919, 19.34137, 154,
  -99.35231, 19.34964, 154,
  -99.36265, 19.34964, 154,
  -99.36577, 19.35791, 154,
  -99.37611, 19.35791, 154,
  -99.37923, 19.36618, 154,
  -99.36889, 19.36618, 154,
  -99.35854, 19.36618, 154,
  -99.36166, 19.37445, 154,
  -99.35132, 19.37445, 154,
  -99.35444, 19.38272, 154,
  -99.3441, 19.38272, 154,
  -99.34722, 19.39099, 154,
  -99.33688, 19.39099, 154,
  -99.34313, 19.40753, 154,
  -99.33278, 19.40753, 154,
  -99.33904, 19.42407, 154,
  -99.31834, 19.42407, 154,
  -99.308, 19.42407, 154,
  -99.31113, 19.43234, 154,
  -99.30078, 19.43234, 154,
  -99.30704, 19.44889, 154,
  -99.2967, 19.44889, 154,
  -99.30297, 19.46543, 154,
  -99.29262, 19.46543, 154,
  -99.29576, 19.4737, 154,
  -99.28541, 19.4737, 154,
  -99.29797, 19.50679, 154,
  -99.28762, 19.50679, 154,
  -99.29076, 19.51506, 154,
  -99.28041, 19.51506, 154,
  -99.28356, 19.52334, 154,
  -99.27321, 19.52334, 154,
  -99.27635, 19.53161, 154,
  -99.266, 19.53161, 154,
  -99.28491, 19.58125, 154,
  -99.29527, 19.58125, 154,
  -99.29842, 19.58952, 154,
  -99.30878, 19.58952, 154,
  -99.31194, 19.5978, 154,
  -99.32229, 19.5978, 154,
  -99.32545, 19.60607, 154,
  -99.34616, 19.60607, 154,
  -99.34299, 19.5978, 154,
  -99.35335, 19.5978, 154,
  -99.37234, 19.64744, 154,
  -99.27915, 19.64744, 154,
  -99.2688, 19.64744, 154,
  -99.27197, 19.65572, 154,
  -99.26161, 19.65572, 154,
  -99.26795, 19.67227, 154,
  -99.27831, 19.67227, 154,
  -99.28148, 19.68055, 154,
  -99.3022, 19.68055, 154,
  -99.30537, 19.68882, 154,
  -99.29502, 19.68882, 154,
  -99.29819, 19.6971, 154,
  -99.27748, 19.6971, 154,
  -99.26712, 19.6971, 154,
  -99.2703, 19.70538, 154,
  -99.25994, 19.70538, 154,
  -99.26312, 19.71365, 154,
  -99.25277, 19.71365, 154,
  -99.24241, 19.71365, 154,
  -99.24559, 19.72193, 154,
  -99.23523, 19.72193, 154,
  -99.23841, 19.73021, 154,
  -99.22806, 19.73021, 154,
  -99.23124, 19.73848, 154,
  -99.13506, 19.62262, 154,
  -99.1319, 19.61435, 154,
  -99.14225, 19.61435, 154,
  -99.1391, 19.60607, 154,
  -99.14945, 19.60607, 154,
  -99.13999, 19.58125, 154,
  -99.12964, 19.58125, 154,
  -99.12649, 19.57297, 154,
  -99.07473, 19.57297, 154,
  -99.07788, 19.58125, 154,
  -99.06752, 19.58125, 154,
  -99.07383, 19.5978, 154,
  -99.08418, 19.5978, 154,
  -99.08733, 19.60607, 154,
  -99.09769, 19.60607, 154,
  -99.10084, 19.61435, 154,
  -99.1112, 19.61435, 154,
  -99.11435, 19.62262, 154,
  -99.13506, 19.62262, 154,
  -98.99036, 19.26696, 154,
  -98.98727, 19.25869, 154,
  -98.99761, 19.25869, 154,
  -98.99144, 19.24215, 154,
  -98.9811, 19.24215, 154,
  -98.97802, 19.23389, 154,
  -98.95734, 19.23389, 154,
  -98.95426, 19.22562, 154,
  -98.93358, 19.22562, 154,
  -98.93666, 19.23389, 154,
  -98.92632, 19.23389, 154,
  -98.93249, 19.25042, 154,
  -98.94283, 19.25042, 154,
  -98.94592, 19.25869, 154,
  -98.96659, 19.25869, 154,
  -98.96968, 19.26696, 154,
  -98.99036, 19.26696, 154,
  -103.4523, 20.78271, 88,
  -103.4419, 20.78271, 88,
  -103.4384, 20.77441, 88,
  -103.4176, 20.77441, 88,
  -103.414, 20.76611, 88,
  -103.3932, 20.76611, 88,
  -103.3968, 20.77441, 88,
  -103.3864, 20.77441, 88,
  -103.3828, 20.76611, 88,
  -103.3516, 20.76611, 88,
  -103.3552, 20.77441, 88,
  -103.3343, 20.77441, 88,
  -103.3308, 20.76611, 88,
  -103.3204, 20.76611, 88,
  -103.3169, 20.75781, 88,
  -103.3273, 20.75781, 88,
  -103.3203, 20.74122, 88,
  -103.3099, 20.74122, 88,
  -103.3064, 20.73292, 88,
  -103.296, 20.73292, 88,
  -103.2855, 20.70803, 88,
  -103.2751, 20.70803, 88,
  -103.2716, 20.69973, 88,
  -103.2612, 20.69973, 88,
  -103.2577, 20.69144, 88,
  -103.2369, 20.69144, 88,
  -103.2334, 20.68314, 88,
  -103.223, 20.68314, 88,
  -103.2195, 20.67485, 88,
  -103.2091, 20.67485, 88,
  -103.2021, 20.65825, 88,
  -103.2125, 20.65825, 88,
  -103.2056, 20.64166, 88,
  -103.216, 20.64166, 88,
  -103.2125, 20.63337, 88,
  -103.2229, 20.63337, 88,
  -103.2194, 20.62507, 88,
  -103.2298, 20.62507, 88,
  -103.2263, 20.61678, 88,
  -103.2367, 20.61678, 88,
  -103.2263, 20.59189, 88,
  -103.2159, 20.59189, 88,
  -103.2124, 20.5836, 88,
  -103.2228, 20.5836, 88,
  -103.2193, 20.57531, 88,
  -103.2401, 20.57531, 88,
  -103.2436, 20.5836, 88,
  -103.2747, 20.5836, 88,
  -103.2713, 20.57531, 88,
  -103.2817, 20.57531, 88,
  -103.2747, 20.55872, 88,
  -103.2643, 20.55872, 88,
  -103.2574, 20.54213, 88,
  -103.2678, 20.54213, 88,
  -103.2782, 20.54213, 88,
  -103.2747, 20.53384, 88,
  -103.2955, 20.53384, 88,
  -103.299, 20.54213, 88,
  -103.3301, 20.54213, 88,
  -103.3267, 20.53384, 88,
  -103.337, 20.53384, 88,
  -103.3474, 20.53384, 88,
  -103.344, 20.52555, 88,
  -103.3544, 20.52555, 88,
  -103.3509, 20.51725, 88,
  -103.3613, 20.51725, 88,
  -103.3474, 20.48408, 88,
  -103.3578, 20.48408, 88,
  -103.3613, 20.49238, 88,
  -103.3717, 20.49238, 88,
  -103.3751, 20.50067, 88,
  -103.3959, 20.50067, 88,
  -103.3925, 20.49238, 88,
  -103.4028, 20.49238, 88,
  -103.3959, 20.47579, 88,
  -103.4063, 20.47579, 88,
  -103.4098, 20.48408, 88,
  -103.4202, 20.48408, 88,
  -103.4271, 20.50067, 88,
  -103.4167, 20.50067, 88,
  -103.4236, 20.51725, 88,
  -103.434, 20.51725, 88,
  -103.4375, 20.52555, 88,
  -103.4583, 20.52555, 88,
  -103.4548, 20.51725, 88,
  -103.4756, 20.51725, 88,
  -103.486, 20.54213, 88,
  -103.4756, 20.54213, 88,
  -103.4791, 20.55042, 88,
  -103.4687, 20.55042, 88,
  -103.4756, 20.56701, 88,
  -103.486, 20.56701, 88,
  -103.4895, 20.57531, 88,
  -103.4687, 20.57531, 88,
  -103.4583, 20.57531, 88,
  -103.4618, 20.5836, 88,
  -103.4514, 20.5836, 88,
  -103.4619, 20.60848, 88,
  -103.4723, 20.60848, 88,
  -103.4897, 20.64996, 88,
  -103.4689, 20.64996, 88,
  -103.4585, 20.64996, 88,
  -103.462, 20.65825, 88,
  -103.4516, 20.65825, 88,
  -103.4621, 20.68314, 88,
  -103.4517, 20.68314, 88,
  -103.4658, 20.71633, 88,
  -103.4554, 20.71633, 88,
  -103.4589, 20.72462, 88,
  -103.4485, 20.72462, 88,
  -103.4555, 20.74122, 88,
  -103.4451, 20.74122, 88,
  -103.4592, 20.77441, 88,
  -103.4488, 20.77441, 88,
  -103.4523, 20.78271, 88,
  -103.4376, 20.57531, 88,
  -103.4271, 20.55042, 88,
  -103.4167, 20.55042, 88,
  -103.4133, 20.54213, 88,
  -103.3821, 20.54213, 88,
  -103.3856, 20.55042, 88,
  -103.3752, 20.55042, 88,
  -103.3856, 20.57531, 88,
  -103.396, 20.57531, 88,
  -103.3995, 20.5836, 88,
  -103.4306, 20.5836, 88,
  -103.4272, 20.57531, 88,
  -103.4376, 20.57531, 88,
  -98.29311, 19.14296, 177,
  -98.2621, 19.14296, 177,
  -98.25906, 19.13469, 177,
  -98.24873, 19.13469, 177,
  -98.24568, 19.12643, 177,
  -98.22502, 19.12643, 177,
  -98.22806, 19.13469, 177,
  -98.21772, 19.13469, 177,
  -98.21468, 19.12643, 177,
  -98.20435, 19.12643, 177,
  -98.20131, 19.11816, 177,
  -98.18064, 19.11816, 177,
  -98.18368, 19.12643, 177,
  -98.17335, 19.12643, 177,
  -98.17639, 19.13469, 177,
  -98.16605, 19.13469, 177,
  -98.15572, 19.13469, 177,
  -98.15876, 19.14296, 177,
  -98.14842, 19.14296, 177,
  -98.13627, 19.1099, 177,
  -98.12594, 19.1099, 177,
  -98.1229, 19.10163, 177,
  -98.11257, 19.10163, 177,
  -98.10954, 19.09337, 177,
  -98.09921, 19.09337, 177,
  -98.09315, 19.07684, 177,
  -98.10348, 19.07684, 177,
  -98.09743, 19.06031, 177,
  -98.08709, 19.06031, 177,
  -98.08407, 19.05205, 177,
  -98.05308, 19.05205, 177,
  -98.0561, 19.06031, 177,
  -98.04577, 19.06031, 177,
  -98.04879, 19.06857, 177,
  -98.03846, 19.06857, 177,
  -98.02939, 19.04378, 177,
  -98.01906, 19.04378, 177,
  -98.01604, 19.03552, 177,
  -98.02638, 19.03552, 177,
  -98.03671, 19.03552, 177,
  -98.03369, 19.02726, 177,
  -98.04402, 19.02726, 177,
  -98.04704, 19.03552, 177,
  -98.11935, 19.03552, 177,
  -98.11633, 19.02726, 177,
  -98.12666, 19.02726, 177,
  -98.13699, 19.02726, 177,
  -98.13397, 19.01899, 177,
  -98.1443, 19.01899, 177,
  -98.16496, 19.01899, 177,
  -98.16194, 19.01073, 177,
  -98.17227, 19.01073, 177,
  -98.1572, 18.96942, 177,
  -98.16753, 18.96942, 177,
  -98.16151, 18.95289, 177,
  -98.17184, 18.95289, 177,
  -98.17484, 18.96116, 177,
  -98.21616, 18.96116, 177,
  -98.21315, 18.95289, 177,
  -98.22347, 18.95289, 177,
  -98.22046, 18.94463, 177,
  -98.25144, 18.94463, 177,
  -98.25445, 18.95289, 177,
  -98.27511, 18.95289, 177,
  -98.27812, 18.96116, 177,
  -98.28845, 18.96116, 177,
  -98.29146, 18.96942, 177,
  -98.31212, 18.96942, 177,
  -98.31815, 18.98594, 177,
  -98.32848, 18.98594, 177,
  -98.3315, 18.99421, 177,
  -98.34183, 18.99421, 177,
  -98.36301, 19.05205, 177,
  -98.35268, 19.05205, 177,
  -98.35571, 19.06031, 177,
  -98.34538, 19.06031, 177,
  -98.33505, 19.06031, 177,
  -98.33808, 19.06857, 177,
  -98.32775, 19.06857, 177,
  -98.33382, 19.0851, 177,
  -98.34415, 19.0851, 177,
  -98.35023, 19.10163, 177,
  -98.3399, 19.10163, 177,
  -98.34294, 19.1099, 177,
  -98.33261, 19.1099, 177,
  -98.33565, 19.11816, 177,
  -98.32531, 19.11816, 177,
  -98.31923, 19.10163, 177,
  -98.3089, 19.10163, 177,
  -98.30586, 19.09337, 177,
  -98.2852, 19.09337, 177,
  -98.28823, 19.10163, 177,
  -98.2779, 19.10163, 177,
  -98.29311, 19.14296, 177
)
# Small extract of the data to plot

Attempt 1-A, no fill

sample_tbl %>% 
  ggplot2::ggplot(ggplot2::aes(x, y, group = fid)) +
  ggplot2::geom_polygon() +
  ggplot2::geom_path(
    ggplot2::aes(long, lat, group = group),
    ggplot2::map_data("world", "mexico")
  ) +
  ggplot2::coord_fixed() +
  ggplot2::scale_fill_viridis_c(option = "magma") + 
  ggplot2::guides(fill = "none") +
  ggplot2::theme_void()

It is not striking because we are currently working with a sample but using the full set, it can be hard to distinguish city borders. To alleviate this concern I simply map the city identifiers (already used to define which points are part of the same polygon) to the fill aesthetics.

Attempt 1-B, fill

sample_tbl %>% 
  ggplot2::ggplot(ggplot2::aes(x, y, group = fid, fill = fid)) +
  ggplot2::geom_polygon() +
  ggplot2::geom_path(
    ggplot2::aes(long, lat, group = group),
    ggplot2::map_data("world", "mexico")
  ) +
  ggplot2::coord_fixed() +
  ggplot2::scale_fill_viridis_c(option = "magma") + 
  ggplot2::guides(fill = "none") +
  ggplot2::theme_void()
#> Error in FUN(X[[i]], ...): objet 'fid' introuvable

This produces the error I do not understand as fid was already used in 1-A.

Attempt 2

By simply inversing the order the calls (country borders first) we can produce a graph.

ggplot2::map_data("world", "mexico") %>% 
  ggplot2::ggplot(ggplot2::aes(long, lat, group = group)) + 
  ggplot2::geom_path() +
  ggplot2::geom_polygon(
    ggplot2::aes(x, y, group = fid, fill = fid),
    sample_tbl
  ) +
  ggplot2::coord_fixed() +
  ggplot2::scale_fill_viridis_c(option = "magma", end = 0.75) + 
  ggplot2::guides(fill = "none") +
  ggplot2::theme_void()

output

Created on 2022-03-25 by the reprex package (v2.0.1)

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.2 (2021-11-01)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  French_France.1252
#>  ctype    French_France.1252
#>  tz       Europe/Paris
#>  date     2022-03-25
#>  pandoc   2.14.0.3 @ C:/Program Files/RStudio/bin/pandoc/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date (UTC) lib source
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 4.1.0)
#>  cli           3.2.0   2022-02-14 [1] CRAN (R 4.1.3)
#>  colorspace    2.0-2   2021-06-24 [1] CRAN (R 4.1.0)
#>  crayon        1.5.0   2022-02-14 [1] CRAN (R 4.1.2)
#>  curl          4.3.2   2021-06-23 [1] CRAN (R 4.1.0)
#>  DBI           1.1.2   2021-12-20 [1] CRAN (R 4.1.2)
#>  digest        0.6.27  2020-10-24 [1] CRAN (R 4.1.0)
#>  dplyr       * 1.0.8   2022-02-08 [1] CRAN (R 4.1.2)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.1.0)
#>  evaluate      0.14    2019-05-28 [1] CRAN (R 4.1.0)
#>  fansi         1.0.2   2022-01-14 [1] CRAN (R 4.1.2)
#>  farver        2.1.0   2021-02-28 [1] CRAN (R 4.1.0)
#>  fastmap       1.1.0   2021-01-25 [1] CRAN (R 4.1.0)
#>  fs            1.5.0   2020-07-31 [1] CRAN (R 4.1.0)
#>  generics      0.1.2   2022-01-31 [1] CRAN (R 4.1.2)
#>  ggplot2     * 3.3.5   2021-06-25 [1] CRAN (R 4.1.0)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.1.2)
#>  gtable        0.3.0   2019-03-25 [1] CRAN (R 4.1.0)
#>  highr         0.9     2021-04-16 [1] CRAN (R 4.1.0)
#>  htmltools     0.5.2   2021-08-25 [1] CRAN (R 4.1.1)
#>  httr          1.4.2   2020-07-20 [1] CRAN (R 4.1.0)
#>  knitr         1.37    2021-12-16 [1] CRAN (R 4.1.2)
#>  labeling      0.4.2   2020-10-20 [1] CRAN (R 4.1.0)
#>  lifecycle     1.0.1   2021-09-24 [1] CRAN (R 4.1.0)
#>  magrittr      2.0.2   2022-01-26 [1] CRAN (R 4.1.2)
#>  maps          3.4.0   2021-09-25 [1] CRAN (R 4.1.0)
#>  mime          0.11    2021-06-23 [1] CRAN (R 4.1.0)
#>  munsell       0.5.0   2018-06-12 [1] CRAN (R 4.1.0)
#>  pillar        1.7.0   2022-02-01 [1] CRAN (R 4.1.2)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.1.0)
#>  purrr         0.3.4   2020-04-17 [1] CRAN (R 4.1.0)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.1.0)
#>  reprex        2.0.1   2021-08-05 [1] CRAN (R 4.1.0)
#>  rlang         1.0.2   2022-03-04 [1] CRAN (R 4.1.2)
#>  rmarkdown     2.13    2022-03-10 [1] CRAN (R 4.1.3)
#>  rstudioapi    0.13    2020-11-12 [1] CRAN (R 4.1.0)
#>  scales        1.1.1   2020-05-11 [1] CRAN (R 4.1.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.1.2)
#>  stringi       1.7.6   2021-11-29 [1] CRAN (R 4.1.2)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 4.1.0)
#>  tibble        3.1.6   2021-11-07 [1] CRAN (R 4.1.2)
#>  tidyselect    1.1.2   2022-02-21 [1] CRAN (R 4.1.2)
#>  utf8          1.2.2   2021-07-24 [1] CRAN (R 4.1.0)
#>  vctrs         0.3.8   2021-04-29 [1] CRAN (R 4.1.0)
#>  viridisLite   0.4.0   2021-04-13 [1] CRAN (R 4.1.0)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.1.3)
#>  xfun          0.30    2022-03-02 [1] CRAN (R 4.1.3)
#>  xml2          1.3.3   2021-11-30 [1] CRAN (R 4.1.2)
#>  yaml          2.3.5   2022-02-21 [1] CRAN (R 4.1.2)
#> 
#>  [1] C:/Users/Peio/Documents/R/win-library/4.1
#>  [2] C:/Program Files/R/R-4.1.2/library
#> 
#> ------------------------------------------------------------------------------

I am really unsure as to why 1-B produces an error whereas 2 runs correctly.

Thank you !

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.