Geospatial Analysis with R

Class 5

library(sf)
library(dplyr)
f <- system.file("extdata", "farmer_spatial.csv", package = "geospaar")
farmers <- readr::read_csv(f)
farmers <- farmers %>% select(uuid, x, y) %>% distinct() %>% 
  st_as_sf(., coords = c("x", "y"))
f <- system.file("extdata", "districts.shp", package = "geospaar")
dists <- read_sf(f)
st_crs(farmers) <- st_crs(dists)

# join farmers with districts (h/t https://mattherman.info/blog/point-in-poly/)
farmers_in_dists <- st_join(farmers, dists, join = st_within) %>%
  tidyr::drop_na()
farmer_count <- count(as_tibble(farmers_in_dists), distName)
dists_w_farmers <- left_join(dists, farmer_count) %>% 
  mutate(n = ifelse(is.na(n), 0, n))

png("figures/sms-farmers.png", height = 4, width = 5, res = 300,
    units = "in")
plot(dists_w_farmers["n"], breaks = c(0, 5, 10, 15, 20, 50, 500), 
     reset = FALSE, main = "Number of SMS Farmers by District")
plot(farmers %>% filter(uuid %in% unique(farmers_in_dists$uuid)) %>%
       st_geometry(), add = TRUE, pch = "+", col = "cyan", cex = 0.5)
dev.off()

Today

  • Projects and package set-up
  • git / GitHub
    • syncing, commit, push, pull, branching, merging
  • data folder and lazy loads
  • inst folder and how to get at it
  • If time
    • RMarkdown
    • The R ecosystem
    • Building blocks of R: data types, functions, etc

Git exercises (1)

  • Open your personal R repo (e.g. mjc346 in RStudio)
  • Create a new branch, test_merge. You can create this branch in the Git tab, or in Terminal, using git checkout -b test_merge
  • With the new branch active, create a new file test_function within the R folder. Create a simple function that takes a number x as an input, and prints “x is my favorite number!”. Save and commit this file in the new branch.
  • Switch back to the main branch. You should see a pop-up message. What happens to the test_function.R file? Can you see it in your file explorer?
  • merge the new file to the main branch using the command git merge test_merge in Terminal. What happens?
  • The merge command automatically merges and commits changes to the main branch

Git exercises (2)

  • In the test_merge branch, open the Description file. Update the version to 0.0.2. Save and commit.
  • Switch to the main branch. Add a second author in the Author line. Save and commit.
  • Now test merging the change from test_merge to main using git merge test_merge. Does this work?

Git exercises (3)

  • In the test_merge branch, add a third fictional author. Save and commit.
  • Switch to the main branch. Again add a third author, but use a different author than in the test_merge branch.
  • Now test merging the change from test_merge to main using git merge test_merge. Does this work?
  • Open the Description file. What does it look like?
  • After you are done, delete the branch using git branch -D test_merge
  • Update the Description file in the main branch by pasting the text you saved. Save and commit.

Tips and Tricks

  • Tab completion and shortcuts
  • Reusing code
  • Code syntax
  • Posting guide

Knowing how to get help as a skillset

  • Slack posting guide
  • Getting help via the search engine
  • (Eventually) posting to listserves

Search Engine Science

  • Sometimes you just need the error message

Search Engine Science

  • Sometimes you need to search

    fatal: unable to access 'https://github.com/agroimpacts/xyz346.git/': 
    error setting certificate verify locations:
     CAfile: C:/Users/xyz/Desktop/ADP/RStudio/xyz346/Git/mingw64/ssl/
     certs/ca-bundle.crt
     CApath: none
  • How you search matters

Listserves

Package functions

  • install.packages : installs binary packages from CRAN
  • devtools::install_github: installs from Github
  • devtools::install("C:/Users/micha/Documents/geospaar/") to install locally

Data in packages

  • packages often include example data
  • Lazy loading data only loads when used
  • Lazy loaded data in data/ folder
    • formats: .R, .rda, .RData, .tab, .txt, .csv
  • Non lazy loads (raw data) in inst/extdata
ls()
character(0)
data("farmers_env", package = "geospaar")
ls()
[1] "farmers_env"
farmers_env
        uuid        geometry     rain district
1   009a8424 27.256, -16.926 66.93754       11
2   00df166f 26.942, -16.504 72.00297       11
3   02671a00 27.254, -16.914 66.93754       11
4   03f4dcca 27.237, -16.733 69.78009       11
5   042cf7b3 27.138, -16.807 75.14184       11
6   05618404 26.875, -16.611 66.09323       11
7   064beba0 26.752, -16.862 58.36053       20
8   083a46a2 26.977, -16.765 70.38586       11
9   08eb2224 26.912, -16.248 53.95671       59
10  0ab761d6 27.113, -16.950 72.43802       11
11  0bd19b6a 26.772, -16.860 58.36053       20
12  0c0c6ed8 26.794, -16.843 57.79966       11
13  0c18f625 26.862, -16.674 68.36250       11
14  0cbc4225 26.859, -16.176 57.92710       59
15  0eb65faa 27.056, -16.935 69.99150       11
16  0ed7bf8d 27.294, -16.746 80.89200       11
17  12d7333e 27.237, -16.733 69.78009       11
18  130455fd 26.885, -16.589 73.05731       11
19  146fd88d 27.237, -16.922 73.24045       11
20  14e2047a 27.306, -16.742 78.35793       11
21  14eb1bc1 26.913, -16.251 55.04950       11
22  14f4d804 27.336, -16.834 72.22664       11
23  16d25908 26.780, -16.851 58.36053       20
24  186977a2 26.862, -16.674 68.36250       11
25  19c2befd 26.933, -17.041 63.51126       11
26  1a3ed58f 27.276, -16.878 67.82761       11
27  1a4008c2 26.859, -16.178 57.92710       59
28  1ae8ccff 27.094, -16.813 78.34108       11
29  1c7690e0 27.261, -16.921 66.93754       11
30  1cba393a 26.930, -16.508 72.00297       11
31  261e38c9 26.974, -16.748 69.62228       11
32  26b02eaa 27.114, -16.790 69.24673       11
33  26ccd1ca 27.279, -16.926 66.93754       11
34  26d99644 26.917, -16.532 72.00297       11
35  28706e65 26.969, -16.723 69.62228       11
36  28c79d87 26.857, -16.191 57.92710       59
37  2abd46c3 27.294, -16.744 80.89200       11
38  2b60914d 27.275, -16.884 67.82761       11
39  2cf13d38 27.050, -17.003 69.43579       11
40  2d70af82 26.863, -16.590 73.05731       11
41  30c2e51a 27.313, -16.779 78.28657       11
42  3112ec39 27.272, -16.873 67.82761       11
43  32855ee6 26.975, -16.760 70.38586       11
44  33361d1c 26.830, -16.817 63.43196       11
45  36c0532e 26.953, -16.487 67.75720       11
46  373bc918 27.050, -17.003 69.43579       11
47  381e38ea 27.293, -16.744 80.89200       11
48  38c83136 26.933, -16.463 69.48450       11
49  3a042f06 27.076, -16.952 79.16811       11
50  3a0b6560 27.285, -16.748 80.89200       11
51  3a5c6f75 27.050, -17.004 69.43579       11
52  3b3d1539 26.857, -16.193 57.92710       59
53  3b6cbc47 27.059, -17.006 78.89503       11
54  3e3c2a80 26.971, -16.753 70.38586       11
55  3e8b66b7 27.118, -16.919 72.43802       11
56  3fed4ec6 27.239, -16.741 69.78009       11
57  4120e368 26.979, -16.762 70.38586       11
58  4313155f 27.266, -16.921 66.93754       11
59  44c8a2b6 27.063, -17.004 78.89503       11
60  45a89b91 27.109, -16.980 70.20730       11
61  46fa47e5 26.930, -17.054 52.02611       11
62  47939706 27.275, -16.884 67.82761       11
63  48635f6e 27.099, -16.964 79.16811       11
64  48c828d0 27.265, -16.921 66.93754       11
65  4932fac2 26.810, -16.607 59.16776       11
66  496c557b 27.297, -16.935 66.93754       11
67  499a72b8 26.831, -16.817 63.43196       11
68  4a58fbbb 26.877, -16.585 73.05731       11
69  4afc2d3e 27.067, -16.988 79.16811       11
70  4b671e6b 27.294, -16.744 80.89200       11
71  4ca666fd 27.089, -16.951 79.16811       11
72  4cb11854 27.129, -16.790 69.24673       11
73  4d524878 27.032, -16.961 75.39918       11
74  4f75193d 26.961, -16.727 69.62228       11
75  51d50f10 26.983, -16.765 70.38586       11
76  54d0a15c 26.941, -16.485 69.48450       11
77  55772276 26.864, -16.662 68.36250       11
78  561a6a5d 27.080, -16.972 79.16811       11
79  58d39a53 26.791, -16.841 57.79966       11
80  5b732fcd 26.850, -16.216 53.30880       59
81  5c093270 27.255, -16.908 66.93754       11
82  5c13f0ee 27.255, -16.909 66.93754       11
83  5e0473ca 26.821, -16.604 59.16776       11
84  5e37a888 27.128, -16.772 69.24673       11
85  5e65fc11 27.094, -16.890 73.09578       11
86  5e911b62 27.061, -17.004 78.89503       11
87  61228b69 26.802, -16.832 63.43196       11
88  6132a9b3 27.316, -16.782 78.28657       11
89  62642d7c 27.234, -16.733 69.78009       11
90  646d6573 27.256, -16.926 66.93754       11
91  64a63ad8 27.230, -16.717 69.78009       11
92  664bdf41 26.781, -16.870 58.36053       20
93  66e41828 26.804, -16.854 61.28291       11
94  67cbcae6 26.896, -16.704 72.95570       11
95  684d8902 26.966, -16.733 69.62228       11
96  6b38721b 26.788, -16.876 58.36053       20
97  6c223ecd 26.913, -16.519 72.00297       11
98  6d05224a 26.853, -16.210 53.86879       59
99  6d774598 26.913, -16.250 53.95671       59
100 6dfd9cdf 27.301, -16.816 72.22664       11
101 6ff740a4 27.299, -16.935 66.93754       11
102 703825ba 26.788, -16.876 58.36053       20
103 70b5f403 27.037, -16.954 75.39918       11
104 718d866e 26.859, -16.178 57.92710       59
105 730b727a 27.056, -16.934 69.99150       11
106 732af424 26.833, -16.818 63.43196       11
107 74ccfcac 26.899, -16.856 61.73315       11
108 7572e663 27.199, -16.924 71.00794       11
109 770da037 26.833, -16.817 63.43196       11
110 78284b9d 26.995, -16.972 75.29367       11
111 7af5af0a 27.301, -16.758 78.28657       11
112 7d101d28 27.305, -16.803 72.22664       11
113 7da072ff 27.066, -16.944 69.99150       11
114 7eed2695 26.923, -17.049 63.51126       11
115 7f49bc48 27.284, -16.749 80.89200       11
116 7f9ab0f7 27.094, -16.976 79.16811       11
117 814ca378 27.061, -17.004 78.89503       11
118 85867e62 27.111, -16.933 72.43802       11
119 85f03621 26.938, -16.513 72.00297       11
120 88462901 26.881, -16.597 73.05731       11
121 890ca2c8 27.107, -16.940 72.43802       11
122 8b816f5f 27.255, -16.915 66.93754       11
123 8d074cec 26.869, -16.596 73.05731       11
124 8d2db211 26.934, -17.036 63.51126       11
125 8d690816 26.936, -16.744 72.52380       11
126 8da4a6d6 26.858, -16.594 73.05731       11
127 92563785 27.234, -16.923 73.24045       11
128 926caf97 26.869, -16.610 66.09323       11
129 95374d3f 27.039, -16.842 70.56110       11
130 96b6d097 26.995, -16.953 75.29367       11
131 975ffe94 26.831, -16.818 63.43196       11
132 981208ad 27.344, -16.776 78.28657       11
133 991ece73 27.086, -16.967 79.16811       11
134 99dc8db6 27.182, -16.917 71.00794       11
135 9a8786eb 27.258, -16.929 66.93754       11
136 9b42e80a 26.869, -16.614 66.09323       11
137 9c0fe82f 26.974, -16.760 70.38586       11
138 a006eab2 27.335, -16.798 78.28657       11
139 a0f8b4ef 27.039, -16.830 70.56110       11
140 a30b3bde 27.048, -16.926 71.20597       11
141 a5ad178a 27.060, -17.005 78.89503       11
142 a62be645 26.863, -16.595 73.05731       11
143 a67f255e 26.815, -16.585 66.42364       11
144 a84d2d02 26.831, -16.817 63.43196       11
145 a914f6e1 26.788, -16.863 58.36053       20
146 a9a99b3e 26.920, -17.052 52.02611       11
147 a9d39da7 26.928, -16.520 72.00297       11
148 aa5f0d29 26.951, -16.727 69.62228       11
149 aac48cd5 27.050, -17.003 69.43579       11
150 abd530e7 26.981, -16.762 70.38586       11
151 ace80c2e 27.306, -16.931 66.28913       11
152 ad783a0a 27.336, -16.797 78.28657       11
153 afaecd2e 27.305, -16.793 78.28657       11
154 affb013a 26.963, -16.920 70.25295       11
155 b0e82f78 27.339, -16.834 72.22664       11
156 b1e1a3f3 26.789, -16.878 58.36053       20
157 b3d90826 26.922, -16.526 72.00297       11
158 b5a7a1f4 26.935, -16.513 72.00297       11
159 b66a5a55 26.974, -16.766 70.38586       11
160 b825d94e 27.113, -16.773 69.24673       11
161 b9d85ebc 27.234, -16.923 73.24045       11
162 ba5973c2 26.835, -16.815 63.43196       11
163 baea69b4 27.279, -16.877 67.82761       11
164 bb876912 26.936, -16.505 72.00297       11
165 bba2dfd0 27.339, -16.797 78.28657       11
166 bc32b0b4 26.864, -16.599 73.05731       11
167 bc8d8a74 27.275, -16.877 67.82761       11
168 bf8b44c4 26.791, -16.874 58.36053       20
169 c084cfc1 26.795, -16.879 58.36053       20
170 c124742c 27.209, -16.917 73.24045       11
171 c152455a 27.085, -16.934 69.99150       11
172 c2668cdf 27.123, -16.769 69.24673       11
173 c32d45ee 27.068, -16.939 69.99150       11
174 c42827cf 27.096, -16.949 69.99150       11
175 c6f737ea 27.304, -16.793 78.28657       11
176 c784ee02 26.859, -16.194 57.92710       59
177 c7d6f91c 26.831, -16.817 63.43196       11
178 c7e2a514 26.810, -16.606 59.16776       11
179 c946796f 27.004, -16.841 70.56110       11
180 c9ee7136 27.039, -16.842 70.56110       11
181 c9f5f663 27.128, -16.779 69.24673       11
182 cc014f7d 26.778, -16.870 58.36053       20
183 cc230be1 27.286, -16.788 76.04762       11
184 cdcc9666 27.293, -16.747 80.89200       11
185 ce041f38 26.961, -16.743 69.62228       11
186 d027ee45 27.293, -16.747 80.89200       11
187 d16f790f 27.016, -16.932 71.20597       11
188 d1d9637e 27.136, -16.800 69.24673       11
189 d1e20dc3 26.912, -16.254 55.04950       11
190 d263ea45 26.827, -16.820 63.43196       11
191 d362925c 26.859, -16.193 57.92710       59
192 d6313bed 27.301, -16.758 78.28657       11
193 d644ee96 26.867, -16.610 66.09323       11
194 d6e18dd9 27.086, -16.961 79.16811       11
195 d9ce012d 27.325, -16.757 78.28657       11
196 de338705 27.293, -16.747 80.89200       11
197 dea21f52 27.097, -16.899 73.09578       11
198 df1604d4 27.271, -16.784 76.04762       11
199 dfc6f992 26.823, -16.625 59.16776       11
200 e2510e54 27.123, -16.922 72.43802       11
201 e25b2b0f 26.789, -16.877 58.36053       20
202 e27cd268 27.056, -16.935 69.99150       11
203 e3407303 26.781, -16.856 58.36053       20
204 e340de50 26.956, -16.738 69.62228       11
205 e36fdd30 26.947, -16.746 72.52380       11
206 e82a9751 26.790, -16.823 57.79966       11
207 e91d6065 27.135, -16.770 69.24673       11
208 e9f6b304 27.066, -16.944 69.99150       11
209 ebd881fc 27.310, -16.803 72.22664       11
210 ee2f89cf 27.090, -16.971 79.16811       11
211 f0118efa 27.286, -16.932 66.93754       11
212 f08a0aa3 27.032, -16.961 75.39918       11
213 f0bcb418 27.107, -16.772 69.24673       11
214 f6ebaa5b 27.300, -16.934 66.93754       11
215 f752c993 27.300, -16.756 76.04762       11
216 f825b96c 27.060, -16.986 79.16811       11
217 fb3fc0e0 27.086, -16.783 71.25740       11
218 fb666168 26.780, -16.851 58.36053       20
219 fbdacd81 26.999, -16.956 75.29367       11
220 fbef7ba1 27.227, -16.738 69.78009       11
221 fc263f78 27.232, -16.720 69.78009       11
222 fce31f54 26.826, -16.595 66.42364       11
223 fe096545 27.260, -16.922 66.93754       11
224 0649944b 27.336, -16.784 78.28657       11
225 08683ecf 27.284, -16.749 80.89200       11
226 0a2efd25 27.338, -16.794 78.28657       11
227 0f095777 26.815, -16.599 66.42364       11
228 116e1bcc 26.859, -16.595 73.05731       11
229 16128e91 27.100, -16.894 73.09578       11
230 27fb5351 27.094, -16.906 69.99150       11
231 2a840b88 27.338, -16.794 78.28657       11
232 3182c9bb 27.086, -16.961 79.16811       11
233 3210d99e 26.939, -16.490 69.48450       11
234 36883452 27.051, -16.840 78.34108       11
235 36db3c21 26.769, -16.873 58.36053       20
236 3c0a7255 27.280, -16.872 67.82761       11
237 41b213e1 26.900, -16.852 61.73315       11
238 4285ad8d 26.808, -16.835 63.43196       11
239 46498dc8 26.975, -16.826 69.10195       11
240 48b2c57f 26.781, -16.849 57.79966       11
241 4ae722c5 27.298, -16.930 66.93754       11
242 4bc9a120 27.183, -16.915 71.00794       11
243 5769b555 27.336, -16.834 72.22664       11
244 5ad27ec3 26.812, -16.599 66.42364       11
245 60734a06 26.989, -16.830 69.10195       11
246 646ea49f 27.053, -16.927 69.99150       11
247 6be46cee 26.967, -16.821 69.10195       11
248 6df8bb5e 26.977, -16.819 69.10195       11
249 6e1aeb91 27.045, -16.962 75.39918       11
250 73c31707 27.117, -16.920 72.43802       11
251 748a4af0 26.814, -16.612 59.16776       11
252 79afec99 27.326, -16.764 78.28657       11
253 7a2965b2 27.185, -16.917 71.00794       11
254 7c62ae6a 26.940, -16.727 72.52380       11
255 7c6dbe51 26.886, -16.584 73.05731       11
256 7de10584 27.338, -16.799 78.28657       11
257 7e77ffc9 27.086, -16.970 79.16811       11
258 86f14077 27.299, -16.752 76.04762       11
259 897c6236 27.336, -16.834 72.22664       11
260 8bae7654 27.040, -16.842 70.56110       11
261 9c5f30d9 26.863, -16.620 66.09323       11
262 a039fcbf 27.059, -17.005 78.89503       11
263 a3016253 27.299, -16.753 76.04762       11
264 ae3e29b7 26.977, -16.819 69.10195       11
265 b4a51504 26.944, -16.471 69.48450       11
266 b9b6b017 27.086, -16.961 79.16811       11
267 bb4616c2 27.102, -16.906 72.43802       11
268 bd8c8fda 26.955, -16.558 80.94247       11
269 c07fca86 27.084, -16.999 79.16811       11
270 c276acb6 26.906, -16.857 66.99890       11
271 c482ffa7 27.234, -16.923 73.24045       11
272 c56ed10c 26.967, -16.821 69.10195       11
273 c647d0ba 27.111, -16.933 72.43802       11
274 c69577b4 27.313, -16.784 78.28657       11
275 ca6fc5e6 27.105, -16.915 72.43802       11
276 cc984ea8 26.900, -16.197 57.92710       59
277 cca69f84 26.974, -16.752 70.38586       11
278 d410cd79 26.936, -16.479 69.48450       11
279 d9297c58 27.095, -16.891 73.09578       11
280 de20cb83 27.093, -16.937 69.99150       11
281 e0bd44cb 26.820, -16.834 63.43196       11
282 e4899f8b 26.984, -16.944 70.25295       11
283 f08180bf 27.237, -16.733 69.78009       11
284 f27f24df 26.814, -16.601 59.16776       11
285 f58e95e7 26.934, -16.510 72.00297       11
286 f838678c 27.052, -16.933 69.99150       11
287 f89b6638 26.935, -16.500 69.48450       11
288 fd33886d 26.803, -16.857 61.28291       11
289 0216b983 26.967, -16.821 69.10195       11
290 0360d642 26.825, -16.604 59.16776       11
291 0e49e4ef 26.979, -16.762 70.38586       11
292 0ed18f13 26.959, -16.548 74.59067       11
293 107e8347 26.917, -16.250 53.95671       59
294 14e7cec2 26.810, -16.601 59.16776       11
295 158a59a2 27.099, -16.893 73.09578       11
296 1ad68009 27.200, -16.913 71.00794       11
297 2596a920 26.941, -17.042 63.51126       11
298 25ea180f 27.157, -16.790 69.47702       11
299 2cad566c 26.877, -16.567 73.05731       11
300 31d97950 27.052, -16.942 69.99150       11
301 37ef5507 27.016, -16.932 71.20597       11
302 3b5c58da 26.938, -16.515 72.00297       11
303 41066075 26.899, -16.193 57.92710       59
304 4589580c 26.812, -16.601 59.16776       11
305 4e8f7c6c 26.980, -16.918 70.25295       11
306 4ea9a204 27.090, -16.944 69.99150       11
307 5127de85 27.287, -16.874 67.82761       11
308 544b43d4 27.123, -16.923 72.43802       11
309 569a6897 26.984, -16.944 70.25295       11
310 5ed6fa13 27.039, -16.842 70.56110       11
311 5fa80769 27.064, -16.986 79.16811       11
312 6276c250 26.891, -16.194 57.92710       59
313 65d21910 26.896, -16.275 51.30970       11
314 6b04c587 27.056, -16.905 69.99150       11
315 6e508c11 27.236, -16.732 69.78009       11
316 73735711 27.297, -16.750 80.89200       11
317 75bee886 27.086, -16.783 71.25740       11
318 760b8688 27.015, -16.905 71.20597       11
319 776d8240 26.863, -16.594 73.05731       11
320 784cfe86 26.984, -16.944 70.25295       11
321 7b418746 26.971, -16.554 80.94247       11
322 7ed0ad89 26.958, -16.547 74.59067       11
323 898e8a07 26.961, -16.921 70.25295       11
324 8d130d52 26.874, -16.252 51.30970       11
325 8f709944 26.865, -16.599 73.05731       11
326 91332f7e 27.293, -16.745 80.89200       11
327 9195ad7e 26.955, -16.913 70.25295       11
328 97ad1f89 26.862, -16.674 68.36250       11
329 9ad19ac7 26.901, -16.267 55.04950       11
330 a50d4f55 27.016, -16.932 71.20597       11
331 a8edaee8 26.980, -16.916 70.25295       11
332 ab4888cd 26.772, -16.860 58.36053       20
333 af430afb 27.304, -16.793 78.28657       11
334 b097b7db 26.803, -16.553 66.42364       11
335 b6b9017d 26.959, -16.758 70.38586       11
336 bec93f73 26.806, -16.842 63.43196       11
337 c7514c14 26.961, -16.721 69.62228       11
338 c90931aa 27.274, -16.871 67.82761       11
339 cc52b149 26.799, -16.825 57.79966       11
340 d35929ad 26.861, -16.674 68.36250       11
341 d89263d6 26.911, -16.248 53.95671       59
342 dab297d9 26.867, -16.590 73.05731       11
343 dec8fc25 26.943, -16.734 72.52380       11
344 e34bba70 27.093, -16.955 79.16811       11
345 e35de09f 26.815, -16.608 59.16776       11
346 e729acc8 26.812, -16.593 66.42364       11
347 ecec693f 27.112, -16.782 69.24673       11
348 f789ca13 27.283, -16.879 67.82761       11
349 f892223e 26.974, -17.047 76.38082       11
350 fae53879 26.930, -17.045 63.51126       11
351 fe63ae9b 26.801, -16.866 61.28291       11
352 0daa4c9b 27.270, -16.876 67.82761       11
353 0dedd7a0 26.936, -16.744 72.52380       11
354 14557178 26.938, -16.513 72.00297       11
355 262271c1 26.828, -16.820 63.43196       11
356 3257f84b 27.157, -16.790 69.47702       11
357 3b267544 27.004, -16.841 70.56110       11
358 3c3032ca 26.953, -17.026 76.38082       11
359 3e8ff90d 26.923, -17.035 63.51126       11
360 46154734 27.225, -16.731 69.78009       11
361 49cba362 26.895, -16.709 72.95570       11
362 516a8bc0 26.870, -16.619 66.09323       11
363 52a8a387 26.938, -16.473 69.48450       11
364 57b9cb34 27.210, -16.916 73.24045       11
365 5a7e9343 26.793, -16.839 57.79966       11
366 5adcb604 26.814, -16.596 66.42364       11
367 5d3dbde4 27.298, -16.930 66.93754       11
368 69056f82 26.967, -16.821 69.10195       11
369 76a576f2 27.305, -16.794 78.28657       11
370 86856ad7 27.237, -16.733 69.78009       11
371 868c621b 26.827, -16.611 59.16776       11
372 86d2aec9 26.797, -16.877 58.36053       20
373 8d3db35f 26.949, -16.727 72.52380       11
374 8dd5fd9f 26.864, -16.599 73.05731       11
375 90a76991 26.944, -16.757 70.71572       11
376 930b2f35 27.440, -16.291 59.00846       47
377 9490dc28 26.791, -16.873 58.36053       20
378 963d0434 26.912, -17.037 63.51126       11
379 b89376a6 27.237, -16.733 69.78009       11
380 c26611bd 27.451, -16.280 59.08787       47
381 cab979dd 26.995, -16.954 75.29367       11
382 d498aafe 27.009, -17.005 69.43579       11
383 df56340d 27.456, -16.287 59.08787       47
384 e32c79f7 27.114, -16.790 69.24673       11
385 e6c01a65 27.032, -16.961 75.39918       11
386 e93a43a1 27.235, -16.923 73.24045       11
387 eb3a46a8 27.446, -16.287 59.00846       47
388 edd0ab45 27.305, -16.793 78.28657       11
389 f89c29a3 26.879, -16.294 51.30970       11
390 04702070 26.892, -16.275 51.30970       11
391 05a95f44 26.961, -16.759 70.38586       11
392 07f59a2d 27.048, -16.963 75.39918       11
393 235db966 26.941, -17.047 63.51126       11
394 2533bbaa 26.975, -16.758 70.38586       11
395 26f5ab40 27.123, -16.769 69.24673       11
396 2b941a51 26.953, -16.718 69.62228       11
397 2cfdc618 27.125, -16.787 69.24673       11
398 315e7ce7 26.902, -16.708 72.52380       11
399 3407f1a6 26.945, -16.726 72.52380       11
400 34c290c3 27.033, -16.915 71.20597       11
401 42a5b4ad 26.961, -16.921 70.25295       11
402 452b8e53 26.986, -16.910 70.25295       11
403 47f06b2f 27.117, -16.919 72.43802       11
404 4b144665 26.940, -17.039 63.51126       11
405 5236ac71 27.016, -16.938 71.20597       11
406 529081b9 27.055, -16.937 69.99150       11
407 561bbccc 26.862, -16.674 68.36250       11
408 5abe2dbb 26.912, -16.255 55.04950       11
409 612f14a1 26.961, -16.921 70.25295       11
410 6284f760 27.309, -16.785 78.28657       11
411 649cbcfa 27.039, -16.842 70.56110       11
412 686ce602 26.868, -16.615 66.09323       11
413 6fe09cc3 26.944, -16.743 72.52380       11
414 7020b5bc 26.799, -16.830 57.79966       11
415 7fc9b3fd 26.819, -16.608 59.16776       11
416 8089357c 27.134, -16.804 75.14184       11
417 830005c6 27.063, -17.004 78.89503       11
418 84e88b69 27.063, -17.004 78.89503       11
419 8be0615d 26.866, -16.676 68.36250       11
420 92236b7f 27.039, -16.842 70.56110       11
421 9344ba63 27.235, -16.732 69.78009       11
422 94fc37ca 26.775, -16.859 58.36053       20
423 9546584e 27.282, -16.917 66.93754       11
424 9628f66d 26.936, -16.506 72.00297       11
425 9a22652d 26.809, -16.603 59.16776       11
426 9c0d1075 27.097, -16.960 79.16811       11
427 a43af521 27.264, -16.921 66.93754       11
428 a4efec06 26.835, -16.815 63.43196       11
429 a703fca8 27.048, -16.926 71.20597       11
430 bd03ac93 27.014, -16.920 71.20597       11
431 ca4ae55a 26.866, -16.676 68.36250       11
432 d89e31a7 26.955, -16.913 70.25295       11
433 de53b089 27.009, -17.005 69.43579       11
434 dfbc17bf 27.200, -16.919 71.00794       11
435 e50ddf16 26.833, -16.816 63.43196       11
436 e6275eb0 27.127, -16.793 69.24673       11
437 f5997c87 26.975, -16.826 69.10195       11
438 fe7bd547 27.132, -16.913 72.43802       11
439 081ba99c 27.097, -16.935 69.99150       11
440 0c486e63 26.975, -16.762 70.38586       11
441 0da27ae7 26.956, -16.715 69.62228       11
442 1252a40e 26.893, -16.271 51.30970       11
443 196c8dc2 27.279, -16.877 67.82761       11
444 1acdf613 26.912, -16.282 55.04950       11
445 2164a6f6 27.275, -16.874 67.82761       11
446 23aad12f 26.981, -16.913 70.25295       11
447 2d931107 27.041, -17.004 69.43579       11
448 2fd2e505 27.239, -16.756 74.13513       11
449 377e5809 26.955, -16.729 69.62228       11
450 3ee3db75 26.984, -16.944 70.25295       11
451 411c9cad 26.948, -16.927 67.12045       11
452 411e992e 26.978, -16.757 70.38586       11
453 4513d92e 27.128, -16.798 69.24673       11
454 455b9da8 27.024, -16.899 70.63496       11
455 4c1f61f8 26.794, -16.827 57.79966       11
456 54f07739 26.967, -16.821 69.10195       11
457 55dc2d3f 26.965, -16.831 69.10195       11
458 571fc71b 26.898, -16.708 72.95570       11
459 6d1ac34f 26.789, -16.878 58.36053       20
460 6f7993bb 26.834, -16.853 61.28291       11
461 80fa5b78 27.446, -16.286 59.00846       47
462 86955d62 27.303, -16.794 78.28657       11
463 8cc611ed 26.947, -16.483 69.48450       11
464 9e592aed 26.918, -17.051 52.02611       11
465 a347ab0f 26.941, -16.500 69.48450       11
466 c74d0381 26.835, -16.815 63.43196       11
467 c9be2a2e 26.823, -16.608 59.16776       11
468 cf95d0b8 27.004, -16.841 70.56110       11
469 cfa227e3 27.067, -16.988 79.16811       11
470 d18bc770 27.044, -16.930 71.20597       11
471 e7d7f01e 27.296, -16.756 76.04762       11
472 f256785d 26.869, -16.596 73.05731       11
473 f4798847 26.977, -16.819 69.10195       11
474 f8c5930b 26.930, -16.912 67.12045       11
475 0da7a2fd 27.441, -16.291 59.00846       47
476 119ff66f 27.222, -16.929 73.24045       11
477 2e995475 27.114, -16.790 69.24673       11
478 30454c4c 26.823, -16.625 59.16776       11
479 331900d7 26.827, -16.602 59.16776       11
480 44bf7911 26.858, -16.607 66.09323       11
481 49d34672 26.978, -16.756 70.38586       11
482 4ea3b5a7 26.956, -16.913 70.25295       11
483 55b721f3 26.868, -16.617 66.09323       11
484 564a4de5 26.794, -16.827 57.79966       11
485 5c6f191a 27.304, -16.794 78.28657       11
486 638ede33 27.051, -16.840 78.34108       11
487 660bde18 26.830, -16.818 63.43196       11
488 672188d4 27.106, -16.916 72.43802       11
489 673a2e48 26.946, -16.506 72.00297       11
490 7604b41b 26.939, -16.510 72.00297       11
491 801fcb9d 27.114, -16.790 69.24673       11
492 91d2792c 26.837, -16.800 65.26975       11
493 a5bb7274 26.936, -16.744 72.52380       11
494 b007b592 26.858, -16.685 68.36250       11
495 d6d785ac 27.342, -16.774 78.28657       11
496 dbc3667c 27.342, -16.774 78.28657       11
497 e13d623f 26.984, -16.945 70.25295       11
498 f3d8d51a 26.891, -16.710 72.95570       11
499 f60e51e5 26.959, -16.547 74.59067       11
500 f7cad22a 26.952, -16.722 69.62228       11
501 0d998c6c 27.222, -16.930 73.24045       11
502 11ccfb84 27.286, -16.873 67.82761       11
503 26d784d7 27.284, -16.749 80.89200       11
504 3b176c15 27.068, -16.949 69.99150       11
505 4a87393d 26.869, -16.611 66.09323       11
506 579080db 27.061, -16.985 79.16811       11
507 62666abd 26.854, -16.219 53.86879       59
508 66c96afe 26.868, -16.609 66.09323       11
509 7f673186 26.974, -16.554 80.94247       11
510 947482a8 27.255, -16.916 66.93754       11
511 9814974d 26.967, -16.821 69.10195       11
512 a28c4697 27.138, -16.799 69.24673       11
513 a2a144a1 26.862, -16.578 73.05731       11
514 ca1e5256 26.954, -16.700 74.20352       11
515 cf911b7b 26.943, -16.503 72.00297       11
516 d5382add 26.863, -16.620 66.09323       11
517 df467a5c 27.012, -16.944 71.20597       11
518 e56ece45 26.787, -16.860 58.36053       20
519 e7f584e2 26.877, -16.270 51.30970       11
520 e7f9d2f6 26.949, -16.726 72.52380       11
521 fd130085 26.995, -16.954 75.29367       11
522 044f9ff6 26.817, -16.604 59.16776       11
523 0a3d83be 27.252, -16.917 66.93754       11
524 2ddf17ac 26.827, -16.607 59.16776       11
525 4e84b690 27.061, -16.985 79.16811       11
526 5d59103a 27.298, -16.938 66.93754       11
527 7ce943ca 27.282, -16.905 66.93754       11
528 8b5ae414 26.913, -16.525 72.00297       11
529 9497a637 26.896, -16.707 72.95570       11
530 94c05d4e 26.868, -16.617 66.09323       11
531 9502b174 26.934, -16.510 72.00297       11
532 a5f6bf50 27.000, -16.916 70.25295       11
533 b626ceb6 27.247, -16.734 69.78009       11
534 c0a6cc0a 27.285, -16.872 67.82761       11
535 fa8283d2 26.748, -16.865 60.54577       20
536 2b5e2dd8 26.975, -16.826 69.10195       11
537 3f603815 26.828, -16.613 59.16776       11
538 45417d5d 26.827, -16.607 59.16776       11
539 71cf1dea 26.983, -16.944 70.25295       11
540 908ad848 26.977, -16.819 69.10195       11
541 98d64487 26.817, -16.608 59.16776       11
542 11986229   26.95, -16.75 72.52380       11
543 1ae8ed91 26.895, -16.708 72.95570       11
544 1d202f52 26.944, -16.743 72.52380       11
545 22d422e9 27.285, -16.872 67.82761       11
546 368d706a 26.963, -16.708 69.62228       11
547 3d721335 26.834, -16.816 63.43196       11
548 3ddf8640 26.789, -16.877 58.36053       20
549 46d2163d 26.961, -16.921 70.25295       11
550 8ce3d060 26.859, -16.194 57.92710       59
551 9d9960f4 26.789, -16.878 58.36053       20
552 a055b28e 26.875, -16.611 66.09323       11
553 d672e664 26.824, -16.595 66.42364       11
554 d7c10ac8 26.936, -16.744 72.52380       11
555 dc5ee37f 26.968, -16.718 69.62228       11
556 f7425695 26.802, -16.612 59.16776       11
557 6b3963ac 27.298, -16.938 66.93754       11
558 8667383e 27.331, -16.797 78.28657       11
559 9206d4f3 27.039, -16.842 70.56110       11
560 9658c1f9 27.311, -16.798 78.28657       11
561 a3a6a9b3 26.918, -17.053 52.02611       11
562 1a81d9db 27.113, -16.782 69.24673       11
563 1e8cdd0b 26.796, -16.872 58.36053       20
564 3aa32187 27.258, -16.929 66.93754       11
565 477b7e8d 26.813, -16.598 66.42364       11
566 52f393e1 26.915, -16.520 72.00297       11
567 593705a8 26.795, -16.827 57.79966       11
568 73dc6e5b 26.909, -16.248 53.95671       59
569 b01ff38e 26.869, -16.611 66.09323       11
570 fd5c7fc5 26.961, -16.762 70.38586       11
571 0610312c 26.936, -16.744 72.52380       11
572 125aa135 27.090, -16.971 79.16811       11
573 59efe51b 27.128, -16.771 69.24673       11
574 e43938fe 27.139, -16.795 69.24673       11
575 327251ca 26.873, -16.598 73.05731       11
576 18a7611d 27.291, -16.741 80.89200       11
577 2c13d66d 26.975, -16.768 70.38586       11
578 914e67c8 26.961, -16.921 70.25295       11
579 e1825268 26.942, -16.501 72.00297       11
580 fe671804 26.875, -16.611 66.09323       11
581 0d10b051 26.939, -16.510 72.00297       11
582 326c7d48 27.113, -16.782 69.24673       11
583 59f9e56f 26.949, -16.736 72.52380       11
584 897e4909 26.977, -16.819 69.10195       11
585 e9d10913 26.977, -16.819 69.10195       11
586 0db22d41 26.980, -16.748 69.62228       11
587 06feb6e8 32.266, -10.309 36.54598        9
588 3556d951 31.481, -14.034 55.33195       63
589 3704808d 32.252, -10.320 36.54598        9
590 3a8e82af 33.028, -12.156 40.36482       36
591 3ac7b239 33.325, -12.402 42.72912       36
592 46a7f978 28.678, -13.256 63.86148       41
593 58e6bdc7 28.375, -13.336 63.78424       41
594 6259ed92 28.652, -13.385 70.04521       41
595 6bc0a328 28.662, -13.671 73.82898       41
596 6dd49f02 28.694, -13.388 70.04521       41
597 725b0836 32.321, -10.076 32.80511        9
598 74635a76 32.183, -10.610 22.30976        9
599 761655ec 32.183, -10.612 22.30976        9
600 78bc25a2 28.657, -13.671 73.82898       41
601 82db8ad2 27.836, -13.633 79.56444       49
602 8bf1c0c2 28.640, -13.512 72.46116       41
603 9385fcbe 28.646, -13.826 75.62058       41
604 9a9761bb 28.649, -13.836 75.62058       41
605 9d53e0b9 28.657, -13.692 73.82898       41
606 a7b10699 28.649, -13.830 75.62058       41
607 ab7b92b3 32.244, -10.320 33.73501        9
608 ad29db5a 27.921, -13.465 77.63628       49
609 b9ece37c 28.640, -13.544 72.46116       41
610 bc14d354 28.669, -13.230 72.40546       41
611 c1208498 28.688, -13.253 63.86148       41
612 c40143eb 28.660, -13.378 70.04521       41
613 c41a5503 32.315, -10.098 32.80511        9
614 d4bfa888 28.677, -18.222       NA       NA
615 d9f7662d 28.678, -13.221 72.40546       41
616 dbc2d431 32.253, -10.318 36.54598        9
617 f65f5cb6 33.332, -12.408 42.72912       36
618 f8ea87a1 31.311, -14.474 62.22379       63
619 f9e85779 31.216, -14.385 72.91299       63
620 ff09d005 28.438, -13.374 69.39651       49
621 06c32bd5 27.180, -16.913 71.00794       11
622 67b89e9a 26.862, -16.674 68.36250       11
623 a857c6cb 27.039, -16.842 70.56110       11
624 e9f45870 27.043, -16.956 75.39918       11
625 57c1c6e9 27.117, -16.892 76.40279       11
626 019d99f9 24.782, -13.199 55.14384       53
627 02be9843 27.085, -15.407 54.18965       54
628 065cf44d 26.974, -16.766 70.38586       11
629 0fae9736 26.776, -16.413 70.70723       11
630 11ca3539  31.236, -9.360 47.74985       43
631 123d71cb 27.283, -16.872 67.82761       11
632 150ec977 24.781, -13.200 55.14384       53
633 15f36ed3 27.336, -15.193 47.47742       54
634 18e7b7a2 29.069, -13.736 53.63661       45
635 1ad34415 27.094, -16.976 79.16811       11
636 221d7cbe 26.808, -16.585 66.42364       11
637 22bf98e8 29.585, -13.582 63.70206       45
638 234938f6 27.235, -16.732 69.78009       11
639 28b573be 25.489, -12.106 68.82276       71
640 2a4ff8f7 32.252, -10.322 36.54598        9
641 2c4d8b67 32.314, -10.082 32.80511        9
642 2c6fc2b9 26.161, -12.539 62.10518       71
643 2f8a5a25 26.736, -15.060 62.96255       54
644 33d6b30e  31.659, -9.020 31.98688       43
645 36ccf2f8 26.770, -15.083 57.77769       54
646 3730ea50 26.711, -15.713 30.80526       59
647 396e1eec 27.351, -15.212 49.05542       54
648 3c1ce1b6 26.762, -15.749 26.99358       59
649 3ff30f50 26.867, -16.683 68.36250       11
650 401cf5dc 26.936, -16.744 72.52380       11
651 4602c484 25.488, -12.105 68.82276       71
652 4824f655 24.946, -13.169 58.17973       53
653 494a6547 25.369, -13.056 44.26578       53
654 49fcf7a7 26.742, -15.733 30.80526       59
655 4a6c4ac1 25.487, -12.103 68.82276       71
656 4d29e608 26.170, -12.564 51.20012       71
657 4fba5ee7 27.332, -15.189 47.47742       54
658 52ad3248 25.886, -12.327 72.05606       71
659 5321d9df 27.125, -16.784 69.24673       11
660 5608a7b3 27.095, -17.196 77.24889       11
661 5656fd92 27.060, -17.005 78.89503       11
662 5683c0a3 27.141, -17.153 78.16374       11
663 583b4e09 27.348, -15.213 48.29046       54
664 5b8060f8 26.734, -15.734 30.80526       59
665 5d8b2b30 28.937, -13.524 61.80630       41
666 609b90dc 25.877, -12.322 72.05606       71
667 662391ac 26.743, -15.065 62.96255       54
668 66d66f3c 29.047, -13.728 38.58265       45
669 6d5970de 27.331, -15.186 47.47742       54
670 72526a74  31.216, -9.542 44.36200       43
671 74fb45af 27.142, -17.155 78.16374       11
672 7721c946 26.771, -16.394 62.40511       11
673 788cab52 27.140, -17.154 78.16374       11
674 7dcbf58f 27.283, -16.872 67.82761       11
675 7e5b01c5 33.111, -18.111       NA       NA
676 816acafe 26.713, -15.712 30.80526       59
677 85405673  31.202, -9.556 42.81581       43
678 8cd6bd60 25.494, -12.102 68.82276       71
679 8ec3639d 24.784, -13.202 64.42429       53
680 9101ebb4  31.680, -8.997 36.49800       43
681 91afe119 27.183, -16.915 71.00794       11
682 92a9664f 28.903, -13.574 58.78981       45
683 93474fad 26.761, -16.472 69.18250       11
684 93839142 26.702, -16.256 55.25837       11
685 95d5a7e7 24.786, -13.202 64.42429       53
686 9678853b 26.869, -16.619 66.09323       11
687 97f5bf98 26.772, -16.391 62.40511       11
688 98123b60 28.650, -14.697 62.07531        4
689 9a5a547c 26.779, -16.859 58.36053       20
690 9b0033a8 25.488, -12.108 68.82276       71
691 9c6f813f 27.200, -16.913 71.00794       11
692 9c736315 25.884, -12.325 72.05606       71
693 9e5bd11e 26.753, -12.235 62.38456       71
694 9e88a4f7 26.144, -12.556 71.91343       71
695 a00ebbbb 27.353, -15.211 49.05542       54
696 a5db60b7 27.275, -16.884 67.82761       11
697 a6d1ad26 26.775, -12.197 58.64490       71
698 a700a3a1 29.445, -13.991 45.75317       45
699 a8d3bcd6 26.864, -16.662 68.36250       11
700 ad6a6d59 27.285, -16.900 67.82761       11
701 ae41c6d0 26.762, -16.471 69.18250       11
702 b00aed40 26.775, -12.202 62.38456       71
703 b92fc9c0 26.931, -14.519 44.70253       54
704 b9a107a7 28.659, -13.383 70.04521       41
705 ba913ba0 26.860, -16.598 73.05731       11
706 bace1435 24.948, -13.169 58.17973       53
707 bd4009d4 24.999, -13.466 42.21804       53
708 bd435876 27.271, -16.784 76.04762       11
709 be8276ce 26.773, -16.389 62.40511       11
710 be904a62 26.788, -16.843 57.79966       11
711 c0956226 25.002, -13.470 38.48902       53
712 c0b44f43 26.700, -16.253 56.39547       59
713 c0dd9cac 32.311, -10.098 32.80511        9
714 c5911f9d 31.215, -14.386 72.91299       63
715 c98d6fab 26.928, -14.554 56.31413       54
716 cb68f842 28.899, -13.540 63.73785       41
717 cf26e9a5 33.323, -12.405 42.72912       36
718 d1ef6a21 27.091, -15.400 56.95235       54
719 d3256de1 27.338, -15.194 47.47742       54
720 d344fef6 25.002, -13.465 38.48902       53
721 d3e5073a 26.719, -15.722 30.80526       59
722 d547ed48 26.691, -16.262 56.39547       59
723 d5fe7151 27.275, -16.924 66.93754       11
724 d87b2ba4 27.110, -17.202 72.66420       11
725 de703d8d 25.380, -13.056 44.26578       53
726 e199fd8a 33.029, -12.154 40.36482       36
727 e39eb833 25.834, -12.329 61.66153       71
728 e4b16f8e 32.311, -10.087 32.80511        9
729 e4ce7051 25.493, -12.101 68.82276       71
730 e589c762 27.110, -17.205 72.66420       11
731 e912f704 32.839, -12.676 58.93127       36
732 eeb933eb 26.954, -14.507 47.66192       54
733 f172d121 27.271, -16.784 76.04762       11
734 f3af4eba 28.444, -13.387 69.39651       49
735 f4831cde 26.779, -16.419 70.70723       11
736 f6062450 32.189, -10.611 22.30976        9
737 f6685654 33.327, -12.419 42.72912       36
738 fa4c6e6e 26.771, -16.393 62.40511       11
739 fb088f30  31.672, -9.026 31.98688       43
740 fcfcc16c  31.196, -9.562 43.63295       50
741 fe787454 27.275, -16.892 67.82761       11
742 0e05db59 26.933, -16.058 63.05702       59
743 140e3941 25.000, -13.466 42.21804       53
744 1fae151e 28.650, -13.828 75.62058       41
745 26195598 32.252, -10.319 36.54598        9
746 53d0495e 27.285, -16.872 67.82761       11
747 5d05bfc1 32.291, -10.098 36.06217        9
748 5f0d09cc 32.267, -10.310 36.54598        9
749 67f251fe 32.315, -10.088 32.80511        9
750 75111bb0 27.346, -15.223 48.29046       54
751 7c69cff0 26.912, -16.282 55.04950       11
752 a85004ef 26.940, -16.501 72.00297       11
753 ca04c2b6 26.690, -16.252 56.39547       59
754 dcc27ec3 29.578, -13.587 63.70206       45
755 e6c88812 33.327, -12.402 42.72912       36
756 e715af5a 27.242, -16.775 74.13513       11
757 e7e416f5 28.646, -13.529 72.46116       41
758 f9938fa0 29.064, -13.726 53.63661       45
759 260773a1 32.839, -12.675 58.93127       36
760 32daae1b 28.659, -13.693 73.82898       41
761 bfa90e8f 25.880, -12.324 72.05606       71
762 cb6d3906   31.94, -10.65 30.82363        9
763 d5217eeb 27.013, -16.933 71.20597       11
764 e911f934  31.196, -9.562 43.63295       50
765 04845532  31.235, -9.384 47.74985       43
766 63001bed 26.866, -16.590 73.05731       11
767 72b2e62d 25.367, -13.058 44.26578       53
768 74b3735b 26.405, -16.142 56.13718       59
769 b1cebf22  31.217, -9.542 44.36200       43
770 d02e3b93 27.286, -16.932 66.93754       11
771 d3dddce3 27.231, -16.738 69.78009       11
772 1fcb8ab8 26.527, -15.921 40.09698       59
773 3cb24370 32.307, -10.135 27.33848        9
774 4ac54ab4 25.506, -12.114 68.72966       71
775 53e9d1a5 32.187, -10.611 22.30976        9
776 7268663b  31.234, -9.357 47.74985       43
777 8b06cf36 28.912, -13.536 61.80630       41
778 8b9b82d2 26.929, -16.029 63.79404       59
779 b704d152 27.111, -16.787 69.24673       11
780 cc7a4975 28.668, -13.682 73.82898       41
781 2d497f79 29.572, -13.577 63.70206       45
782 b4df829f 27.626, -17.113 58.47983       70
783 1132da30 24.777, -13.199 55.14384       53
784 523f840d 26.405, -16.142 56.13718       59
785 6a906acb  31.196, -9.562 43.63295       50
786 9cc78ee8 27.273, -16.872 67.82761       11
787 c62e8af5 26.926, -14.554 56.31413       54
788 187ad80f 29.585, -13.585 63.70206       45
789 3f286438 32.877, -12.687 60.75867       36
790 7743fc52 31.215, -14.384 72.91299       63
791 a0dba7aa 26.914, -14.515 44.70253       54
792 c133f2bc 26.917, -16.522 72.00297       11
793 cc8a8538 28.371, -13.332 63.78424       41
rm(list = ls())
ls()
character(0)
library(geospaar)
ls()
character(0)
farmers_env
Simple feature collection with 793 features and 3 fields
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 24.777 ymin: -18.222 xmax: 33.332 ymax: -8.997
CRS:           NA
# A tibble: 793 × 4
   uuid             geometry  rain district
 * <chr>             <POINT> <dbl>    <dbl>
 1 009a8424 (27.256 -16.926)  66.9       11
 2 00df166f (26.942 -16.504)  72.0       11
 3 02671a00 (27.254 -16.914)  66.9       11
 4 03f4dcca (27.237 -16.733)  69.8       11
 5 042cf7b3 (27.138 -16.807)  75.1       11
 6 05618404 (26.875 -16.611)  66.1       11
 7 064beba0 (26.752 -16.862)  58.4       20
 8 083a46a2 (26.977 -16.765)  70.4       11
 9 08eb2224 (26.912 -16.248)  54.0       59
10 0ab761d6  (27.113 -16.95)  72.4       11
# ℹ 783 more rows
ls()
character(0)

Raw data in inst/extdata

system.file("extdata", package = "geospaar")
[1] "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/geospaar/extdata"
dir(system.file("extdata", package = "geospaar"))
 [1] "cdf_corn.csv"          "chilanga_farmer"       "chirps.tif"           
 [4] "districts.geojson"     "EJ_POLY.cpg"           "EJ_POLY.dbf"          
 [7] "EJ_POLY.prj"           "EJ_POLY.sbn"           "EJ_POLY.sbx"          
[10] "EJ_POLY.shp"           "EJ_POLY.shp.xml"       "EJ_POLY.shx"          
[13] "FAOSTAT_maize.csv"     "FAOSTAT_sorghum.csv"   "FAOSTAT_wheat.csv"    
[16] "farmer_spatial.csv"    "filt_data.rda"         "roads.geojson"        
[19] "train_reference.csv"   "westluse.rdc"          "westluse.rst"         
[22] "westroad.vct"          "westroad.vdc"          "whittier_down_d_h.rda"
[25] "whittier_mid_d_h.rda"  "whittier_up_d_h.rda"  
f <- system.file("extdata", "farmer_spatial.csv", package = "geospaar")
head(read.csv(f))
      uuid      x       y       date season rained planted
1 009a8424 27.256 -16.926 2015-11-15      1      0       0
2 00df166f 26.942 -16.504 2015-11-15      1      0       0
3 02671a00 27.254 -16.914 2015-11-15      1      0       0
4 03f4dcca 27.237 -16.733 2015-11-15      1      0       0
5 042cf7b3 27.138 -16.807 2015-11-15      1      0       0
6 05618404 26.875 -16.611 2015-11-15      1      0       0

Other package folders

A look at RMarkdown

Chunk options

Rmarkdown demo by Lei Song RMarkdown gallery

RMarkdown exercises

  • In your personal R project, Create new RMarkdown file using usethis::use_vignette(name = "example_vignette")
  • Create chunks for the following:
    • Load the geospaar package
    • Load the chirps data and print its structure using str(chirps)
    • Plot chirps data using raster::plot(chirps). Above this chunk, include a text description for the CHIRPS data using different text formatting (bold, italics, etc). You can see information on the CHIRPS data in the man folder.
    • Include a chunk with an obvious error, like 5 + "string"
    • Try knitting this RMD using different chunk options

The R Ecosystem

The R Ecosystem

Common objects

Credit: L. Song

The R Ecosystem

Data types

There are 6 atomic data types:

  • character e.g. 'hello world', 'abc'
  • double (real or decimal) e.g. 10, 3.14, 1e10
  • integer e.g. 1L
  • logical e.g. TRUE, FALSE, T, F
  • complex e.g. 1 + 3i (not commonly used by us)
  • raw (rarely used by us)

The R Ecosystem

Special data types

  • NULL: Does not exist
  • Missing data: NA. A special logical type that converts into the type it is associated with.
  • Infinity: Inf (e.g. 1 / 0) and -Inf (e.g. -1 / 0. A special double type.
  • Undefined value: NaN. Also a special double type. (e.g. 0 / 0)

The R Ecosystem

Special data types

  • Date: as.Date('1970-1-5')
  • Time: as.POSIXct('1970-1-5')
  • Factor: factors are integers with associated labels.

The R Ecosystem

Checking data type

  • typeof(x)

  • is.xxx(x):

    • e.g. is.double(x), is.integer(x), is.logical(x), is.character(x), is.complex(x), is.raw(x), is.factor

    • is.numeric(x)

    • e.g. is.na(y), is.nan(y), is.null(y), is.infinite(y), is.finite(y).

The R Ecosystem

Converting data type

  • as.xxx(x):

    • e.g. as.numeric(x), as.double(x), as.character(x), as.integer(x), as.logical(x), as.complex(x), as.raw(x), as.factor(x), as.Date(x), as.POSIXct(x).
  • logical < integer < double < character

The R Ecosystem

Data structures

  • Atomic vectors (most commonly thought of kind):

    • A sequence of objects of the same class.

    • Arrays and matrices are vectors with more than one dimension.

      • Matrices have 2 dimensions.
      • Arrays could have higher dimensions.
  • Lists

    • Lists can contain objects of different classes.
    • Lists can be converted list-matrix or list-array by defining dimensions.
    • data.frame and tibble are S3 objects that are lists in tabular form

The R Ecosystem

Vectors

Credit: L. Song

Let’s create some data

  • vector
  • matrix
  • data.frame
  • list

Creating a vector

v1 <- c(1,2,3,4,5)
v2 <- 6:10
print(v1)
[1] 1 2 3 4 5
print(v2)
[1]  6  7  8  9 10

Combining vectors

v1 <- c(1,2,3,4,5)
v2 <- 6:10
v3 <- c(v1, v2)
print(v3)
 [1]  1  2  3  4  5  6  7  8  9 10
print(class(v3))
[1] "numeric"

Combining vectors

What happens when you combine data types in a vector?

v4 <- c(v1, "test")
print(v4)
[1] "1"    "2"    "3"    "4"    "5"    "test"
print(class(v4))
[1] "character"

Vectorized operations

v1 <- 1:9
print(v1)
[1] 1 2 3 4 5 6 7 8 9
print(v1 + 5) ## addition applied to each element in vector
[1]  6  7  8  9 10 11 12 13 14
print(v1 * 3) ## multiplication applied to each element in vector
[1]  3  6  9 12 15 18 21 24 27

Accessing elements in vector

v1 <- (1:9)*3 
print(v1)
[1]  3  6  9 12 15 18 21 24 27
print(v1[4])
[1] 12
v1 <- letters[1:7]
print(paste0("This letter is ", v1)) # paste0 concatenates strings
[1] "This letter is a" "This letter is b" "This letter is c" "This letter is d"
[5] "This letter is e" "This letter is f" "This letter is g"

Question: How would you say “Letter 1 is a”, “Letter 2 is b”, etc.

Creating a matrix

v1 <- 1:9
m1 <- matrix(v1, nrow = 3, byrow = T)
m2 <- cbind(v1 = 1:3, v2 = 1:3, v3 = 0:0)
print(m1)
     [,1] [,2] [,3]
[1,]    1    2    3
[2,]    4    5    6
[3,]    7    8    9
print(m2)
     v1 v2 v3
[1,]  1  1  0
[2,]  2  2  0
[3,]  3  3  0

Accessing elements in a matrix

m2 <- cbind(v1 = 1:3, v2 = 1:3, v3 = 0:0)
print(m2)
     v1 v2 v3
[1,]  1  1  0
[2,]  2  2  0
[3,]  3  3  0
print("first row:")
[1] "first row:"
print(m2[1, ])
v1 v2 v3 
 1  1  0 
print("second column")
[1] "second column"
print(m2[, 2])
[1] 1 2 3
print("access by column name")
[1] "access by column name"
print(m2[, "v2"])
[1] 1 2 3

Question: Create a 3 row, 4 column matrix, where the first column is (1, 2, 3), second column is (4, 5, 6 ) etc.

Lists

Lists can mix object of different types.

l <- list("a", 1, 0.5, TRUE)
print(l)
[[1]]
[1] "a"

[[2]]
[1] 1

[[3]]
[1] 0.5

[[4]]
[1] TRUE
print(str(l)) # structure of l
List of 4
 $ : chr "a"
 $ : num 1
 $ : num 0.5
 $ : logi TRUE
NULL

Lists

Lists can also be nested.

l1 <- list("a", 1, 0.5, TRUE)
l2 <- list(l1, "test", matrix(1:9, nrow = 3)) ## first element of l2 is a list.
print(l2)
[[1]]
[[1]][[1]]
[1] "a"

[[1]][[2]]
[1] 1

[[1]][[3]]
[1] 0.5

[[1]][[4]]
[1] TRUE


[[2]]
[1] "test"

[[3]]
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

Question: what is the length of l1? what is the length of each element of l1? (use length function)

Accessing elements in lists

Use double brackets [[ ]] to access elements in lists.

l1 <- list("a", 1, 0.5, TRUE)
l2 <- list(l1, "test", matrix(1:9, nrow = 3)) ## first element of l2 is a list.
print(l2[[1]])
[[1]]
[1] "a"

[[2]]
[1] 1

[[3]]
[1] 0.5

[[4]]
[1] TRUE
print(l2[[2]])
[1] "test"
print(l2[[3]])
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

Question: The first element of l2 is a list. Access this first element from l2, then the 4th element from l1

Data frames

We will use data frames A LOT. Data frames are really tables, but they are stored in R as lists, with the following conditions.

  • Each element in the list represents a column.
  • Each element in the list is an atomic vector.
  • The length of each vector is the same (the number of rows)
m1 <- cbind(1:3, letters[1:3])
print(m1) # a matrix cannot hold multiple data types. 
     [,1] [,2]
[1,] "1"  "a" 
[2,] "2"  "b" 
[3,] "3"  "c" 
print(class(m1))
[1] "matrix" "array" 
df <- data.frame(numbers = 1:3, abc = letters[1:3])
print(df) # a data frame CAN hold multiple data types. 
  numbers abc
1       1   a
2       2   b
3       3   c
print(class(df))
[1] "data.frame"

Useful functions

  • print
  • You can print just about anything, but as a generic function, print works differently for different types of objects.
a <- "test"
df <- data.frame(numbers = 1:3, abc = letters[1:3])
print(a) # a data frame CAN hold multiple data types. 
[1] "test"
print(df)
  numbers abc
1       1   a
2       2   b
3       3   c
methods(print) ## all the different ways to print...
  [1] print.acf*                                          
  [2] print.activeConcordance*                            
  [3] print.AES*                                          
  [4] print.all_vars*                                     
  [5] print.anova*                                        
  [6] print.any_vars*                                     
  [7] print.aov*                                          
  [8] print.aovlist*                                      
  [9] print.ar*                                           
 [10] print.Arima*                                        
 [11] print.arima0*                                       
 [12] print.AsIs                                          
 [13] print.aspell*                                       
 [14] print.aspell_inspect_context*                       
 [15] print.bbox*                                         
 [16] print.bibentry*                                     
 [17] print.Bibtex*                                       
 [18] print.bootstrap.lca*                                
 [19] print.browseVignettes*                              
 [20] print.by                                            
 [21] print.bytes*                                        
 [22] print.changedFiles*                                 
 [23] print.check_bogus_return*                           
 [24] print.check_code_usage_in_package*                  
 [25] print.check_compiled_code*                          
 [26] print.check_demo_index*                             
 [27] print.check_depdef*                                 
 [28] print.check_details*                                
 [29] print.check_details_changes*                        
 [30] print.check_doi_db*                                 
 [31] print.check_dotInternal*                            
 [32] print.check_make_vars*                              
 [33] print.check_nonAPI_calls*                           
 [34] print.check_package_code_assign_to_globalenv*       
 [35] print.check_package_code_attach*                    
 [36] print.check_package_code_data_into_globalenv*       
 [37] print.check_package_code_startup_functions*         
 [38] print.check_package_code_syntax*                    
 [39] print.check_package_code_unload_functions*          
 [40] print.check_package_compact_datasets*               
 [41] print.check_package_CRAN_incoming*                  
 [42] print.check_package_datalist*                       
 [43] print.check_package_datasets*                       
 [44] print.check_package_depends*                        
 [45] print.check_package_description*                    
 [46] print.check_package_description_encoding*           
 [47] print.check_package_license*                        
 [48] print.check_packages_in_dir*                        
 [49] print.check_packages_used*                          
 [50] print.check_po_files*                               
 [51] print.check_pragmas*                                
 [52] print.check_Rd_line_widths*                         
 [53] print.check_Rd_metadata*                            
 [54] print.check_Rd_xrefs*                               
 [55] print.check_RegSym_calls*                           
 [56] print.check_S3_methods_needing_delayed_registration*
 [57] print.check_so_symbols*                             
 [58] print.check_T_and_F*                                
 [59] print.check_url_db*                                 
 [60] print.check_vignette_index*                         
 [61] print.checkDocFiles*                                
 [62] print.checkDocStyle*                                
 [63] print.checkFF*                                      
 [64] print.checkRd*                                      
 [65] print.checkRdContents*                              
 [66] print.checkReplaceFuns*                             
 [67] print.checkS3methods*                               
 [68] print.checkTnF*                                     
 [69] print.checkVignettes*                               
 [70] print.citation*                                     
 [71] print.classIntervals*                               
 [72] print.cli_ansi_html_style*                          
 [73] print.cli_ansi_string*                              
 [74] print.cli_ansi_style*                               
 [75] print.cli_boxx*                                     
 [76] print.cli_diff_chr*                                 
 [77] print.cli_doc*                                      
 [78] print.cli_progress_demo*                            
 [79] print.cli_rule*                                     
 [80] print.cli_sitrep*                                   
 [81] print.cli_spark*                                    
 [82] print.cli_spinner*                                  
 [83] print.cli_tree*                                     
 [84] print.codoc*                                        
 [85] print.codocClasses*                                 
 [86] print.codocData*                                    
 [87] print.col_spec*                                     
 [88] print.collector*                                    
 [89] print.colorConverter*                               
 [90] print.compactPDF*                                   
 [91] print.condition                                     
 [92] print.connection                                    
 [93] print.CRAN_package_reverse_dependencies_and_views*  
 [94] print.crossdist*                                    
 [95] print.crs*                                          
 [96] print.data.frame                                    
 [97] print.Date                                          
 [98] print.date_names*                                   
 [99] print.default                                       
[100] print.dendrogram*                                   
[101] print.density*                                      
[102] print.difftime                                      
[103] print.dist*                                         
[104] print.Dlist                                         
[105] print.DLLInfo                                       
[106] print.DLLInfoList                                   
[107] print.DLLRegisteredRoutines                         
[108] print.document_context*                             
[109] print.document_position*                            
[110] print.document_range*                               
[111] print.document_selection*                           
[112] print.dplyr_join_by*                                
[113] print.dplyr_sel_vars*                               
[114] print.dummy_coef*                                   
[115] print.dummy_coef_list*                              
[116] print.ecdf*                                         
[117] print.eigen                                         
[118] print.element*                                      
[119] print.evaluate_evaluation*                          
[120] print.factanal*                                     
[121] print.factor                                        
[122] print.family*                                       
[123] print.fclust*                                       
[124] print.fileSnapshot*                                 
[125] print.findLineNumResult*                            
[126] print.flatGridListing*                              
[127] print.formula*                                      
[128] print.fseq*                                         
[129] print.ftable*                                       
[130] print.fun_list*                                     
[131] print.function                                      
[132] print.getAnywhere*                                  
[133] print.ggplot*                                       
[134] print.ggplot2_bins*                                 
[135] print.ggproto*                                      
[136] print.ggproto_method*                               
[137] print.gknn*                                         
[138] print.gList*                                        
[139] print.glm*                                          
[140] print.glue*                                         
[141] print.gpar*                                         
[142] print.GridCoords*                                   
[143] print.GridGrobCoords*                               
[144] print.GridGTreeCoords*                              
[145] print.grob*                                         
[146] print.gtable*                                       
[147] print.hashtab*                                      
[148] print.hclust*                                       
[149] print.help_files_with_topic*                        
[150] print.hexmode                                       
[151] print.hms*                                          
[152] print.HoltWinters*                                  
[153] print.hsearch*                                      
[154] print.hsearch_db*                                   
[155] print.htest*                                        
[156] print.html*                                         
[157] print.html_dependency*                              
[158] print.htmltools.selector*                           
[159] print.htmltools.selector.list*                      
[160] print.ica*                                          
[161] print.infl*                                         
[162] print.integrate*                                    
[163] print.isoreg*                                       
[164] print.json*                                         
[165] print.key_missing*                                  
[166] print.kmeans*                                       
[167] print.knitr_kable*                                  
[168] print.last_dplyr_warnings*                          
[169] print.Latex*                                        
[170] print.LaTeX*                                        
[171] print.lca*                                          
[172] print.libraryIQR                                    
[173] print.lifecycle_warnings*                           
[174] print.listof                                        
[175] print.lm*                                           
[176] print.loadings*                                     
[177] print.locale*                                       
[178] print.loess*                                        
[179] print.logLik*                                       
[180] print.ls_str*                                       
[181] print.m_range*                                      
[182] print.medpolish*                                    
[183] print.MethodsFunction*                              
[184] print.mixed_units*                                  
[185] print.mtable*                                       
[186] print.naiveBayes*                                   
[187] print.NativeRoutineList                             
[188] print.news_db*                                      
[189] print.nls*                                          
[190] print.noquote                                       
[191] print.numeric_version                               
[192] print.object_size*                                  
[193] print.octmode                                       
[194] print.packageDescription*                           
[195] print.packageInfo                                   
[196] print.packageIQR*                                   
[197] print.packageStatus*                                
[198] print.paged_df*                                     
[199] print.pairdist*                                     
[200] print.pairwise.htest*                               
[201] print.path*                                         
[202] print.person*                                       
[203] print.pillar*                                       
[204] print.pillar_1e*                                    
[205] print.pillar_colonnade*                             
[206] print.pillar_ornament*                              
[207] print.pillar_shaft*                                 
[208] print.pillar_squeezed_colonnade*                    
[209] print.pillar_tbl_format_setup*                      
[210] print.pillar_vctr*                                  
[211] print.pillar_vctr_attr*                             
[212] print.POSIXct                                       
[213] print.POSIXlt                                       
[214] print.power.htest*                                  
[215] print.ppr*                                          
[216] print.prcomp*                                       
[217] print.princomp*                                     
[218] print.proc_time                                     
[219] print.proj_pipelines*                               
[220] print.proxy_registry*                               
[221] print.purrr_function_compose*                       
[222] print.purrr_function_partial*                       
[223] print.purrr_rate_backoff*                           
[224] print.purrr_rate_delay*                             
[225] print.quosure*                                      
[226] print.quosures*                                     
[227] print.R6*                                           
[228] print.R6ClassGenerator*                             
[229] print.raster*                                       
[230] print.Rconcordance*                                 
[231] print.Rcpp_stack_trace*                             
[232] print.Rd*                                           
[233] print.recordedplot*                                 
[234] print.registry_entry*                               
[235] print.registry_field*                               
[236] print.rel*                                          
[237] print.restart                                       
[238] print.RGBcolorConverter*                            
[239] print.RGlyphFont*                                   
[240] print.rlang_box_done*                               
[241] print.rlang_box_splice*                             
[242] print.rlang_data_pronoun*                           
[243] print.rlang_dict*                                   
[244] print.rlang_dyn_array*                              
[245] print.rlang_envs*                                   
[246] print.rlang_error*                                  
[247] print.rlang_fake_data_pronoun*                      
[248] print.rlang_lambda_function*                        
[249] print.rlang_message*                                
[250] print.rlang_trace*                                  
[251] print.rlang_warning*                                
[252] print.rlang_zap*                                    
[253] print.rlang:::list_of_conditions*                   
[254] print.rle                                           
[255] print.rlib_bytes*                                   
[256] print.rlib_error_3_0*                               
[257] print.rlib_trace_3_0*                               
[258] print.roman*                                        
[259] print.scalar*                                       
[260] print.sessionInfo*                                  
[261] print.sf*                                           
[262] print.sf_layers*                                    
[263] print.sfc*                                          
[264] print.sfg*                                          
[265] print.sgbp*                                         
[266] print.shiny.tag*                                    
[267] print.shiny.tag.env*                                
[268] print.shiny.tag.list*                               
[269] print.shiny.tag.query*                              
[270] print.simil*                                        
[271] print.simple.list                                   
[272] print.smooth.spline*                                
[273] print.socket*                                       
[274] print.src*                                          
[275] print.srcfile                                       
[276] print.srcref                                        
[277] print.stepfun*                                      
[278] print.stl*                                          
[279] print.stringr_view*                                 
[280] print.StructTS*                                     
[281] print.subdir_tests*                                 
[282] print.summarize_CRAN_check_status*                  
[283] print.summary.aov*                                  
[284] print.summary.aovlist*                              
[285] print.summary.ecdf*                                 
[286] print.summary.glm*                                  
[287] print.summary.lca*                                  
[288] print.summary.lm*                                   
[289] print.summary.loess*                                
[290] print.summary.manova*                               
[291] print.summary.nls*                                  
[292] print.summary.packageStatus*                        
[293] print.summary.ppr*                                  
[294] print.summary.pr_DB*                                
[295] print.summary.prcomp*                               
[296] print.summary.princomp*                             
[297] print.summary.svm*                                  
[298] print.summary.table                                 
[299] print.summary.tune*                                 
[300] print.summary.warnings                              
[301] print.summaryDefault                                
[302] print.svm*                                          
[303] print.table                                         
[304] print.tables_aov*                                   
[305] print.tbl*                                          
[306] print.terms*                                        
[307] print.theme*                                        
[308] print.tidyverse_conflicts*                          
[309] print.tidyverse_logo*                               
[310] print.transform*                                    
[311] print.trunc_mat*                                    
[312] print.ts*                                           
[313] print.tskernel*                                     
[314] print.TukeyHSD*                                     
[315] print.tukeyline*                                    
[316] print.tukeysmooth*                                  
[317] print.tune*                                         
[318] print.undoc*                                        
[319] print.uneval*                                       
[320] print.unit*                                         
[321] print.units*                                        
[322] print.vctrs_bytes*                                  
[323] print.vctrs_sclr*                                   
[324] print.vctrs_unspecified*                            
[325] print.vctrs_vctr*                                   
[326] print.viewport*                                     
[327] print.vignette*                                     
[328] print.warnings                                      
[329] print.xfun_md_viewable*                             
[330] print.xfun_raw_string*                              
[331] print.xfun_record_results*                          
[332] print.xfun_rename_seq*                              
[333] print.xfun_strict_list*                             
[334] print.xgettext*                                     
[335] print.xngettext*                                    
[336] print.xtabs*                                        
[337] print.z_range*                                      
see '?methods' for accessing help and source code

Examining objects

  • ls, class, str
a <- "test"
df <- data.frame(numbers = 1:3, abc = letters[1:3])
ls() ## list objects in global environemtn
 [1] "a"  "df" "f"  "l"  "l1" "l2" "m1" "m2" "v1" "v2" "v3" "v4"
class(df) ## class
[1] "data.frame"
str(df) ## structure
'data.frame':   3 obs. of  2 variables:
 $ numbers: int  1 2 3
 $ abc    : chr  "a" "b" "c"

Sampling

  • Sample without replacement
set.seed(1234) ## set a random seed
v <- 1:100
s <- sample(v, 50)
print(s)
 [1] 28 80 22  9  5 38 16  4 86 90 70 79 78 14 56 62 93 84 21 40 92 67 96 66 47
[26] 81 48  3 41 32 42 43  2 54 49 99 51  6 77 29 71 85 57  8 26 17 58 91 60 76
print(sort(s))
 [1]  2  3  4  5  6  8  9 14 16 17 21 22 26 28 29 32 38 40 41 42 43 47 48 49 51
[26] 54 56 57 58 60 62 66 67 70 71 76 77 78 79 80 81 84 85 86 90 91 92 93 96 99
  • Sample with replacement
s2 <- sample(v, 50, replace = T)
print(sort(s2))
 [1]  2  3  3  6  6  9 10 17 17 19 20 22 22 25 27 28 30 32 35 36 41 41 48 50 51
[26] 55 57 58 58 60 61 63 63 65 66 70 70 71 72 76 77 80 83 85 85 86 86 87 90 96

Does S2 have duplicates?

s2_unique <- unique(s2)
print(length(s2))
[1] 50
print(length(s2_unique))
[1] 40
print(length(s2) == length(s2_unique))
[1] FALSE