簡體   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