Logistic models
To run your code, click run. It will let you know if your code is correct or not, and will offer hints on what to fix if needed. If you are stuck, you can see the solution by clicking Solution.
Exercise 1: Using mutate()
Reminder:
\[
yoy\_growth = \frac{level_t - level_{t-4}}{level_{t-4}}
\]
eyJsYW5ndWFnZSI6InIiLCJwcmVfZXhlcmNpc2VfY29kZSI6ImRmIDwtIGRhdGEuZnJhbWUodGljPXJlcChcIldNVFwiLDE5NCksXG4gICAgICAgICAgICAgICAgIGZ5ZWFycT1jKDE5NzAsMTk3MCwxOTcwLDE5NzAsMTk3MSwxOTcxLDE5NzEsMTk3MSwxOTcyLDE5NzIsMTk3MiwxOTcyLDE5NzMsMTk3MywxOTczLDE5NzMsMTk3NCwxOTc0LDE5NzQsMTk3NCwxOTc1LDE5NzUsMTk3NSwxOTc1LDE5NzYsMTk3NiwxOTc2LDE5NzYsMTk3NywxOTc3LDE5NzcsMTk3NywxOTc4LDE5NzgsMTk3OCwxOTc4LDE5NzksMTk3OSwxOTc5LDE5NzksMTk4MCwxOTgwLDE5ODAsMTk4MCwxOTgxLDE5ODEsMTk4MSwxOTgxLDE5ODIsMTk4MiwxOTgyLDE5ODIsMTk4MywxOTgzLDE5ODMsMTk4MywxOTg0LDE5ODQsMTk4NCwxOTg0LDE5ODUsMTk4NSwxOTg1LDE5ODUsMTk4NiwxOTg2LDE5ODYsMTk4NiwxOTg3LDE5ODcsMTk4NywxOTg3LDE5ODgsMTk4OCwxOTg4LDE5ODgsMTk4OSwxOTg5LDE5ODksMTk4OSwxOTkwLDE5OTAsMTk5MCwxOTkwLDE5OTEsMTk5MSwxOTkxLDE5OTEsMTk5MiwxOTkyLDE5OTIsMTk5MiwxOTkzLDE5OTMsMTk5MywxOTkzLDE5OTQsMTk5NCwxOTk0LDE5OTQsMTk5NSwxOTk1LDE5OTUsMTk5NSwxOTk2LDE5OTYsMTk5NiwxOTk2LDE5OTcsMTk5NywxOTk3LDE5OTcsMTk5OCwxOTk4LDE5OTgsMTk5OCwxOTk5LDE5OT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0aW9uKCdwYWNrYWdlJywgbm90X2NhbGxlZF9tc2c9JycsaW5jb3JyZWN0X21zZz0nJylcbiMgICAgIC0gdGVzdF9pZl9lbHNlKCkgLS0gY2hlY2tpbmcgaWYgc3RhdGVtZW50c1xuIyAgICAgLSB0ZXN0X2V4cHJlc3Npb25fZXJyb3IoKSAtLSBjYW4gY2hlY2sgaWYgZnVuY3Rpb25zIGFyZSBwcm9wZXJseSBkZWZpbmVkXG4jICAgICAtIHRlc3Rfb3BlcmF0b3IoJ29wZXJhdG9yJywpLCBub3RfY2FsbGVkX21zZz0nJyxpbmNvcnJlY3RfbXNnPScnKVxuIyAgICAgLSB0ZXN0X2Z1bmN0aW9uX2RlZmluaXRpb24oKSAtLSByaWdvcm91c2x5IGNoZWNrIGRlZmluZWQgZnVuY3Rpb25cbiMgICAgIC0gdGVzdF9kYXRhX2ZyYW1lKCkgLS0gY2hlY2sgaWYgZGF0YWZyYW1lIFtjb2x1bW5zXSBhcmUgZXF1aXZhbGVudFxuIyAgICAgLSB0ZXN0X2Z1bmN0aW9uX3Jlc3VsdCwgdGVzdF9leHByZXNzaW9uX3Jlc3VsdCJ9
Visualization with maps
Exercise 3: Using Plotly for maps
NOTE: Unforetunately, though DataCamp light has plotly
installed, it doesn’t work at present (plots don’t open). As such, we can’t run this here and see any output. Instead, you can download this file, load the file into R with load.csv()
, and then run the code given below. Alternatively, you can download this Rmd file containing this exercise’s code. The output of the code is available here.
You will need plotly
installed to run the code. If you do not have it installed, run install.packages("plotly")
.
eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiIjIFRoZSBmaWxlIG1nLmNzdiBjb250YWlucyB0aGUgZm9sbG93aW5nIGluZm9ybWF0aW9uIGZvciBUeXBob29uIE1hbmdraHV0OlxuIyAgICAgLSBsYXQ6IGxhdGl0dWRlXG4jICAgICAtIGxvbjogbG9uZ2l0dWRlIChmaXhlZClcbiMgICAgIC0gZHQ6IERhdGUgdGltZSBpbiBmb3JtYXQgXCIlWSViJW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Y29sb3IgPSB0b1JHQihcImdyYXk0MFwiKSxcbiAgICBncmlkd2lkdGggPSAwLjVcbiAgKSxcbiAgbGF0YXhpcyA9IGxpc3QoXG4gICAgc2hvd2dyaWQgPSBUUlVFLFxuICAgIGdyaWRjb2xvciA9IHRvUkdCKFwiZ3JheTQwXCIpLFxuICAgIGdyaWR3aWR0aCA9IDAuNVxuICApXG4pXG5cblxuIyBQbG90XG5wbG90X2dlbygpICU+JVxuICBhZGRfbWFya2VycyhkYXRhPW1nLFxuICAgICAgICAgICAgICB4ID0gfmxvbixcbiAgICAgICAgICAgICAgeSA9IH5sYXQsXG4gICAgICAgICAgICAgIHRleHQ9fnBhc3RlKFwiVGltZTogXCIsIGR0KSkgJT4lXG4gIGxheW91dChzaG93bGVnZW5kID0gVFJVRSwgZ2VvID0gZ2VvLFxuICAgIHRpdGxlID0gJ1R5cGhvb24gTWFuZ2todXQsIHRocm91Z2ggMjAxOCBTZXB0IDE3JylcbiNFTkQifQ==
Exercise 4: Plotting with leaflet…
NOTE: Unforetunately, DataCamp light doesn’t have leaflet
installed. As such, we can’t run this here. If you would like to see a nice graph of this in leaflet, you can download this file, load the file into R with load.csv()
, and then run the code given below. Alternatively, you can download this Rmd file containing this exercise’s code. The output of the code is available here.
You will need leaflet
installed to run the code. If you do not have it installed, run install.packages("leaflet")
The third map also requires leaflet.extras
installed. If you do not have it installed, run install.packages("leaflet.extras")
eyJsYW5ndWFnZSI6InIiLCJzYW1wbGUiOiIjIFRoZSBmaWxlIG1nLmNzdiBjb250YWlucyB0aGUgZm9sbG93aW5nIGluZm9ybWF0aW9uIGZvciBUeXBob29uIE1hbmdraHV0OlxuIyAgICAgLSBsYXQ6IGxhdGl0dWRlXG4jICAgICAtIGxvbjogbG9uZ2l0dWRlIChmaXhlZClcbiMgICAgIC0gZHQ6IERhdGUgdGltZSBpbiBmb3JtYXQgXCIlWSViJWQgJUglTSVTXCJcbm1nIDwtIHJlYWQuY3N2KFwibWcuY3N2XCIpXG5cb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