2017-07-20 56 views
1

安裝後我試圖創建我的第一個R包,基本上遵循this tutorialR的功能和不提供從GitHub

我創建了包,並把它添加到Github

現在我想其實從GitHub安裝並運行它,這是我看到:

> install_github("nriddiford/cnvPlotteR") 

Downloading GitHub repo nriddiford/[email protected] 
from URL https://api.github.com/repos/nriddiford/cnvPlotteR/zipball/master 
Installing cnvPlotteR 
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL \ 
    '/private/var/folders/fb/xk_7jg3s3sj4vc19hbjz92900000gn/T/RtmpN7J2Qt/devtools149042e0f3cd/nriddiford-cnvPlotteR-3f9164e' \ 
    --library='/Library/Frameworks/R.framework/Versions/3.4/Resources/library' --install-tests 

* installing *source* package ‘cnvPlotteR’ ... 
** R 
** data 
*** moving datasets to lazyload DB 
** preparing package for lazy loading 
Warning: Installed Rcpp (0.12.12) different from Rcpp used to build dplyr (0.12.11). 
Please reinstall dplyr to avoid random crashes or undefined behavior. 
** help 
*** installing help indices 
** building package indices 
** testing if installed package can be loaded 
Warning: Installed Rcpp (0.12.12) different from Rcpp used to build dplyr (0.12.11). 
Please reinstall dplyr to avoid random crashes or undefined behavior. 
* DONE (cnvPlotteR) 

我使用RStudio,打字時加載函數時,通常自動填充。不過,我看不到任何的功能,當我嘗試運行一個(例如plot.chrom())我得到以下錯誤:

Error in plot.chrom() : could not find function "plot.chrom"

難道我做錯了什麼?這與Please reinstall dplyr to avoid random crashes or undefined behaviour錯誤有關嗎?如果是這樣,我該如何解決這個問題?


編輯:

這裏是我的會話信息 - 看來,它不是安裝正確:

> session_info() 
Session info ------------------------------------------------------------------------------------------------------------------------------- 
setting value      
version R version 3.4.1 (2017-06-30) 
system x86_64, darwin15.6.0   
ui  RStudio (1.0.143)   
language (EN)       
collate en_GB.UTF-8     
tz  XXX     
date  2017-07-20     

Packages ----------------------------------------------------------------------------------------------------------------------------------- 
package * version date  source        
assertthat 0.2.0  2017-04-11 CRAN (R 3.4.0)      
backports 1.1.0  2017-05-22 CRAN (R 3.4.0)      
base  * 3.4.1  2017-07-07 local        
commonmark 1.2  2017-03-01 cran (@1.2)       
compiler  3.4.1  2017-07-07 local        
crayon  1.3.2  2016-06-28 cran (@1.3.2)      
curl   2.7  2017-06-26 CRAN (R 3.4.1)      
datasets * 3.4.1  2017-07-07 local        
desc   1.1.0  2017-01-27 cran (@1.1.0)      
devtools * 1.13.2  2017-06-02 CRAN (R 3.4.0)      
digest  0.6.12  2017-01-27 CRAN (R 3.4.0)      
git2r  0.18.0  2017-01-01 CRAN (R 3.4.0)      
graphics * 3.4.1  2017-07-07 local        
grDevices * 3.4.1  2017-07-07 local        
httr   1.2.1  2016-07-03 CRAN (R 3.4.0)      
magrittr  1.5  2014-11-22 CRAN (R 3.4.0)      
memoise  1.1.0  2017-04-21 CRAN (R 3.4.0)      
methods * 3.4.1  2017-07-07 local        
R6   2.2.2  2017-06-17 CRAN (R 3.4.0)      
Rcpp   0.12.12 2017-07-15 CRAN (R 3.4.1)      
roxygen2  6.0.1.9000 2017-07-19 Github (klutometis/[email protected]) 
rprojroot 1.2  2017-01-16 cran (@1.2)       
rstudioapi 0.6  2016-06-27 CRAN (R 3.4.0)      
stats  * 3.4.1  2017-07-07 local        
stringi  1.1.5  2017-04-07 CRAN (R 3.4.0)      
stringr  1.2.0  2017-02-18 CRAN (R 3.4.0)      
tools  3.4.1  2017-07-07 local        
utils  * 3.4.1  2017-07-07 local        
withr  1.0.2  2016-06-20 CRAN (R 3.4.0)      
xml2   1.1.1  2017-01-24 cran (@1.1.1) 
+0

你附加了嗎? – Hugh

+0

@Hugh - 不是我的知識 - 我該怎麼做,它做了什麼? – fugu

+0

對不起,行話。你運行'library(cnvPlotteR)'並且在你的包中嘗試了一個函數嗎? – Hugh

回答

2

我建議哈德利的Advanced RR Packages針對各種[R話題更多的閱讀相關的編程和包。那裏有很多好的信息和答案。

編輯:關於您的編輯和查看github - 您嘗試使用的功能尚未導出。您正確地把@export標籤上您的文檔,但你沒有重新生成NAMESPACE文件(CF):

# Generated by roxygen2: do not edit by hand 

S3method(plot,all.grid) 
S3method(plot,chrom) 
S3method(plot,region) 
export(clean_theme) 
export(file.cleanR) 
import(dplyr) 
import(ggplot2) 
import(scales) 
import(RColorBrewer) 

EDIT2:未被出口​​都含有.的功能(例如plot.all.grid)和roxygen是由於.預期S3方法,所以你遇到了一個常見的命名約定no-no。請參閱OO或命名約定。該@method標籤或其他一些roxygen內可以幫助消除歧義,如果你需要包括.

解決方案 =重命名功能,以排除.,例如將plot.all.grid更改爲plotAllGrid

+0

還推薦使用['packrat'](https://rstudio.github.io/packrat/)和許多其他['Rstudio'包](https://www.rstudio。因爲它會使包開發(和控制版本的依賴關係)變得更容易。 – cole

+0

感謝您的建議,但它對我無效。運行'install.packages('dplyr')'似乎工作正常,並重新啓動我的會話。當我從GitHub安裝我的軟件包時,我的問題與以前完全相同(並且它仍然安裝了'Warning:安裝的Rcpp(0.12.12)與用於構建dplyr(0.12.11)的Rcpp不同)。 請重新安裝dplyr以避免隨機崩潰或未定義的行爲。' – fugu

+0

當我運行ls('package:cnvPlotteR')'我看到只有兩個軟件包已被加載: '[1]「clean_theme」「file.cleanR」' – fugu