Comments (15)
It's easy enough to fix but I'm wondering if we're taking a slightly wrong approach. For instance
# The only vignette in xtable is called "xtableGallery"
# so this loads that vignette
vignette("xtableGallery")
# One would expect our convenience function would
# be able to load a vignette by name but currently
# it gives an error
p_vignette("xtableGallery")
#Error in find.package(package, lib.loc) :
# there is no package called ‘xtableGallery’
So I'm thinking first we get a list of the vignettes installed locally (easy enough using vignette()) and check to see if the provided input is the actual name of a vignette. If not then we check if it's the name of a package that provides a vignette.
That takes care of checking out what's going on locally. I don't know of a good way to check for available vignettes on CRAN though. We might just have to concede that point and only allow p_vignette to find vignettes that are stored locally. Maybe in the future we can figure something out to search CRAN though.
I can take care of modifying p_vignette to do what I suggested if you think that sounds reasonable.
from pacman.
I agree. I also like the ability to look at a vignettes for packages not in the users library. I think an approach (if it's somewhat feasible) would be to do exactly as you say and then look to the CRAN vignettes if not found locally. If tthe vignette is still not found return an error.
I asked on Stack Overflow about doing this (LINK). If it's unreasonable we abandon it for now.
I also like your idea of searching for the vignette by name as well not just by package name.
from pacman.
Dason go ahead with the changes you proposed. MY SO question didn't receive much attention. I think that getting vignettes from CRAN is rather difficult and would involve some serious bogging down of the function (eg XML use). If the SO gets a hit later on we can make the changes at that point. Feel free to close this issue after making the changes.
from pacman.
Ok. I'm going to keep this open until I make the changes... which with the way things are looking won't happen until tomorrow.
from pacman.
I attempted to do this an then tried to upload it as p_vign
which had been deleted (I forgot to pull before committing). Anyway here's the attempt:
p_vignette <-
function(package = "all"){
x <- as.character(substitute(package))
vigns <- vignette()
if (x == "all") {
vigns
} else {
vn <- vigns$results
if (x %in% vn[, 3]) {
pn <- vn[vn[, 3] %in% x, 3]
vignette(pn)
} else {
if (!x %in% vn[, 1]){
stop (paste(x,
"does not appear to be a package with a vignette or the name of a vignette"))
} else {
y <- vignette(package = x)$results[, 3]
if (length(y) > 1) {
w <- c(y, "All Vignettes")
z <- menu(w)
if (w[z] == "All Vignettes") {
lapply(y, vignette)
} else {
vignette(w[z])
}
} else {
vignette(y)
}
}
}
}
}
p_vign <- p_vignette
#Test it
p_vignette(tm)
p_vignette(data.table)
p_vignette(xtableGallery)
p_vignette(ggplot2) #throws up an error that makes sense
Please don't handle this or any code I write with kid gloves. I'm learning from this process and I learn by knowing how I can improve. So suggest or start over. I'm not married to any code, I just want to learn and have a good final product.
PS I added the commit problem as an issue to be resolved as I can't really make changes or receive them anymore (locally)
from pacman.
Wow that's cool that it knew the commit referenced this issue. Anyway...
Ben Bolker at SO wrote a scrapper to get the Vignettes available. This would be a long process that obviously the user wouldn't want to do, however, we (as a possibility) could do the scraping at the beginning of each package release and include this information as a data set within the package. This is an option as is to just worry about local vignettes.
from pacman.
Including it as a dataset along with the package wouldn't be a bad idea. It would be fast to load. The problem being that it would most likely be out of date fairly quickly. We could do something like post the data online somewhere and just search that if we need to.
from pacman.
I tried the scraper (Ben's and it doesn't quite work). He updated it and I still can't get it to work right (I can download the names of available packages but fail to make them correspond to a package name).
I don't want to keep bothering Ben. Dason maybe you can figure out how to work it:
SO LINK
from pacman.
I'll see what I can do.
from pacman.
I added an R file to the dropbox. I think that takes care of getting the vignette info. Messing with this made me realize that I think we also need to account for the case where there are more than one vignettes with the same name but in different packages.
from pacman.
I tested that bad boy out but get warnings. I put a .txt file of the output in the dropbox.
from pacman.
Hmm. It was working for me before - I'll give it a try.
from pacman.
Yup - still working for me. I don't know exactly what is going wrong for you. It might be the tempfile magic I'm trying to do. If instead of using a tempfile you just provide some other file name does it work for you?
from pacman.
The original issue was solved though so I'm going to close this. We can start a new issue for scraping vignettes.
from pacman.
Yeah not sure what the deal is for me. There would only need to be one person scraping but I really like the idea of scraping and storing somewhere on the net for quick grabbing.
from pacman.
Related Issues (20)
- Feature request: suppress warning for trailing comma
- BiocManager missing in fresh install HOT 1
- INSTALL_opts=c("--no-docs", "--no-help","--no-html") but still trying to install HOT 1
- Failing to find bioconductor packages HOT 2
- Cannot Install pacman via CRAN HOT 1
- “there is no package called ‘rgl’” 🐞 HOT 2
- p_load_gh( ... , update = TRUE) does not update github packages
- passing dependecies = T to p_load
- Strange capitalisation warning when trying to update loaded github package HOT 1
- misleading warning for bioconductor packages HOT 1
- GPLv2 license
- pak as package install backend?
- backspace characters in message() cause errors for pdf output HOT 1
- Pacman packages HOT 1
- file loading issues
- No code completion with `p_load()` in VS COde HOT 3
- need a p_delete() function
- setting library location in p_load
- [Feature] P_Install only if package does not exists
- p_install quiet option
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pacman.