Re: [R] Number of Cores limited to two in CRAN

2023-07-02 Thread Henrik Bengtsson
Short answer: You don't want to override that limit in your R package. Don't do it. Long answer: You'll find the reason for this in the 'CRAN Repository Policy' (https://cran.r-project.org/web/packages/policies.html). Specifically, the following passage: "Checking the package should take as

Re: [R] suprising behaviour of tryCatch()

2023-05-18 Thread Henrik Bengtsson
... or just put the R expression inside curly brackets, e.g. tryCatch({ sexsnp[i] = fisher.test(table(data[,3], data[,i+38]))$p }, error=function(e) print(NA)) Exercise: Compare > list(a = 2) $a [1] 2 with > list({ a = 2 }) [[1]] [1] 2 and > list(b = { a = 2 }) $b [1] 2 BTW, note how the

Re: [R] netstat in R in linux...

2022-12-06 Thread Henrik Bengtsson
o yum install netstat rather than sudo yum install > net-tools > > By the by, what advantages does port4me have as compared to netstat? > > THanking you, > Yours sincerely, > AKSHAY M KULKARNI > > ____ > From: Henrik Bengtsson > Sent: Wedn

Re: [R] netstat in R in linux...

2022-12-06 Thread Henrik Bengtsson
The error is: > > > library(netstat) > > free_port() > sh: netstat: command not found > Error in system("netstat -n -a", intern = TRUE) : > error in running command > > Thanking you, > Yours sincerely > AKSHAY M KULKARNI > ___

Re: [R] netstat in R in linux...

2022-12-06 Thread Henrik Bengtsson
What's the error?!? /Henrik On Tue, Dec 6, 2022 at 10:19 AM akshay kulkarni wrote: > > dear members, > > I am using free_port() in netstat package in R. It is working in windows but > not in linux. It is throwing an error in linux. ANy help please? > > THanking you, > Yours sincerely > AKSHAY

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Henrik Bengtsson
You need to pass character.only = TRUE to require() whenever you specify the package using a character variable. I agree, the error message is confusing. /Henrik On Mon, Oct 24, 2022 at 9:26 AM Kelly Thompson wrote: > > # Below, when using require(), why do I get the error message "Error > in

Re: [R] Deprecating download method='wininet' in R on Windows causes trouble with corporate proxy

2022-09-29 Thread Henrik Bengtsson
Is R centrally installed? If so, environment variables 'HTTP_PROXY', 'HTTPS_PROXY', and 'HTTPS_PROXY_USER' could be set for all users by setting them in the R_HOME/etc/Renviron.site file. R_HOME is the folder where R is installed. You can find this file from within R by calling: >

Re: [R] error with more 100 forked processes

2022-04-08 Thread Henrik Bengtsson
efined limit of 128. (A few connections are used by > default, and a few more will likely be used by user code during the > actual program run.) > > Try increasing the limit in #define NCONNECTIONS in > src/main/connections.c and re-compiling R. > > See also: https://github.com

Re: [R] checkpointing

2021-12-14 Thread Henrik Bengtsson
On Tue, Dec 14, 2021 at 1:17 AM Andy Jacobson wrote: > > Those are good points, Duncan. I am experimenting with a nice checkpointing > tool called DMTCP. It operates on the system level but is quite OS-dependent. > It can be found at http://dmtcp.sourceforge.net/index.html. > > Still, it would

Re: [R] I'd like to request that my R CRAN package is not tested on Solaris OS

2021-10-22 Thread Henrik Bengtsson
I agree with others that this suggests there is a hidden bug in the code. In addition to running with Valgrind, R-hub's > rhub::check(platform="linux-x86_64-rocker-gcc-san") will compile the native code with the Address Sanitizer (ASan) and the UndefinedBehaviorSanitizer (UBSan). Those have

Re: [R] small object but huge RData file exported

2021-10-20 Thread Henrik Bengtsson
Example illustrating what Duncan says: > make_formula <- function() { large <- rnorm(1e6); x ~ y } > formula <- make_formula() # "Apparent" size of object > object.size(formula) 728 bytes # Actual serialization size > length(serialize(formula, connection = NULL)) [1] 8000203 # A better size

Re: [R] Package installation help: Stuck at "** byte-compile and prepare package for lazy loading"

2021-09-29 Thread Henrik Bengtsson
I just tried on an up-to-date CentOS 7 with R 4.1.1 built from source using gcc 8.3.1 (from SCL devtoolset-8; so not the default gcc 4.8.5), and it works there. If of any help, here's the output when installing to user's personal package library: > chooseCRANmirror(ind = 1) >

Re: [R] Getting different results with set.seed()

2021-08-19 Thread Henrik Bengtsson
You need to use %dorng% from the doRNG package instead of %dopar% when parallelizing with foreach::foreach() to get reproducible random numbers. See also https://www.jottr.org/2020/09/22/push-for-statical-sound-rng/. /Henrik On Thu, Aug 19, 2021 at 1:38 PM Eric Berger wrote: > > In that case,

Re: [R] R does not start from (Debian) linux command line - error with doWithOneRestart() - segmentation fault

2021-04-08 Thread Henrik Bengtsson
Ashim, as Martin says, there's something really weird going on with your core R installation. This is definitely not expected, and I don't know think if I've every seen this reported before. Here are some questions/comments that might help you move forward and for others to pitch in: 1. How did

Re: [R] Warning messages while parallel computing

2021-03-04 Thread Henrik Bengtsson
e(gc()) > > rm(cl) > > invisible(gc()) > > > > The fact that he got 8 warnings when playing a cluster of size 8 makes > me suspect that omitting stopCluster is the problem. > > -Bill > > On Thu, Mar 4, 2021 at 10:12 AM Henrik Bengtsson > wrote: > &g

Re: [R] Warning messages while parallel computing

2021-03-04 Thread Henrik Bengtsson
I don't think 'parallel' is to blame in this case. Those warnings: Warning in for (i in seq_len(Ne + echo)) { : closing unused connection 19 come from base::source() [https://github.com/wch/r-source/blob/9caddc1eaad1f480283f1e98af34a328699d1869/src/library/base/R/source.R#L166-L244]. Unless

Re: [R] parallel: socket connection behind a NAT router

2021-01-18 Thread Henrik Bengtsson
'm in the opposite situation, the server does not have a public IP, but the > remote does. I'm not sure if this package can handle my case, but it looks > very powerful and I appreciate your help! Thanks. I've updated the text to "remote clusters without knowing [local] public IP". /Henrik

Re: [R] parallel: socket connection behind a NAT router

2021-01-18 Thread Henrik Bengtsson
If you have SSH access to the workers, then workers <- c("machine1.example.org", "machine2.example.org") cl <- parallelly::makeClusterPSOCK(workers) should do it. It does this without admin rights and port forwarding. See also the README in https://cran.r-project.org/package=parallelly.

Re: [R] vanilla session in R Gui or RStudio

2020-10-22 Thread Henrik Bengtsson
ent of .RData may trigger packages being loaded. /Henrik On Thu, Oct 22, 2020 at 7:54 PM Jeff Newmiller wrote: > > Can you be more specific about what conditions cause R to automatically load > a package when a .RData file is loaded? My experience has actually been the > opposite

Re: [R] vanilla session in R Gui or RStudio

2020-10-22 Thread Henrik Bengtsson
As Jeff says, it might be that you have a ~/.Rprofile file with instructions to load packages when R starts. It could also be that you have a .RData file, which is saved if you answer yes to: > Save workspace image? [y/n/c]: y when you quit R. If this file exists, then R loads it and all the

Re: [R] tempdir() does not respect TMPDIR

2020-08-30 Thread Henrik Bengtsson
tempdir() does not respect > the environmental variable TMPDIR, but launch R by double clicking Rgui > icon does. > > Best, > Jinsong > > On 2020/8/30 0:36, Henrik Bengtsson wrote: > > It is too late to set TMPDIR in .Renviron. It is one of the > > environment varia

Re: [R] serialize does not work as expected

2020-08-29 Thread Henrik Bengtsson
Does serialize(..., version = 2L) do what you want? /Henrik On Sat, Aug 29, 2020 at 10:10 AM Sigbert Klinke wrote: > > Hi, > > is there in R a way to "normalize" a vector from > compact_intseq/compact_realseq to a "normal" vector? > > Sigbert > > Am 29.08.20 um 18:13 schrieb Duncan Murdoch: > >

Re: [R] tempdir() does not respect TMPDIR

2020-08-29 Thread Henrik Bengtsson
It is too late to set TMPDIR in .Renviron. It is one of the environment variables that has to be set prior to launching R. From help("tempfile", package = "base"): The environment variables TMPDIR, TMP and TEMP are checked in turn and the first found which points to a writable directory is

Re: [R] & and |

2020-08-19 Thread Henrik Bengtsson
A version of Eric's answer is to use grepl(), which returns a logical vector: mydata[grepl("ConfoMap", mydata) & grepl("GuineaPigs", mydata)] with the OR analogue: mydata[grepl("ConfoMap", mydata) | grepl("GuineaPigs", mydata)] /Henrik On Wed, Aug 19, 2020 at 8:24 AM Ivan Calandra wrote: > >

Re: [R] [External] Re: Playing a music file in R

2020-07-23 Thread Henrik Bengtsson
FWIW, see also the 'midi' R package (https://github.com/moodymudskipper/midi). It's not on CRAN. /Henrik On Thu, Jul 23, 2020 at 12:19 PM Rasmus Liland wrote: > > On 2020-07-23 14:19 -0400, Richard M. Heiberger wrote: > > On Thu, Jul 23, 2020 at 7:21 AM bretschr wrote: > > > > > > Dear Vahid,

Re: [R] doParallel cores HPC

2020-06-26 Thread Henrik Bengtsson
> On the other hand, [...], you can spawn 20 workers on each of the 10 hosts: > > makePSOCKcluster(names = rep(c('Host01', ..., 'Host10'), each = 20)) Unfortunately, this will most likely not work because it will require 200 open connections - one for each worker - but R limits you to 125 (see

Re: [R] Rtools required

2020-04-29 Thread Henrik Bengtsson
Careful so you don't overwrite an existing ~/.Renviron file; it's safer to use something like: cat('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"\n', file="~/.Renviron" append=TRUE) /Henrik On Wed, Apr 29, 2020, 15:33 Fox, John wrote: > Dear Steven, > > It's possible that Windows will hide

Re: [R] Please correct my iterative merge sort code. The lack of recursion in the code is the main condition.

2019-12-16 Thread Henrik Bengtsson
Folks on this list, this is my personal opinion, but please refrain from answering this person's requests. It's pretty clear by now that they are misusing your good intentions of trying to help people interested in R to get their homework-like "questions" answered. There are no indications that

Re: [R] cannot open file '--no-restore.matrix'

2019-11-23 Thread Henrik Bengtsson
gt; > > I also tried this: > Rscript --no-save MR.R ENSG0154803.ld ENSG0154803.matrix > [1] "ENSG0154803.ld" "ENSG0154803.matrix" > Error: File not found: NA.matrix > Execution halted > > > Rscript --no-save MR.R ENSG0154803.ld

Re: [R] cannot open file '--no-restore.matrix'

2019-11-23 Thread Henrik Bengtsson
Maybe it would help to add: file<-paste(gene,"matrix",sep=".") if (!file.exists(file)) stop("File not found: ", file) filecluster<-read.table(file,header=T,sep=" ",dec=".") /Henrik On Sat, Nov 23, 2019 at 11:55 AM Duncan Murdoch wrote: > > On 23/11/2019 1:21 p.m., Ana Marija wrote: > > Hi

Re: [R] .libPaths() can not deal non-latin characters?

2019-10-21 Thread Henrik Bengtsson
The folder must exist. If not, .libPaths() *silently* ignores it. Could that be it? Henrik On Mon, Oct 21, 2019, 02:32 Jinsong Zhao wrote: > Hi there, > > I have a computer run Win10 with user names in Chinese. I installed R on > it. It can run normally. When I installed a package, for

Re: [R] Error with install.packages using R v 3.5.1 and 3.5.2

2019-01-16 Thread Henrik Bengtsson
Immediately after you get that error: Error in if (any(diff)) { : missing value where TRUE/FALSE needed what does > traceback() output? (I suspect this error occurs in tools:::checkMD5sums() used to assert that the package files are correctly downloaded). Also, going forward, let's try with

Re: [R] g++ error causes non-zero exit status for package installation

2019-01-05 Thread Henrik Bengtsson
On Sat, Jan 5, 2019 at 9:41 AM Dirk Eddelbuettel wrote: > > > On 5 January 2019 at 09:14, William Dunlap via R-help wrote: > | You would get these errors ("R: file or directory not found, version: file > | or directory not found...") if you had a ~/.Rprofile file containing the > | line

Re: [R] Access function as text from package by name

2018-09-27 Thread Henrik Bengtsson
deparse(graphics::box) /Henrik On Thu, Sep 27, 2018 at 3:30 AM Sigbert Klinke wrote: > > Hi, > > I want to have a function, e.g. graphics::box, as text. > Currently I'am using > > deparse(eval(parse(text='graphics::box'))) > > It is important that '::' and ':::' can be used in the name. > > Is

Re: [R] makeCluster() hangs infinitely

2018-09-17 Thread Henrik Bengtsson
s like a "connection problem" - this could be a firewall issue or similar. I'm not on macOS, so I cannot help you there, but maybe others can pitch in. /Henrik > > Thanks, > Zhihao > -- > Zhihao (Daniel) Huang > Graduate Student > Department of Statistics, > Uni

Re: [R] makeCluster() hangs infinitely

2018-09-16 Thread Henrik Bengtsson
Hi, did you see my answer on StackOverflow? Specifically, if you set argument 'outfile = NULL' to either of those two functions, you'll get a little bit more information that *might* provide some clues. /Henrik On Sun, Sep 16, 2018 at 5:38 PM Zhihao Huang wrote: > > Hi all, > > The function

Re: [R] sink() output to another directory

2018-09-13 Thread Henrik Bengtsson
On Thu, Sep 13, 2018 at 7:12 PM Rich Shepard wrote: > > On Thu, 13 Sep 2018, Henrik Bengtsson wrote: > > >> sink('stat-summaries/estacada-se-precip.txt') > >> print(summary(estacada_se_wx)) > >> sink() > >> > >> while accept

Re: [R] sink() output to another directory

2018-09-13 Thread Henrik Bengtsson
On Thu, Sep 13, 2018 at 6:05 PM Rich Shepard wrote: > > On Thu, 13 Sep 2018, MacQueen, Don wrote: > > > In my experience, any path that can be used at the shell prompt in a > > unix-alike can be used anywhere that R wants a file name. > > Don, > >That's been my experiences, too. > > >

Re: [R] sink() output to another directory

2018-09-13 Thread Henrik Bengtsson
On Thu, Sep 13, 2018 at 3:33 PM Rich Shepard wrote: > >Neither ?sink nor ?capture.output indicates how the output file can be > specified to be in a directory other than the cwd. > >When the cwd is ../analyses/ and I want the output to be in > ../analyses/stat-summaries/ how do I write

Re: [R] Mysterious seg fault --- SOLVED

2018-08-13 Thread Henrik Bengtsson
On Mon, Aug 13, 2018 at 3:51 AM Rolf Turner wrote: > > > OK everybody! You can relax. :-) I managed to spot the loony. After > mucking around with valgrind, and before trying gdb, I had one more look > at my code and *finally* saw the stupid thing that I had been doing. > > In the call to

Re: [R] subsetting ls() as per class...

2018-07-28 Thread Henrik Bengtsson
The ll() function of R.oo returns a data.frame with various attributes that you can subset on, e.g. > subset(R.oo::ll(), data.class %in% c("zoo", "xts")) member data.class dimension objectSize 2 fzzoo10 1344 4 sample.xtsxts c(180,4) 10128 5

Re: [R] Unable to Change Library Paths in R 3.5.1 in Windows 10

2018-07-26 Thread Henrik Bengtsson
Some more info: 1. The library folder have to exist; if not, then R will silently ignore it. 2. Try call your .libPaths(my_new_folder) setup in an interactive R session. Then, in the same session, look at .libPaths(). The first element should be your new folder. If not, make sure it exists,

Re: [R] [bug] spdep package?

2018-07-23 Thread Henrik Bengtsson
This is intended/expected because the spdep package *depends* on the spData package (see https://cran.r-project.org/web/packages/spdep/), which means that the maintainer of spdep intends also spData to be *attached* whenever spdep is attached.If they would have only imported it, then spData

Re: [R] [bug] spdep package?

2018-07-23 Thread Henrik Bengtsson
It turns out that that 'x' comes from the spData package and lives inside that package (part of its namespace). > spData::x [1] 0 30 60 90 120 150 180 210 240 270 300 330 360 390 420 450 This is conceptually no different from other objects in package namespace, although we are more used to

Re: [R] Package 'data.table' in version R-3.5.0 not successfully being installed

2018-04-26 Thread Henrik Bengtsson
If you're installing packages to the default location in your home account and you didn't remove those library folders, you still have you R 3.4 package installs there, e.g. > dir(dirname(.libPaths()[1]), full.names = TRUE) [1] "/home/hb/R/x86_64-pc-linux-gnu-library/3.4" [2]

Re: [R] Information about compatibility R

2018-04-11 Thread Henrik Bengtsson
I guess I misread your question. /Henrik On Wed, Apr 11, 2018 at 12:15 PM, Marcos Fiorini wrote: > Hi Albrecht, thanks for your return. > > I'm using the SUSE Linux Enterprise Server 11 (x86_64) PATCHLEVEL = 4 and > not the openSUSE. Do you know if exist a

Re: [R] Information about compatibility R

2018-04-11 Thread Henrik Bengtsson
Hi, your question is nearly impossible to answer without actual testing of your existing pipelines. But from my soon 20-year usage of R, it's clear to me that the R Core Team strives to keep things backward compatible as far as they can. The NEWS file:

Re: [R] Possible Improvement to sapply

2018-03-13 Thread Henrik Bengtsson
FYI, in R devel (to become 3.5.0), there's isFALSE() which will cut some corners compared to identical(): > microbenchmark::microbenchmark(identical(FALSE, FALSE), isFALSE(FALSE)) Unit: nanoseconds expr min lqmean median uq max neval identical(FALSE, FALSE) 984

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
On Sun, Mar 4, 2018 at 3:23 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > On 04/03/2018 5:54 PM, Henrik Bengtsson wrote: >> >> The following helps identify when .GlobalEnv$.Random.seed has changed: >> >> rng_tracker <- local({ >>last

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
On Sun, Mar 4, 2018 at 10:18 AM, Paul Gilbert wrote: > On Mon, Feb 26, 2018 at 3:25 PM, Gary Black > wrote: > > (Sorry to be a bit slow responding.) > > You have not supplied a complete example, which would be good in this case > because what you

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
The following helps identify when .GlobalEnv$.Random.seed has changed: rng_tracker <- local({ last <- .GlobalEnv$.Random.seed function(...) { curr <- .GlobalEnv$.Random.seed if (!identical(curr, last)) { warning(".Random.seed changed") last <<- curr } TRUE } })

Re: [R] change location of temporary files

2018-02-23 Thread Henrik Bengtsson
On Fri, Feb 23, 2018 at 1:55 PM, William Dunlap via R-help wrote: > Does setting the environment variable TMPDIR, before starting R, > to a directory on a bigger file system help? On Linux I get > > % mkdir /tmp/RTMP-BILL > % env TMPDIR=/tmp/RTMP-BILL R --quiet

Re: [R] Take the maximum of every 12 columns

2018-02-20 Thread Henrik Bengtsson
It looks like OP uses a data.frame, so in order to use matrixStats (I'm the author) one would have to pay the price to coerce to a matrix before using matrixStats::rowMaxs(). However, if it is that the original data could equally well live in a matrix, then matrixStats should be computational

Re: [R] PSOCK cluster and renice

2018-02-11 Thread Henrik Bengtsson
d work fine! Thanks a lot. > > Best, > Andreas > > > > Henrik Bengtsson <henrik.bengts...@gmail.com> writes: > >> Looks like a bug to me due to wrong assumptions about 'nice' >> arguments, but could be because a "non-standard" 'nice' is used. If &g

Re: [R] Error while working with png output on linux server

2018-02-01 Thread Henrik Bengtsson
You could try with png2() in the R.devices package, which is just a convenient wrapper around the bitmap() device which can also produce PNGs. It's not perfect but it might get you going. Henrik On Feb 1, 2018 08:24, "Sariya, Sanjeev" wrote: > Thanks for your reply. I

Re: [R] Newbie wants to compare 2 huge RDSs row by row.

2018-01-28 Thread Henrik Bengtsson
The diffobj package (https://cran.r-project.org/package=diffobj) is really helpful here. It provides "diff" functions diffPrint(), diffStr(), and diffChr() to compare two object 'x' and 'y' and provide neat colorized summary output. Example: > iris2 <- iris > iris2[122:125,4] <-

Re: [R] Merging RData files

2018-01-16 Thread Henrik Bengtsson
To expand on what Bert suggests. Use: loadToEnv <- function(file, ..., envir = new.env()) { base::load(file = file, envir = envir, ...) } envA <- loadToEnv("a.RData") envB <- loadToEnv("b.RData") and then access the objects in environments envA and envB using environment access methods, e.g.

Re: [R] R minor version

2018-01-12 Thread Henrik Bengtsson
This can be controlled by environment variables R_LIBS, R_LIBS_SITE, and R_LIBS_USER, which support "conversion specifiers". See help(".libPaths") or aliases help("R_LIBS") etc. You can set these in in any of the Renviron files (~/.Renviron, /path/to/R/etc/Renviron,

Re: [R] How to programmatically save a web-page using R (mimicking Command+S)

2018-01-06 Thread Henrik Bengtsson
The 'webshot' package (on CRAN) can do this. Henrik On Jan 6, 2018 05:27, "Christofer Bogaso" wrote: > Hi, > > I would appreciate if someone can give me a pointer on how to save a > webpage programmatically using R. > > For example, let say I have this webpage open

Re: [R] PSOCK cluster and renice

2017-12-03 Thread Henrik Bengtsson
Looks like a bug to me due to wrong assumptions about 'nice' arguments, but could be because a "non-standard" 'nice' is used. If we do: > trace(system, tracer = quote(print(command))) Tracing function "system" in package "base" we see that the system call used is: > cl <-

Re: [R] valid package repositories

2017-10-02 Thread Henrik Bengtsson
Here's my view on this: CRAN = Comprehensive R Archive Network. The "Archive" part is very important - it "promises" the research community that R packages that have ever been published on CRAN, and all the versions of each package, will be available also in the future. It requires quite a bit

Re: [R] R_LIBS_USER not in libPaths

2017-09-16 Thread Henrik Bengtsson
I'm not sure I follow what.the problem is. Are you trying to set R_LIBS_USER but R does not acknowledge it, or do you observe something in R that you didn't expect to be there and you are trying to figure out why that is / where that happens? Henrik On Sep 16, 2017 07:10, "Rene J Suarez-Soto"

Re: [R] getOption() versus Sys.getenv

2017-08-25 Thread Henrik Bengtsson
There's also the alternative to use both, e.g. by having a system environment variable set a corresponding R option, which then can be overridden using options(). For instance, the R option mc.cores, which is used by the parallel package, is set to the (integer) value of system environment

Re: [R] about reading files in order

2017-06-29 Thread Henrik Bengtsson
You can use: > files <- list.files(path = "folder01") > files <- gtools::mixedsort(files) to order the files in a "human-friendly" order rather than lexicographic order (which sort() provides). FYI 1; it's preferred to use file.path("folder01", list[i]) rather than

Re: [R] odfWeave - A loop of the "same" data

2017-06-01 Thread Henrik Bengtsson
This is what the R.rsp (https://cran.r-project.org/package=R.rsp; I'm the author) and it's RSP markup is good at and was designed to handle. We're using it lots in report generation where we iterate of elements, e.g. over the 24 chromosomes. See Section 2.3 in

Re: [R] Maximum length for a -e argument to Rscript?

2017-04-21 Thread Henrik Bengtsson
That Rscript stalls sounds like a bug, but not sure it's R or the terminal that needs to be fixed: Rscript -e "$long_expression" WARNING: '-e

Re: [R] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-19 Thread Henrik Bengtsson
I'd be really surprised if basically not all text editors could be used here; it more that some have quirks making it less obvious. For instance, with plain old Notepad that comes with all Windows distros you can put (double) quotes around the file name in the Save As... dialog to prevent Notepad

Re: [R] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-17 Thread Henrik Bengtsson
Did you try any of the troubleshooting I suggested? If you do that, I'm 99.99% certain it'll help you to resolve this. Henrik On Apr 17, 2017 03:07, "Bruce Ratner PhD" wrote: David: When I launch Rstudio the effects of the Rprofile do not show, e.g., I want the prompt to be

Re: [R] Setting .Rprofile for RStudio on a Windows 7 x64bit

2017-04-15 Thread Henrik Bengtsson
Hi. First, there should be no difference in where and how R and RStudio locate the R startup file. Second, if there is an .Rprofile in the working directory (i.e. ./.Rprofile), then that file with have higher priority than the file located in ~/.Rprofile. You can use the following R calls, also

[R] The R-help community list was started on this day 20 years ago

2017-04-01 Thread Henrik Bengtsson
Today, it is been 20 years since Martin Mächler started the R-help community list (https://stat.ethz.ch/pipermail/r-help/). The first post was written by Ross Ihaka on 1997-04-01: Subject: R-alpha: R-testers: pmin heisenbug From: Ross Ihaka When: Tue Apr 1 10:35:48 CEST 1997 Archive:

Re: [R] Setting up a .Rprofile file

2017-03-24 Thread Henrik Bengtsson
R for Windows is a bit peculiar where it locates your .Rprofile file, or rather what it consider to be your home directory. If you look from within R, the file you do want to create / edit is: > f <- normalizePath("~/.Rprofile", mustWork = FALSE) > f [1] "C:\\Users\\joe\\Documents\\.Rprofile"

Re: [R] How to do double (nested) parSapply in R?

2017-02-02 Thread Henrik Bengtsson
Quick comment: sapply() / parSapply() can behaves "unexpectedly". To troubleshoot this, use parLapply() instead to see if you at least get the individual results you think you should get. Henrik On Feb 2, 2017 08:03, "Art U" wrote: > Hello, > > I have a data orig.raw that

Re: [R] [FORGED] file.exists() on device files

2017-01-11 Thread Henrik Bengtsson
On Wed, Jan 11, 2017 at 3:56 PM, Rolf Turner wrote: > On 11/01/17 23:12, Benjamin Tyner wrote: >> >> Hi, >> >> On my linux machine (Ubuntu, and also tested on RHEL), I am curious to >> know what might be causing file.exists (and also normalizePath) to not >> see the final

Re: [R] getTimeLimit?

2017-01-03 Thread Henrik Bengtsson
On Tue, Jan 3, 2017 at 2:43 PM, William Dunlap via R-help wrote: > I am interested in measuring the time it takes to run an expression. > system.time(expr) does this but I would like to have it report just 'more > than xxx seconds', where xxx is a argument to the timing

Re: [R] Memory problem

2016-11-22 Thread Henrik Bengtsson
On Windows 32-bit I think (it's been a while) you can push it to 3 GB but to go beyond you need to run R on 64-bit Windows (same rule for all software not just R). I'm pretty sure this is already documented in the R documentation. Henrik On Nov 22, 2016 19:49, "Ista Zahn"

Re: [R] Is this foreach behaviour correct?

2016-11-13 Thread Henrik Bengtsson
On Nov 13, 2016 13:54, "Henrik Bengtsson" <henrik.bengts...@gmail.com> wrote: > > It looks like a bug. I don't think c.Date() is every called, because: > > > trace(c.Date, tracer = quote(message("c.Date() called"))) > Tracing function "c.Date&qu

Re: [R] Is this foreach behaviour correct?

2016-11-13 Thread Henrik Bengtsson
It looks like a bug. I don't think c.Date() is every called, because: > trace(c.Date, tracer = quote(message("c.Date() called"))) Tracing function "c.Date" in package "base" [1] "c.Date" Tracing works: > c(as.Date(1L), as.Date(10001L)) Tracing c.Date(as.Date(1L), as.Date(10001L)) on

Re: [R] remove a "corrupted file" after using download.file() with R on Windows 7

2016-09-29 Thread Henrik Bengtsson
1. It could be that a virus checker locks the file. 2. There are Windows software tools that identify which process locks a particular file, e.g. LockHunter (http://lockhunter.com/). Those should help you figure out what's going on. 3. R.utils::downloadFile() tries it's best to download files

Re: [R] Replacing value with "1"

2016-09-23 Thread Henrik Bengtsson
which(df == 1, arr.ind=TRUE) is useful here: > df <- matrix(c(0,NA,0,0,0,1,1,1,0,0,1,0,0,0,NA), nrow=3) > df [,1] [,2] [,3] [,4] [,5] [1,]00100 [2,] NA0110 [3,]0100 NA > ## Identify (row,col) indices for 1:s > idxs <- which(df == 1,

Re: [R] Accelerating binRead

2016-09-18 Thread Henrik Bengtsson
I second Mike's proposal - it works, e.g. https://github.com/HenrikBengtsson/affxparser/blob/5bf1a9162904c56d59c4735a8d7eb427e4f085e4/R/readCcg.R#L535-L583 Here's an outline. Say each row consists of tuple (=4-byte integer, =4-byte float, ss=2 byte integer) so that the byte-by-byte

Re: [R] Maximum # of DLLs reached, or, how to clean up after yourself?

2016-09-14 Thread Henrik Bengtsson
t the end of the >>Script2. *Unless there's a better way to do it* (which is my question >>- >>is there?). I'm possibly just pushing the whole procedural scripting >>thing too far, but I also think that this likely isn't uncommon in R. >> >>Any thoughts greatly a

Re: [R] Maximum # of DLLs reached, or, how to clean up after yourself?

2016-09-13 Thread Henrik Bengtsson
In R.utils (>= 2.4.0), which I hope to submitted to CRAN today or tomorrow, you can simply call: R.utils::gcDLLs() It will look at base::getLoadedDLLs() and its content and compare to loadedNamespaces() and unregister any "stray" DLLs that remain after corresponding packages have been

Re: [R] save R object into a remote directory

2016-09-06 Thread Henrik Bengtsson
On Tue, Sep 6, 2016 at 2:00 AM, Rainer M Krug wrote: > Please reply to the mailing list to keep the conversation available for > everybody. I Send this mail to the mailing list as well. > > Simone Tenan writes: > >> Thanks Rainer, >> it's very kind of

Re: [R] paste0 in file path

2016-08-31 Thread Henrik Bengtsson
Also, the recommended way to build file paths is to use file.path(), i.e. file.path("C:", "temp", filename) rather than paste0("C:/temp/", filename) BTW, R provides tempdir() that gives you the temporary directory that R prefers to use on your OS. So, you might want to consider using:

Re: [R] Antwort: Re: Antwort: Re: Re: sink(): Cannot open file

2016-05-11 Thread Henrik Bengtsson
Sounds like it would be helpful to find out exactly which process is holding on to the file in order to figure out what's going on. From a quick look, it seems that http://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows gives some useful info on

Re: [R] Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?

2016-04-20 Thread Henrik Bengtsson
On Wed, Apr 20, 2016 at 1:25 AM, Martin Maechler <maech...@stat.math.ethz.ch> wrote: >>>>>> Henrik Bengtsson <henrik.bengts...@gmail.com> >>>>>> on Tue, 19 Apr 2016 14:04:11 -0700 writes: > > > Using the Matrix package, how can I

[R] Matrix: How create a _row-oriented_ sparse Matrix (=dgRMatrix)?

2016-04-19 Thread Henrik Bengtsson
Using the Matrix package, how can I create a row-oriented sparse Matrix from scratch populated with some data? By default a column-oriented one is created and I'm aware of the note that the package is optimized for column-oriented ones, but I'm only interested in using it for holding my sparse

Re: [R] Reshaping an array - how does it work in R

2016-03-19 Thread Henrik Bengtsson
xNA-wrong-way.html for details. /Henrik > > -Roy > > >> On Mar 18, 2016, at 7:37 PM, Henrik Bengtsson <henrik.bengts...@gmail.com> >> wrote: >> >> On Fri, Mar 18, 2016 at 3:15 PM, Roy Mendelssohn - NOAA Federal >> <roy.mendelss...@noaa.gov>

Re: [R] Reshaping an array - how does it work in R

2016-03-18 Thread Henrik Bengtsson
On Fri, Mar 18, 2016 at 3:15 PM, Roy Mendelssohn - NOAA Federal wrote: > Thanks. That is what I needed to know. I don’t want to play around with > some of the other suggestions, as I don’t totally understand what they do, > and don’t want to risk messing up something

Re: [R] Create macro_var in R

2016-02-03 Thread Henrik Bengtsson
Don't know what `population` is, but a simple assignment MVAR <- population may provide what you need. Note, no c(). For example, > foo <- rnorm > foo(3) [1] -0.08093862 -0.87827617 1.52826914 /Henrik On Wed, Feb 3, 2016 at 9:41 AM, Amoy Yang via R-help wrote: >

Re: [R] Error because of large dimension

2016-01-24 Thread Henrik Bengtsson
FYI, the matrix you tried to allocate would hold (3195*1290*495*35*35*35*15) * 3 = 3.936248e+15 values. Each value would occupy 8 bytes of memory (for the double data type). In other words, in order to keep this data matrix in memory you would require a computer with at least 3.148998e+16 bytes

Re: [R] close specific graphics device

2015-12-16 Thread Henrik Bengtsson
The R.devices package provides functions for this. For instance, you can open several devices with different labels and the close then in whatever order you'd like: > library("R.devices") > devSet("foo") > plot(1:10) > devSet("bar") > plot(10:1) > devSet("foo") > points(10:1) > devSet("bar") >

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Henrik Bengtsson
On Sat, Dec 12, 2015 at 6:08 AM, Hadley Wickham <h.wick...@gmail.com> wrote: > On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler > <maech...@stat.math.ethz.ch> wrote: >>>>>>> Henrik Bengtsson <henrik.bengts...@gmail.com> >>>>>>>

Re: [R] stopifnot with logical(0)

2015-12-11 Thread Henrik Bengtsson
On Fri, Dec 11, 2015 at 8:10 AM, David Winsemius wrote: > >> On Dec 11, 2015, at 5:38 AM, Dario Beraldi wrote: >> >> Hi All, >> >> I'd like to understand the reason why stopifnot(logical(0) == x) doesn't >> (never?) throw an exception, at least in

Re: [R] Ordering Filenames stored in list or vector

2015-12-04 Thread Henrik Bengtsson
> filenames <- c("Q_Read_prist#1...@1.xls", "Q_Read_prist#1...@10.xls", > "Q_Read_prist#1...@2.xls") > filenames <- gtools::mixedsort(filenames, numeric.type="decimal") > filenames [1] "Q_Read_prist#1...@1.xls" "Q_Read_prist#1...@2.xls" "Q_Read_prist#1...@10.xls" /Henrik On Fri, Dec 4, 2015

Re: [R] SWEAVE - a gentle introduction

2015-11-17 Thread Henrik Bengtsson
When choosing source format, it's probably helpful to know that if you work with a Markdown-based format (e.g. Rmarkdown) you'll be able to generate either/both HTML or/and PDF documents, whereas if you work with LaTeX-based formats (e.g. Sweave/knitr) you will only be able output PDF documents

Re: [R] conditionally disable evaluation of chunks in Rmarkdown...

2015-11-10 Thread Henrik Bengtsson
On Tue, Nov 10, 2015 at 9:00 AM, Yihui Xie wrote: > The short answer is you cannot. Inline R code is always evaluated. > When it is not evaluated, I doubt if your output still makes sense, > e.g. "The value of x is `r x`." becomes "The value of x is ." That > sounds odd to me. >

Re: [R] Changing text file to .r format

2015-11-06 Thread Henrik Bengtsson
My guess is that your on Windows. If so, make sure to change settings in Explorer to always show filename extensions, because now I think it drops .txt when it lists/displays your files (this is one of the most annoying features in Windows). Also, some basic editors add .txt extension when you

Re: [R] Last msg not sent to the list

2015-10-14 Thread Henrik Bengtsson
In addition, if you go to https://stat.ethz.ch/mailman/listinfo/r-help (which is in the footer of every R-help message), you'll find a link to 'R-help Archives' (https://stat.ethz.ch/pipermail/r-help/). On that latter page, you'll see all messages that have been sent out to the list. That will

Re: [R] why must a named colClasses in read.table be in correct order

2015-07-08 Thread Henrik Bengtsson
---end---8--- What am I missing? Best, Andreas On 09/07/2015 02:21, Henrik Bengtsson wrote: read.table() does not make use of names(colClasses) - only its values. Because of this, ordering is critical, as you noted. It shouldn't be too hard to add support for a named `colClasses

  1   2   3   4   5   6   >