Re: [R] Matching backslash in a table's column using R language

2020-08-25 Thread Peter Bishop
To be honest, I've only used the hex values as that was the format in which the patterns were passed to me. However from your explanation, I now understand what's going on. I didn't appreciate that the characters were passed to another layer and not seeing the hex code as the raw backslash.

Re: [R] Matching backslash in a table's column using R language

2020-08-25 Thread Jeff Newmiller
In my opinion, using hexadecimal ASCII is much more obscure than simply using the escape character properly... that is, you are doing no-one any favors by using them. But to attain clarity here, you need to envision what the various software layers are doing. In your case, SQLServer may not uti

Re: [R] Matching backslash in a table's column using R language

2020-08-25 Thread Peter Bishop
The feed is coming from a SQL table and this is using the embedded support for R which comes with SQL 2016. The source is therefore a SELECT statement. As an aside, I found a workaround by changing the pattern from: "[\x22\x27\x2c\x3f\x5c\x60]" to: "[\x22\x27\x2c\x3f\x5c\x5c\x60]" This s

Re: [R] Matching backslash in a table's column using R language

2020-08-25 Thread Bert Gunter
1. I am far from an expert on such matters 2. It is unclear to me what your input is -- I assume a file. The problem, as you indicate, is that R's parser sees "\B" as an incorrect escape character, so, for example: > cat("\B") Error: '\B' is an unrecognized escape in character string starting ""\B

Re: [R] How to obtain individual log-likelihood value from glm?

2020-08-25 Thread peter dalgaard
If you don't worry too much about an additive constant, then half the negative squared deviance residuals should do. (Not quite sure how weights factor in. Looks like they are accounted for.) -pd > On 25 Aug 2020, at 17:33 , John Smith wrote: > > Dear R-help, > > The function logLik can be u

Re: [R] How to obtain individual log-likelihood value from glm?

2020-08-25 Thread Bert Gunter
If you look at stats:::logLik.glm #3 ":" because it's unexported, as is true of most methods it should be obvious. Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County"

[R] Matching backslash in a table's column using R language

2020-08-25 Thread Peter Bishop
In SQL, I'm using R as a way to filter data based on: - 20 characters in the range to - excluding , , , , , Given a SQL column containing the data: code A\BCDEFG and the T-SQL script: EXEC [sys].[sp_execute_external_script] @language=N'R',

[R] How to obtain individual log-likelihood value from glm?

2020-08-25 Thread John Smith
Dear R-help, The function logLik can be used to obtain the maximum log-likelihood value from a glm object. This is an aggregated value, a summation of individual log-likelihood values. How do I obtain individual values? In the following example, I would expect 9 numbers since the response has leng

Re: [R] Classification Tree Prediction Error

2020-08-25 Thread John Smith
As Bert advised correctly, this is not an R programming question. There is some misunderstanding on how training//test data work together in predictions. Suppose your test data has only one class. Therefore, you can get the following rate by betting on the majority class every time, again using dat

Re: [R] Classification Tree Prediction Error

2020-08-25 Thread Xu Jun
Thank you for your comment! This tree function is from the tree package. Although it might be a pure statistical question, it could be related to how the tree function is used. I will explore the site that you suggested. But if there is anyone who can figure it out off the top of their head, I'd ve

Re: [R] which.min, equal values and fractions

2020-08-25 Thread Ivan Krylov
On Tue, 25 Aug 2020 14:26:43 +0200 Mike wrote: > But which.min only does so if the values don't contain fractions. > And I get > > > identical (data3ba, c(2.9,2.9)) > [1] FALSE > > Why is which.min not always returning 1 but which.max does? It's the unfortunate consequence of the way floatin

[R] which.min, equal values and fractions

2020-08-25 Thread Mike
Hi, According to ?which.min it returns the "index of the (first) minimum". So I would expect it to also return the first minimum when providing two identical extrema. But my minimal reproducible doesn't do so: data1a <- c(3.2,4.2) data1b <- c(3.1,4.1) data2a <- c(0.2,1.2) data2b <- c(4.2,5.2) d

Re: [R] ggplot 3-color gradient scales

2020-08-25 Thread Rui Barradas
Hello, If you want a predetermined number of colors, discretise the data and use scale_color_manual. In the code below I first compute another vector z, with a different range, 0 to 2. (In my first mail it was 0 to 1.) g <- function(x, a = 0, b = 1){ (b - a)*(x - min(x))/(max(x) - min(x)) +

Re: [R] ggplot 3-color gradient scales

2020-08-25 Thread PIKAL Petr
Hi Maybe scale_colour_manual? Cheers Petr > -Original Message- > From: R-help On Behalf Of April Ettington > Sent: Tuesday, August 25, 2020 11:39 AM > To: Rui Barradas > Cc: r-help@r-project.org > Subject: Re: [R] ggplot 3-color gradient scales > > Is there a way to set it to 3 color c

Re: [R] ggplot 3-color gradient scales

2020-08-25 Thread April Ettington
Is there a way to set it to 3 color categories instead of a gradient? Like if the color is based on the numbers in a dataframe column, can I make it so anything >1.2 is red, <0.8 is blue, and anything in the middle is green? On Mon, Aug 24, 2020 at 6:28 PM April Ettington wrote: > Thank you so

Re: [R] incompatible dimensions error

2020-08-25 Thread Jeff King
Hi, It seems like the package "mvpart" is quite outdated and not available for the current R release. Since PCA is a very common need I'll suggest finding a replacement for it so that the error will either go away, or it is easier for us to reproduce it. Best, Jiefei On Tue, Aug 25, 2020 at 1:06