search for: fileext

Displaying 20 results from an estimated 29 matches for "fileext".

2011 Mar 18
1
[Patch suggestion] Adding 3rd arg to tempfile() to set extension
...tempfile()---as it is portable and clever and the files get cleaned by R and all that---I noticed one missing feature I would like to see: beside a starting name pattern, and an optional directory, an 'file extension' argument would be nice to have. As e.g. in tmppdf <- tempfile(fileext=".pdf") tmppng <- tempfile(fileext=".png") tmpjpeg <- tempfile(fileext=".jpeg") Below is a short and simple patch which extends tempfile() to three arguments with the new one (fileext) defaulting to "". If set, the extension is appended t...
2015 Nov 06
2
corrupt PACKAGES.gz?
...gzfile() complains about it and Cygwin's gzip cannot decompress it. I tried the following repos <- "https://cran.rstudio.com" v <- "3.2" pkgs.gz <- paste(sep="/", repos, "bin/windows/contrib", v, "PACKAGES.gz") tfile <- tempfile(fileext=".gz") download.file(pkgs.gz, dest=tfile) r.gz <- readLines(gzfile(tfile, "r")) tail(system(paste("c:\\cygwin\\bin\\gzip -d - ", shQuote(tfile)), intern=TRUE)) and got > repos <- "https://cran.rstudio.com" > v <- "3.2" > pkgs.gz...
2018 Jul 17
2
Output mis-encoded on Windows w/ RGui 3.5.1 in strange case
...the reported behavior. Here's something standalone that you should hopefully be able to copy + paste into RGui to reproduce: code <- ' x <- 1 print(list()) save(x, file = tempfile()) output <- encodeString("apple") print(output) ' file <- tempfile(fileext = ".R") writeLines(code, con = file) source(file) When I run this, I see: > code <- ' + x <- 1 + print(list()) + save(x, file = tempfile()) + output <- encodeString("apple") + print(output) + ' > > file <- tempfile(fileext = ".R...
2016 Jul 27
2
Model object, when generated in a function, saves entire environment when saved
...al.Width, data = iris, subset = subset)) > } > Then we get > > saveSize(tfun1(1:4)) # see below for def. of saveSize > [1] 910 > instead of the 2129743 bytes in the save file when using the naive method. > > saveSize <- function (object) { > tf <- tempfile(fileext = ".RData") > on.exit(unlink(tf)) > save(object, file = tf) > file.size(tf) > } > > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Wed, Jul 27, 2016 at 10:48 AM, Kenny Bell <kmb56 at berkeley.edu> wrote: > >> In t...
2018 Jul 18
1
Output mis-encoded on Windows w/ RGui 3.5.1 in strange case
...> + paste into RGui to reproduce: >> >> code <- ' >> x <- 1 >> print(list()) >> save(x, file = tempfile()) >> output <- encodeString("apple") >> print(output) >> ' >> >> file <- tempfile(fileext = ".R") >> writeLines(code, con = file) >> source(file) >> >> When I run this, I see: >> >>> code <- ' >> + x <- 1 >> + print(list()) >> + save(x, file = tempfile()) >> + output <- encodeString("a...
2020 Jan 29
2
Model object, when generated in a function, saves entire environment when saved
...e notes for the last few years (Ctrl-F-ing "environment") and couldn't see it. Many thanks for any help and best wishes to all. The following code uses R 3.6.2 and requires you to run install.packages("qs") first: save_size_qs <- function (object) { tf <- tempfile(fileext = ".qs") on.exit(unlink(tf)) qs::qsave(object, file = tf) file.size(tf) } save_size_rds <- function (object) { tf <- tempfile(fileext = ".rds") on.exit(unlink(tf)) saveRDS(object, file = tf) file.size(tf) } normal_lm <- function(){ junk <- 1:1e+08...
2017 Sep 19
2
what do you think about write.table(... qmethod = "excel")?
On 19/09/2017 4:10 PM, Ista Zahn wrote: > On Tue, Sep 19, 2017 at 1:04 PM, Paul Johnson <pauljohn32 at gmail.com> wrote: >> Last week one of our clients reported trouble with a csv file I >> generated with write.table. He said that columns with quotes for >> character variables were rejected by their data importer, which was >> revised to match the way Microsoft
2015 Nov 07
0
corrupt PACKAGES.gz?
...Cygwin's gzip cannot decompress it. I tried the > following > > repos <- "https://cran.rstudio.com" > v <- "3.2" > pkgs.gz <- paste(sep="/", repos, "bin/windows/contrib", v, "PACKAGES.gz") > > tfile <- tempfile(fileext=".gz") > download.file(pkgs.gz, dest=tfile) > r.gz <- readLines(gzfile(tfile, "r")) > tail(system(paste("c:\\cygwin\\bin\\gzip -d - ", shQuote(tfile)), > intern=TRUE)) > > and got > >> repos <- "https://cran.rstudio.com" >&...
2020 Jul 09
0
Is this surprising behavior of tkimage.create function a bug?
tkimage.create function can read some images but can't read the other images. We can reproduce it by running the code below. ------------------------------------------------------------------------------------- library(tcltk) library(magick) # works fine tmp <- tempfile(fileext = ".gif") image_write(logo, tmp) image_tcl <- tkimage.create("photo", "image_tcl", file = tmp) # doesn't work fine logo2 <- image_convert(logo, format = "jpeg") tmp2 <- tempfile(fileext = ".jpg") image_write(logo2, tmp2) image_tcl <...
2013 Feb 28
1
using a personal template for new R scripts
Does anyone know if there's an easy facility to create and specify a template file to be used for new R scripts? I found myself creating this function which works well (in RStudio on Windows). newR = function(filename=tempfile(tmpdir='.',fileext='.R'), open=TRUE) { template = paste(Sys.getenv('R_USER'), 'R_template.R', sep='/') lines = readLines(template) lines = sub('Sys.time', format(Sys.time(), '%A, %d %B %Y'), lines) lines = sub('getwd', getwd(), lines) lines = sub('...
2013 Sep 09
1
Package installation and path.package
...DBPath" <- function() { db.path <- tempfile(pattern = "mmstructDB", tmpdir = file.path(path.package("mmstruct"), "data", "databases"), fileext = ".db") return(db.path) } .mmstructBASE <- setClass("mmstructBASE", representation("VIRTUAL", dbName = "character",...
2017 Sep 20
0
what do you think about write.table(... qmethod = "excel")?
...Johnson ##' @examples ##' set.seed(234) ##' x1 <- data.frame(x1 = c("a", "b,c", "b", "The \"Washington, DC\""), ##' x2 = rnorm(4), stringsAsFactors = FALSE) ##' x1 ##' fn <- tempfile(pattern = "testcsv", fileext = ".csv") ##' writeCSV(x1, file = fn) ##' readLines(fn) ##' x2 <- read.table(fn, sep = ",", header = TRUE, stringsAsFactors = FALSE) ##' all.equal(x1,x2) writeCSV <- function(x, file, row.names = FALSE){ xischar <- colnames(x)[sapply(x, is.character)...
2018 Jul 18
0
Output mis-encoded on Windows w/ RGui 3.5.1 in strange case
...at you should hopefully be able to copy > + paste into RGui to reproduce: > > code <- ' > x <- 1 > print(list()) > save(x, file = tempfile()) > output <- encodeString("apple") > print(output) > ' > > file <- tempfile(fileext = ".R") > writeLines(code, con = file) > source(file) > > When I run this, I see: > >> code <- ' > + x <- 1 > + print(list()) > + save(x, file = tempfile()) > + output <- encodeString("apple") > + print(output) >...
2018 Jul 16
2
Output mis-encoded on Windows w/ RGui 3.5.1 in strange case
Given the following R script: x <- 1 print(list()) save(x, file = tempfile()) output <- encodeString("apple") print(output) If I source this script from RGui on Windows, I see the output: > source("encoding.R") list() [1] "\002??apple\003??" That is, it's as though R has injected what looks like byte order marks around the
2011 Oct 18
2
Remote environments, calling functions
Hi there, I'm trying to do something like a migration of an R program. I've got a function and some variables in an interactive-session: r <- .5 ## estimatePi references r estimatePi <- function(seed) { set.seed(seed) numDraws <- 1e+05 x <- runif(numDraws, min = -r, max = r) y <- runif(numDraws, min = -r, max = r) inCircle <- ifelse((x^2 + y^2)^0.5
2017 May 09
2
source(), parse(), and foreign UTF-8 characters
...quot; id <- "\u5e78\u798f" id <- "\u0441\u0447\u0430\u0441\u0442\u044c\u0435" id <- "\ud589\ubcf5" file_contents <- paste0('"', id, '"') Encoding(file_contents) raw_file_contents <- charToRaw(file_contents) path <- tempfile(fileext = ".R") writeBin(raw_file_contents, path) file.size(path) length(raw_file_contents) # Escapes the string parse(text = file_contents) # Throws an error print(source(path, encoding = "UTF-8"))
2016 Jul 27
3
Model object, when generated in a function, saves entire environment when saved
In the below, I generate a model from an environment that isn't .GlobalEnv with a large object that is unrelated to the model generation. It seems to save the irrelevant object unnecessarily. In my actual use case, I am running and saving many models in a loop that each use a single large data.frame (that gets collapsed into a small data.frame for estimation), so removing it isn't an
2016 May 25
0
odd warning unlinking symlink on Windows
...'There is a mismatch between the tag specified in the request and the tag present in the reparse point. #' file.exists(tlink) #[1] TRUE I can remove the symbolic link, without any warnings, if it is in a directory that I remove with unlink(recursive=TRUE): dir.create(tdir <- tempfile(fileext=".dir")) file.create(tfile <- file.path(tdir, "file")) #[1] TRUE file.symlink(tfile, tlink <- file.path(tdir, "symlinkToFile")) #[1] TRUE dir(tdir) #[1] "file" "symlinkToFile" print(unlink(tdir, recursive=TRUE)) #[1] 0 file.exists(tdi...
2016 Jul 27
0
Model object, when generated in a function, saves entire environment when saved
...set with(env, lm(Sepal.Length ~ Sepal.Width, data = iris, subset = subset)) } Then we get > saveSize(tfun1(1:4)) # see below for def. of saveSize [1] 910 instead of the 2129743 bytes in the save file when using the naive method. saveSize <- function (object) { tf <- tempfile(fileext = ".RData") on.exit(unlink(tf)) save(object, file = tf) file.size(tf) } Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jul 27, 2016 at 10:48 AM, Kenny Bell <kmb56 at berkeley.edu> wrote: > In the below, I generate a model from an environment that isn't...
2011 Jul 06
1
including figures in html documentation/help
Dear list members, is it somehow possible to include figures to the html help pages of individueal functions (containing for example a plot produced by that function?) I thought about adding these figures into a 'graphs' subfolder of the package folder and then to somehow insert some sort of html link into the documentation code. I use inlinedocs for creating the documentation. Any