Re: [R] Using Partial Column Matching for Mutate

2019-08-06 Thread Eric Berger
Hi Shawn, Here is a solution using base R (no dplyr). The only regex appears in the statement to get the common prefixes. colsPrefixes <- sub("_Planned$","",colnames(gross_test)[ grep("_Planned$",colnames(gross_test))]) f <- function(s) { gross_test[,paste(s,"Diff",sep="_")] <<- gross_test[,past

Re: [R] filter and add a column

2019-08-07 Thread Eric Berger
Here is a different approach that does not involve dplyr or the creation of the intermediate data frame 'controls' f <- function(v) { any(v %in% c("E109","E119","E149")) & any(v %in% c("Caucasian")) & any(v %in% c("No kinship found","Ten or more third-degree relatives identified")) } tot$co

Re: [R] separate and gather functions

2019-08-13 Thread Eric Berger
Chapeau Ista :-) On Tue, Aug 13, 2019 at 4:22 PM Ista Zahn wrote: > How about > > > library(tidyr) > > separate_rows(d, Col2) > Col1 Col2 > 1 Agency A Function1 > 2 Agency A Function2 > 3 Agency A Function3 > 4 Agency A Function4 > 5 Agency B Function2 > 6 Agency B Function4 > 7 Agenc

Re: [R] Colouring selected columns in a facetted column chart

2019-08-24 Thread Eric Berger
Hi Phil, Please resubmit your question with the data frame contents shown as the output from the command dput(t1.txt). This will make it easier for people to run your reprex and respond to your question. Best, Eric On Sun, Aug 25, 2019 at 5:26 AM wrote: > I am having difficulty with a chart u

Re: [R] Colouring selected columns in a facetted column chart

2019-08-24 Thread Eric Berger
0.4, 0.2, 0.7, 0.3, > 0.3, 0.3, 0.4, 0.3, 0.2, 0.6, 1, 1.1, 0.3, 0.4, 0.4, 0.6, > 0.5, 0.1, 0.1, 0.9, 2.3, -1.2, -1, 0.9, 0.8, 0.6, 0.3, 0.8, > 0.1, 0.8, 0.7, 0.6, 0.7, 0.7, 0.4, 0.4, 0.3, 0.3, 0.5, 0.2, > 0.2, 1.7, 0.1, 0.3, 1.1, 0.4, 0.2, 0.1, 0, 0.6, 0.6, 0.8, &g

Re: [R] New Work Based on R

2019-08-29 Thread Eric Berger
Rich writes: " I've been out of academia for a very long time ... " He may not be aware that currently authors are encouraged to support reproducible research, which includes making available (where possible) both the data and the software programs that were used in the analysis. I think the OP's s

Re: [R] Sequential date by group

2019-09-02 Thread Eric Berger
dtV <- seq(from=as.Date("1975-01-01"),by='1 month',length=372) x$dt <- dtV[x$id] HTH, Eric On Mon, Sep 2, 2019 at 8:36 PM Miluji Sb wrote: > Dear all, > > I have a panel data with a large number of groups and the cumulative number > of months (1 - 372) for January 1995 to December 2005. My goa

Re: [R] Strange behaviour of sapply function.

2019-09-12 Thread Eric Berger
Can you create a reproducible example? You don't show: income, atv, sktaxb, sktax On Thu, Sep 12, 2019 at 12:04 PM wrote: > Here is are a few lines of my R session: > > > class(income) > [1] "integer" > > class(sapply(1000*income-999,atv,sktaxb,sktax)) > [1] "numeric" > > class(sapply(1000*inc

Re: [R] Average distance in kilometers between subsets of points with ggmap /geosphere

2019-09-23 Thread Eric Berger
Hi Malte, I only skimmed your question and looked at the desired output. I wondered if the apply function could meet your needs. Here's a small example that might help you: m <- matrix(1:9,nrow=3) m <- cbind(m,apply(m,MAR=1,mean)) # MAR=1 says to apply the function row-wise m # [,1] [,2]

Re: [R] Average distance in kilometers between subsets of points with ggmap /geosphere

2019-09-24 Thread Eric Berger
23.09.2019 um 09:32 schrieb Eric Berger : > > Hi Malte, > I only skimmed your question and looked at the desired output. > I wondered if the apply function could meet your needs. > Here's a small example that might help you: > > m <- matrix(1:9,nrow=3) > m <- cbind(m,

Re: [R] how to calculate True Positive Rate in R?

2019-09-24 Thread Eric Berger
https://cran.r-project.org/web/packages/qvalue/index.html states Package ‘qvalue’ was removed from the CRAN repository. Just an FYI On Tue, Sep 24, 2019 at 6:48 PM Ana Marija wrote: > Hello, > > I tried using qvalue function: > > library(qvalue) > qval_obj=qvalue(pvalR) > pi1=1-qval

Re: [R] Creating a before-and-after variable in R

2019-10-03 Thread Eric Berger
Hi Faradj, Suppose your data frame is labeled 'a'. Then the following seems to do what you want. v <- rep(NA_integer_,max(a$country_code)) v[ a$country_code[a$x==1] ] <- a$year[a$x==1] a$treatment <- sapply( 1:nrow(a), function(i) { a$year[i] - v[a$country_code[i]]}) HTH, Eric On Thu, Oct 3, 20

Re: [R] Creating a before-and-after variable in R

2019-10-03 Thread Eric Berger
, > Faradj > > > > 3 okt. 2019 kl. 15:18 skrev Eric Berger : > > > > Hi Faradj, > > Suppose your data frame is labeled 'a'. Then the following seems to do > what you want. > > > > v <- rep(NA_integer_,max(a$country_code)) > > v[ a$c

Re: [R] Creating a before-and-after variable in R

2019-10-03 Thread Eric Berger
Best, > Faradj > > > > 3 okt. 2019 kl. 16:11 skrev Eric Berger : > > > > Hi Faradj, > > What should the treatment variable be in those cases? If you want to set > it to a constant y (such as y=0), you can add something like > > > > y <- 0 > > a$

Re: [R] Vargha and delaney effect size

2019-10-04 Thread Eric Berger
For general documentation about the effsize package you would do: > help(package="effsize") For information on calculations related to vargha: >??vargha This command displays effsize::VD.A, which you can find out about via the command >?effsize::VD.A This displays the documentation for the functio

Re: [R] Vargha and delaney effect size

2019-10-06 Thread Eric Berger
excel and we read it in code with read.csv. > > Best regards > > On Friday, October 4, 2019, Eric Berger wrote: > >> For general documentation about the effsize package you would do: >> > help(package="effsize") >> >> For information on calculat

Re: [R] how to use a matrix as an index to another matrix?

2019-10-11 Thread Eric Berger
Here is one way A <- sapply(1:ncol(A), function(i) {A[,i][B[,i]]}) On Fri, Oct 11, 2019 at 12:44 PM Jinsong Zhao wrote: > Hi there, > > I have two matrices, A and B. The columns of B is the index of the > corresponding columns of A. I hope to rearrange of A by B. A minimal > example is followin

Re: [R] using a variable and a superscript in a legend

2019-10-20 Thread Eric Berger
I did a Google search on R plot superscript in legend and the first search result was https://stackoverflow.com/questions/20453408/superscript-r-squared-for-legend which looks like it might address your question. On Sun, Oct 20, 2019 at 3:30 PM Patrick Giraudoux < patrick.giraud...@univ-fcomte

Re: [R] add error bars to rarecurve from package vegan

2019-10-21 Thread Eric Berger
You might improve your chances for getting a response by supplying a minimal reproducible example. Remember to include all the library() commands showing which packages you are using. On Mon, Oct 21, 2019 at 2:53 PM Luigi Marongiu wrote: > Hello, > I am using the package vegan to generate raref

Re: [R] How to merge 3 data frames by rownames?

2019-11-05 Thread Eric Berger
I think your code is a bit buggy. Try this for(i in 2:length(l)) { allF <- merge(allF, l[[i]], by= "row.names", all.x= F, all.y= F) rownames(allF) <- allF$Row.names allF <- allF[,-1] } HTH, Eric On Tue, Nov 5, 2019 at 6:16 PM Ana Marija wrote: > Hi, > > I have 3 data frames like this:

Re: [R] how to get higher precision p value output

2019-11-05 Thread Eric Berger
> set.seed(1) > m <- matrix(rnorm(500),ncol=2) > cor(m) # [,1] [,2] # [1,] 1. 0.04060113 # [2,] 0.04060113 1. > options(digits=12) > cor(m) # [,1][,2] # [1,] 1.0 0.0406011304584 # [2,] 0.0406011304584 1.0 HTH,

Re: [R] Obtaining the time to execute a R command

2019-11-20 Thread Eric Berger
Hi Jeff, You might want to check out the microbenchmark() function in the microbenchmark package. install.packages("microbenchmark") library(microbenchmark) ?microbenchmark HTH, Eric On Wed, Nov 20, 2019 at 5:45 PM Jeff Reichman wrote: > R- Help > > > > Is there a command or way to obtain the

Re: [R] Extract lines from pdf files

2019-11-20 Thread Eric Berger
Hi Thomas, As Jeff wrote, your HTML email is difficult to read. This is a "plain text" forum. As for "pointers", here is one suggestion. Since you write that you can do the necessary actions with a specific file, try to write a function that carries out those actions for that same file. Except when

Re: [R] ggplot inside of the function

2019-11-25 Thread Eric Berger
Hi Mayooran, If you define the following function f <- function(m,v) { sprintf("Norm(mu=%.1f, var=%.1f)",m,v) } Then you can modify the setting of Prob as follows Prob <- plyr::rename(Prob_df, c("p_1"=f(mu1,var1),"p_2"=f(mu2,var2),"p_3"=f(mu3,var3))) The lesson here is that wherever you set a

Re: [R] Combining text files

2019-12-04 Thread Eric Berger
Continuing with Jeff's point: do you know for certain that the serial number in row 5 of one file corresponds to the 'work order number' in row 5 of a different file? Ideally this could be verified based on some sort of identifier that appears as a column in both files and you could match up corres

[R] passing reference class method within the class as an argument

2019-12-05 Thread Eric Berger
Here is the code of a reproducible example: foo <- setRefClass("foo", fields=list(x="numeric"), methods=list( initialize=function(a) { x <<- a }, funcA=function(f)

[R] SOLVED: passing reference class method within the class as an argument

2019-12-05 Thread Eric Berger
Here is the modified code of the reproducible example I sent previously. Notice the .self$ prefix to funcB which is what has changed foo <- setRefClass("foo", fields=list(x="numeric"), methods=list( initialize=function(a) {

Re: [R] Having problems with the ifelse and negative numbers

2019-12-09 Thread Eric Berger
Hi Bob, You wrote "the following error message" - when in fact it is a Warning and not an error message. I think your code does what you hoped it would do, in the sense it successfully calculates the sqrt(abs(negativeNumber)), where appropriate. If you want to run the code without seeing this warn

Re: [R] Where is the SD in output of glm with Gaussian distribution

2019-12-09 Thread Eric Berger
summary(gnul) shows the std error of the coefficient estimate On Mon, Dec 9, 2019 at 5:16 PM Marc Girondot via R-help wrote: > > Let do a simple glm: > > > y=rnorm(100) > > gnul <- glm(y ~ 1) > > gnul$coefficients > (Intercept) >0.1399966 > > The logLik shows the fit of two parameters (DF

Re: [R] Data Structure to Unnest_tokens in tidytext package

2019-12-11 Thread Eric Berger
Hi Sarah, I looked at the documentation that you linked to. It contains the step text_df <- tibble(line = 1:4, text = text) before it does the step text_df %>% unnest_tokens(word, text) So you may be missing a step. Best, Eric On Tue, Dec 10, 2019 at 9:05 PM Sarah Payne wrote: > > Hi--I'm

Re: [R] Errors in R package installation

2019-12-12 Thread Eric Berger
Apparently it does not like that the fact that your user 'David Stevens' has a blank. Looking at the documentation ?install.packages it seems that if you modify your call to something like install.packages('callr',destdir='C:\tmp') you might be ok. (caveat: I did not try this) You should make th

Re: [R] Errors in R package installation

2019-12-12 Thread Eric Berger
e ‘callr’ had non-zero exit status > > I also tried > > install.packages('callr',lib='c:/myRLib',destdir='c:/myRLib') > > with the same result. There's something more here that I'm unable to discover. > > Best > David > On 12/12/20

Re: [R] Errors in R package installation

2019-12-12 Thread Eric Berger
gt; > > Thanks Eric - I'll follow up with this link. I'd tried some of these > > things before but I'll keep after it. > > > > Best > > > > David > > > > On 12/12/2019 9:52 AM, Eric Berger wrote: > > > Actually there was progress as afte

Re: [R] Please help translate this program in C++ to R

2019-12-14 Thread Eric Berger
It is fairly easy to incorporate C++ code into R programs using the Rcpp package. Definitely worth the effort to learn how to do this. On Sun, Dec 15, 2019 at 5:48 AM Boris Steipe wrote: > > See this thread why that's a bad idea ... > https://stackoverflow.com/questions/26080716/merge-sort-in-r

Re: [R] Please help translate this program in python to R.

2019-12-14 Thread Eric Berger
And similar to my response to the C++ question you posted, it is possible to incorporate Python code into R programs using the reticulate package. On Sun, Dec 15, 2019 at 5:58 AM Boris Steipe wrote: > > See my response to the C++ question you posted a minute later. > > B. > > > > > > On 2019-12-1

Re: [R] Huge differences in Ram Consumption with different versions of R on the same scripts

2023-05-08 Thread Eric Berger
Assuming the vignettes are the same in both cases, try going back to the system where it worked and introduce a single change? i.e. a) previous linux system and R 4.2 b) Previous R version and Oracle Linux 8 Repeat the test for a) and b) and if one works fine and the other fails at least that will

Re: [R] RandomForest tuning the parameters

2023-05-08 Thread Eric Berger
Hi, One problem you have is with the command: regr<-randomForest(y~x1+x2, data=X_train, proximity=TRUE) What you need is something like this: X2 <- cbind(X,y) regr<-randomForest(y~x1+x2, data=X2, proximity=TRUE) HTH, Eric On Mon, May 8, 2023 at 11:11 PM varin sacha via R-help wrote: > > Dear

Re: [R] RandomForest tuning the parameters

2023-05-09 Thread Eric Berger
X_test) HTH, Eric On Tue, May 9, 2023 at 6:40 AM Eric Berger wrote: > Hi, > One problem you have is with the command: > regr<-randomForest(y~x1+x2, data=X_train, proximity=TRUE) > > What you need is something like this: > > X2 <- cbind(X,y) > regr<-randomFo

Re: [R] Recombining Mon and Year values

2023-05-17 Thread Eric Berger
An alternative that does not use the zoo package but uses the built-in constant month.abb df1 <- data.frame(Year = c(2021, 2021, 2021), Mon = c("Mar", "Jan", "Apr")) df1$mon_year <- df1$Year*100 + sapply(df1$Mon, \(x) match(x,month.abb)) sort(df1$mon_year) On Wed, May 17, 202

Re: [R] plot level, velocity, acceleration with one x axis

2023-05-29 Thread Eric Berger
How about this: a <- cbind(AirPassengers, diff(log(AirPassengers)), diff(diff(log(AirPassengers colnames(a)[2:3] <- c("percent increase", "acceleration") plot(a, xlab="year", main="AirPassengers") HTH, Eric On Mon, May 29, 2023 at 7:57 AM Spencer Graves wrote: > > Hello, All: > > >

Re: [R] plot level, velocity, acceleration with one x axis

2023-05-30 Thread Eric Berger
Untested but why not a <- cbind(log(DAX), exp(diff(log(DAX))), exp(diff(diff(log(DAX) colnames(a) <- c("logDAX", "vel", "accel") plot(a) On Tue, May 30, 2023 at 1:46 PM Spencer Graves wrote: > > > > On 5/29/23 2:37 AM, Eric Berger wrote: >

Re: [R] plot level, velocity, acceleration with one x axis

2023-05-30 Thread Eric Berger
My code assumes that DAX is a ts object, as in your original post. On Tue, May 30, 2023 at 2:06 PM Eric Berger wrote: > > Untested but why not > > a <- cbind(log(DAX), exp(diff(log(DAX))), exp(diff(diff(log(DAX) > colnames(a) <- c("logDAX", "vel"

Re: [R] plot level, velocity, acceleration with one x axis

2023-05-30 Thread Eric Berger
to plot, and what would be the Y labels that you want to appear at those levels (assuming that there was a Y label for each of them - just to understand the units you are talking about) On Tue, May 30, 2023 at 4:06 PM Spencer Graves wrote: > > > > On 5/30/23 6:16 AM, Eric Berger wrote:

Re: [R] plot level, velocity, acceleration with one x axis

2023-05-30 Thread Eric Berger
What if you just precede these commands as follows: par(mfrow=c(3,1)) plot(DAX.[, 1], log='y', ylab='DAX') plot(DAX.[, 2], ylab='vel (%)') plot(DAX.[, 3], ylab='accel (%)') On Tue, May 30, 2023 at 5:45 PM Spencer Graves wrote: > > > > O

Re: [R] plot level, velocity, acceleration with one x axis

2023-05-31 Thread Eric Berger
Slight modification to have the xaxt ticks and labels only appear on the bottom chart par(mfrow=c(3,1)) plot(DAX.[, 1], log='y', ylab='DAX', xaxt="n") plot(DAX.[, 2], ylab='vel (%)', xaxt="n") plot(DAX.[, 3], ylab='accel (%)') On Tue,

Re: [R] plot level, velocity, acceleration with one x axis

2023-05-31 Thread Eric Berger
27;) On Wed, May 31, 2023 at 4:27 PM Spencer Graves wrote: > > > > On 5/30/23 10:23 AM, Eric Berger wrote: > > What if you just precede these commands as follows: > > > > par(mfrow=c(3,1)) > > plot(DAX.[, 1], log='y', ylab='DAX') > >

Re: [R] inconsistency in mclapply.....

2023-06-09 Thread Eric Berger
Hi Akshay, You do not have to quit R to run 'top'. You can have, for example, 2 windows, with R running in one and top running in the oher. Eric On Sat, Jun 10, 2023 at 12:19 AM akshay kulkarni wrote: > Dear Ivan, > Thanks for the reply. I am pressurised by a fast > approachin

Re: [R] Problem with filling dataframe's column

2023-06-13 Thread Eric Berger
Hi Javed, grep returns the positions of the matches. See an example below. > v <- c("abc", "bcd", "def") > v [1] "abc" "bcd" "def" > grep("cd",v) [1] 2 > w <- v[-grep("cd",v)] > w [1] "abc" "def" > On Tue, Jun 13, 2023 at 8:50 AM javad bayat wrote: > > Dear Rui; > Hi. I used your codes, but it

Re: [R] Feature selection for multiclass classification

2023-06-16 Thread Eric Berger
you might want to search bioconductor https://www.bioconductor.org/ https://bioconductor.org/books/3.13/OSCA.basic/feature-selection.html On Fri, Jun 16, 2023 at 9:04 AM Andrew Zhang wrote: > Hello everyone, can someone share a list of packages that can do feature > selection for multiclass (m

Re: [R] OK, next Q - a sort of factorial on a vector

2023-06-20 Thread Eric Berger
Hi Philip, In the decades since you learned R there have been some additions to the language. In particular, R now supports lambda functions. Applying this feature to Ivan's beautiful solution cuts down 7 characters (continuing his golfing analogy) unlist(lapply(seq_along(x), \(i) x[i] * x[-(1:i)]

Re: [R] Technical Help Request for "Version Differences" (i.e., CYTOFKIT package)

2023-08-04 Thread Eric Berger
Hi Murat, I am not sure why you are using R 3.5. CRAN has R 4.3.1 https://cran.r-project.org/bin/windows/base/ I suggest you start over and install R 4.3.1 and then your cytofkit install might work. Good luck, Eric On Fri, Aug 4, 2023 at 5:47 PM Murat DELMAN wrote: > > Dear Ms./Mr., > > > I s

Re: [R] Stacking matrix columns

2023-08-06 Thread Eric Berger
Stacking columns of a matrix is a standard operation in multilinear algebra, usually written as the operator vec(). I checked to see if there is an R package that deals with multilinear algebra. I found rTensor, which has a function vec(). So, yet another way to accomplish what you want would be:

Re: [R] Stacking matrix columns

2023-08-06 Thread Eric Berger
er answer. > > -Original Message- > From: R-help On Behalf Of Eric Berger > Sent: Sunday, August 6, 2023 3:34 AM > To: Bert Gunter > Cc: R-help Mailing List ; Steven Yen > Subject: Re: [R] Stacking matrix columns > > Stacking columns of a matrix is a standard operatio

Re: [R] Merge with closest (not equal) time stamps

2023-08-08 Thread Eric Berger
Hi Naresh, Perhaps the below is faster than your approach library(dplyr) library(tidyr) merge(option.trades, stock.trades, by="timestamp", all=TRUE) |> dplyr::arrange(timestamp) |> dplyr::mutate(stock.timestamp = as.POSIXct(ifelse(is.na(option.price), timestamp, NA))) |> tidyr::fill(stock.pr

Re: [R] time series transformation....

2023-08-12 Thread Eric Berger
Hi Akshay, The forecast package will do the BoxCox transform and automatically backtransform the forecasts. The package also handles xts objects. For example, modifying the example from the help page of forecast::forecast for Arima > dt <- as.Date("2023-01-01") + 1:length(WWWusage) > a <- xts(WWWu

Re: [R] time series transformation....

2023-08-14 Thread Eric Berger
ote: > > Dear Eric, > THanks for the reply...will this also work with arfima() ? > What if I want to fit a model like GARCH and friends? > > THanking you, > Yours sincerely, > AKSHAY M KULKARNI > ____ > From: Eric Berger > Sent: Sunday, Augu

Re: [R] Help needed with olsrr package

2023-08-22 Thread Eric Berger
I copied your data and ran your code. It worked fine for me. > sessionInfo() R version 4.3.1 (2023-06-16) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.2 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 LAPACK: /usr/lib/x86_64-linux

Re: [R] lag.plot showing only lines....

2023-08-28 Thread Eric Berger
Hi Akshay, I have never used this function before but according to ?lag.plot you simply need to pass the argument do.lines=FALSE. HTH, Eric On Mon, Aug 28, 2023 at 5:45 PM akshay kulkarni wrote: > > Dear members, > I am using the following code: > > lag.plot(ygrpch(OHLC

Re: [R] Finding combination of states

2023-09-04 Thread Eric Berger
The function purrr::cross() can help you with this. For example: f <- function(states, nsteps, first, last) { paste(first, unlist(lapply(purrr::cross(rep(list(v),nsteps-2)), \(x) paste(unlist(x), collapse=""))), last, sep="") } f(LETTERS[1:5], 3, "B", "E") [1] "BAE" "BBE" "BCE" "BDE" "BEE" HTH

Re: [R] Finding combination of states

2023-09-04 Thread Eric Berger
quot; "BEBD" "BACD" "BBCD" "BCCD" "BDCD" "BECD" "BADD" >> [17] "BBDD" "BCDD" "BDDD" "BEDD" "BAED" "BBED" "BCED" "BDED" >> [25]

Re: [R] Finding combination of states

2023-09-05 Thread Eric Berger
;b" "c" "a" "e" > [2,] "b" "d" "a" "e" > [3,] "b" "e" "a" "e" > [4,] "b" "a" "b" "e" > [5,] "b" "c

Re: [R] Merge and replace data

2023-09-05 Thread Eric Berger
xx <- pmax(x1,x2) On Tue, Sep 5, 2023 at 11:56 AM roslinazairimah zakaria wrote: > > Hi all, > > I have these data > > x1 <- c(116,0,115,137,127,0,0) > x2 <- c(0,159,0,0,0,159,127) > > I want : xx <- c(116,115,137,127,159, 127) > > I would like to merge these data into one column. Whenever the da

Re: [R] Merge and replace data

2023-09-05 Thread Eric Berger
As Duncan points out, ifelse() provides a more general approach than the specific pmax(). Even more generally, you might want to consider the apply() function (and its relatives sapply(), lapply(), ...) For example apply(cbind(x1,x2), MAR=1, max) In the above statement, x1 and x2 are combined i

Re: [R] prop.trend.test

2023-09-07 Thread Eric Berger
You might want to consider exponential smoothing models such as Holt's (Double Exponential Smoothing). This method continually updates the trend parameter, and you can monitor the most recent value (for sign, or magnitude, or both). In R, some choices to fit the Holt model: 1. stats::HoltWinters(

Re: [R] [EXT] Theta from negative binomial regression and power_NegativeBinomiial from PASSED

2023-09-14 Thread Eric Berger
I asked your question to ChatGPT4 In statistics, what is the theta parameter of the negative binomial distribution? The response contained some math symbols but I am sending in plain text mode so there may be some loss, hopefully not serious. The negative binomial distribution is used to model t

Re: [R] annotate

2023-10-05 Thread Eric Berger
Another approach (still seems to require experimentation to get the value '2') would be to replace the annotate() with geom_text(data=above_92, aes(x=eruptions,y=waiting, label=waiting), nudge_y=2) At least this makes clear the reason for the magic number '2' in the code. For details see ?geom_t

Re: [R] Code editor for writing R code

2023-11-29 Thread Eric Berger
Another direction would be to replace your R script (.R file) with a Quarto document (.qmd file). VS-code has good support for Quarto and you could intersperse your Latex with R chunks. On Wed, Nov 29, 2023 at 6:15 PM Ben Bolker wrote: > > > >Presumably there's nothing stopping you *writing*

Re: [R] Code editor for writing R code

2023-11-29 Thread Eric Berger
Bert, Posit (formerly RStudio) has moved from RMarkdown to Quarto. They still support RMarkdown but major new features will be in Quarto. For new users a better choice would be Quarto. See https://quarto.org/docs/faq/rmarkdown.html Secondly, the OP stated he was using the VS-Code IDE, so there is

Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Eric Berger
full_filename <- paste(filepath, filename,sep="/") On Sat, Dec 30, 2023 at 1:45 PM Andy wrote: > Thanks Ivan and Calum > > I continue to appreciate your support. > > Calum, I entered the code snippet you provided, and it returns 'file > missing'. Looking at this, while the object 'full_filename'

Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Eric Berger
ull filename and > # passes it ( |> command) to the next line > # which summarises it. > # the result is saved in a data frame object > # called content which we shall show some > # heading into from > > head(content) > } > > > Running this, results i

Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Eric Berger
! # The rest here is Calum's > > suggestion > > if (!file.exists(full_filename)) { > > message("File missing") > > } else { > > content <- read_docx(full_filename) > > docx_summary() > > # this reads docx for the full fil

Re: [R] How to tweak genomic plot with genoPlotR?

2024-04-02 Thread Eric Berger
According to https://cran.r-project.org/web/packages/genoPlotR/index.html the maintainer of genoPlotR is Lionel Guy Send your question also to him. On Tue, Apr 2, 2024 at 11:27 AM Luigi Marongiu wrote: > > I would like to use your genoPlotR package > (doi:10.1093/bioinformatics/btq413) to comp

Re: [R] Format

2024-06-10 Thread Eric Berger
Since you are loading lubridate it is enough to do Atest$ddate1 <- dmy(Atest$ddate) On Sun, Jun 9, 2024 at 11:59 PM Duncan Murdoch wrote: > > On 2024-06-09 4:39 p.m., Val wrote: > > HI all, > > > > My > > I am trying to convert character date (mm/dd/yy) to -mm-dd date > > format in one of

Re: [R] I have Problem using the Pipe Command

2024-06-18 Thread Eric Berger
Please show the output of > sessionInfo() On Tue, Jun 18, 2024 at 7:49 PM Ogbos Okike wrote: > Thanks, Duncan for contributing. I quickly tried entering the command on a > new line. But the error pointed specifically to the point. It didn't run. > Best regards > Ogbos > > On Tue, Jun 18, 2024 a

Re: [R] I have Problem using the Pipe Command

2024-06-18 Thread Eric Berger
C_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > loaded via a namespace (and not attached): > [1] compiler_3.4.4

Re: [R] I have Problem using the Pipe Command

2024-06-19 Thread Eric Berger
; [1] 55 > > On Wed, Jun 19, 2024 at 7:52 AM Eric Berger wrote: > >> In your R session do >> >> library(magrittr) >> 1:10 %>% sum() >> >> This should output 55. >> If that does not work send the results, include the output of >> sessionIn

Re: [R] Naming output file

2024-06-24 Thread Eric Berger
How about assign(paste0("bop",im), boprobit( etc )) On Mon, Jun 24, 2024 at 2:41 PM Steven Yen wrote: > I would like a loop to > > (1) read data files 2010midata1,2010midata2,2010midata3; and > > (2) name OUTPUT bop1,bop2,bop3. > > I succeeded in line 3 of the code below, > > BUT not line 4.

Re: [R] Naming output file

2024-06-24 Thread Eric Berger
assign(paste0("bop",im),boprobit(eqs,mydata,wt=weight,method="BHHH",tol=0,reltol=0,gradtol=1e-5,Fisher=TRUE)) On Mon, Jun 24, 2024 at 2:56 PM Steven Yen wrote: > Thanks Eric. I am not following your suggested line. Would you just edit > my line 4? Thanks. > On 6

Re: [R] help on date objects...

2024-07-27 Thread Eric Berger
as.Date("2022-01-02", origin="1900-01-01", format="%Y-%d-%m") On Sun, Jul 28, 2024 at 7:24 AM akshay kulkarni wrote: > Dear members, > WHy is the following code returning NA > instead of the date? > > > > as.Date("2022-01-02", origin = "1900-01-01", format = "%y%d%m

Re: [R] ts_regular....in tsbox

2024-07-27 Thread Eric Berger
Did you try converting the date column to class Date? Does that work? On Sun, Jul 28, 2024 at 7:40 AM akshay kulkarni wrote: > dear members, > I have a data frame which contains, among > others, a date object of monthly frequency which is not regular, i.e some > mont

Re: [R] An error message with the command fm<-1m (Version 4.4.1. p. 80, An introduction to R)

2024-08-06 Thread Eric Berger
The function is lm(), not 1m(). lm stands for "linear model" (the first letter of each word) On Tue, Aug 6, 2024 at 11:22 AM Rosana Curzel wrote: > Dear all, > > I am introducing in R and I had a problem in the beginning. Please, you can > see an error message below: (Maybe I am in error. If so

Re: [R] Force conversion of (POSIXct) time zone with base R

2024-08-22 Thread Eric Berger
as.POSIXct(as.character(now),tz="UTC") or as.POSIXct(as.character(Sys.time()),tz="UTC") On Thu, Aug 22, 2024 at 12:00 PM Iago Giné Vázquez wrote: > Hi, > > How should POSIXct time zone be changed without modifying the specified > time (so fix the time zone). I tried > > > now <- Sys.time() >

Re: [R] "And" condition spanning over multiple columns in data frame

2024-09-12 Thread Eric Berger
Hi, To rephrase what you are trying to do, you want a copy of all the cp columns, in which all the NAs become 1s and any other value becomes a zero. There is an exception for the first row, where the NAs should become 0s. a <- c10Dt b <- matrix(as.numeric(is.na(a[,-1])), nrow=nrow(a)) b[1,] <- 0

Re: [R] date

2019-12-19 Thread Eric Berger
Martin writes: "there's really no reason for going beyond base R" I disagree. Lubridate is a fantastic package. I use it all the time. It makes working with dates really easy, as evidenced by John Kane's suggestion. I strongly recommend learning to work with it. The bottom line: as is often the

Re: [R] date

2019-12-19 Thread Eric Berger
point is: > If you know the structure of the data you want to > parse, then it is best to tell R (or any other language) > this structure explicitly. " > > Fortune nomination! > > -- Bert > > > > > > > Thu, Dec 19, 2019, 2:49 AM Enrico Schumann wrote:

Re: [R] Alignment of the title in a key for xyplot in lattice.

2019-12-24 Thread Eric Berger
Lovely solution Rolf :-) On Tue, Dec 24, 2019 at 8:42 AM Rolf Turner wrote: > > On 24/12/19 2:29 pm, Jim Lemon wrote: > > > Hi Rolf, > > Following the docs back to draw.key, It looks like the ellipsis > > argument is ignored. I was hoping for a brilliant solution along the > > lines of: > > > >

[R] outer join of xts's

2020-01-02 Thread Eric Berger
Hi, I have a list L of about 2,600 xts's. Each xts has a single numeric column. About 90% of the xts's have approximately 500 rows, and the rest have fewer than 500 rows. I create a single xts using the command myXts <- Reduce( merge.xts, L ) By default, merge.xts() does an outer join (which is w

Re: [R] outer join of xts's

2020-01-02 Thread Eric Berger
; perfroms one > multiway merge rather than k-1 two way merges. > > do.call("merge", L) > > On Thu, Jan 2, 2020 at 6:13 AM Eric Berger wrote: > > > > Hi, > > I have a list L of about 2,600 xts's. > > Each xts has a single numeric column. About

Re: [R] outer join of xts's

2020-01-02 Thread Eric Berger
= "left" only applies with merge.xts if there are two objects. > If there are more it acts the same as join = TRUE.. > See the Details section of ?merge.xts > > On Thu, Jan 2, 2020 at 1:29 PM Duncan Murdoch > wrote: > > > > On 02/01/2020 9:31 a.m., Eric Berger

Re: [R] outer join of xts's

2020-01-03 Thread Eric Berger
<- xts(x=rnorm(5),order.by=dtV) a1Xts <- aXts[1:3,] a2Xts <- aXts[2:4,] etc Happy to hear your views on why other conventions might be better. Regards, Eric On Fri, Jan 3, 2020 at 3:45 PM Joshua Ulrich wrote: > > On Fri, Jan 3, 2020 at 1:14 AM Eric Berger wrote: > > &g

Re: [R] Dataframe by Serial ID

2020-01-08 Thread Eric Berger
Hi Thomas, Jeff is correct that this can be handled via merge, e.g. df3 <- merge( df2, df1, by="Serial", all=FALSE ) This operation is called an "inner join", and you could use other tools, such as the dplyr package to accomplish the same thing df3 <- dplyr::inner_join( df2, df1, by="Serial" ) H

[R] Fwd: Extracting a particular column from list

2020-01-17 Thread Eric Berger
is Sent from Yahoo Mail on Android <https://go.onelink.me/107872968?pid=InProduct&c=Global_Internal_YGrowth_AndroidEmailSig__AndroidUsers&af_wl=ym&af_sub1=Internal&af_sub2=Global_YGrowth&af_sub3=EmailSignature> On Thu, 16 Jan 2020 at 4:24 PM, Eric Berger wrote: > u <- l

Re: [R] How to save multiple values of a variable in a json file in R

2020-01-20 Thread Eric Berger
I have had success using the fromJSON() function in the rjson package. On Thu, Jan 16, 2020 at 4:22 PM Ioanna Ioannou wrote: > hello everyone, > > and happy new year! > > I have this problem: I want to save the name of the 'countries', the > 'taxonomy_gem' and the 'minimum_im' and 'maximum_im' .

Re: [R] Extracting a particular column from list

2020-01-20 Thread Eric Berger
> u <- list(a=1:5, b=letters[1:3]) > u # $a # [1] 1 2 3 4 5 # # $b # [1] "a" "b" "c" > u[["a"]] [1] 1 2 3 4 5 On Thu, Jan 16, 2020 at 1:04 PM Faheem Jan via R-help wrote: > Hi. How to extract a column from the list.. I will be thanks full.. > > Sent from Yahoo Mail on Android > [[alt

Re: [R] Correct place to put an import directive

2020-01-29 Thread Eric Berger
I think a better place to post this question would be r-package-devel On Wed, Jan 29, 2020 at 1:07 PM Ashim Kapoor wrote: > Dear All, > > This is a cross post of the following query:- > > > https://stackoverflow.com/questions/59946803/import-directive-in-r-which-file-and-where-in-that-file-sh

Re: [R] Statistical Analysis of an Exchange Rate

2020-03-05 Thread Eric Berger
Alternatively you might try posting to r-sig-fina...@r-project.org On Wed, Mar 4, 2020 at 9:38 PM Bert Gunter wrote: > Your question is way off topic here -- this list is for R programming > questions, not statistical consulting. You might wish to try > stats.stackexchange.com for the latter.

Re: [R] (no subject)

2020-03-08 Thread Eric Berger
I have no experience with these packages/libraries. I did a Google search on 'R interface for G@RCH' and there seemed to be a number of relevant hits, such as https://faculty.chicagobooth.edu/ruey.tsay/teaching/bs41202/sp2009/G@RCH_info.txt HTH, Eric On Sun, Mar 8, 2020 at 12:42 PM Jim Lemon

Re: [R] Relatively Simple Maximization Using Optim Doesnt Optimize

2020-03-12 Thread Eric Berger
It is possible to work out this problem explicitly. Playing with a few different calls to optim shows that the method="L-BFGS-B" gives the correct answer. I don't have particular insight into why method="CG" is problematic. On Thu, Mar 12, 2020 at 4:12 PM Jeff Newmiller wrote: > The help file p

Re: [R] About the multiprecision computing package in R

2020-03-14 Thread Eric Berger
CRAN Rmpfr On Sat, Mar 14, 2020 at 7:36 PM 林伟璐 <13917987...@163.com> wrote: > Dear all > > > I need a multiprecision computing package in R, if anyone in the list > knows, please let me known... > > > Many thanks > > > Weilu Lin > [[alternative HTML version deleted]] > >

Re: [R] Program to produce multiple plots

2020-03-30 Thread Eric Berger
Another comment: if you are running your program in RStudio, it will create the sequence of plots but you need to "page back" to see them. Click the "Plots" tab and notice there are two arrows: back (pointing to the left) and forward (pointing to the right) HTH, Eric On Mon, Mar 30, 2020 at 5:04

<    1   2   3   4   5   6   >