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

2023-04-12 Thread Bert Gunter
I always find regex puzzles amusing, so after changing the unicode typo quotes and dashes to ascii, the following simple prescription, similar to those proffered by others, seems to produce what you requested with your example: x <- c("leucocyten + gramnegatieve staven +++ grampositieve staven

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

2023-04-12 Thread avi.e.gross
Sometimes you need to NOT use a regular expression and do things simpler. You have a fairly simple example that not only does not need great power but may be a pain to do using a very powerful technique, especially if you want to play with look-ahead and look behind. Assuming you have a line

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

2023-04-12 Thread David Winsemius
I thought replacing the spaces following instances of +++,++,+,- with "\n" and then reading with scan should succeed. Like Ivan Krylov I was fairly sure that you meant the minus sign to be "-" rather than "–", but perhaps your were using MS Word as an editor which is inconsistent with effective

Re: [R] converting a character matrix into numeric....

2023-04-12 Thread akshay kulkarni
Dear Jeff, Regrets for not trying that before...never knew that % was the culprit...! THanking you, Yours sincerely, AKSHAY M KULKARNI From: Jeff Newmiller Sent: Thursday, April 13, 2023 1:08 AM To: r-help@r-project.org ; akshay kulkarni ; Rui

Re: [R] converting a character matrix into numeric....

2023-04-12 Thread Jeff Newmiller
Isn't this like trying to tie up the horse after it has left the barn? Why not figure all this out _before_ converting to xts? On April 12, 2023 12:29:49 PM PDT, akshay kulkarni wrote: >Dear Rui, > Not working. I have entirely removed the column containing % > but am still

Re: [R] converting a character matrix into numeric....

2023-04-12 Thread akshay kulkarni
Dear Rui, Not working. I have entirely removed the column containing % but am still bootless: > head(coredata(INFYTX)) INFY Historical Data INFY Historical Data INFY Historical Data INFY Historical Data [1,] "47.26" "44.28" "47.56"

Re: [R] converting a character matrix into numeric....

2023-04-12 Thread Rui Barradas
Às 19:57 de 12/04/2023, akshay kulkarni escreveu: Dear members, I have an xts object: head(INFYTX) INFY Historical Data INFY Historical Data.1 INFY Historical Data.2 2003-04-16 "47.26" "44.28""47.56" 2003-04-17 "46.30"

[R] converting a character matrix into numeric....

2023-04-12 Thread akshay kulkarni
Dear members, I have an xts object: > head(INFYTX) INFY Historical Data INFY Historical Data.1 INFY Historical Data.2 2003-04-16 "47.26" "44.28""47.56" 2003-04-17 "46.30" "44.92""46.53" 2003-04-21

Re: [R] R-error

2023-04-12 Thread Ivan Krylov
On Wed, 12 Apr 2023 16:04:55 +0800 (GMT+08:00) "Dezhi Wang" wrote: > I run R 4.2.2 on CentOS-7.6. Thank you for this useful information. Could you tell us how this build of R was installed on this machine? > > install.packages('sf') > --- Please select a CRAN mirror for use in this session

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

2023-04-12 Thread Ivan Krylov
On Wed, 12 Apr 2023 08:29:50 + Emily Bakker wrote: > Some example data: > “leucocyten + gramnegatieve staven +++ grampositieve staven ++” > “leucocyten – grampositieve coccen +” >   > I want to split the strings such that I get the following result: > c(“leucocyten +”,  “gramnegatieve staven

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

2023-04-12 Thread akshay kulkarni
Hi Eric, THanks a lot.. Thanking you, Yours sincerely, AKSHAY M KULKARNI From: Eric Berger Sent: Wednesday, April 12, 2023 8:20 PM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] converting to date object... lubridate::dmy("12 APR

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

2023-04-12 Thread akshay kulkarni
Hi Mark, Thanks a lot... Thanking you, Yours sincerely, AKSHAY M KULKARNI From: Marc Schwartz Sent: Wednesday, April 12, 2023 8:33 PM To: akshay kulkarni ; R help Mailing list Subject: Re: [R] converting to date object... Hi, You do not need

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

2023-04-12 Thread akshay kulkarni
Dear Dirk, Thaks a lot... THanking you, Yours sincerely, AKSHAY M KULKARNI From: Dirk Eddelbuettel Sent: Wednesday, April 12, 2023 8:38 PM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] converting to date object... That is

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

2023-04-12 Thread Eric Berger
This seems to do the job but there are probably more elegant solutions: f <- function(s) { sub("^ ","",unlist(strsplit(gsub("\\+ ","+@ ",s),"@"))) } g <- function(s) { sub("^ ","",unlist(strsplit(gsub("- ","-@ ",s),"@"))) } h <- function(s) { g(f(s)) } To try it out: s <- “leucocyten +

[R] Split String in regex while Keeping Delimiter

2023-04-12 Thread Emily Bakker
Hello List,   I have a dataset consisting of strings that I want to split while saving the delimiter.   Some example data: “leucocyten + gramnegatieve staven +++ grampositieve staven ++” “leucocyten – grampositieve coccen +”   I want to split the strings such that I get the following result:

[R] R-error

2023-04-12 Thread Dezhi Wang
Hello, I run R 4.2.2 on CentOS-7.6. I install package through install.packages("sf").It threw the above error: > install.packages('sf') --- Please select a CRAN mirror for use in this session --- *** caught segfault *** address 0x60, cause 'memory not mapped' Traceback: 1: download.file(url,

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

2023-04-12 Thread Dirk Eddelbuettel
That is what I wrote the anytime package for: effortless automatic parsing. Also works for dates: > library(anytime) > anydate("12 APR 2023") [1] "2023-04-12" > Dirk -- dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __

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

2023-04-12 Thread Marc Schwartz via R-help
Hi, You do not need to use third party packages for date or date/time objects in R. If you review ?as.Date, you will see that there are two default formats for Date objects that are specified in the 'tryFormats' argument:   tryFormats = c("%Y-%m-%d", "%Y/%m/%d") If your date character vector

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

[R] converting to date object...

2023-04-12 Thread akshay kulkarni
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 message: All formats failed to parse. No formats found. > as_date("12-APR-2023") [1] NA Warning message:

Re: [R] aborting the execution of a script...

2023-04-12 Thread akshay kulkarni
Dear Duncan, But it is entirely different in my case...! As you said, the problem may be with my version of RStudio. The main point is that it doesn't pose any serious problems... Thanks any way for your reply... Thanking you, Yours sincerely, AKSHAY M KULKARNI

Re: [R] aborting the execution of a script...

2023-04-12 Thread Duncan Murdoch
This is what I get: > source("~/temp/test.R", echo = TRUE) > print(1) [1] 1 > stop("here") Error in eval(ei, envir) : here I get similar output in every variation I tried. It never prints the 2. On 12/04/2023 8:13 a.m., akshay kulkarni wrote: Dear Duncan,                          What if

Re: [R] aborting the execution of a script...

2023-04-12 Thread akshay kulkarni
Dear Duncan, What if I use source() with echo? I am using that in RStudio. THanking you, Yours sincerely AKSHAY M KULKARNI From: Duncan Murdoch Sent: Wednesday, April 12, 2023 5:35 PM To: akshay kulkarni ; R help Mailing list Subject:

Re: [R] aborting the execution of a script...

2023-04-12 Thread Duncan Murdoch
On 12/04/2023 7:03 a.m., akshay kulkarni wrote: Dear members, I have a script which I source it interactively. I have the following questions: 1. If there is an error in an expression, an error message is printed, but the execution continues till the end of

[R] aborting the execution of a script...

2023-04-12 Thread akshay kulkarni
Dear members, I have a script which I source it interactively. I have the following questions: 1. If there is an error in an expression, an error message is printed, but the execution continues till the end of the script. I am sourcing with echo. Is there any

[R] [R-pkgs] DNAmixturesLite and KinMixLite

2023-04-12 Thread Peter Green
Dear all, We are pleased to announce that CRAN now hosts our packages DNAmixturesLite and KinMixLite. These are fully R-based versions of our packages DNAmixtures and KinMix, which rely on a commercial software, HUGIN, for performing efficient computations in Bayesian networks. The lite

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

2023-04-12 Thread Iago Giné Vázquez
You may take a look at the bigmemory package or other which deal with large memory data in https://cran.r-project.org/web/views/HighPerformanceComputing.html#large-memory-and-out-of-memory-data Some extra explanation is in https://stackoverflow.com/a/11127229/997979 Iago

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

2023-04-12 Thread Eric Berger
One possibility might be to use Rcpp. An R matrix is stored in contiguous memory, which can be considered as a vector. Define a C++ function which operates on a vector in place, as in the following: library(Rcpp) cppFunction( 'void subtractConst(NumericVector x, double c) { for ( int i = 0; i