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

2023-07-02 Thread Henrik Bengtsson
e my blog post 'Please Avoid detectCores() in your R Packages' (https://www.jottr.org/2022/12/05/avoid-detectcores/) from 2022-12-05 for even more reasons. /Henrik On Sun, Jul 2, 2023 at 9:55 AM Ravi Varadhan via R-help wrote: > > This is the specific error messsage from R CMD che

Re: [R] suprising behaviour of tryCatch()

2023-05-18 Thread Henrik Bengtsson
e how the latter two assigned a <- 2 to the global environment. /Henrik On Thu, May 18, 2023 at 8:22 AM Berwin A Turlach wrote: > > G'day Federico, > > On Wed, 17 May 2023 10:42:17 + > "Calboli Federico (LUKE)" wrote: > > > sexsnp = rep(NA, 1750) &g

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

2022-12-06 Thread Henrik Bengtsson
d port4me, see the vignette <https://cran.r-project.org/web/packages/port4me/vignettes/port4me-overview.html>. /Henrik On Tue, Dec 6, 2022 at 11:00 AM akshay kulkarni wrote: > > Dear Henrik > It is workingthanks a lot! I had actually > previously t

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

2022-12-06 Thread Henrik Bengtsson
m the author) A cross-platform alternative to netstat::free_port(), is port4me::port4me(), which is also available from CRAN (https://cran.r-project.org/package=port4me). It requires no external tools, but R (>= 4.0.0). /Henrik On Tue, Dec 6, 2022 at 10:41 AM akshay kulkarni wrote: > > Dear Henr

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,

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 "

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

2022-09-29 Thread Henrik Bengtsson
ron") [1] "C:\\Users\\alice\\Documents\\.Renviron" For example, > cat(file = "~/.Renviron", append = TRUE, > "HTTP_PROXY=http://proxy-host:3128/";, "HTTPS_PROXY=https://proxy-host:3128/";, > "HTTPS_PROXY_USER=dummy", sep = "\n") At l

Re: [R] error with more 100 forked processes

2022-04-08 Thread Henrik Bengtsson
compatible with multi-threaded code used by some packages. This is a problem independent of futures per se. Hope this helps Henrik On Fri, Apr 8, 2022 at 2:19 PM Ivan Krylov wrote: > > On Fri, 8 Apr 2022 22:02:25 +0200 > Guido Kraemer via R-help wrote: > > > > cl <-

Re: [R] checkpointing

2021-12-14 Thread Henrik Bengtsson
ov/development/checkpoint-restart/dmtcp/ * http://wiki.orc.gmu.edu/mkdocs/Creating_Checkpoints_%28DMTCP%29/ * https://wiki.york.ac.uk/display/RCS/VK21%29+Checkpointing+with+DMTCP That's all I have time for now, Henrik > > -Andy > > On 12/13/21 11:51 AM, Duncan Murdoch wrote: > >

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

2021-10-22 Thread Henrik Bengtsson
BSan). Those have helped me in the past to track down mistakes, and even spot things I was not aware of. And it's an ease of mind as a developer when these tools and Valgrind checks give all OK reports. The R-hub services is cross-platform and requires no local setup. /Henrik On Fri, Oct 2

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

2021-10-20 Thread Henrik Bengtsson
)) [1] 8000203 # A better size estimate > lobstr::obj_size(formula) 8,000,888 B /Henrik On Wed, Oct 20, 2021 at 12:57 PM Duncan Murdoch wrote: > > On 20/10/2021 9:20 a.m., Jinsong Zhao wrote: > > On 2021/10/20 21:05, Duncan Murdoch wrote: > >> On 20/10/2021 8:57 a.m., J

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

2021-09-29 Thread Henrik Bengtsson
install.packages("forensim") Installing package into ‘/c4/home/henrik/R/x86_64-pc-linux-gnu-library/4.1-CBI-gcc8’ (as ‘lib’ is unspecified) trying URL 'https://cloud.r-project.org/src/contrib/forensim_4.3.tar.gz' Content type 'appl

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 tha

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

2021-04-08 Thread Henrik Bengtsson
f any of 2-4 gives a different result, that's a first clue. /Henrik On Wed, Apr 7, 2021 at 1:17 AM Ashim Kapoor wrote: > > On Wed, Apr 7, 2021 at 12:51 PM Martin Maechler > wrote: > > > > >>>>> Ashim Kapoor > > >>>>>

Re: [R] Warning messages while parallel computing

2021-03-04 Thread Henrik Bengtsson
Test with: clusterCall(cl, function() { suppressWarnings(source("xx.R")) }) If the warnings disappear, then the warnings are produced on the workers from source():ing the file. /Henrik On Thu, Mar 4, 2021 at 10:20 AM Bill Dunlap wrote: > > The warnings come from the garbage

Re: [R] Warning messages while parallel computing

2021-03-04 Thread Henrik Bengtsson
ing source("xx.R") sequentially in a for() loop or an lapply() call. Hope this helps, Henrik On Thu, Mar 4, 2021 at 9:58 AM Bill Dunlap wrote: > > To avoid the warnings from gc(), call parallel::stopCluster(cl) before > removing or overwriting cl. > > -Bill > >

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

2021-01-18 Thread Henrik Bengtsson
uot;. I think this might be where the confusion is, it may mean > the remote machine does not have a public IP, but the server machine does. > I'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 cas

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

2021-01-18 Thread Henrik Bengtsson
ect.org/package=parallelly. /Henrik On Mon, Jan 18, 2021 at 6:45 AM Jiefei Wang wrote: > > Hi all, > > I have a few cloud instances and I want to use them to do parallel > computing. I would like to create a socket cluster on my local machine to > control the remote instances. Here i

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

2020-10-22 Thread Henrik Bengtsson
quot;base" "lattice" > > Also, if you have saved S4 objects (e.g. x <- Matrix::Matrix(0, 3, 2)), they will trigger their corresponding packages to be loaded when "used" (e.g. print():ed) but not before. Not saying it explains all of OPs packages - just wanted to sa

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

2020-10-22 Thread Henrik Bengtsson
an start R at the terminal with 'R --vanilla'. /Henrik On Thu, Oct 22, 2020 at 4:14 PM Jeff Newmiller wrote: > > Have you looked into your .Rprofile file? Loading packages is not something R > normally does without your telling it to do so, but many people forget that > they

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

2020-08-30 Thread Henrik Bengtsson
hat is, the .Renviron file that is located in the same folder as the .RData file. It will never load ~/.Renviron (e.g. C:/Users\alice/Documents/.Renviron) unless the .RData file is in that folder too. This looks odd to me but it could be that I made another mistake in my conclusions above. I let someon

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 > &

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

2020-08-29 Thread Henrik Bengtsson
le directory is used: if none succeeds ‘/tmp’ is used. The path should not contain spaces. **Note that setting any of these environment variables in the R session has no effect on tempdir(): the per-session temporary directory is created before the interpreter is started.** /Henrik On Sat, Aug

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

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 wr

Re: [R] doParallel cores HPC

2020-06-26 Thread Henrik Bengtsson
> larger than 125. Depending on the system, you might be able to increase this by rebuilding R from source after editing a hard-coded constant. I've verified that this worked on a local Ubuntu 16.04 system. See https://github.com/HenrikBengtsson/Wishlist-for-R/issues/28 for details about this

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 Steve

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
no indications that this person has even attempted to solve the "problems" themselves. This smells bad intent to me. /Henrik On Mon, Dec 16, 2019, 07:40 Александр Дубровский wrote: > mrg <- function(A,B){ > R <- c() > while(length(A)>0 length(B)>0){ &

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

2019-11-23 Thread Henrik Bengtsson
quot;gene","alpha","SE","P","Nsnps","Ngene") file<-paste(gene,"matrix",sep=".") if (!file.exists(file)) stop("File not found: ", file) filecluster<-read.table(file,header=T,sep=" ",dec=".&qu

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 wrot

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

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

2019-01-16 Thread Henrik Bengtsson
try with a single package installed, e.g. install.packages("glue"). Does that also give an error? /Henrik On Wed, Jan 16, 2019 at 11:10 AM Jeff Newmiller wrote: > > I don't know specifically where that error comes from... but I can think of > two possible directions to

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

2019-01-05 Thread Henrik Bengtsson
ipt option to silence all R startup stdout and/or stderr output? For example, Rscript --quiet-startup -e "Rcpp:::LdFlags()"` /Henrik PS. It's probably better to output to stderr in .Rprofile, e.g. by always using message() instead of cat(

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 

Re: [R] makeCluster() hangs infinitely

2018-09-17 Thread Henrik Bengtsson
On Mon, Sep 17, 2018 at 12:56 PM Zhihao Huang wrote: > > Hi Henrik, > > Thanks for the suggestions! I tried your approach, and obtained the following > output, which is pretty similar to the previous ones. > > > cl <- future::makeClusterPSOCK(1, outfile = NULL, verbos

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

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() > >> > >> wh

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

2018-09-13 Thread Henrik Bengtsson
xt' > > generates the same error "same error" as what? (ambiguity is the reason for not being able to help you - all the replies in this thread this far are correct and on the spot) BTW, not that it should matter, what is your opera

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

2018-09-13 Thread Henrik Bengtsson
r(s) to help you by being as explicit as possible what you've tried (i.e. cut'n'paste your code), provide error messages (cut'n'paste) you get, if any, and/or what you mean by "don't sit well with R" (that can mean many different things). /Henrik > What is t

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

2018-08-13 Thread Henrik Bengtsson
t R CMD check pick this up, that is, didn't it report that 'nphi' is a "global" variable? /Henrik > > It seems that passing a non-existent value as an argument to a Fortran > subroutine can *sometimes* confuse it. Understandably. > > I think that this "n

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

2018-07-28 Thread Henrik Bengtsson
z2zooc(4,3)904 14z20zooc(4,0)616 15 z3zoo 8528 16 z4zoo 5592 17 z5zoo 5792 Henrik On Sat, Jul 28, 2018, 08:22 Jeff Newmiller wrote: > You ca

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

2018-07-26 Thread Henrik Bengtsson
122923’ (29 bytes) Warning message: In check_rprofile_eof(all = all, fix = fix, backup = backup, debug = debug) : SYNTAX ISSUE FIXED: Added missing newline to the end of file ~/.Rprofile, which otherwise would cause R to silently ignore the file in the startup process. > /Henrik On Wed, Jul 25,

Re: [R] [bug] spdep package?

2018-07-23 Thread Henrik Bengtsson
thub.io/drat/', type='source')) > loadedNamespaces() [1] "compiler" "graphics" "utils" "grDevices" "stats" "datasets" [7] "methods" "spData""base" ## Now, spData is on the se

Re: [R] [bug] spdep package?

2018-07-23 Thread Henrik Bengtsson
more used to seeing functions and not data object. Another well-known example of this is: > base::pi [1] 3.141593 So, this 'x' is *not* in your global workspace and you cannot remove it without unloading the package. /Henrik On Mon, Jul 23, 2018 at 12:30 PM Jeremie Juste wro

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

2018-04-26 Thread Henrik Bengtsson
[2] "/home/hb/R/x86_64-pc-linux-gnu-library/3.5" [3] "/home/hb/R/x86_64-pc-linux-gnu-library/3.6" /Henrik On Thu, Apr 26, 2018 at 11:41 AM, Akhilesh Singh wrote: > You are right. I do take backups. But, this time I was too sure that > nothing will go wrong. But, this w

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 compatibility li

Re: [R] Information about compatibility R

2018-04-11 Thread Henrik Bengtsson
all from source. Then you can go back and forth between version whenever you'd like. /Henrik On Wed, Apr 11, 2018 at 8:31 AM, Marcos Fiorini wrote: > Hi everyone. > > I need an information about compatibility of R and Suse Linux. I have > installed R 3.2.1 in Suse Linux 11 S

Re: [R] Possible Improvement to sapply

2018-03-13 Thread Henrik Bengtsson
69 3265472 and another 59 where isTRUE() can be used: $ grep -E "identical[(][^,]+,[ ]*TRUE[)]" -r --include="*.R" | grep -F "/R/" | wc 59 3075021 /Henrik On Tue, Mar 13, 2018 at 9:21 AM, Doran, Harold wrote: > Quite possibly, and I’ll look i

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
On Sun, Mar 4, 2018 at 3:23 PM, Duncan Murdoch 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 <- .GlobalEnv$.Random.seed >>

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
910 random 510 1 8 7 9 3 510 4 pid32199 32199 32199 32200 32200 32200 32200 32201 32201 32201 To base the RNG on the current RNG seed (== .GlobalEnv$.Random.seed), one can use 'future.seed = TRUE'. For performance reasons, I choose the def

Re: [R] Random Seed Location

2018-03-04 Thread Henrik Bengtsson
r.max port <- 11000 + 1000 * ((ran1 + unclass(Sys.time()) / 300) %% 1) if(is.null(seed)) ## there was none, initially rm( ".Random.seed", envir = .GlobalEnv, inherits = FALSE) else # reset assign(".Random.seed", seed, envir = .GlobalEnv, inherits = FALSE) /Henrik On Sun, Ma

Re: [R] change location of temporary files

2018-02-23 Thread Henrik Bengtsson
t needs to be set as in Bill's example above, or similarly: export TMPDIR=/tmp/RTMP-BILL /Henrik > > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Fri, Feb 23, 2018 at 10:52 AM, Kumar Mainali wrote: > >> I would like to change where R stores the

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

2018-02-20 Thread Henrik Bengtsson
, by = 12), FUN = function(offset) { rowMaxs(X[, offset + 1:12]) }) Subsetting data frames by columns is already efficient, so the same argument does not apply there. /Henrik On Tue, Feb 20, 2018 at 10:00 AM, Ista Zahn wrote: > On Tue, Feb 20, 2018 at 11:58 AM, Bert Gunter > wrote: > &g

Re: [R] PSOCK cluster and renice

2018-02-11 Thread Henrik Bengtsson
alhost PORT=11414 OUT=/dev/null TIMEOUT=2592000 XDR=TRUE -- Manually start worker #2 on 'localhost' with: nice --adjustment=19 '/usr/lib/R/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'parallel:::.slaveRSOCK()' MAST

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 searche

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

2018-01-28 Thread Henrik Bengtsson
7.2 3.2 6.0 1.8 virginica 127 6.2 2.8 4.8 1.8 virginica What's not show here is that the colored output (supported by many terminals these days) also highlights exactly which elements in those rows differ. /Henrik On Sun,

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
, /path/to/R/etc/Renviron.site). It sounds like you're trying to set up a site-wide package library to be shared among users. If so, add a line: R_LIBS_SITE=/some/where/else/R/site-%p-library/%v and make sure that folder exists, otherwise it's silently dropped from .libPaths(). /

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 thi

Re: [R] PSOCK cluster and renice

2017-12-03 Thread Henrik Bengtsson
", file.path(R.home("bin"), "Rscript"))) which is backward compatible with parallel::makePSOCKcluster() but provides you with more detailed control. Try adding verbose = TRUE to see what the exact call looks like. /Henrik On Sun, Dec 3, 2017 at 7:35 PM, Andreas Leha wr

Re: [R] valid package repositories

2017-10-02 Thread Henrik Bengtsson
losophy. However convenient GitHub / GitLab / ... is for development etc, it certainly does not provide scientific archiving - in that sense it is no different than sharing packages on Dropbox, Google Drive, etc. /Henrik On Mon, Oct 2, 2017 at 10:25 AM, Jeff Newmiller wrote: > I tend

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, "Ren

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

2017-08-25 Thread Henrik Bengtsson
ry(parallel); getOption('mc.cores')" NULL $ MC_CORES=2 Rscript -e "library(parallel); getOption('mc.cores')" [1] 2 $ MC_CORES=2 Rscript -e "options(mc.cores = 4); library(parallel); getOption('mc.cores')" [1] 4 /Henrik On Fri, Aug 25, 2017

Re: [R] about reading files in order

2017-06-29 Thread Henrik Bengtsson
t[i]) rather than paste('folder01',lists[i],sep='/'). FYI 2; if you use list.files(path = "folder01", full.names = TRUE), you get the full paths rather name just the file names, i.e. you don't have to use file.path(). /Henrik On Thu, Jun 29, 2017 at 12:04 PM,

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

2017-06-01 Thread Henrik Bengtsson
s a pre-processor to those formats). Hope this helps Henrik On Thu, Jun 1, 2017 at 9:35 AM, Charles C. Berry wrote: > On Thu, 1 Jun 2017, POLWART, Calum (COUNTY DURHAM AND DARLINGTON NHS > FOUNDATION TRUST) via R-help wrote: > >> Before I go and do this another way - can I chec

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

2017-04-21 Thread Henrik Bengtsson
C^C ^\Quit (core dumped) On my default Ubuntu 16.04 terminal, R 3.3.3 hangs and does not respond to user interrupts (SIGINT), but it does respond to Ctrl-\ (SIGKILL). A workaround is to pass the expression via standard input to R, e.g. $ echo "$long_expression" | R --no-save /Henrik

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

2017-04-19 Thread Henrik Bengtsson
ovide a proper reply is then hard - like trying to give a scientific presentation when you don't know who's in the audience. This happens all the time and most people quickly picks up what the expectations are and then get a smoother ride going forward. /Henrik PS. With the risk of add

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

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

2017-04-15 Thread Henrik Bengtsson
#x27;C:\Users\hb\Documents\.Rprofile' If you don't see the warning message, you should be fine. Finally, an easy way to setup a ~/.Rprofile startup file is to do it from within R, e.g. > cat('options(prompt="R> ")\n', file = "~/.Rprofile") > cat(&#x

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

2017-04-01 Thread Henrik Bengtsson
d its community the great experience it is today. Thank you! Henrik __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.h

Re: [R] Setting up a .Rprofile file

2017-03-24 Thread Henrik Bengtsson
oe\\Documents\\.Rprofile" For instance, to change what your R prompt looks you can add this from within R as: > cat('options(prompt = "> R ")\n', file = f, append = TRUE) Hope this helps Henrik On Fri, Mar 24, 2017 at 2:36 AM, Bruce Ratner PhD wrote: > Henrico: &g

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.r

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

2017-01-11 Thread Henrik Bengtsson
can query the uptime of the machine by reading from /proc/uptime: $ cat /proc/uptime 332826.96 661438.10 $ cat /proc/uptime 332871.40 661568.50 You can get all IDs (PIDs) of all processes currently running: $ ls /proc/ | grep -E '^[0-9]+$' and for each process you there are multiple

Re: [R] getTimeLimit?

2017-01-03 Thread Henrik Bengtsson
ge (for any language; https://github.com/HenrikBengtsson/R.utils/blob/2.5.0/R/withTimeout.R#L113-L114) this way and returns an error of class TimeoutException. FYI 2, there is as 'Working group for standard error (condition) classes' proposal to the RConsortium "wishlist", cf. htt

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 Zah

Re: [R] Is this foreach behaviour correct?

2016-11-13 Thread Henrik Bengtsson
On Nov 13, 2016 13:54, "Henrik Bengtsson" 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" in package "base

Re: [R] Is this foreach behaviour correct?

2016-11-13 Thread Henrik Bengtsson
-21" "1997-05-22" ... Alternatively, one can use append() which works like c() if no other arguments are specified: > x <- foreach(i=1:10100, .combine = append) %do% { as.Date(i) } > str(x) Date[1:101], format: "1997-05-19" "1997-05-20" "1997-05-21"

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

2016-09-29 Thread Henrik Bengtsson
load files atomically, i.e. it either gives you a fully downloaded file or not all. In your case, you might still end up with a temporary corrupt file, but at least it will have a filename that is different than the one you ask for. Hope this helps /Henrik On Wed, Sep 28, 2016 at 9:32 PM, Fabi

Re: [R] Replacing value with "1"

2016-09-22 Thread Henrik Bengtsson
[,"col"] <- idxs[,"col"] + 1L > idxs row col [1,] 3 3 [2,] 1 4 [3,] 2 4 [4,] 2 5 > df[idxs] <- 1 > df [,1] [,2] [,3] [,4] [,5] [1,]00110 [2,] NA0111 [3,]0110 NA /Henrik On Thu, Sep

Re: [R] Accelerating binRead

2016-09-18 Thread Henrik Bengtsson
nteger", size=4L) f <- readBin(, what="double", size=4L) s <- readBin(ss, what="integer", size=2L) Put into a 3-by-K data.frame: data <- data.frame(i=i, f=f, s=s) /Henrik On Sun, Sep 18, 2016 at 8:02 AM, Philippe de Rochambeau wrote: > I would gladly

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

2016-09-14 Thread Henrik Bengtsson
) > 0) loop over with a try(unloadNamespace(pkg)) until all are unloaded. At the end, run R.utils::gcDLLs() too (now on CRAN). unloadNamespace("foo") should result in the same as detach("package::foo", unload=TRUE) [anyone correct me if I'm wrong]. Hope this helps H

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

2016-09-13 Thread Henrik Bengtsson
hecking loading without being on the library search path ... OK For further details on my thoughts on this, see https://github.com/HenrikBengtsson/Wishlist-for-R/issues/29. Hope this helps Henrik On Tue, Sep 13, 2016 at 6:05 AM, Alexander Shenkin wrote: > Hello all, > > I have a number of

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

2016-09-06 Thread Henrik Bengtsson
you're logging into is running Linux: Before anything else, did you try to save elsewhere than to your /home/ folder/account? Try /tmp/. That probably / hopefully doesn't count to your account quota (and it gets wiped at every reboot). There's also /var/tmp/ (a bit more persistent st

Re: [R] paste0 in file path

2016-08-31 Thread Henrik Bengtsson
u might want to consider using: paste0(tempdir(), filename) It is specific and temporary to the R session running though, so if you want to store things across R sessions, tempdir() is not what you want to use. /Henrik On Wed, Aug 31, 2016 at 8:54 AM, Uwe Ligges wrote: > > > On 3

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

2016-05-11 Thread Henrik Bengtsson
fo on how to track down the process that looks the file. /Henrik On Wed, May 11, 2016 at 9:47 AM, wrote: > Duncan, > > thanks for the hint. > > I have done it correctly in R fashion > > ## capture all the output to a file. > zz <- file("C:/Temp/all.Rout"

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 wrote: >>>>>> Henrik Bengtsson >>>>>> on Tue, 19 Apr 2016 14:04:11 -0700 writes: > > > Using the Matrix package, how can I create a row-oriented sparse > > Matrix from scratch pop

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

2016-04-19 Thread Henrik Bengtsson
ult for coercing "dgCMatrix" to "dgRMatrix" > as(Cr, "dgRMatrix") Error in as(Cr, "dgRMatrix") : no method or default for coercing "dgTMatrix" to "dgRMatrix" Am I doing some wrong here? Or is this what means that the package is opt

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

2016-03-19 Thread Henrik Bengtsson
On Fri, Mar 18, 2016 at 8:28 PM, Roy Mendelssohn - NOAA Federal wrote: > Hi Henrik: > > I want to do want in oceanography is called an EOF, which is just a PCA > analysis. Unless I am missing something, in R I need to flatten my 3-D matrix > into a 2-D data matrix. I can fit

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

2016-03-18 Thread Henrik Bengtsson
ixStats") > rowVars(X, dim.=c(6,4)) The above effectively calculates rowVars(matrix(X, nrow=6, ncol=4)) without making copies. (*) By partial I mean that this is a feature that hasn't been pushed through to all of matrixStats functions, cf. https://github.com/HenrikBengtsson/matrixStats

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: > There

Re: [R] Error because of large dimension

2016-01-24 Thread Henrik Bengtsson
of RAM, i.e. 29327331 GiB = 28640 TiB = 28 PiB. Storing such a large matrix even on file is not possible. In other words, you need to figure out how to approach your original problem in a different way. /Henrik On Sun, Jan 24, 2016 at 8:46 AM, li li wrote: > Hi all, > I am doin

Re: [R] close specific graphics device

2015-12-16 Thread Henrik Bengtsson
automatically taken care of. You can plot to multiple image types at the same time, e.g. devEval(c("png", "pdf", "eps"), name="myplot", aspectRatio=2/3, { plot(10:1) }) There are also "quick" functions such as: toPNG("myplot", as

Re: [R] stopifnot with logical(0)

2015-12-12 Thread Henrik Bengtsson
On Sat, Dec 12, 2015 at 6:08 AM, Hadley Wickham wrote: > On Sat, Dec 12, 2015 at 3:54 AM, Martin Maechler > wrote: >>>>>>> Henrik Bengtsson >>>>>>> on Fri, 11 Dec 2015 08:20:55 -0800 writes: >> >> > On Fri, Dec 11, 2015 at 8

Re: [R] stopifnot with logical(0)

2015-12-11 Thread Henrik Bengtsson
se it will tell you whether it's !length(x) or mode(x) == "logical" that is FALSE. It's as if you wrote: stopifnot(!length(x)) stopifnot(mode(x) == "logical") /Henrik > > >> >> stopifnot(logical(0) == 1) >> stopifnot(logical(0) == TRUE) >

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_pri

Re: [R] SWEAVE - a gentle introduction

2015-11-17 Thread Henrik Bengtsson
vignettes using one of the above formats, choice of vignette format does not matter these days. They're all equally easy to use and incorporate in packages. Cheers, Henrik On Tue, Nov 17, 2015 at 11:09 AM, Duncan Murdoch wrote: > On 17/11/2015 10:42 AM, Marc Schwartz wrote: >>

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

2015-11-10 Thread Henrik Bengtsson
#x27; gets assigned, you could preprocess you R Markdown file with RSP, but for this to work out of the box you basically need to know the value length(specLibrary@ionlibrary) before your R Markdown code is evaluated, i.e. before you compile the Rmd file. Your build pipeline would then look someth

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

2015-11-06 Thread Henrik Bengtsson
save a file the first time. You can try to put quotation marks to force it not to, e.g. "RHtestsV4.r". Henrik On Nov 6, 2015 15:23, "Chattopadhyay, Somsubhra" wrote: Dear all, I am a beginner in R and want to ask a simple question. I have a code file in text format which I

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

2015-10-14 Thread Henrik Bengtsson
the list. That will allow you to make sure your message went out. /Henrik On Wed, Oct 14, 2015 at 3:54 AM, Ivan Calandra wrote: > Maram, > > I have received both of your e-mails on this topic, so they made it to the > list. > There is the option " Receive your own posts to the

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

2015-07-08 Thread Henrik Bengtsson
tch data <- read.table(textConnection(kkk), sep="\t", header = TRUE, colClasses = rev(colClasses)) str(data) ### 'data.frame': 1 obs. of 2 variables: ### $ a: num 3.14 ### $ b: chr "x" Let's hope that the ab

  1   2   3   4   5   6   7   >