Table of Contents
-
cRaggy is Back - Looking at Housing and Evictions in King County
-
3.1 Add your code to the existing source code
3.2 Use thecraggy2019
package from your own independent project
Disclaimer: this package is experimental and intended for use simply as an informal exercise for working with data in the R language. Read the NEWS.md for recent updates.
cRaggy, our data exploration and visualization activity is back! For those of you unfamiliar with cRaggy, the Portland R User Group makes a large dataset available for visualization and analysis, so that you can present and share your results, visualizations, and insights about the dataset.
We will be looking at a combination of housing data and eviction data for King County, Washington, United States, hoping to gain insights about the nature of evictions in King County. This dataset comes courtesy of the planners of the 2019 Symposium for Data Science and Statistics.
We encourage you to collaborate together and work on visualizations! Our goal is to encourage collaboration and share our code and insights.
In September, we'll have a visualization gallery and lightning talks about the visualizations and insights you've come up with. Event information will be posted on our Meetup page.
All are welcome. Participation in cRaggy requires agreeing to the Code of Conduct
King County Eviction Data for cRaggy 2019.
This dataset came from the SDSS 2019 Data Hack Activity.
This project is organized as an R package, which contains the data and includes some examples of reading, exploring, analyzing, and visualizing the data. There are several ways to use this project.
Context: You want to use the existing sample code and write your own code within the same source structure of this package. You might want to contribute some of your code back to this project, but you are not sure about that yet.
Solution: Fork the project, so that you can work in your own version. A "fork" is linked back to the original code, so that you can contribute changes later, if you so choose, by making a Pull Request.
- Fork this project, which creates a separate copy in your Github account.
- Clone the repository that is now forked in your Github account to your local machine.
- Open the copy on your local machine in RStudio.
- Click on the
Build > Install and Restart
button, which in the default application configuration is in theEnvironment, History, ...
pane in the upper right of the application window. - The package will be built, installed in your local package library, and loaded into your session. When you see
library(craggy2019)
executed in the console, then the build and load is complete and your environment is ready for you to use the package. - Now you can use the base::system.file function to reference a data file within the loaded package. For example,
This will read data from the loaded package in the R Session, not from the file system.
readr::read_csv(system.file("extdata", "evictions.csv", package = "craggy2019"))
- Alternatively, you can refer to the data files through the file system in the
inst/extdata
directory. For example,here::here("inst", "extdata", "evictions.csv")`.
- As you write code and perhaps add more data, you will commit those changes with
git
on your local machine. From time to time, you should push those changes to your Github account. Since you forked the project, those changes will only affect your repository, not the pdxlang/craggy_2019 repository from which you forked. - As mentioned previously, you can make a Pull Request from your forked repository to the original pdxlang/craggy_2019 repository, in order to have your code merged into the original source. However, we do not explain how to do that here.
Context: You already have a project where you want to write code to read, explore, analyze, and visualize the Evictions data. You do not want to write your code within the framework of this craggy2019
package source code.
Solution: You need to install and load this craggy2019
package in your local environment, so that you can access the data that it contains. However, you do not need to fork or clone the pdxlang/craggy_2019 repository.
- Install the
craggy2019
package:install.packages("remotes") library(remotes) remotes::install_github("pdxrlang/craggy_2019") # Note: Unfortunately, the repository name and package name do not match! library(craggy2019)
- Now you can use the base::system.file function to reference a data file within the package. For example,
This will read data from the loaded package in the R Session, not from the file system.
readr::read_csv(system.file("extdata", "evictions.csv", package = "craggy2019"))
- FYI: With system.file, you do not reference the
inst
directory level, which is the root level for the data files in the source code, but it is not the root level for the data in the loaded package. When a package is loaded, everything within theinst
directory is placed at the root level of the package. So you start at theextdata
directory level, which is the level that holds all of the data files that we are using for this project. - FYI:
inst/extdata
is the R package convention for where data is placed within a package. Almost all packages follow that convention, so we followed it for this project too.
These examples can help you start analyzing the data:
- Hosted burro demo: Browse King County evictions data.
- Run burro in your local environment.
- Introduction to Geospatial Visualization for the King County data.
- Read data from the
oneNightCount.csv
file with vroom and summarize the contents with skimr and inspectdf.
See the NEWS for recent code changes, as well as links to resources outside of this project.
This code is licensed under the MIT License.