Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中GitHub版本的下载计数_R_Download_Count_Github Api - Fatal编程技术网

R中GitHub版本的下载计数

R中GitHub版本的下载计数,r,download,count,github-api,R,Download,Count,Github Api,我正在尝试使用和R v3.1.2获取公共回购的详细信息。使用谷歌的公共服务,我有以下几点: library(jsonlite) library(httr) url <- "https://api.github.com/repos/googlesamples/google-services/downloads" response <- GET(url) json <- content(response, "text") json <- fromJSON(json) pr

我正在尝试使用和R v3.1.2获取公共回购的详细信息。使用谷歌的公共服务,我有以下几点:

library(jsonlite)
library(httr)

url <- "https://api.github.com/repos/googlesamples/google-services/downloads"
response <- GET(url)
json <- content(response, "text")
json <- fromJSON(json)

print(json)
library(jsonlite)
图书馆(httr)
url在“”中提到的API是:

如前所述,您需要将其应用于回购协议的发行。
例如,这里有一个(by),它提取
下载计数

(不是在R中,而是显示如何使用
/repos/:owner/:repo/releases/:id
url)

摘录:

#遍历每个标记
搜索点=0
格式化字符串时。查找(“标记名称”,搜索点)!=-1:
#查找标签和下载文本在字符串中的位置
find\u point=格式化的字符串。find(“标记名称”,搜索点)
下载\u点=格式化的\u字符串。查找(“下载\u计数”,查找\u点)
下面是一个by,using(用于与GitHub APIv3接口的Python库):

#/usr/bin/env python
“”“从GitHub获取发布的下载统计信息。
需要github3的开发版本。
pip安装github3
pip安装git+https://github.com/sigmavirus24/github3.py.git
"""
进口GITUB3
repo=github3.repository(“chapmanb”、“bcbio.variation”)
在repo.iter_releases()中发布:
对于版本中的资产。iter_资产():
打印release.name、asset.name、asset.download\u计数

(您有)

旧的Github下载计数,似乎不再工作了。您可以从发行版中获得下载计数,但这确实需要一些操作:

library(jsonlite)
library(httr)

url <- "https://api.github.com/repos/allenluce/mmap-object/releases"
response <- GET(url)
json <- content(response, "text")
json <- fromJSON(json)
print(Reduce("+", lapply(json$assets, function(x) sum(x$download_count))))
library(jsonlite)
图书馆(httr)

url如果没有发布,则当前没有获取任意文件下载计数的github API端点。对其使用端点,您将获得count@doug_luce这很好!我在终端中克隆了repo,然后通过Chrome下载了repo-zip,但数量仍然相同(49)。这个数字什么时候变的?确实变了,现在我看到50次下载。他们必须批量执行此操作,我记得在使用以前的格式副本更新计数时阅读了一些有关性能问题的内容。已确认!情况似乎就是这样。我感谢大家的意见,但你的回答正是我想要的。谢谢你的帮助!别担心,希望有帮助,谢谢你的赏金@doug_luce很抱歉坚持,但我通过Chrome下载了mma对象回购的zip,然后通过终端克隆了您的项目,但计数没有移动。您采取了什么措施来增加下载版本号?谢谢你的帮助!
library(jsonlite)
library(httr)

url <- "https://api.github.com/repos/allenluce/mmap-object/releases"
response <- GET(url)
json <- content(response, "text")
json <- fromJSON(json)
print(Reduce("+", lapply(json$assets, function(x) sum(x$download_count))))