繁体   English   中英

如何在 R 上安装 install_github 函数?

[英]How to install install_github function on R?

我正在尝试使用一个有效示例中的 github 包。 我使用了建议的方法

在这里让安装-github工作

library(devtools)
library(httr)
set_config(config(ssl_verifypeer = 0L))
install.packages("install_github")
install_github("ggbiplot", "vqv")

我收到一条警告,将我重定向到R website安装页面,然后出现错误Error in parse_repo_spec(repo): Invalid git repo specification: 'ggbiplot'

最终,我想运行这段代码

# Load data
data(iris)
log.ir <- log(iris[, 1:4])
ir.species <- iris[, 5]

#PCA
ir.pca <- prcomp(log.ir,
                 center = TRUE,
                 scale. = TRUE) 
#Plot
g <- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, 
              groups = ir.species, ellipse = TRUE, 
              circle = TRUE)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal', 
               legend.position = 'top')
print(g)

您需要user/repo语法来指定 repo,因为 GitHub 上有多个名为ggbiplot的包 - R 包有 157 个分支,您必须告诉 R 您想要哪个:

library(devtools)

install_github('vqv/ggbiplot')
#> Downloading GitHub repo vqv/ggbiplot@HEAD

library(ggbiplot)

现在我们可以运行您的代码:

data(iris)
log.ir <- log(iris[, 1:4])
ir.species <- iris[, 5]

#PCA
ir.pca <- prcomp(log.ir,
                 center = TRUE,
                 scale. = TRUE) 
#Plot
g <- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, 
              groups = ir.species, ellipse = TRUE, 
              circle = TRUE)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal', 
               legend.position = 'top')
print(g)

在此处输入图像描述

暂无
暂无

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

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