If I want to download a clone as a zip, it does a redirect.
zip.url = "https://github.com/MonteShaffer/humanVerse/archive/refs/heads/main.zip"
redirects to:
<html><body>You are being redirected.</body></html>
I am trying to using the RCurl library:
require(RCurl)
curl.fun = basicTextGatherer();
curl.ch = getCurlHandle();
x = getBinaryURL(zip.url, curl = curl.ch, headerfunction = curl.fun$update )
One windoze 10, throwing this error:
Error in function (type, msg, asError = TRUE) :
error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
I am assuming github is doing multiple redirects. I want to download the file as a binary 'zip'.
You have to set the curl option followlocation to TRUE, like this:
binary_blob <- RCurl::getBinaryURL(zip.url, .opts = list(followlocation = TRUE))
It might be easier to download the file instead with the following two options:
utils::download.file() comes with R and works for this.
zip.url <- "https://github.com/MonteShaffer/humanVerse/archive/refs/heads/main.zip"
download.file(zip.url, "main.zip")
The curl package has curl_download().
library(curl)
curl::curl_download(zip.url, "main2.zip")
Related
im using R package httr to get a HTTP-Response for a specific link.
When trying to parse the content of the response im getting the Error:
Fehler in parse(text = script_content) : <text>:1:10: Unerwartete(s) '['
1: {"lines":[
Translated to enlgish it says something like this (sorry for my error messages being in German):
Error in parsing(text = script_content) : <text>1:10: Unexpected '['
1: {"lines":[
It seems as there is a problem with the format/encoding of the text. Here is my code:
script <-
GET(
url = "https://my_url.which_origin_is_not_important/my_script.R",
authenticate(username, pass)
)
script_content <- content(script, as = "text", encoding = "ISO-8859-1")
parsed_condent <- parse(text = script_content )
The value of script_content looks like this:
"{\"lines\":[{\"text\":\"################## FUNCTION ##################\"},{\"text\":\"\"},{\"text\":\"library(log4r)\"}],\"start\":0,\"size\":32,\"isLastPage\":true,\"limit\":500,\"nextPageStart\":null}"
Some more background to this operation: Im trying to source a code, which is currently inside of a private repository. I wrote the code myself i'm trying to source. I made sure, that the issue is not coming from within th code.
I got the solution from: Sourcing R files in a private github folder
Thanks for any advice!!
When I try to publish a book to bookdown by running the command:
bookdown::publish_book(render = "none", account="my_account", server="bookdown.org")
I get the following error:
Error in rsconnect::deploySite(siteDir = getwd(), siteName = name, account = account, :
index file with site entry not found in C:\Users\...\...
I have managed to connect to bookdown with the command rsconnect::connectUser(server = 'bookdown.org').
and when I run rsconnect::accounts I get a positive response:
name server
1 my_user bookdown.org
What could be causing this error? Thanks
in the end, I just used rsconnect instead:
library(rmarkdown)
library(rsconnect)
connectUser(account = "my_user", server = "bookdown.org", quiet = TRUE)
# reder app
render("script.Rmd")
deployApp(appFiles = "script.html")
Something seems to have changed in the devtoolspackage, so that the following commands, that used to run now give an error I can't decipher:
> Sys.setenv(R_GSCMD="C:/Program Files/gs/gs9.21/bin/gswin64c.exe")
> devtools::build(args = c('--resave-data','--compact-vignettes="gs+qpdf"'))
The filename, directory name, or volume label syntax is incorrect.
Error in (function (command = NULL, args = character(), error_on_status = TRUE, :
System command error
I've tried other alternatives with other devtools commands, like just passing a single argument, but still get the same error
args = '--compact-vignettes="gs+qpdf"'
devtools::check_win_devel(args=args)
I'm using devtools 2.2.0, under R 3.5.2
I run the following script using an installation of RStudio on a Linux-Server.
require(twitteR)
require(plyr)
setup_twitter_oauth(consumer_key='xxx', consumer_secret='xxx',
access_token='xxx', access_secret='xxx')
searchResults <- searchTwitter("#vds", n=15000, since = as.character(Sys.Date()-1), until = as.character(Sys.Date()))
head(searchResults)
tweetsDf = ldply(searchResults, function(t) t$toDataFrame())
write.csv(tweetsDf, file = paste("tweets_vds_", Sys.Date(), ".csv", sep = ""))
The script works fine, when I run it from the user-interface.
However, when I automatically run it via the terminal using crontab, I get the following error-message:
[1] "Using direct authentication"
Error in twInterfaceObj$getMaxResults :
could not find function "loadMethod"
Calls: searchTwitter -> doRppAPICall -> $
Execution halted
Why?
I want to use the following curl command using RCurl
curl -X POST http://test.reco4j.org:7474/db/data/ext/Reco4jRecommender/node/248/get_recommendations -H "Content-Type: application/json" -d '{"type":"0"}'
so i am using the following R code
library(RCurl)
library(RJSONIO)
postForm("http://test.reco4j.org:7474/db/data/ext/Reco4jRecommender/node/248/get_recommendations",
.opts = list(postfields = toJSON(list(id = "0")),
httpheader = c('Content-Type' = 'application/json', ssl.verifypeer = FALSE)
))
But I get an "Internal server errror", so i am not sure my R code is wrong or it is a windows problem.
The reason I am mentioning this, is that the original curl command fails in windows but works on mac and Linux, so I am not sure the R failure is a windows issue or an R issue.
You have an error in your code. The pair you need to send is "type":"0" you are sending "id":"0".
library(RCurl)
library(RJSONIO)
res <- postForm("http://test.reco4j.org:7474/db/data/ext/Reco4jRecommender/node/248/get_recommendations",
.opts = list(postfields = toJSON(list(type = "0")),
httpheader = c('Content-Type' = 'application/json', ssl.verifypeer = FALSE)
))
out <- fromJSON(rawToChar(res))
> head(out[[1]])
$outgoing_relationships
[1] "http://test.reco4j.org:7474/db/data/node/2285/relationships/out"
$data
$data$movieId
[1] 1342
$data$title
[1] "Convent, The (Convento, O) (1995)"
$data$releaseDate
[1] "14-Jun-1996"
It looks like a bad URL. I get an HTTP ERROR 500: INTERNAL_SERVER_ERROR trying to access that URL in firefox.
EDIT: Disregard, you're right: the curl command worked in a shell prompt. Sorry for doubting you.