First R package - having trouble connecting to GitHub with usethis::use_github - r

Working on first R package ever.
A data package for medical datasets for teaching.
Using the usethis workflow as described by Emil Hvitfelt
on Macbook Air with MacOS 10.15.3 Cataline
Project seems ok.
R> proj_sitrep()
working_directory: '/Users/peterhiggins/Documents/Rcode/medicaldata'
active_usethis_proj: '/Users/peterhiggins/Documents/Rcode/medicaldata'
active_rstudio_proj: '/Users/peterhiggins/Documents/Rcode/medicaldata'
I appear to be stuck on the GitHub connection
I have an account with repos, I have a PAT.
but
R> git_sitrep()
Git user
Name: 'Peter Higgins'
Email: 'higgi13425#yahoo.com'
Vaccinated: TRUE
usethis + git2r
Default usethis protocol: 'https'
git2r supports SSH: FALSE
Credentials: ''
GitHub
Personal access token: ''
User: 'higgi13425'
Name: 'Peter Higgins'
Repo
Path: '/Users/peterhiggins/Documents/Rcode/.git'
Local branch -> remote tracking branch: '' -> ''
GitHub pull request readiness
:information_source: This repo has neither 'origin' nor 'upstream' remote on GitHub.com.
and
R> use_github()
:heavy_check_mark: Checking that current branch is 'master'
Error: Detached head; can't continue
Not sure how to get past this problem.
Ideas welcome.
and any explanation of how I borked this also welcome.
thanks!

Related

R CRAN submission - URLs check

I can not find how to replicate the internal CRAN test for the URLs healthy.
It is important that this test is run only on the Debian winbuilder (yes, debian under winbuilder). As this test is not run on the Windows machine so we could NOT use the https://win-builder.r-project.org/upload.aspx website service to replicate it.
The example error message from the CRAN server, as the website was moved.
Such message is producing the NOTE so the package is not automatically processed.
Found the following (possibly) invalid URLs:
URL: http://blog.obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/
From: inst/doc/tinyverse.html
Status: Error
Message: Could not resolve host: blog.obeautifulcode.com
Edit:
There is a useful source with CRAN policy in this area https://cran.r-project.org/web/packages/URL_checks.html
(Promoting comment to answer as suggested...)
The test code has been pulled out of R itself and made into a package you can install. Other than that it is of course part of any (recent enough) R or R-devel build.
FWIW I also wrapped this into a convenience script I call all the time on my systems.

Failed to install 'unknown package' from GitHub

I am trying to install the ggpattern package from GitHub (https://www.rdocumentation.org/packages/ggpattern/versions/0.2.0)
I've reinstalled R, followed the all steps according to the site, also tried
remotes::install_github("coolbutuseless/ggpattern", force = TRUE)
But I still get:
Error: Failed to install 'unknown package' from GitHub:
HTTP error 401.
Bad credentials
Rate limit remaining: 19/60
Rate limit reset at: 2022-01-29 18:28:15 UTC
I'm working on R version 4.1.2 (newest according to me) on Windows.
Do you have any idea what is the issue here?
You need to check if you have a personal access token set in your environment. For example, when I have a Git project, I set a personal access token. However, I set this in the project environment, so that it isn't any issues outside of that environment.
To see if there is one assigned:
Sys.getenv("GITHUB_PAT")
If there is one set, write it down (you may need that in the future).
To remove it, so you can install the GitHub package:
Sys.unsetenv("GITHUB_PAT")

failing to devtools::install_github() from an enterprise github account

I am trying to install an R package from an enterprise github account
devtools::install_github(
repo = "<owner>/<repo>",
host = "github.<org_name>.com/api/v3/",
auth_token = <my_github_pat>
)
I get this error message
Error: Failed to install '<repo>' from GitHub: HTTP error 404. Not Found Did you spell the repo owner ('<owner>') and repo name ('<repo>') correctly? - If spelling is correct, check that you have the required permissions to access the repo.
I have the correct spellings, and I think that I must have the required permissions because it's actually my repo: I can push and pull from the repo just fine. I am doing the install_github() as a test case so colleagues can install my package, but I can't make sense of this error message.
Literally just needed to drop the last "/" in the host string and this worked. SMH
devtools::install_github(
repo = "<owner>/<repo>",
host = "github.<org_name>.com/api/v3",
auth_token = <my_github_pat>
)

github repo created from Rstudio using 'https' but files not uploaded to github

I'm trying to use git from within RStudio to send my project to github. I'm using HTTPS authentication and with this, I can create repository(locally and remotely) and commit changes. However, when i check my github, only repository is created but my R files not found.
This is what i tried
library(usethis)
edit_r_environ()
GITHUB_PAT = 'xxxx...X' #restart R session
use_github(protocol = 'https', auth_token = Sys.getenv("GITHUB_PAT")) #created a protocol with Access
token generated from PAT
#Are title and description ok?
1: No way
2: Definitely
3: Absolutely not
#i typed 2 and entered
After the above code, repository was created on github but my R codes are missing. I wanted to use push in git connection but the push/pull was greyed out.
Am aware of other approaches but help using the usethis package in R would be apreciated

why this code showing a dwapi::configure()?

How can I get this code correct?
library("data.world")
file_df <- download_file_as_data_frame(
"jonloyens/an-intro-to-dataworld-dataset",
"fatal-police-shootings-data.csv")
Error in auth_token() : API authentication must be configured before any functions can be invoked. To configure, use dwapi::configure().
So to illustrate why I wrote that comment:
packageDescription('data.world')
Package: data.world
Title: Functions and Add-Ins for Working with 'data.world' Data Sets and Projects
Version: 1.2.2
Authors#R: c( person("Rafael", "Pereira", email = "rafael.pereira#data.world", role =
c("aut", "cre")), person("Triet", "Le", email = "triet.le#data.world", role =
c("aut")), person("Bryon", "Jacob", email = "bryon.jacob#data.world", role =
c("aut")), person("Scott", "Came", email = "scott#cascadia-analytics.com",
role = c("aut")))
Description: High-level tools for working with 'data.world' data sets. 'data.world' is
a platform where you can find interesting data, store and showcase your own
data and data projects, and find and collaborate with other members. In
addition to exploring, querying and charting data on the data.world site, you
can access data via 'API' endpoints and integrations. Use this package to
access, query and explore data sets, and to publish your insights. Visit
<https://data.world>, for additional information.
Depends: R (>= 3.3.0), dwapi (>= 0.1.3)
Imports: httr, ini, miniUI, shiny, stringi
Suggests: covr, knitr, lintr, readr, rmarkdown, testthat (>= 2.0.0)
License: Apache License 2.0
Encoding: UTF-8
LazyData: true
URL: https://github.com/datadotworld/data.world-r
BugReports: https://github.com/datadotworld/data.world-r/issues
RoxygenNote: 6.0.1
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2018-04-04 20:36:39 UTC; root
Author: Rafael Pereira [aut, cre], Triet Le [aut], Bryon Jacob [aut], Scott Came [aut]
Maintainer: Rafael Pereira <rafael.pereira#data.world>
Repository: CRAN
Date/Publication: 2018-04-04 22:29:14 UTC
Built: R 3.6.1; ; 2019-09-16 05:09:34 UTC; unix
Every package accepted by CRAN needs a DESCRIPTION file and that shows how you can access from your console. It's a text file with specific requirements. One of the functions is to point you to other packages that are needed for successful functioning as well as external sources of code or in this case data. You should, therefore, go to the value for the "URL:" line, ie. https://github.com/datadotworld/data.world-r and educate yourself. Other times you may need to install System packages, although this particular package does not list any.
Documentation for dwapi::configure() can be found in the Configuration section of that README on Github.
In short, requests to the data.world API require a user token (even a free user token), and the error indicates that a token is not being sent properly.

Resources