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] 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] 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] 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] 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] 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] 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] 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] I have Problem using the Pipe Command

2024-06-18 Thread Eric Berger
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 sessionInfo() showing that you have loaded magrittr. On Wed, Jun 19, 2024 at 9:43 AM Ogbos Okike wrote: > Dear Eric, > Good morning fro

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] 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] 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] Help request: Parsing docx files for key words and appending to a spreadsheet

2023-12-30 Thread Eric Berger
nt which we shall show some ># heading into from > >head(content) > } > > > Results in this error now:Error in x$doc_obj : $ operator is invalid for > atomic vectors > > Thank you. > > > > On 30/12/2023 12:12, Andy wrote: > > Hi Eric > > &

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

2023-12-30 Thread Eric Berger
docx_summary(content) You should read documentation e.g. ?docx_summary and check the examples section On Sat, Dec 30, 2023 at 2:12 PM Andy wrote: > Hi Eric > > Thanks for that. That seems to fix one problem (the lack of a separator), > but introduces a new one when I complete

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] Code editor for writing R code

2023-11-29 Thread Eric Berger
no reason to point him to the Posit/RStudio IDE for this functionality which VS-Code supports very well (as I noted in my response.) Best, Eric On Wed, Nov 29, 2023 at 6:55 PM Christofer Bogaso wrote: > > Hi Sergei, > > Where can I find TeX Comments extension in VS Code? > > On

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] 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] [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] prop.trend.test

2023-09-07 Thread Eric Berger
nters() and set the gamma argument to FALSE for a non-seasonal model 2. forecast::holt() HTH, Eric On Fri, Sep 8, 2023 at 8:23 AM Thomas Subia via R-help wrote: > > Colleagues, > > Thanks all for the responses. > > I am monitoring the daily total number of defects per sample

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] 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] Finding combination of states

2023-09-05 Thread Eric Berger
out[-grep("(.)\\1",out)] Best, Eric On Tue, Sep 5, 2023 at 3:08 AM Bert Gunter wrote: > > ... and just for fun, here is a non-string version (more appropriate for > complex state labels??): > > gvec <- function(ntimes, states, init, final, repeats = TRUE) >#

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-04 Thread Eric Berger
t;E") [1] "BAE" "BBE" "BCE" "BDE" "BEE" HTH, Eric On Mon, Sep 4, 2023 at 3:42 PM Christofer Bogaso wrote: > > Let say I have 3 time points.as T0, T1, and T2.(number of such time > points can be arbitrary) In each time point, an object c

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

Re: [R] Help needed with olsrr package

2023-08-22 Thread Eric Berger
3.1 [19] goftest_1.2-3 dplyr_1.1.2 Rcpp_1.0.11 pkgconfig_2.0.3 rstudioapi_0.15.0 nortest_1.0-4 R6_2.5.1 tidyselect_1.2.0 utf8_1.2.3 [28] pillar_1.9.0 magrittr_2.0.3tools_4.3.1 gtable_0.3.3 ggplot2_3.4.2 > HTH, Eric On Tue, Aug 22, 2023 at 7:47 PM Ivan Krylov

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

2023-08-14 Thread Eric Berger
Hi Akshay, If you do > help(package="forecast") you will find that arfima is listed. Unfortunately, I don't see any ARCH-type models there, but you should check out the help page results. Good luck, Eric On Mon, Aug 14, 2023 at 8:04 PM akshay kulkarni wr

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

2023-08-12 Thread Eric Berger
sage) > a <- xts(WWWusage, order.by=dt) > fit1 <- Arima(a, c(3,1,0)) > fit2 <- Arima(a, lambda=0.5, c(3,1,0)) ## applies the Box-Cox transform with > lambda=0.5 > par(mfrow=c(1,2)) > plot(forecast(fit1)) > plot(forecast(fit2)) HTH, Eric p.s. RJH is the author/maint

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] Stacking matrix columns

2023-08-06 Thread Eric Berger
. On Sun, Aug 6, 2023 at 6:16 PM wrote: > > Eric, > > I am not sure your solution is particularly economical albeit it works for > arbitrary arrays of any dimension, presumably. But it seems to involve > converting a matrix to a tensor just to undo it back to a vector. Other &

Re: [R] Stacking matrix columns

2023-08-06 Thread Eric Berger
: > library(rTensor) > vec(as.tensor(x)) Eric On Sun, Aug 6, 2023 at 5:05 AM Bert Gunter wrote: > > Or just dim(x) <- NULL. > (as matrices in base R are just vectors with a dim attribute stored in > column major order) > > ergo: > > > x > [1] 1 2 3 4 5

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

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] 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] 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] 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 press

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

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

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

2023-05-08 Thread Eric Berger
will narrow down the search. HTH, Eric On Mon, May 8, 2023 at 4:41 AM Robert Knight wrote: > > Hello R Help, > > I have some R vignettes that run fpp2 time series regressions. I have run > these for a long time using R and a 12 core computer system. I ran each > core us

Re: [R] problem installing RGBL library

2023-04-22 Thread Eric Berger
looks fine. what's the problem? On Sat, Apr 22, 2023 at 7:27 PM varin sacha wrote: > Eric, > > Here it is : > > > library(RBGL) > Loading required package: graph > Loading required package: BiocGenerics > > Attaching package: ‘BiocGenerics’ > &

Re: [R] problem installing RGBL library

2023-04-22 Thread Eric Berger
What happens with the command > library(RBGL) On Sat, Apr 22, 2023 at 7:08 PM varin sacha via R-help wrote: > Dear R-experts, > > How to solve that problem? > > My R version is 4.2.1 > > Here below trying to install RGBL library found here : > https://bioconductor.org/packages/release/bioc/htm

Re: [R] Package Caret

2023-04-14 Thread Eric Berger
prettyseq() is in the seqinr package. That seems to usher in a lot of other issues. How about caTools::sample.split() ? (I have never used it, I just learned about it from a search) https://rdrr.io/cran/caTools/src/R/sample.split.R Good luck, Eric On Fri, Apr 14, 2023 at 10:50 AM Gábor

Re: [R] Package Caret

2023-04-14 Thread Eric Berger
What happens if you do the following? > library(caret) > ?caret::createDataPartition i.e. to confirm that caret is loaded, seek help on this function On Fri, Apr 14, 2023 at 9:56 AM Gábor Malomsoki wrote: > Eric, > > Yes, i know, i am calling the package, but this is not wor

Re: [R] Package Caret

2023-04-13 Thread Eric Berger
You first have to load the package using the library command. > library(caret) Then you can call createDataPartition. e.g. > data(oil) > createDataPartition(oilType,2) HTH, Eric On Fri, Apr 14, 2023 at 7:52 AM Gábor Malomsoki wrote: > Dear all, > When i try to use createData

Re: [R] Split String in regex while Keeping Delimiter

2023-04-12 Thread Eric Berger
","-@ ",s),"@"))) } h <- function(s) { g(f(s)) } To try it out: s <- “leucocyten + gramnegatieve staven +++ grampositieve staven ++” t <- “leucocyten – grampositieve coccen +” h(s) h(t) HTH, Eric On Wed, Apr 12, 2023 at 7:56 PM Emily Bakker wrote: > Hello Lis

Re: [R] converting to date object...

2023-04-12 Thread Eric Berger
lubridate::dmy("12 APR 2023") On Wed, Apr 12, 2023 at 5:34 PM akshay kulkarni wrote: > dear members, > I want to convert "12 APR 2023" into a Date > object. I tried as_Date() from lubridate, but it is not working: > > > as_date("12 APR 2023") > [1] NA > Warning messa

Re: [R] Matrix scalar operation that saves memory?

2023-04-11 Thread Eric Berger
subtractConst(m,100.0) print(m) [,1] [,2] [1,] 51.5 56.5 [2,] 52.5 57.5 [3,] 53.5 58.5 [4,] 54.5 59.5 [5,] 55.5 60.5 HTH, Eric On Wed, Apr 12, 2023 at 7:34 AM Bert Gunter wrote: > I doubt that R's basic matrix capabilities can handle this, but have a look > at the Matrix package

Re: [R] Simple Stacking of Two Columns

2023-04-03 Thread Eric Berger
pivot_longer() Sent from my iPhone > On 3 Apr 2023, at 18:09, Sparks, John wrote: > > Hi R-Helpers, > > Sorry to bother you, but I have a simple task that I can't figure out how to > do. > > For example, I have some names in two columns > > NamesWide<-data.frame(Name1=c("Tom","Dick"),Name2

Re: [R] Detpack package

2023-02-01 Thread Eric Berger
Detpack or detpack? What happens when you try detpack::chi2testuniform(...) ? On Wed, Feb 1, 2023 at 6:08 PM Nick Wray wrote: > Hello I've successfully installed the package "Detpack" and remembered to > call it via library() But when I try to use the functions i get this: > > > chi2testuni

Re: [R] Problem to run python code in r markdown

2023-01-20 Thread Eric Berger
e the File pulldown menu and select New File --> 'R Markdown' or New File --> 'Quarto document'. In the R Markdown (or Quarto) document, create a python code chunk: ```{python} import numpy as np print(np.arange(5)) ``` works for me. HTH, Eric On Fri, Jan 20, 2023

Re: [R] Fwd: Reg: Frequency in declaring time series data

2023-01-17 Thread Eric Berger
the markets are closed). This leads to about 250 or 252 trading days per year (52 weeks X 5 days/wk = 260, minus 8-10 holidays). It is standard in financial calculations to annualize based on 250 or 252. So, you might want to specify a frequency of 250 or 252 in your time series when creating a ts

Re: [R] Printing special characters

2023-01-16 Thread Eric Berger
How about just 'EVENT > 30 sec' or 'EVENT > 29 sec' ? On Mon, Jan 16, 2023 at 10:19 AM Dennis Fisher wrote: > R 4.2.2 > OS X > > Colleagues > > A file that I have read includes strings like this: > "EVENT ≥ 30 sec" > When I include the string in a graphic using: > mtext(STRING,

Re: [R] Removing variables from data frame with a wile card

2023-01-13 Thread Eric Berger
mydata[, -grep("^yr",colnames(mydata))] On Sat, Jan 14, 2023 at 8:57 AM Steven T. Yen wrote: > I have a data frame containing variables "yr3",...,"yr28". > > How do I remove them with a wild cardsomething similar to "del yr*" > in Windows/doc? Thank you. > > > colnames(mydata) >[1] "yea

Re: [R] Topological network Map

2023-01-11 Thread Eric Berger
Google using "R package subway map" produced https://www.r-bloggers.com/2021/01/non-hierarchical-edge-bundling-flow-maps-and-metro-maps-in-r/ which looks promising On Wed, Jan 11, 2023 at 2:48 PM Nick Wray wrote: > > Hello I'd like to create a simple topological map of a river system, ie all > t

Re: [R] Reg: ggplot error

2023-01-11 Thread Eric Berger
No code or data came through. Please read the posting guidelines. On Wed, Jan 11, 2023 at 1:38 PM Upananda Pani wrote: > > Dear All, > > I am using roptest function of package "ROptEst" (Kohl and Ruckdeschel > (2019)) to find out the ML, CvM-MD, and the RMX estimator and their > asymptotic conf

Re: [R] Reg: Help in assigning colors to factor variable in ggplot2

2022-12-26 Thread Eric Berger
Your problem is that the color "#4DAF4A8" is not a valid color. It should have only 6 hex digits. e.g. "#4DAF4A" will work. Also you seem to be confused about ggplot. You are not using ggplot in your code at all. You are using base graphics. You can remove the 3 library calls.

Re: [R] Amazing AI

2022-12-19 Thread Eric Berger
ome of the ChatGPT responses have bugs/deficiencies. For example, the Codex code does *not* remove duplicates. It requires knowledge and skill of the material you are teaching, for the students to be able to spot and fix the bugs. In which case, what's your problem? 😁 HTH, Eric * and as a shout-ou

Re: [R] is.na()<- on a character vector

2022-12-16 Thread Eric Berger
maybe this will make it clear x <- c(a=1, b=5) is.na(x) <- "b" i.e. your second case is dealing with a named vector HTH, Eric On Fri, Dec 16, 2022 at 8:29 PM Göran Broström wrote: > I'm confused: > > > x <- 1:2 > > is.na(x) <- 1 > > x >

Re: [R] What is new in R especially about Tidyverse.

2022-11-27 Thread Eric Berger
-disciplines in data science. For example, Rob Hyndman's group has created the tidyverts (the 'ts' refers to time series) which extends the tidyverse packages and also contributed additional packages. The tidyverts facilitates time series forecasting. Good luck, Eric On Sun, Nov 27, 2

Re: [R] IGCI implemented in R package ?

2022-11-21 Thread Eric Berger
ub.io/CausalDiscoveryToolbox/html/index.html HTH, Eric On Mon, Nov 21, 2022 at 9:00 PM varin sacha via R-help wrote: > Dear R experts, > > Google is very often my friend but this time it does not ! > Are you aware of an R package in which the directed causal discovery > algorithm called the Informat

Re: [R] [External] Re: Selecting a minimum value of an attribute associated with point values neighboring a given point and assigning it as a new attribute

2022-11-08 Thread Eric Berger
Hi Tiffany, You can replace Conc_min <- lapply(1:N, function(i) { ... by Conc_min <- lapply(seq_len(nrow(pts)), function(i) { .. Best, Eric On Wed, Nov 9, 2022 at 4:38 AM Duhl, Tiffany R. wrote: > > First off, thanks SO much Eric and Micha for your help on this problem! I >

Re: [R] [External] Re: Selecting a minimum value of an attribute associated with point values neighboring a given point and assigning it as a new attribute

2022-11-07 Thread Eric Berger
ry(igraph) g <- graph_from_adjacency_matrix(B,"undirected") g <- set_vertex_attr(g, "Conc", 1:N, Conc ) Conc_min.igraph <- sapply(1:N, \(i) min(vertex_attr(g,"Conc",neighbors(g,i test.igraph <- identical(Conc_min$Conc_min, Conc_min.igraph) cat("test.

Re: [R] Selecting a minimum value of an attribute associated with point values neighboring a given point and assigning it as a new attribute

2022-11-06 Thread Eric Berger
e(j=Var1,k=Var2) |> filter(j < k) u <- sapply(1:nrow(idx), \(i){ j <- idx$j[i]; k <- idx$k[i]; A[j,k] <<- f(j,k,myData) }) B <- A + t(A) + diag(N) C <- diag(myData$Conc) D <- B %*% C D[D==0] <- NA myData$Conc_min <- apply(D,MAR=1,\(v){min(v,na.rm=TRUE)}) print

Re: [R] Selecting a minimum value of an attribute associated with point values neighboring a given point and assigning it as a new attribute

2022-11-06 Thread Eric Berger
pending on whether the observations in rows i and j in your dataset 'data' are within your cutoff distance (i.e. 50m). You can then use Part 2 almost without changes (except for changing 'myData' to the correct name of your data). I hope this helps, Eric library(dplyr) ## PART 1

Re: [R] Single pdf of all R vignettes request

2022-10-31 Thread Eric Berger
You can see all the installed vignettes on your system with `browseVignettes()`. (This opens a browser page.) Alternatively `browseVignettes("pkgname")` for those related to a single package. HTH, Eric On Mon, Oct 31, 2022 at 11:37 AM Richard O'Keefe wrote: > Let's p

Re: [R] Color Nodes

2022-10-27 Thread Eric Berger
You may want to change the color of the vertex labels. e.g. plot(g, vertex.size = 20, vertex.label.dist = 0.5, vertex.color = V(g)$color, vertex.label.color="cyan") On Thu, Oct 27, 2022 at 1:52 AM Jeff Reichman wrote: > > Yes Rui that will work for my needs thank you > > -Original Mes

Re: [R] Best place to ask questions about non-R Base topics, ex. dplyr, dbplyr, etc. ?

2022-10-26 Thread Eric Berger
Also, since your examples were dplyr and dbplyr which are associated with RStudio.com (aka Posit) you might also try https://community.rstudio.com You can apply filters on that site to narrow the results On Wed, Oct 26, 2022 at 10:12 PM Jeff Newmiller wrote: > > The general recommendation is

Re: [R] Unintended behaviour of stats::time not returning integers for the first cycle

2022-10-15 Thread Eric Berger
Alternatively correct.year <- floor(time(x)+1e-6) On Sat, Oct 15, 2022 at 10:26 AM Andreï V. Kostyrka < andrei.kosty...@gmail.com> wrote: > Dear all, > > > > I was using stats::time to obtain the year as a floor of it, and > encountered a problem: due to a rounding error (most likely due to its

[R] Help installing devtools plus other packages in R terminal

2022-10-05 Thread Rhon Calderon, Eric
*** [aclocal.m4] Error 127 make[1]: Leaving directory `/tmp/RtmpMjF6Ns/R.INSTALL4a3cb2204b0da/httpuv/src/libuv' make: *** [libuv/.libs/libuv.a] Error 2 ERROR: compilation failed for package ‘httpuv’ * removing ‘/home/ericrhon/R/x86_64-pc-linux-gnu-library/4.2/httpuv’ ERROR: dependency ‘httpuv’ is

[R] Help executing R on High Performance Cluster

2022-10-04 Thread Rhon Calderon, Eric
n exec "${R_binary}" ${args} "${@}" else ## Ideally, we would like the debugger to start R with additional ## ('inferior') arguments, but not all debuggers can do this. We know ## about valgrind and some versions of GDB , and deal with these. ## Otherw

Re: [R] Fatal Error: Contains Space

2022-09-28 Thread Eric Berger
so > much for the help!! > > Best, > Kaitlyn Light > > On Thu, Sep 22, 2022 at 3:42 AM Eric Berger wrote: >> >> Does this help? >> https://stackoverflow.com/questions/72138987/r-studio-fatal-error-r-tempdircontains-space >> >> On Thu, Sep 22, 2022

Re: [R] apply to row and column of matrix

2022-09-26 Thread Eric Berger
Bert provided an excellent answer to your question. FYI here is a different approach to do the calculation. It uses data.frame rather than matrix. A data frame is a list of its columns. Here the function supplied to sapply operates on each column of the data.frame. > m <- as.data.frame(t(matrix(1:

Re: [R] Solve equality function with GA

2022-09-25 Thread Eric Berger
?ga states that ga() searches for the maximum of the fitness function. The maximum of your fitness function is at x=0. On Sun, Sep 25, 2022 at 4:52 AM Bert Gunter wrote: > We aren't supposed to do homework on this list. > > Bert Gunter > > On Sat, Sep 24, 2022 at 5:29 PM Barry King via R-help

Re: [R] Fatal Error: Contains Space

2022-09-22 Thread Eric Berger
Does this help? https://stackoverflow.com/questions/72138987/r-studio-fatal-error-r-tempdircontains-space On Thu, Sep 22, 2022 at 10:37 AM Kaitlyn Light wrote: > Hello! > I recently downloaded R and RStudio to my windows laptop. I downloaded the > correct version and made sure it was for windows

Re: [R] Error in if (class(networks) == "matrix") from a function

2022-09-21 Thread Eric Berger
of length > 1 (all the classes). One possible workaround would be: if ( "matrix" %in% class(networks) ) ... HTH, Eric On Wed, Sep 21, 2022 at 10:21 PM Chao Liu wrote: > Dear R-Help community, > > This is a crosspost on SO but I've had no luck so far. So I have

Re: [R] How to set default encoding for sourced files

2022-09-21 Thread Eric Berger
Hi Andrew, If you look at ?source you see its default value for encoding is picked up from getOption("encoding"). Couldn't you just set this option in your Rprofile? HTH, Eric On Wed, Sep 21, 2022 at 5:34 PM Andrew Hart via R-help wrote: > > Hi there. I'm working w

Re: [R] aplpack / bagplot

2022-09-21 Thread Eric Berger
bagplot() function does not handle repeated x-values. I tried adding some noise to the x-values and that worked fine. x2 <- x + rnorm(length(x),0,1.e-5) bagplot(x2,y) HTH, Eric On Wed, Sep 21, 2022 at 12:54 PM Sigbert Klinke wrote: > > Hi, > > I get an error when I use bagplot f

Re: [R] aplpack / bagplot

2022-09-21 Thread Eric Berger
handle repeated x-values. I tried adding some noise to the x-values and that worked fine. x2 <- x + rnorm(length(x),0,1.e-5) bagplot(x2,y) HTH, Eric On Wed, Sep 21, 2022 at 12:54 PM Sigbert Klinke wrote: > Hi, > > I get an error when I use bagplot from the package aplpack. Any

Re: [R] Question concerning side effects of treating invalid factor levels

2022-09-19 Thread Eric Berger
(1,7000,16000),0))) you will see that everything is fine. (New factor values are created.) HTH, Eric On Mon, Sep 19, 2022 at 2:14 PM Tibor Kiss via R-help wrote: > > Dear List members, > > I have tried now for several times to find out about a side effect of > treating invalid fac

Re: [R] Converting time format

2022-09-19 Thread Eric Berger
What is the output of > class(b$time) ? Also, start sending your emails in plaint text format, if possible. On Mon, Sep 19, 2022 at 2:12 PM Parkhurst, David wrote: > > I have a dataframe obtained using read.csv from an excel file. Its first > column is times, running from 18:00 to 19:30. If

Re: [R] removing non-table lines

2022-09-19 Thread Eric Berger
ds names(a2) <- NULL iV <- unlist(lapply(a2, function(x) {g(x) == N})) ## identify the rows with exactly N fields a2 <- a2[iV] ## heuristic: keep only the lines with N fields a3 <- as.data.frame(do.call(rbind,a2)) a3 } myDf <- processFile("tmp3.csv") print

Re: [R] opening nimroad tar gz files in R

2022-09-15 Thread Eric Berger
Is there a way to download a file from that site without registering for the site? If you have a unix/linux shell, what does the 'file' command output? $ file foo.gz On Thu, Sep 15, 2022 at 2:11 PM Nick Wray wrote: > Hello > > I am trying to download data sets from the 1 km Resolution UK Comp

Re: [R] Problem with installing packages in R

2022-09-15 Thread Eric Berger
Can you bring up R in a shell? Do you get the same message? (Also, set your email to send plain text. HTML versions are deleted.) On Thu, Sep 15, 2022 at 11:27 AM Farah Al Saifi wrote: > > Dear Sir/Madam > > After the update of the new version of R 4.2.1, an error message ( Error in > nchar(ho

Re: [R] von Neumann/Bartels/Serial Correlation

2022-08-14 Thread Eric Berger
17] compiler_4.2.1lmom_2.8 expm_0.999-6 HTH, Eric On Sun, Aug 14, 2022 at 11:38 AM Nick Wray wrote: > > Hello Although there is info on the net about the von Neumann test - > VonNeumannTest: > Von Neumann's Successive Difference Test in DescTools: Tools for > D

Re: [R] Fitted values from AR model

2022-08-12 Thread Eric Berger
points. (For all the other values, the fits are extremely close.) HTH, Eric On Thu, Aug 11, 2022 at 9:53 PM bogus christofer wrote: > > Hi, > > I have below AR model and fitted values from the forecast package > > library(forecast) > dta = c(5.0, 11, 16, 23, 36, 58, 29, 20,

Re: [R] extracting numeric values returned when using the by function to run the acf function

2022-05-10 Thread Eric Berger
as.numeric(by(RecallSmall[1:4,"value"],RecallSmall[1:4,"ID"],acf,na.action=na.pass,plot=FALSE)[[1]]$acf) On Tue, May 10, 2022 at 8:29 PM Sorkin, John wrote: > I am using the by function to run the acf function. Each run of the by > function returns more information than I want. All I want is th

Re: [R] struccchange on zoo time series

2022-05-01 Thread Eric Berger
Hi Achim, My point was that tsbox (apparently) provides tools to convert zoo --> ts which should help the OP. On Sun, May 1, 2022 at 5:56 PM Achim Zeileis wrote: > > On Sun, 1 May 2022, Eric Berger wrote: > > > Hi Naresh, > > The tsbox package on CRAN - > >

Re: [R] Confusing fori or ifelse result in matrix manipulation

2022-04-25 Thread Eric Berger
M[,x==1] is not the same as M[,x] :-) However, M[,!!x] is the same as M[,x==1] and saves one character! The point of this is "I can name that tune in ... " (as if that was not obvious) On Mon, Apr 25, 2022 at 5:30 PM Bert Gunter wrote: > x == 1 is the same as M[, x] so your expression is the s

Re: [R] Looping through all matrix columns each 1 row at a time

2022-04-21 Thread Eric Berger
1 1 [5,]265126236 4 3 2 apply(m,MAR=1,function(v) length(setdiff(1:6,v))==0) [1] FALSE FALSE FALSE FALSE TRUE ## only the last row has all numbers from 1-6 HTH, Eric On Thu, Apr 21, 2022 at 7:55 AM Paul Bernal wrote: > > Dear

Re: [R] Max-Diff Package

2022-04-13 Thread Eric Berger
I have no experience with this but a Google search came up with CRAN support.BWS See https://cran.r-project.org/web/packages/support.BWS/index.html On Wed, Apr 13, 2022 at 4:37 PM Dr Cazhaow Qazaz wrote: > Hi All, > > Any recommendations for a R package to perform MaxDiff analysis? > > Thank y

Re: [R] Multiplying each row of data.frame by a row in another data.frame

2022-04-09 Thread Eric Berger
[5,] 10 10 500 > t(apply(as.matrix(val_df),MAR=1,function(v) v * weights$value)) HTH, Eric On Sat, Apr 9, 2022 at 7:57 AM maithili_shiva--- via R-help wrote: > > Dear R forum > weights <- data.frame(id = c("ABC", "DEF", "ONS"), value = c(1, 2, 5)) &

  1   2   3   4   5   6   7   8   9   10   >