Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
.Rhistory
.RData
.Ruserdata

.DS_Store
Thumbs.db
.httr-oauth
/public/
/resources/

content/post/.DS_Store

Expand Down
6 changes: 3 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
baseurl: /
baseurl: https://trusting-payne-5ce5b1.netlify.app/
languageCode: en-us
title: A Hugo website
theme: hugo-lithium
Expand All @@ -17,9 +17,9 @@ menu:
- name: About
url: /about/
- name: GitHub
url: https://github.com/rstudio/blogdown
url: https://github.com/dwfainstein/finalproject_653
- name: Twitter
url: https://twitter.com/rstudio
url: https://twitter.com/TeachAbilities
params:
MathJaxCDN: //cdnjs.cloudflare.com/ajax/libs
MathJaxVersion: 2.7.5
Expand Down
45 changes: 22 additions & 23 deletions content/post/2021-06-01-importing-strava-data/index.Rmarkdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ knitr::opts_chunk$set(echo = TRUE)

# Importing Strava data for use with RStudio

This blog post will guide you the somewhat complicated process of bringing in your own personal Strava data for use within the RStudio environment. To begin, you will need to have two things: an active Strava account and an RStudio .Rmd ready to use.
This blog post will guide you through the somewhat complicated process of bringing in your own personal Strava data to analyze with R. To begin, you will need to have two things: an active Strava account and an RStudio `.Rmd` ready to use.

This post will cover two distinct two ways to download your data.

[The first method: complex and limited (but small!)](#the-first-method-complex-and-limited-but-small) is somewhat complex, and uses API calls to return a dataframe containing a fairly limited set of information: Distance, speed, duration, elevation, location, and time.
[The first method](#the-first-method-complex-and-limited-but-small) is somewhat complex, and uses API calls to return a data frame containing a fairly limited set of information: Distance, speed, duration, elevation, location, and time.

[The second method: quick and easy, but can be a very large download!] (just threaten to delete your account and they will give you an option to download all data they have collected!) and returns a much larger set of information...all of the preceding information, plus entire route maps for each activity, as well any photos you uploaded to Strava with those activities.
[The second method](#the-second-method-quick-and-easy-but-can-be-a-very-large-download) threatens to delete your account, but they give you an option to download all data they have collected! It returns a much larger set of information...all of the preceding information, plus entire route maps for each activity, as well any photos you uploaded to Strava with those activities.

## The first method: complex and limited (but small!) {#the-first-method-complex-and-limited-but-small}

First, visit <https://www.strava.com/settings/api>.

If you are not logged in, it will prompt you to enter your login credentials. Once you are logged in, you will be taken to the Strava page to create an API Application.

<center>


![initial API screen](img/shot1.png)

</center>


You will need to enter some basic information to complete this process.

Expand All @@ -57,21 +57,21 @@ For the **authorization callback domain**, enter *developers.strava.com.*

When you are done, you should have it filled out something like this:

<center>


![completed API creation form](img/shot2.png)

</center>


When you click on Create, it will ask you to update your app icon. You can add any image file you like, and then it will take you to a screen listing your information.

<center>


![click to reveal the secret!](img/shot4.png)

</center>

For the next step, you will need to show your **Client Secret**, which will display a long alphanumeric string that is unique to you. This allows RStudio to talk to Strava for the initial handshake, verifying your identity and allowing RStudio to pull your data.

For the next step, you will need to show your **Client Secret**, which will display a long alphanumeric string that is unique to you. This allows R to talk to Strava for the initial handshake, verifying your identity and allowing R to pull your data.

In your .Rmd, add the following lines of code:

Expand Down Expand Up @@ -125,43 +125,43 @@ Some things to note: be sure to enter your own **Application Name**, **Client ID

Check both boxes, and then click Authorize to link Strava with your data.

<center>


![click to authorize](img/shot5.png)

</center>


After the Authorization is complete, you will have a file called *stoken* appear in your working environment. Once that file is in place, you can comment out the two lines of code directly under the spot where you entered your Client Secret. You will see a little note there that it only needs to happen once:

\#create the authentication token (only once)
`#create the authentication token (only once)`

Once you run that chunk, it will download your data into a dataframe called "**data_df.Rda**" which a simple click will add to RStudio for your continued exploration.

<br> <br>

## The second method: quick and easy, but can be a very large download!

This method is pretty simple. Simply visit <https://www.strava.com/athlete/delete_your_account> and scroll down a bit to the *Download Request* section.
This method is pretty simple. Visit <https://www.strava.com/athlete/delete_your_account> and scroll down a bit to the *Download Request* section.


<center>

![But I don't want to delete my account!](img/shot7.png)

</center>


Click on the Request Your Archive button, and they will prepare your archive and email you a download link to the email they have on file. Make sure your email address is up to date!

<center>


![Seven days to get this done!](img/shot8.png)

</center>


Soon, you will get a download link in your email. Click to download, and you will soon have a folder full of everything that Strava has collected on you as an athlete.

The most useful files for Rstudio will the .csv that houses all of your activity data, and the .gpx files that contain a fairly complete map every individual activity.
The most useful files will be the `.csv` that houses all of your activity data, and the `.gpx` files that contain a fairly complete map of every individual activity.

To add the .csv file, make sure that activities.csv file is housed in a **data** folder in your project directory, and then run the following code:
To add the `.csv` file, make sure that `activities.csv` file is housed in a **data** folder in your project directory, and then run the following code:

```{r importing desired data fields, eval=FALSE}
library(readr)
Expand All @@ -174,14 +174,13 @@ activities <- read_csv("data/activities.csv",
`Distance` =col_number(),
`Elevation Gain` =col_number()))
View(activities)

```

Once you have done that, you should have a .csv file with all of your activities. If you would also like to work with the .gpx files for detailed maps of everything you've done, the following code will do the trick:
Once you have done that, you should have a `.csv` file with all of your activities. If you would also like to work with the `.gpx` files for detailed maps of everything you've done, the following code will do the trick:

```{r bringing in the gpx data, eval=FALSE}
gpxdata <- process_data("data/activities_gpx")
#gpxdata <- slice(gpxdata, -c(63744, 63745, 63746)) YOU MIGHT NEED TO USE SOMETHINNG LIKE THIS LINE IF YOU BRING IN IN ANY BAD DATA...I DID
```

You will have to wait a while, as this is quite a large file to bring in...but once it is in, you will have quite a few options for manipulating your data! As a first step, you will want to tidy your imported data. See David's informative blog post for more details on how to do that.
You will have to wait a while, as this is quite a large file to bring in...but once it is in, you will have quite a few options for manipulating your data! As a first step, you will want to tidy your imported data. See [David's informative blog post](/2021/06/02/tidying-and-wrangling-strava-data/) for more details on how to do that.
46 changes: 23 additions & 23 deletions content/post/2021-06-01-importing-strava-data/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ tags: []

# Importing Strava data for use with RStudio

This blog post will guide you the somewhat complicated process of bringing in your own personal Strava data for use within the RStudio environment. To begin, you will need to have two things: an active Strava account and an RStudio .Rmd ready to use.
This blog post will guide you through the somewhat complicated process of bringing in your own personal Strava data to analyze with R. To begin, you will need to have two things: an active Strava account and an RStudio `.Rmd` ready to use.

This post will cover two distinct two ways to download your data.

[The first method: complex and limited (but small!)](#the-first-method-complex-and-limited-but-small) is somewhat complex, and uses API calls to return a dataframe containing a fairly limited set of information: Distance, speed, duration, elevation, location, and time.
[The first method](#the-first-method-complex-and-limited-but-small) is somewhat complex, and uses API calls to return a data frame containing a fairly limited set of information: Distance, speed, duration, elevation, location, and time.

[The second method: quick and easy, but can be a very large download!] (just threaten to delete your account and they will give you an option to download all data they have collected!) and returns a much larger set of information...all of the preceding information, plus entire route maps for each activity, as well any photos you uploaded to Strava with those activities.
[The second method](#the-second-method-quick-and-easy-but-can-be-a-very-large-download) threatens to delete your account, but they give you an option to download all data they have collected! It returns a much larger set of information...all of the preceding information, plus entire route maps for each activity, as well any photos you uploaded to Strava with those activities.

## The first method: complex and limited (but small!) {#the-first-method-complex-and-limited-but-small}

First, visit <https://www.strava.com/settings/api>.

If you are not logged in, it will prompt you to enter your login credentials. Once you are logged in, you will be taken to the Strava page to create an API Application.
If you are not logged in, it will prompt you to enter your login credentials. Once you are logged in, you will be taken to the Strava page to create an API Application.


<center>

![initial API screen](img/shot1.png)

</center>


You will need to enter some basic information to complete this process.

Expand All @@ -53,21 +53,21 @@ For the **authorization callback domain**, enter *developers.strava.com.*

When you are done, you should have it filled out something like this:

<center>


![completed API creation form](img/shot2.png)

</center>


When you click on Create, it will ask you to update your app icon. You can add any image file you like, and then it will take you to a screen listing your information.

<center>


![click to reveal the secret!](img/shot4.png)

</center>

For the next step, you will need to show your **Client Secret**, which will display a long alphanumeric string that is unique to you. This allows RStudio to talk to Strava for the initial handshake, verifying your identity and allowing RStudio to pull your data.

For the next step, you will need to show your **Client Secret**, which will display a long alphanumeric string that is unique to you. This allows R to talk to Strava for the initial handshake, verifying your identity and allowing R to pull your data.

In your .Rmd, add the following lines of code:

Expand Down Expand Up @@ -121,43 +121,43 @@ Some things to note: be sure to enter your own **Application Name**, **Client ID

Check both boxes, and then click Authorize to link Strava with your data.

<center>


![click to authorize](img/shot5.png)

</center>


After the Authorization is complete, you will have a file called *stoken* appear in your working environment. Once that file is in place, you can comment out the two lines of code directly under the spot where you entered your Client Secret. You will see a little note there that it only needs to happen once:

\#create the authentication token (only once)
`#create the authentication token (only once)`

Once you run that chunk, it will download your data into a dataframe called "**data_df.Rda**" which a simple click will add to RStudio for your continued exploration.

<br> <br>

## The second method: quick and easy, but can be a very large download!

This method is pretty simple. Simply visit <https://www.strava.com/athlete/delete_your_account> and scroll down a bit to the *Download Request* section.
This method is pretty simple. Visit <https://www.strava.com/athlete/delete_your_account> and scroll down a bit to the *Download Request* section.


<center>

![But I don't want to delete my account!](img/shot7.png)

</center>


Click on the Request Your Archive button, and they will prepare your archive and email you a download link to the email they have on file. Make sure your email address is up to date!

<center>


![Seven days to get this done!](img/shot8.png)

</center>


Soon, you will get a download link in your email. Click to download, and you will soon have a folder full of everything that Strava has collected on you as an athlete.

The most useful files for Rstudio will the .csv that houses all of your activity data, and the .gpx files that contain a fairly complete map every individual activity.
The most useful files will be the `.csv` that houses all of your activity data, and the `.gpx` files that contain a fairly complete map of every individual activity.

To add the .csv file, make sure that activities.csv file is housed in a **data** folder in your project directory, and then run the following code:
To add the `.csv` file, make sure that `activities.csv` file is housed in a **data** folder in your project directory, and then run the following code:


```r
Expand All @@ -173,12 +173,12 @@ activities <- read_csv("data/activities.csv",
View(activities)
```

Once you have done that, you should have a .csv file with all of your activities. If you would also like to work with the .gpx files for detailed maps of everything you've done, the following code will do the trick:
Once you have done that, you should have a `.csv` file with all of your activities. If you would also like to work with the `.gpx` files for detailed maps of everything you've done, the following code will do the trick:


```r
gpxdata <- process_data("data/activities_gpx")
#gpxdata <- slice(gpxdata, -c(63744, 63745, 63746)) YOU MIGHT NEED TO USE SOMETHINNG LIKE THIS LINE IF YOU BRING IN IN ANY BAD DATA...I DID
```

You will have to wait a while, as this is quite a large file to bring in...but once it is in, you will have quite a few options for manipulating your data! As a first step, you will want to tidy your imported data. See David's informative blog post for more details on how to do that.
You will have to wait a while, as this is quite a large file to bring in...but once it is in, you will have quite a few options for manipulating your data! As a first step, you will want to tidy your imported data. See [David's informative blog post](/2021/06/02/tidying-and-wrangling-strava-data/) for more details on how to do that.
6 changes: 4 additions & 2 deletions content/post/2021-06-01-parallel-iteration/index.Rmarkdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Earlier in our blog series, you can read a post on how we used API calls to brin

```{r firststep}
#reading in data for sandbox
strav_data <- read_csv(here("content/post/2021-04-16-functional-programming-with-strava-data/data", "strav_csv.csv"))
strav_data <- read_csv(here("static", "data", "strav_csv.csv"))

tidyfunc <- strav_data %>%
select(where(~length(unique(.)) > 1)) %>%
Expand Down Expand Up @@ -86,6 +86,7 @@ oneplot <- tidy_data %>%
subtitle = "Data displays trends found within the week",
x = "",
y = "Number of Hikes")
oneplot
```

Now we will create a parallel iteration of the data by grouping by activity and nesting. This will create a data frame with individual frames nested within it categorized by activity. By doing this, we are able to produce separate plots displaying weekly data for each activity type.
Expand All @@ -99,7 +100,7 @@ final_plots <-
nest() %>%
mutate(plots = map2(data, act_type, ~{
ggplot(.x, aes(weekday)) +
geom_histogram(stat = "count") +
geom_bar(stat = "count") +
labs(title = glue("Amount of {.y} activity over the week"),
subtitle = "Data displays trends found within the week",
x = "",
Expand All @@ -109,6 +110,7 @@ final_plots <-
#display a plot. To change which activity you are able to view, change the number within the brackets.
weeklydata$plots[[2]]

weeklydata$plots[[4]]
```

The final step is to save all of the plots. We will do this in three steps:
Expand Down
11 changes: 10 additions & 1 deletion content/post/2021-06-01-parallel-iteration/index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ oneplot <- tidy_data %>%
subtitle = "Data displays trends found within the week",
x = "",
y = "Number of Hikes")
oneplot
```

<img src="{{< blogdown/postref >}}index_files/figure-html/one plot-1.png" width="672" />

Now we will create a parallel iteration of the data by grouping by activity and nesting. This will create a data frame with individual frames nested within it categorized by activity. By doing this, we are able to produce separate plots displaying weekly data for each activity type.


Expand All @@ -54,7 +57,7 @@ final_plots <-
nest() %>%
mutate(plots = map2(data, act_type, ~{
ggplot(.x, aes(weekday)) +
geom_histogram(stat = "count") +
geom_bar(stat = "count") +
labs(title = glue("Amount of {.y} activity over the week"),
subtitle = "Data displays trends found within the week",
x = "",
Expand All @@ -67,6 +70,12 @@ weeklydata$plots[[2]]

<img src="{{< blogdown/postref >}}index_files/figure-html/multiple plots-1.png" width="672" />

```r
weeklydata$plots[[4]]
```

<img src="{{< blogdown/postref >}}index_files/figure-html/multiple plots-2.png" width="672" />

The final step is to save all of the plots. We will do this in three steps:
1. create a directory within your machine's files
2. create file paths for the plots to follow
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
308 changes: 0 additions & 308 deletions content/post/2021-06-01-ridgeline-plots/index.html

This file was deleted.

269 changes: 0 additions & 269 deletions content/post/2021-06-08-oh-snap-it-is-bonus-content/index.html

This file was deleted.

Loading