Comments (9)
In my experience file.path
is only useful in specific cases where there's a conflict between Windows and Unix-alike OS paths. In this case I suggest we don't use it - will remove I get the green light...
from efficientr.
I'm happy with either.
What about mentioning file path in an rmdnote
from efficientr.
Sounds good - will do
from efficientr.
FWIW, I think the main thing worth mentioning is that if you're calling an external program, depending on how that program behaves you might need Windows \
slashes vs. /
slashes (and so normalizePath()
is your friend).
At the R level, using paths with /
(or from file.path()
) is generally the right thing to do; it's just munging those paths for e.g. calls to system()
that can be tricky.
from efficientr.
@kevinushey Thanks, very helpful.
from efficientr.
One thing that IMHO is not covered in enough detail by Hadley's 'R Packages' is where to put raw files (pick from /inst/exdata
, /vignettes
, /testthat/tests
), but also how to deal with finding these files. For example, when building a vignette, the folder /vignette
is temporarily uses as a working directory, so a path like /inst/exdata/my_file.txt
will fail there.
As an ugly workaround I end up writing functions like this:
find_path <- function(filename) {
if (file.exists(filename)) {
return(filename)
}
prefixes <- c(
"E:/Git/Cer2016/inst/extdata/", # nolint
"/home/richel/GitHubs/Cer2016/inst/extdata/", # nolint
"/home/p230198/GitHubs/Cer2016/inst/extdata/", # nolint
"/home/travis/build/richelbilderbeek/Cer2016/inst/extdata/", # nolint
"C:/Users/Aline/Cer2016/inst/extdata/" # nolint
)
for (prefix in prefixes) {
full_path <- paste(prefix, filename, sep = "")
if (file.exists(full_path)) {
return(full_path)
}
}
stop(
"find_path: ",
"cannot find '", filename, "'"
)
}
I hope you guys come up with some clear guidelines on this. If you haven't already written something up one this :-)
from efficientr.
Thanks. I've managed to somehow avoid this problem, so I don't much insight. Perhaps @Robinlovelace does.
I'm not sure if this fits naturally into the book, but we'll have a think.
from efficientr.
Just been looking into this. Seems inst/extdata
is the right place according to the first 3 results of an internet search, the R Packages book (which says "If you want to store raw data, put it in inst/extdata") and this question
Here is a typical example, from the datapack package:
csvfile <- system.file("extdata/sample-data.csv", package="datapack")
@kevinushey I'll add your insight and fix this asap.
Many thanks for the input.
from efficientr.
Awesome! Thanks for the research!
from efficientr.
Related Issues (20)
- 2.6.2 - Rho interpreter HOT 2
- Chapter 2 footnote references HOT 1
- Update Authors info section HOT 1
- Code including quotation marks within blockquotes HOT 1
- 4.4.1: Issues replicating rdocumentation.org and RSiteSearch results HOT 4
- 4.4.2: Dead reference to Barry Rowlingson's Hadleyverse
- 5.3.1: read_tsv example with unexpected parsing error HOT 6
- 4.5.2: Referencing remotes? HOT 1
- bracket typo HOT 1
- 8.6 CPU `get_datatable` HOT 1
- add arrow/parquet as alternative in Chapter 5 HOT 4
- Superscript to subscript HOT 1
- some typos
- minor wrong code in section 3.2
- there is no "co2.csv" file in "efficient package
- Plot lines missing in figure 6.1
- browse Vignettes HOT 7
- Suspected typo in Chapter 1 HOT 6
- Using deprecated function rbind_all of dplyr package which is no longer supported and code fails HOT 4
- Following example in chapter 7 not possible: source file `monopoly.R` not found HOT 1
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 efficientr.