简体   繁体   English

使用knitr加载在github上传的URL Rdata

[英]load url Rdata uploaded at github using knitr

I had been trying to load some data (Rdata) using knitr: 我一直在尝试使用knitr加载一些数据(Rdata):

load(url("https://github.com/gualis91/teacherperception/blob/master/tp.Rdata?raw=true",method="curl"))

When I Knit to HTML, the next output is presented: 当我编织到HTML时,将显示下一个输出:

Error un parse(text = x, srcfile = src) : <text>:3:0: unexpected end of input 1: load(url("https://github.com/gualis91/teacherperception/blob/master/tp.Rdata?raw=true",method="curl") 2: Calls: <Anonymous> ... evaluate -> parse_all -> pase_all.character -> parse Execution halted

I'd tried to eliminate the "method", changing the "https" to "http", eliminating the "?raw=True" to access the archive and nothing seems to work. 我试图消除“方法”,将“ https”更改为“ http”,消除了“?raw = True”以访问存档,但似乎没有任何效果。 But when I run it as code in the console it seems to work just fine! 但是,当我在控制台中将其作为代码运行时,它似乎工作正常!

When I run your code in a regular R session I get 当我在常规R会话中运行您的代码时,我得到

Error in url(" https://github.com/gualis91/teacherperception/blob/master/tp.Rdata?raw=true ", : unused argument (method = "curl") 网址错误(“ https://github.com/gualis91/teacherperception/blob/master/tp.Rdata?raw=true ”,:未使用的参数(方法=“ curl”)

Now, if I remove method='curl' it works. 现在,如果我删除method='curl'它将起作用。

And does so in within a example from knitr 并在knitr的示例中这样做

knitr::knit(text ='```{r}
load(url("https://github.com/gualis91/teacherperception/blob/master/tp.Rdata?raw=true"))
head(tp)
```')

|.................................................................| 100%
label: unnamed-chunk-1

[1] "\n```r\nload(url(\"https://github.com/gualis91/teacherperception/blob/master/tp.Rdata?raw=true\"))\nhead(tp)\n```\n\n```\n##   Gender Age YearsWorkinginthisSchool YearsWorkingasTeacher     Education\n## 1   Male  37                        1                     5       Masters\n## 2   Male  29                        3                     4       Masters\n## 3   Male  32                        1                     3 Undergraduate\n## 4 Female  32                       10                    10 Undergraduate\n## 5   Male  61                       34                    36       Masters\n## 6   Male  36                        7                    15 Undergraduate\n##   SuperiorsLeadership CommunicationProcessess JobSatisfaction\n## 1                   4                       2               5\n## 2                   4                       4               5\n## 3                   5                       5               5\n## 4                   2                       2               5\n## 5                   5                       3               5\n## 6                   5                       4               5\n##   InfrastructureResources FaithFormation AcademicLevel PromotionofCulture\n## 1                       3              5             5                  4\n## 2                       4              5             4                  3\n## 3                       3              5             4                  4\n## 4                       3              5             3                  2\n## 5                       5              5             3                  2\n## 6                       4              5             4                  4\n##   PromotionofArts PromotionofScience PromotionofHumanities\n## 1               3                  3                     4\n## 2               4                  4                     4\n## 3               4                  4                     5\n## 4               2                  2                     2\n## 5               2                  3                     2\n## 6               3                  4                     5\n##   FeedbackRecieved OverallTeacherPerfomance WorkEnvironment Discipline\n## 1                3                        4               4         -5\n## 2                4                        5               4          4\n## 3                5                        4               5          4\n## 4                3                        5               3          2\n## 5                4                        5               5          4\n## 6                4                        5               4          1\n##   TrainingOpportunities\n## 1                     4\n## 2                     4\n## 3                     4\n## 4                     3\n## 5                     4\n## 6                     3\n```"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM