Re: [R] Minimal match to regexp?

2023-01-25 Thread Andrew Simmons
It seems like a bug to me. Using perl = TRUE, I see the desired result: ``` x <- "\n```html\nblah blah \n```\n\n```r\nblah blah\n```\n" pattern2 <- "\n([`]{3,})html\n.*?\n\\1\n" cat(regmatches(x, regexpr(pattern2, x, perl = TRUE))) ``` If you change it to something like: ``` x <- c(

Re: [R] Minimal match to regexp?

2023-01-25 Thread Duncan Murdoch
Thanks for pointing out my mistake. I oversimplified the real problem. I'll try to post a version of it that comes closer: Suppose I have a string like this: x <- "\n```html\nblah blah \n```\n\n```r\nblah blah\n```\n" If I cat() it, I see that it is really markdown source: ```html

Re: [R] Minimal match to regexp?

2023-01-25 Thread Jeff Newmiller
Perhaps sub( "^.*(a.*?a).*$", "\\1", x ) On January 25, 2023 4:19:01 PM PST, Duncan Murdoch wrote: >The docs for ?regexp say this: "By default repetition is greedy, so the >maximal possible number of repeats is used. This can be changed to ‘minimal’ >by appending ? to the quantifier.

Re: [R] Minimal match to regexp?

2023-01-25 Thread Duncan Murdoch
On 25/01/2023 7:19 p.m., Duncan Murdoch wrote: The docs for ?regexp say this: "By default repetition is greedy, so the maximal possible number of repeats is used. This can be changed to ‘minimal’ by appending ? to the quantifier. (There are further quantifiers that allow approximate matching:

Re: [R] Minimal match to regexp?

2023-01-25 Thread Andrew Simmons
grep(value = TRUE) just returns the strings which match the pattern. You have to use regexpr() or gregexpr() if you want to know where the matches are: ``` x <- "abaca" # extract only the first match with regexpr() m <- regexpr("a.*?a", x) regmatches(x, m) # or # extract every match with

[R] Minimal match to regexp?

2023-01-25 Thread Duncan Murdoch
The docs for ?regexp say this: "By default repetition is greedy, so the maximal possible number of repeats is used. This can be changed to ‘minimal’ by appending ? to the quantifier. (There are further quantifiers that allow approximate matching: see the TRE documentation.)" I want the

Re: [R] as.factor and floating point numbers

2023-01-25 Thread Tobias Fellinger
Hello, I'll reply in one mail to all. Thank you for your suggestions. I already tried Andrews solution with increasing the digits. In the most extreme case I encountered I had to take the maximum possible digits in format but it worked. Tims solution is also a good workaround but in this

Re: [R] as.factor and floating point numbers

2023-01-25 Thread Valentin Petzel
Hello Tobias, A factor is basically a way to get a character to behave like an integer. It consists of an integer with values from 1 to nlev, and a character vector levels, specifying for each value a level name. But this means that factors only really make sense with characters, and anything

Re: [R] Shadow Graphics Error in R Studio

2023-01-25 Thread Duncan Murdoch
On 24/01/2023 2:35 p.m., Brinkley Norton wrote: Good afternoon! I'm new to R Studio and am encountering a plotting issue. I'm currently using version 4.2.2 on a Mac OSX. RStudio has been deleted and re-downloaded (as per the help pages) yet I am still encountering the same error. The plot

Re: [R] Shadow Graphics Error in R Studio

2023-01-25 Thread Jeff Newmiller
If the problem goes away in R but persists in RStudio, then most likely you will need to ask in a forum where RStudio experts hang out, like the RStudio community forum website. On January 24, 2023 11:35:52 AM PST, Brinkley Norton wrote: >Good afternoon! > >I'm new to R Studio and am

Re: [R] Plotmath isn't working for special characters

2023-01-25 Thread Uwe Ligges
Yes, and is is fixed in R-4.2.2-pacthed for soe time already. Best, Uwe Ligges On 25.01.2023 15:48, Shawn Way wrote: I see the same thing using 4.2.2 on Windows 10. Thank you kindly, Shawn Way, PE   Director of Engineering Phone: (832) 403-0414 Empower Pharmacy   Expanding Access.

[R] Shadow Graphics Error in R Studio

2023-01-25 Thread Brinkley Norton
Good afternoon! I'm new to R Studio and am encountering a plotting issue. I'm currently using version 4.2.2 on a Mac OSX. RStudio has been deleted and re-downloaded (as per the help pages) yet I am still encountering the same error. The plot works in R but not in R Studio. Here is the code:

Re: [R] Plotmath isn't working for special characters

2023-01-25 Thread Shawn Way
I see the same thing using 4.2.2 on Windows 10. Thank you kindly, Shawn Way, PE   Director of Engineering Phone: (832) 403-0414 Empower Pharmacy   Expanding Access.    -Original Message- From: R-help On Behalf Of David Stevens Sent: Wednesday, January 25, 2023 8:34 AM To: Bert

Re: [R] Plotmath isn't working for special characters

2023-01-25 Thread David Stevens
A more extensive test (no=produced an empty box on the plot, yes=produced the intended plotmath result). It appears that plotmath is not producing the special math characters. Greek symbols are produced. I'll try to reinstall R and report back. David plot(1,1, main = parse(text = "x >= y")) -

Re: [R] Plotmath isn't working for special characters

2023-01-25 Thread Rui Barradas
Às 12:36 de 25/01/2023, Rui Barradas escreveu: Às 21:53 de 24/01/2023, Spencer Graves escreveu: On 1/24/23 3:33 PM, David Stevens wrote: Simple expressions on plots, such as parse(text='x >= y') have been resulting in just a placeholder box (x box y and not the symbol) in my R plot labels in

Re: [R] Plotmath isn't working for special characters

2023-01-25 Thread Rui Barradas
Às 21:53 de 24/01/2023, Spencer Graves escreveu: On 1/24/23 3:33 PM, David Stevens wrote: Simple expressions on plots, such as parse(text='x >= y') have been resulting in just a placeholder box (x box y and not the symbol) in my R plot labels in windows, R v 4.2.2. I haven't down an

Re: [R] as.factor and floating point numbers

2023-01-25 Thread Ebert,Timothy Aaron
Another option is to convert all times to base units or the sample rate from the analog-to-digital converter. If this is 100 milliseconds then use milliseconds rather than fractions of an hour or day. This approach might not help if the range in values spans more than 16 digits: slightly finer

Re: [R] as.factor and floating point numbers

2023-01-25 Thread Andrew Simmons
R converts floats to strings with ~15 digits of accuracy, specifically to avoid differentiating between 1 and 1 + .Machine$double.eps, it is assumed that small differences such as this are due to rounding errors and are unimportant. So, if when making your factor, you want all digits, you could

[R] as.factor and floating point numbers

2023-01-25 Thread Tobias Fellinger
Hello, I'm encountering the following error: In a package for survival analysis I use a data.frame is created, one column is created by applying unique on the event times while others are created by running table on the event times and the treatment arm. When there are event times very close