KnitR unable to download documents - r

I am able to run this code normally in R.
setInternet2(use = TRUE)
download.file("http://d396qusza40orc.cloudfront.net/dsscapstone/dataset/Coursera-SwiftKey.zip", "Coursera-SwiftKey.zip", method = "curl", mode = 'wb')
unzip("Coursera-SwiftKey.zip", files=c("final/en_US/en_US.twitter.txt", "final/en_US/en_US.news.txt", "final/en_US/en_US.blogs.txt"), exdir=".")
But when i try to use knitR it gives me this error
Quitting from lines 15-21 (milestone.Rmd)
Error in parse(text = x, srcfile = src) : <text>:5:106: unexpected ')'
4: unzip("Coursera-SwiftKey.zip", files=c("final/en_US/en_US.twitter.txt", "final/en_US/en_US.news.txt", "final/en_US/en_US.blogs.txt"), exdir=".")
5: file.copy(c("final/en_US/en_US.twitter.txt", "final/en_US/en_US.news.txt", "final/en_US/en_US.blogs.txt"?)
^
Calls: <Anonymous> ... <Anonymous> -> parse_all -> parse_all.character -> parse
Execution halted
I am using R Studio and MAC OS X.
I tried removing the s from https but it still di not work.

Related

Trouble with knitting, object not found

I was trying to knit my document, but came across an error:
Error in eval (expr, envir, enclos) : object 'AVG' not found
Calls: ...withVisible -> eval_with_user_handlers -> eval -> eval
Execution halted
This was my code. I'm confused because I thought I defined AVG in the second line. Any ideas?
for (i in 1:30)
{AVG[i] <- mean(rnorm(100))
}
"SD" <- sd(AVG)
print(SD)

How to solve a R package installing problem?

When I install a r package through biomanager,
BiocManager::install("hcg110.db",ask = F,update = F)
though I already downloaded it, it has such error:
Using library: D:/Program Files/rgragh/r/R-4.0.5/library
Error in get(x, envir = ns, inherits = FALSE) :
object 'is.rserver' not found
Calls: suppressMessages ... withCallingHandlers -> .get_fun -> <Anonymous> -> get
Execution halted
How could I solve it?

R Url function on Mac

When running the following call on Mac I get an error as follows
jsonlite::fromJSON(url(paste("https://fantasy.premierleague.com/api/element-summary/236")))
Error in parse_con(txt, bigint_as_char) : parse error: premature EOF
(right here) ------^
However the following call works correctly, with the only difference being the omission of the url().
jsonlite::fromJSON(paste("https://fantasy.premierleague.com/api/element-summary/236"))
The traceback from the error is as follows:
4: parse_con(txt, bigint_as_char)
3: parseJSON(txt, bigint_as_char)
2: parse_and_simplify(txt = txt, simplifyVector = simplifyVector,
simplifyDataFrame = simplifyDataFrame, simplifyMatrix = simplifyMatrix,
flatten = flatten, ...)
1: jsonlite::fromJSON(url(paste("https://fantasy.premierleague.com/api/element-summary/236")))
I've tried on two separate installations with the same result. I wonder if the line break after the first line of the JSON is being interpreted as EOF....

Rmarkdown error in eval, object not found

I have been trying to knit my rmd file, but keep getting an error message
line 56 Error in eval(expr, envir, enclos) : object 'gol.fac' not found Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval Execution halted
```{r}
data(golub, package = "multtest")
grep("Zyxin",golub.gnames[,2])
all <- golub[2124,gol.fac=="ALL"]
aml <- golub[2124,gol.fac=="AML"]
summary(all)
summary(aml)
```
Line 56 is the first line after the ```{r}.
I am not sure why it is giving me errors, when I am able to run the code before knitting

Subscript out of bounds error in rmarkdown

While executing the below code using rmarkdown
```{r}
rasList <- list.files("NDVI_Modis/AOI_NDVI", full.names = TRUE, pattern = ".tif$")
NDVI_Otjo_stack <- stack(rasList)
```
I get the error
Quitting from lines 42-44 (MODIS_TimeSeriesProcessor.Rmd)
Error in x[[1]] : subscript out of bounds
Calls: <Anonymous> ... stack -> stack -> .local -> stack -> stack -> .local
Execution halted
Where am I doing wrong?

Resources