Re: [R] draw a circle with a gradient fill

2017-10-24 Thread Berry, Charles
> On Oct 24, 2017, at 2:56 AM, Alaios via R-help wrote: > > Hi all,I would like to draw a simple circle where the color gradient follows > the rule color = 1/(r^2) where r is the distance from the circle. This is called a radial gradient fill in SVG speak. [snip] > but this package does not

Re: [R] libPaths displays truncated path?

2017-11-23 Thread Berry, Charles
> On Nov 23, 2017, at 4:34 AM, Loris Bennett wrote: > > Hi, > > TL;DR > - > > I define the path > >/cm/shared/apps/R/site-library/3.4.2 > > and add it to libPath. Why does libPath then display it as > >/cm/shared/apps/R/site-library/3.4 > > ? > Because it is a symbolic li

Re: [R] Gaussian Process Classification R packages

2017-12-11 Thread Berry, Charles
> On Dec 11, 2017, at 8:06 AM, Damjan Krstajic wrote: > > I have kindly asked for help and I am sad to receive such a reply from some > on the r-help list. > > Well, you only said you were `struggling' to find a package. Bert may well have done the Google search himself and found numerous r

Re: [R] getting all circular arrangements without accounting for order

2018-03-30 Thread Berry, Charles
> On Mar 29, 2018, at 6:48 PM, Ranjan Maitra wrote: > > Dear friends, > > I would like to get all possible arrangements of n objects listed 1:n on a > circle. > > Now this is easy to do in R. Keep the last spot fixed at n and fill in the > rest using permuations(n-1, n-1) from the gtools pa

Re: [R] How to define mutualy exclusive parameters of a function

2018-04-26 Thread Berry, Charles
> On Apr 26, 2018, at 6:46 AM, Polychronis Kostoulas > wrote: > > Dear All, > apologies if this is basic: I am writing a function: > > fb<-function(mean, median, mode, a, b=0.95, lower=F) > {} > > The arguments mean, median and mode are mutually exclusive (i.e. the user > should define o

Re: [R] is there any method to defer the execution of code in r?

2018-05-13 Thread Berry, Charles
> On May 13, 2018, at 9:24 AM, Jeff Newmiller wrote: > > Not when I click on that link. > > Nor me, but what I get is actually https://stackoverflow.com/questions/1174799/how-to-make-execution-pause-sleep-wait-for-x-seconds-in-r note the number is *different* than 50314015 - the OPs postin

Re: [R] to R Core T: mle function in 32bits not respecting the constrain

2018-05-28 Thread Berry, Charles
> On May 27, 2018, at 10:31 PM, francesc badia roca wrote: > > I have an issue using mle in versions of 32 bits. > > I am writing a package which I want to submit to the CRAN. > When doing the check, there is an example that has an error running in the > 32 bits version. > > The problem comes

Re: [R] printing an arbitrary-length character vector in columns on a page of a pdf report

2018-06-05 Thread Berry, Charles
> On Jun 5, 2018, at 9:45 AM, Christopher W Ryan wrote: > > I'm writing code for a recurring report, using an R --> Sweave --> pdflatex > workflow. It includes a character vector of short words that I would like > to display compactly, in columns on a page, rather than one word per line, > whi

Re: [R] subsetting lists....

2018-06-18 Thread Berry, Charles
> On Jun 18, 2018, at 4:15 AM, akshay kulkarni wrote: > > correctionI want the method without a for loop Here are two. The first is more readable, but the second is 5 times faster. mapply("[", YH, iuhV) unlist(YH, recursive = FALSE, use.names = FALSE)[cumsum( lengths(YH)) - lengths(YH)

Re: [R] R maintains old values

2018-07-03 Thread Berry, Charles
> On Jul 3, 2018, at 6:25 AM, J C Nash wrote: > > Now, to add to the controversy, how do you set a computer on fire? >From the bash prompt: stuxnet --overload=cpu,disk,network,gpu --fan=off --no-warnings HTH, Chuck __ R-help@r-project.org maili

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Berry, Charles
A liitle math goes along way. See below. > On Jul 5, 2018, at 10:35 PM, Marino David wrote: > > Dear Bert, > > I know it is a simple question. But for me, at current, I fail to implement > it. So, I ask for help here. > > It is not homework. > > Best, > > David > > 2018-07-06 13:32 GMT+08:0

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Berry, Charles
> On Jul 6, 2018, at 3:31 PM, Duncan Murdoch wrote: > > On 06/07/2018 1:18 PM, Berry, Charles wrote: >> A liitle math goes along way. See below. >>> On Jul 5, 2018, at 10:35 PM, Marino David wrote: >>> >>> Dear Bert, >>> >>> I kno

Re: [R] Generate random Bernoulli draws

2018-07-06 Thread Berry, Charles
On Jul 6, 2018, at 4:27 PM, Charles Berry wrote: > >> On Jul 6, 2018, at 3:31 PM, Duncan Murdoch wrote: >> >> On 06/07/2018 1:18 PM, Berry, Charles wrote: >>> A liitle math goes along way. See below. >>>> On Jul 5, 2018, at 10:35 PM, Marino David wrote:

Re: [R] Suggestions for scatter plot of many data

2018-07-19 Thread Berry, Charles
> On Jul 18, 2018, at 1:55 PM, Rich Shepard wrote: > > I have daily precipitation data for 58 locations from 2005-01-01 through > 2018-06-18. So roughly 5000 observations of latitiude, longitude, elevation(?), and amount. Maybe something dynamic like Hans Rosling does: https://towardsdatas

Re: [R] "Improvement with the R code"

2017-08-28 Thread Berry, Charles
All of this can be done without for loops. Use head(..., -1), tail(..., -1) to get the pre and post states. Use factor or pmin to recode them as necessary Use table(pre, post) to get the transition counts. Use prop.table(table_of_counts,1) to get the probabilities. HTH, Chuck > On Aug 28,

Re: [R] "Improvement with the R code"

2017-08-28 Thread Berry, Charles
> On Aug 28, 2017, at 9:26 AM, Elie Canonici Merle > wrote: > > Chuck (Is it fine to call you Chuck?) In this forum, yes please. > I don't know much about pmin and factor but it might worth looking into if > you want to manipulate states by names (I assume this is why one might want > to use

Re: [R] A slightly unorthodox matrix product.

2018-08-04 Thread Berry, Charles
> On Aug 4, 2018, at 10:01 AM, Eric Berger wrote: > > Hi Rolf, > A few edits because (i) nrow(a) should be nrow(A) and (ii) you have > calculated C[j,k,i] = A[i,j]*B[i,k], (iii) minor style change on lapply. > > library(abind) > xxx <- lapply(1:nrow(A),function(i){A[i,]%o%B[i,]}) > yyy <- do.

Re: [R] A slightly unorthodox matrix product.

2018-08-04 Thread Berry, Charles
> On Aug 4, 2018, at 11:43 AM, Jeff Newmiller wrote: > > Sometimes a good old for loop performs best, even if it doesn't look sexy: > > Fair enough, but a vectorized solution beats them all (see below). Also, [SNIP] > # Charles > ans1b <- function( a, b ) > { The lapply you put here wa

Re: [R] A slightly unorthodox matrix product.

2018-08-04 Thread Berry, Charles
> On Aug 4, 2018, at 12:59 PM, Jeff Newmiller wrote: > ... > Slick work on the vectorizing, but for the future reference it was slightly > buggy: > Thanks for catching that! Chuck __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more,

Re: [R] For loop with multiple iteration indexes

2018-09-10 Thread Berry, Charles
I have a sense of deja vu: https://www.mail-archive.com/r-help@r-project.org/msg250494.html There is some good advice there. > On Sep 9, 2018, at 3:49 PM, David Disabato wrote: > > Hi R-help, > > I am trying to create a for loop with multiple iteration indexes. I don't > want to use two diffe

[R] fortune nomination WAS:Re: help

2018-12-13 Thread Berry, Charles
"You need Santa Claus not r-help." in response to an unrealistic and poorly posed request for help. Best, Chuck > On Dec 13, 2018, at 11:12 AM, David L Carlson wrote: > > You need Santa Claus not r-help. You haven't given us a fraction of the > information we would need to help. You don't

Re: [R] Accessing Data Frame

2019-01-03 Thread Berry, Charles
See below. > On Jan 3, 2019, at 6:50 AM, Benoit Galarneau > wrote: > > Hi everyone, > I'm new to the R world. > Probably a newbie question but I am stuck with some concept with data frame. > I am following some examples in the "Hands-On Programming with R". > > In short, how can I access/filte

Re: [R] Vectorizing a for-loop for cross-validation in R

2019-01-23 Thread Berry, Charles
See inline. > On Jan 23, 2019, at 2:17 AM, Aleksandre Gavashelishvili > wrote: > > I'm trying to speed up a script that otherwise takes days to handle larger > data sets. So, is there a way to completely vectorize or paralellize the > following script: > >*# k-fold cross valida

Re: [R] Alternative to lops

2019-04-04 Thread Berry, Charles
Comments inline, but first: Please review the posting guide and follow the instructions there, especially: 1) "No HTML posting..." 2) "When providing examples, it is best to give an R command that constructs the data,..." > On Apr 4, 2019, at 9:41 AM, Ek Esawi wrote: > > Hi All-- > > Sorry

Re: [R] text on curve

2020-09-22 Thread Berry, Charles
> On Sep 22, 2020, at 1:10 AM, Jinsong Zhao wrote: > > Hi there, > > I write a simple function that could place text along a curve. Since I am not > familiar with the operation of rotating graphical elements, e.g., text, > rectangle, etc., I hope you could give suggestions or hints on how t

Re: [R] dependent nested for loops in R

2021-01-31 Thread Berry, Charles
> On Jan 30, 2021, at 9:32 PM, Shaami wrote: > > Hi > I have made the sample code again. Could you please guide how to use > vectorization for variables whose next value depends on the previous one? > Glad to help. First, it could help you to trace your code. I suspect that the results ar

Re: [R] if statement and for loop question

2021-05-30 Thread Berry, Charles
Kai, You have made a simple mistake. And now you cannot see it. I believe this is not uncommon among programmers. It has happened to me more times than I want to recall. > On May 30, 2021, at 9:28 AM, Kai Yang via R-help wrote: > > Hello List,I have a data frame which having the character c

Re: [R] concatenating columns in data.frame

2021-07-01 Thread Berry, Charles
> On Jul 1, 2021, at 7:36 AM, Micha Silver wrote: > > I need to create a new data.frame column as a concatenation of existing > character columns. But the number and name of the columns to concatenate > needs to be passed in dynamically. The code below does what I want, but seems > very clu

Re: [R] concatenating columns in data.frame

2021-07-01 Thread Berry, Charles
> On Jul 1, 2021, at 11:24 AM, Bert Gunter wrote: > > Why not simply: > > ## reprex > set.seed(123) > df = data.frame("A"=sample(letters, 10), "B"=sample(letters, 10), >"C"=sample(letters,10), "D"=sample(letters, 10)) > df > use_columns = c("D", "B") > > ## one liner > df$com

Re: [R] Cacheing of functions from libraries other than the base in Rmarkdown

2021-09-19 Thread Berry, Charles
Chris, > On Sep 18, 2021, at 12:26 PM, Chris Evans wrote: > > This question may belong somewhere else, if so, please signpost me and accept > apologies. > > What is happening is that I have a large (for me, > 3k lines) Rmarkdown file > with many R code blocks (no other code or > engine is u

[R] fortune nomination WAS: Re: How long does it take to learn the R programming language?

2022-09-28 Thread Berry, Charles
Aha! CCB > On Sep 27, 2022, at 6:08 PM, Rolf Turner wrote: > > > On Mon, 26 Sep 2022 11:14:57 +0800 > Turritopsis Dohrnii Teo En Ming wrote: > >> Subject: How long does it take to learn the R programming language? >> >> Good day from Singapore, >> >> How long does it take to learn the R pro

Re: [R] lm fails on some large input

2019-04-18 Thread Berry, Charles
> On Apr 18, 2019, at 8:24 AM, Michael Dewey wrote: > > Perhaps subtract 1506705766 from y? Good advice. Some further notes follow. One can specify `tol` to have a smaller than default value e.g. m2 <- lm(x ~ y, tol=1e-12) which is accurate: plot(y,x) abline(coef=coef(m2)) Users

Re: [R] Tying to underdressed the magic of lm redux

2019-06-01 Thread Berry, Charles
John, I believe the pieces you are missing are filed under 'computing on the language', 'passing unevaluated objects', and 'language objects'. Forgive me if I belabor things you already know. lm, transform, and many other functions do their "magic" by operating on language objects. You migh

Re: [R] Open a file which name contains a tilde

2019-06-06 Thread Berry, Charles
> On Jun 6, 2019, at 3:59 AM, Ivan Krylov wrote: > > On Wed, 5 Jun 2019 18:07:15 +0200 > Frank Schwidom wrote: > >> +> path.expand("a ~ b") >> [1] "a /home/user b" > >> How can I switch off any file crippling activity? > > It doesn't seem to be possible if readline is enabled and works >

Re: [R] Open a file which name contains a tilde

2019-06-07 Thread Berry, Charles
> On Jun 6, 2019, at 2:04 PM, Richard O'Keefe wrote: > > How can expanding tildes anywhere but the beginning of a file name NOT be > considered a bug? > > I think that that IS what libreadline is doing if one allows a whitespace separated list of file names. As reported in R-help,

Re: [R] Efficient way to update a survival model

2019-08-31 Thread Berry, Charles
The i^th model is included in the Cox[[ i ]] object. You can extract the formula objects with: frms <- lapply(Cox, formula) then if you want the existing and incremental terms: indeps <- lapply(frms, function(x) as.list( x[[ 3 ]] )) oldTerms <- lapply(indeps, "[[", 2) newTerms <- lapply(indep

Re: [R] Creating a histogram from a frequency vector

2019-10-10 Thread Berry, Charles
> On Oct 9, 2019, at 9:58 AM, Rui Barradas wrote: > > Hello, > > Here are 3 ways. > For a large number of bars, sometimes this: plot( y, type='h') # maybe use lwd=5 Chuck > The first are almost the same, they use base graphics. > > x <- 1:6 > y <- c(73,53,42,67,41,50) > > barplot(setN

Re: [R] Identifying presence of Java

2019-11-09 Thread Berry, Charles
> On Nov 9, 2019, at 8:51 AM, Dennis Fisher wrote: > > R 3.6.3 > OSX and Windows > > Colleagues > > I want to identify if Java is installed on a particular computer. > [...] > I execute something like: > CAPTURE <- system("Java -version", intern=TRUE, ignore.stderr=FALSE, > ignore.

Re: [R] How to read a file containing two types of rows - (for the Netflix challenge data format)

2020-01-31 Thread Berry, Charles
> On Jan 31, 2020, at 1:04 AM, Emmanuel Levy wrote: > > Hi, > > I'd like to use the Netflix challenge data and just can't figure out how to > efficiently "scan" the files. > https://www.kaggle.com/netflix-inc/netflix-prize-data > > The files have two types of row, either an *ID* e.g., "1:" ,

Re: [R] consecutive n values

2020-06-04 Thread Berry, Charles
Catalin, > On Jun 4, 2020, at 6:06 AM, Catalin Roibu wrote: > > Dear R users, > > Please help me to detect consecutive n values in R and their interval. > > > rle.seq1<-rle(reco$extr) > cbind(rle.seq1$values) > index<-any(rle.seq1$values=="DRY"&rle.seq1$lengths>=3) > cumsum(rle.seq1$lengths)[

Re: [R] Nonlinear logistic regression fitting

2020-07-28 Thread Berry, Charles
Did you try searching for "Michaelis" on rseek.org? It seems like there are many hits that might be pertinent to your query. If none is pertinent, maybe saying why they are not sufficient will help others see how their "expert opinions" can help you. HTH, Chuck > On Jul 28, 2020, at 8:19 AM

Re: [R] passing a modified argument to an S3 method

2024-04-20 Thread Berry, Charles via R-help
> On Apr 19, 2024, at 1:36 PM, CRAN.r via R-help wrote: > > Is there a way to pass a modified argument from an S3 generic to a method? > Here's a non-working example that I want to return "abcd". > grep-ing the source code is often a good way to answer a question like this. Particularly, w