Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #62 from ropensci/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bretsw authored Aug 6, 2022
2 parents b983839 + 28207fd commit 65b681f
Show file tree
Hide file tree
Showing 33 changed files with 486 additions and 1,345 deletions.
17 changes: 4 additions & 13 deletions .github/workflows/with-real-requests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ jobs:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
VCR_TURN_OFF: true
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
OPENCAGE_KEY: ${{ secrets.OPENCAGE_KEY }}
TWITTER_APP: ${{ secrets.TWITTER_APP }}
TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
TWITTER_API_SECRET: ${{ secrets.TWITTER_API_SECRET }}
TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_BEARER_TOKEN: ${{ secrets.TWITTER_BEARER_TOKEN }}

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -65,12 +59,9 @@ jobs:

- name: Create rtweet token
run: |
token <- rtweet::create_token(
app = Sys.getenv('TWITTER_APP'),
consumer_key = Sys.getenv('TWITTER_API_KEY'),
consumer_secret = Sys.getenv('TWITTER_API_SECRET'),
access_token = Sys.getenv('TWITTER_ACCESS_TOKEN'),
access_secret = Sys.getenv('TWITTER_ACCESS_TOKEN_SECRET'))
app <-
rtweet::rtweet_app(bearer_token = Sys.getenv('TWITTER_BEARER_TOKEN'))
rtweet::auth_as(app)
shell: Rscript {0}

- name: Session info
Expand Down
34 changes: 17 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Contributing

This contributing guide has been derived from the {tidyverse} boilerplate (see their high-level [contributing guide](https://www.tidyverse.org/contribute/)). If you have any questions about contributing, please don't hesitate to [reach out](https://docs.ropensci.org/tidytags/#getting-help). We appreciate every contribution. We suggest first reading the [Getting started with tidytags](https://docs.ropensci.org/tidytags/articles/setup.html) vignette.
This contributing guide has been derived from the **tidyverse** boilerplate (see their high-level [contributing guide](https://www.tidyverse.org/contribute/)). If you have any questions about contributing, please don't hesitate to [reach out](https://docs.ropensci.org/tidytags/#getting-help). We appreciate every contribution. We suggest first reading the [Getting started with tidytags](https://docs.ropensci.org/tidytags/articles/setup.html) vignette.

## Contributor Code of Conduct

Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.

## Non-technical contributions to {tidytags}
## Non-technical contributions to **tidytags**

Feel free to [report issues](https://github.com/ropensci/tidytags/issues):

* **Questions** are for seeking clarification or more information. Both question askers and question answerers are welcome contributors!
* **Bug reports** are for unplanned malfunctions. If you have found a bug, follow the issue template to create a minimal [reprex](https://www.tidyverse.org/help/#reprex).
* **Enhancement requests** are for ideas and new features.

## Technical contributions to {tidytags}
## Technical contributions to **tidytags**

If you would like to contribute to the {tidytags} code base, follow the process below:
If you would like to contribute to the **tidytags** code base, follow the process below:

* [Prerequisites](#prerequisites)
* [PR process](#pr-process)
Expand All @@ -33,29 +33,29 @@ If you would like to contribute to the {tidytags} code base, follow the process
* [Resources](#resources)
* [Code of conduct](#code-of-conduct)

This explains how to propose a change to {tidytags} via a pull request using
This explains how to propose a change to **tidytags** via a pull request using
Git and GitHub.

For more general info about contributing to {tidytags}, see the
For more general info about contributing to **tidytags**, see the
[Resources](#resources) at the end of this document.

### Prerequisites

To test the {tidytags} package, you can use an openly shared [TAGS tracker](https://docs.google.com/spreadsheets/d/18clYlQeJOc6W5QRuSlJ6_v3snqKJImFhU42bRkM_OX8) that has been collecting tweets associated with the AECT 2019 since September 30, 2019. This is the same TAGS tracker used in the [Using tidytags with a conference hashtag](https://docs.ropensci.org/tidytags/articles/tidytags-with-conf-hashtags.html) vignette.
To test the **tidytags** package, you can use an openly shared [TAGS tracker](https://docs.google.com/spreadsheets/d/18clYlQeJOc6W5QRuSlJ6_v3snqKJImFhU42bRkM_OX8) that has been collecting tweets associated with the AECT 2019 since September 30, 2019. This is the same TAGS tracker used in the [Using tidytags with a conference hashtag](https://docs.ropensci.org/tidytags/articles/tidytags-with-conf-hashtags.html) vignette.

Note that this TAGS tracker is read-only in the web browser, because the utility of {tidytags} is reading a TAGS tracker archive into R using `read_tags("18clYlQeJOc6W5QRuSlJ6_v3snqKJImFhU42bRkM_OX8")` and then conducting analyses in an R environment.
Note that this TAGS tracker is read-only in the web browser, because the utility of **tidytags** is reading a TAGS tracker archive into R using `read_tags("18clYlQeJOc6W5QRuSlJ6_v3snqKJImFhU42bRkM_OX8")` and then conducting analyses in an R environment.

* Before you do a pull request, you should always file an issue and make sure someone from the {tidytags} team agrees that it’s a problem, and is happy with your basic proposal for fixing it. We don’t want you to spend a bunch of time on something that we don’t think is a real problem or an appropriate solution.
* Also make sure to read the [{tidyverse} style guide](http://style.tidyverse.org/) which will make sure that your new code and documentation matches the existing style. This makes the review process much smoother.
* Before you do a pull request, you should always file an issue and make sure someone from the **tidytags** team agrees that it’s a problem, and is happy with your basic proposal for fixing it. We don’t want you to spend a bunch of time on something that we don’t think is a real problem or an appropriate solution.
* Also make sure to read the [**tidyverse** style guide](http://style.tidyverse.org/) which will make sure that your new code and documentation matches the existing style. This makes the review process much smoother.

### PR process

You are welcome to contribute a *pull request* (PR) to {tidytags}. The most important thing to know is that tidyverse packages use {roxygen2}: this means that documentation is found in the R code close to the source of each function.
You are welcome to contribute a *pull request* (PR) to **tidytags**. The most important thing to know is that tidyverse packages use **roxygen2**: this means that documentation is found in the R code close to the source of each function.

#### Fork, clone, branch

The first thing you'll need to do is to [fork](https://help.github.com/articles/fork-a-repo/)
the [{tidytags} GitHub repo](https://github.com/ropensci/tidytags), and
the [**tidytags** GitHub repo](https://github.com/ropensci/tidytags), and
then clone it locally. We recommend that you create a branch for each PR.

#### Check
Expand All @@ -71,7 +71,7 @@ devtools::check()
#### Style

Match the existing code style. This means you should follow the tidyverse
[style guide](http://style.tidyverse.org). Use the [{styler}](https://CRAN.R-project.org/package=styler) package to apply the style guide automatically and the [{spelling}](https://CRAN.R-project.org/package=spelling) package to check spelling.
[style guide](http://style.tidyverse.org). Use the [**styler**](https://CRAN.R-project.org/package=styler) package to apply the style guide automatically and the [**spelling**](https://CRAN.R-project.org/package=spelling) package to check spelling.

Be careful to only make style changes to the code you are contributing. If you find that there is a lot of code that doesn't meet the style guide, it would be better to file an issue or a separate PR to fix that first.

Expand All @@ -83,21 +83,21 @@ spelling::update_wordlist()

#### Document

We use [{roxygen2}](https://cran.r-project.org/package=roxygen2), specifically with the [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/markdown.html), to create `NAMESPACE` and all `.Rd` files. All edits to documentation should be done in roxygen comments above the associated function or object. Then, run `devtools::document()` to rebuild the `NAMESPACE` and `.Rd` files.
We use [**roxygen2**](https://cran.r-project.org/package=roxygen2), specifically with [Markdown syntax](https://cran.r-project.org/web/packages/roxygen2/vignettes/markdown.html), to create `NAMESPACE` and all `.Rd` files. All edits to documentation should be done in roxygen comments above the associated function or object. Then, run `devtools::document()` to rebuild the `NAMESPACE` and `.Rd` files.

See the `RoxygenNote` in [DESCRIPTION](DESCRIPTION) for the version of
{roxygen2} being used.
**roxygen2** being used.

#### Test

We use [{testthat}](https://cran.r-project.org/package=testthat) for testing. Contributions with test cases are easier to review and verify.
We use [**testthat**](https://cran.r-project.org/package=testthat) for testing. Contributions with test cases are easier to review and verify.

```r
devtools::test()
devtools::test_coverage()
```

Note that because {tidytags} queries OpenCage and Twitter APIs, testing can be a bit tricky. Be sure to follow the [Getting started with tidytags](https://docs.ropensci.org/tidytags/articles/setup.html) vignette for establishing your own OpenCage API key and Twitter API tokens to conduct local testing. For CI testing, view the [setup-tidytags.R](tests/testthat/setup-tidytags.R) file in the package testing documentation to see how fake OAuth tokens are set up. The [HTTP testing in R](https://books.ropensci.org/http-testing/index.html) book is an invaluable resource.
Note that because **tidytags** queries the Twitter API, testing can be a bit tricky. Be sure to follow the [Getting started with tidytags](https://docs.ropensci.org/tidytags/articles/setup.html) vignette for establishing your own Twitter API tokens to conduct local testing. For CI testing, view the [setup-tidytags.R](tests/testthat/setup-tidytags.R) file in the package testing documentation to see how fake OAuth tokens are set up. The [HTTP testing in R](https://books.ropensci.org/http-testing/index.html) book is an invaluable resource.

#### Re-check

Expand Down
15 changes: 6 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tidytags
Title: Importing and Analyzing Twitter Data Collected with Twitter Archiving Google Sheets
Version: 0.3.0
Version: 1.0.0
License: MIT + file LICENSE
Authors@R: c(
person("K. Bret", "Staudt Willet", ,
Expand Down Expand Up @@ -30,34 +30,31 @@ Description: The 'tidytags' package coordinates the simplicity of collecting twe
Language: en-US
URL: https://docs.ropensci.org/tidytags/ (website) https://github.com/ropensci/tidytags
Depends:
R (>= 4.1)
R (>= 4.2)
Imports:
dplyr (>= 1.0),
googlesheets4 (>= 1.0),
purrr (>= 0.3),
rlang (>= 0.4),
rtweet (>= 0.7),
rlang (>= 1.0),
rtweet (>= 1.0),
stringr (>= 1.4),
tibble (>= 3.1),
tidyr (>= 1.1)
tidyr (>= 1.2)
Suggests:
beepr,
covr,
ggplot2,
ggraph,
knitr,
longurl,
mapview,
opencage (>= 0.2),
readr,
rmarkdown,
sf,
testthat,
tidygraph,
urltools,
vcr (>= 1.0)
Encoding: UTF-8
BugReports: https://github.com/ropensci/tidytags/issues
VignetteBuilder: knitr
RoxygenNote: 7.1.2
RoxygenNote: 7.2.1
Roxygen: list(markdown = TRUE)
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
export(add_users_data)
export(create_edgelist)
export(filter_by_tweet_type)
export(geocode_tags)
export(get_char_tweet_ids)
export(get_upstream_tweets)
export(get_url_domain)
export(lookup_many_tweets)
export(lookup_many_users)
export(process_tweets)
export(pull_tweet_data)
export(read_tags)
Expand Down
18 changes: 16 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@ tidytags development version
*


tidytags 0.3.0 (2022-02-04)
tidytags 1.0 (2022-08-05)
=========================

### BREAKING CHANGES

* Updated Twitter authentication process to align with breaking changes caused by the rtweet 1.0 release.
* Updated the process_tweets() function to align with changes in available metadata and new variable names used in rtweet 1.0.
* Removed the lookup_many_users() function. With the rtweet 1.0 update, user information can be accessed with the rtweet::users_data() function.
* Updated flag_unknown_upstream() and get_upstream_tweets() to align with new variable names used in rtweet 1.0.
* Updated filter_by_tweet_type(), create_edgelist(), and add_users_data() to align with new variable names used in rtweet 1.0.
* Removed the geocodetags() function because rtweet 1.0 changed how location data is available and also added a new rtweet::lookup_coords() function. Note that at this time, rtweet::lookup_coords() requires a Google Maps API key rather than the OpenCage API we had recommended in earlier versions of tidytags. We still recommend the sf and mapview R packages for working with locations and geocding.

### NEW FEATURES

* Released tidytags on CRAN for the first time.
* Updated the read_tags() function so that a Google API key is no longer needed to pull tweet data from publicly shared Google Sheets.
* The process_tweets() function now also adds user information associated with the creator of each status. process_tweets() also now returns a column for the tweet type of each status.


tidytags 0.3.0 (2022-02-04)
=========================

### BUG FIXES

Expand Down
44 changes: 12 additions & 32 deletions R/add-users-data.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Retrieve user information for everyone in an edgelist
#'
#' Updates an edgelist created with `create_edgelist()` by appending user
#' data retrieved with `lookup_many_users()`. The resulting dataframe
#' data retrieved with `rtweet::lookup_users()`. The resulting dataframe
#' adds many additional columns and appends "_sender" or "_receiver" to the
#' column names.
#' @param edgelist An edgelist of senders and receivers, such as that returned
Expand All @@ -11,8 +11,6 @@
#' about the senders and receivers.
#' @details This function requires authentication; please see
#' `vignette("setup", package = "tidytags")`
#' @seealso Review documentation for `rtweet::lookup_users()` for a full
#' list of metadata retrieved (i.e., column names) by this function.
#' @examples
#'
#' \dontrun{
Expand All @@ -26,47 +24,29 @@
add_users_data <-
function(edgelist) {
all_users <- unique(c(edgelist$sender, edgelist$receiver))
users_data <- lookup_many_users(all_users)
users_data <- rtweet::lookup_users(all_users)

users_prepped <-
dplyr::select(
users_data,
.data$screen_name,
.data$user_id,
.data$name:.data$profile_image_url
)

senders_prepped <-
dplyr::rename(
users_prepped,
sender = .data$screen_name
)

names(senders_prepped)[2:length(senders_prepped)] <-
stringr::str_c(names(senders_prepped),
"_sender")[2:length(senders_prepped)]

receivers_prepped <-
dplyr::rename(
users_prepped,
receiver = .data$screen_name
)
senders_data <-
dplyr::filter(users_data, .data$screen_name %in% edgelist$sender)
names(senders_data) <- stringr::str_c("sender_", names(senders_data))
names(senders_data)[4] <- "sender"

names(receivers_prepped)[2:length(receivers_prepped)] <-
stringr::str_c(names(receivers_prepped),
"_receiver")[2:length(receivers_prepped)]
receivers_data <-
dplyr::filter(users_data, .data$screen_name %in% edgelist$receiver)
names(receivers_data) <- stringr::str_c("receiver_", names(receivers_data))
names(receivers_data)[4] <- "receiver"

edgelist_with_senders_data <-
dplyr::left_join(
edgelist,
senders_prepped,
senders_data,
by = "sender"
)

edgelist_with_all_users_data <-
dplyr::left_join(
edgelist_with_senders_data,
receivers_prepped,
receivers_data,
by = "receiver"
)

Expand Down
Loading

0 comments on commit 65b681f

Please sign in to comment.