From Writing R Extensions
वर्णन फ़ाइलों में चक्रीय घोषणाओं के परीक्षण की जरूरत खजाने (सहित क्रैन) सेट: ~/.Rprofile में ऐसा करते हैं, उदाहरण के लिए
options(repos = c(CRAN="http://cran.r-project.org"))
अनुशंसित द्वारा
उपयोगकर्ता दोबारा जांच करनी चाहिए कि क्या उसका रिफॉफाइल अपने घर में है और इसमें उल्लिखित विकल्प है।
# in R session (any platform)
# where is my profile?
file.path(Sys.glob("~"),".Rprofile")
# is it there?
file.exists(file.path(Sys.glob("~"),".Rprofile"))
या आर सत्र से अतिरिक्त पैकेज का उपयोग:
library(pathological)
r_profile()
उपयोगकर्ता दोबारा जांच करता है, तो विकल्प प्रविष्टि निम्न कोड में की तरह अगर हालत में नेस्ट नहीं है, करना चाहिए:
# this will not help for R CMD check --as-cran
if(interactive()) {
options(repos = c(CRAN="http://cran.r-project.org"))
}
किसी प्लेटफ़ॉर्म के लिए सूखी दौड़
यहां आर स्क्रिप्ट परीक्षण के लिए आर पैकेज के आसान अस्थायी मामले की तैयारी कर रहा है, जो आपके स्थानीय उपयोग में क्या गलत हो रहा है, तेज़ी से ढूंढने में मदद करता है। इस अपहरण ने मुझे यह जानने में मदद की कि मेरी क्या समस्या है। प्रोफोफाइल फ़ाइल और आम तौर पर प्रारंभिक स्थिति को स्थापित करने में मदद कर सकती है। सर्वोत्तम मामले में, चेक रन को नए सबमिशन के बारे में केवल 1 नोट दिखाना चाहिए।
- पहले कॉपी/कोड और अपने अनुसंधान सत्र में यह स्रोत पेस्ट (--vanilla अधिमानतः)
- तो परीक्षण का मामला जांच करने के लिए आदेश स्क्रिप्ट के द्वारा मुद्रित चलाने --as-Cran।
उदाहरण
# for example
R --vanilla -f makePackage.R
# here the resulting package path is as below
R --no-site-file CMD check --as-cran /tmp/pkgtest
# now see the check log
अपने .Rprofile यह मौजूद नहीं है, तो बनाया जाएगा और एक नई लाइन किसी भी मामले में फ़ाइल के अंत में रखा।
makePackage.R
स्क्रिप्ट
# makePackage.R
# makes simple package for playing with check --as-cran
# copy this content to file makePackage.R
# then source it into your R --vanilla session
name <- "pkgtest"
#
# prepare and adjust package template
#
tempbase <- dirname(tempdir())
e <- new.env()
path <- dirname(tempdir())
# make simple package in path
e$fu <- function(){"Hello"}
package.skeleton(name=name,force=T,path=path,environment=e)
nil <- file.remove(
file.path(path,name,'Read-and-delete-me'),
file.path(path,name,'man',paste0(name,'-package.Rd'))
)
# adjust DESCRIPTION
D <- readLines(file.path(path,name,"DESCRIPTION"))
D[grepl("^Title: ",D)] <- "Title: Testing Skeleton"
D[grepl("^Author: ",D)] <- "Author: John Doe"
D[grepl("^Description: ",D)] <- "Description: Checking --as-cran check."
D[grepl("^Maintainer: ",D)] <- "Maintainer: John Doe <[email protected]>"
D[grepl("^License: ",D)] <- "License: GPL (>= 2)"
write(D,file.path(path,name,"DESCRIPTION"))
# make fu.Rd
write(
"\\name{fu}\\alias{fu}\\title{Prints}\\description{Prints}
\\usage{fu()}\\examples{fu()}",
file.path(path,name,'man','fu.Rd'))
#
# ensure that .Rprofile contains repos option
# add fresh new line et the end of .Rprofile
#
userRp <- file.path(Sys.glob("~"),".Rprofile")
write("options(repos = c(CRAN='http://cran.r-project.org'))",file=userRp, append=TRUE)
#
# print final message
#
msg <- sprintf("
Your test package was created in %s,
under name %s,
your user .Rprofile in %s was modified (option repos),
now check this test package from command line by command:
R --no-site-file CMD check --as-cran %s
", path, name, userRp, file.path(path,name)
)
# now is time to check the skeleton
message(msg)
पैकेज
# replace package-path by the path adviced by the sourcing the script above
R --no-site-file CMD check --as-cran package-path
उपयोगकर्ता प्रोफ़ाइल और साइट प्रोफ़ाइल, आप ऊपर दृष्टिकोण में नहीं है साइट प्रोफ़ाइल (दूसरे चरण में नजरअंदाज जाँच हो रही है) पैकेज कंकाल विकल्प के लिए --no-site-file
विकल्प का उपयोग कर।
पीडीएफ त्रुटियों
आप पीडीएफ और लेटेक्स से संबंधित त्रुटियों का अनुभव कर सकते, लापता या नहीं पूरा लेटेक्स instalation के द्वारा बहुत संभावना का कारण बना। पीडीएफ परीक्षणों को छोड़ने के लिए Ycan --no-manual
विकल्प का उपयोग करें।
R --no-site-file CMD check --no-manual --as-cran /tmp/pkgtest
आप कहते हैं कि आपके पास पैकेज की मूल निर्देशिका में एक प्रोमोफाइल है - क्या आप अपनी होम निर्देशिका में आरप्रोफाइल से रिपो विकल्प चुन रहे हैं? आप यह जांच सकते हैं कि 'Sys.getenv ("R_USER")' – Dason
@Dason I को चलाकर कौन सा है। 'होम' निर्देशिका में 'विकल्प' सेटिंग के साथ एक 'repos' सेट किया गया है। यह नोट से छुटकारा पाता है। क्या आप इसे उत्तर के रूप में फेंक सकते हैं? क्या 'रिपोज़' w/o को सेट करने का कोई तरीका है। मेरे घर डीआईआर में प्रोफाइलाइल, जो कि पैकेज निर्देशिका में कुछ सेट है जो 'repos' सेट करेगा? –
'repos' के लिए एक पर्यावरण चर अच्छा होगा। – sgibb