Re: [R] combine filter() and select()

2020-08-19 Thread Ivan Calandra
Hi Jeff, The code you show is exactly what I usually do, in base R; but I wanted to play with tidyverse to learn it (and also understand when it makes sense and when it doesn't). And yes, of course, in the example I gave, I end up with a 1-cell tibble, which could be better extracted as a length-

Re: [R] combine filter() and select()

2020-08-19 Thread Ivan Calandra
Dear Chris, I didn't think about having the assignment at the end as you showed; it indeed fits the pipe workflow better. By "easy", I actually meant shorter. As you said, in base R, I usually do that in 1 line, so I was hoping to do the same in tidyverse. But I'm glad to hear that I'm using tidy

Re: [R] & and |

2020-08-19 Thread Ivan Calandra
Thank you all for all the very helpful answers! Best, Ivan -- Dr. Ivan Calandra TraCEr, laboratory for Traceology and Controlled Experiments MONREPOS Archaeological Research Centre and Museum for Human Behavioural Evolution Schloss Monrepos 56567 Neuwied, Germany +49 (0) 2631 9772-243 https://www

Re: [R] & and |

2020-08-19 Thread Richard O'Keefe
There are & and | operators in the R language. There is an | operator in regular expressions. There is NOT any & operator in regular expressions. grep("ConfoMap&GuineaPigs", mydata, value=TRUE) looks for elements of mydata containing the literal string 'ConfoMap&GuineaPigs'. > foo <- c("a","b","ca

Re: [R] Trouble getting labels for bars in Pareto Chart

2020-08-19 Thread Jim Lemon
Hi Paul, I ran this: library(qcc) pareto.chart(dataset2$Points) and like you, got the chart. As you have 140 long labels, I thought at first it might be the function trying to abbreviate some of them and actually displaying about 1 in 5. Looking at the code for the function, this is not the case.

Re: [R] Trouble getting labels for bars in Pareto Chart

2020-08-19 Thread Rasmus Liland
Dear Paul, I answer inline: On 2020-08-19 16:27 -0500, Paul Bernal wrote: | | I tried using the function | pareto.chart from the qcc package, but | the names of the columns in the pareto | chart are some codes What codes? Can you please elaborate on this? | that do not match the school n

Re: [R] & and |

2020-08-19 Thread Rasmus Liland
On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra wrote: | | I have the following vector: | mydata <- | c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv", | "SSFA-ConfoMap_Lithics_NMPfilled.csv", | "SSFA-ConfoMap_Sheeps_NMPfilled.csv", | "SSFA-Toothfrax_GuineaPigs.xlsx", |

[R] Trouble getting labels for bars in Pareto Chart

2020-08-19 Thread Paul Bernal
Dear friends, Hope you are doing well. I am currently using R version 3.6.2. I installed and loaded package qcc by Mr. Luca Scrucca. This is the structure of my data: str(dataset2) 'data.frame': 140 obs. of 2 variables: $ School: Factor w/ 140 levels "24 de Diciembre",..: 39 29 66 16 67 116

Re: [R] combine filter() and select()

2020-08-19 Thread Jeff Newmiller
The whole point of dplyr primitives is to support data frames... that is, lists of columns. When you pare your data frame down to one column you are almost certainly using the wrong tool for the job. So, sure, your code works... and it even does what you wanted in the dplyr style, but what a po

Re: [R] combine filter() and select()

2020-08-19 Thread Chris Evans
Inline - Original Message - > From: "Ivan Calandra" > To: "R-help" > Sent: Wednesday, 19 August, 2020 16:56:32 > Subject: [R] combine filter() and select() > Dear useRs, > > I'm new to the tidyverse world and I need some help on basic things. > > I have the following tibble: > mytbl <

Re: [R] & and |

2020-08-19 Thread William Dunlap via R-help
Instead of intersect you could use grepl(pattern1,x) & grepl(pattern2,x). Use which() on the result if you must have integers, but the logicals that grepl() produces are often easier to use as subscripts. Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Aug 19, 2020 at 8:54 AM Ivan Calandra

Re: [R] & and |

2020-08-19 Thread Henrik Bengtsson
A version of Eric's answer is to use grepl(), which returns a logical vector: mydata[grepl("ConfoMap", mydata) & grepl("GuineaPigs", mydata)] with the OR analogue: mydata[grepl("ConfoMap", mydata) | grepl("GuineaPigs", mydata)] /Henrik On Wed, Aug 19, 2020 at 8:24 AM Ivan Calandra wrote: > >

Re: [R] & and |

2020-08-19 Thread Ivan Calandra
Indeed! I was just hoping that there would be a shorter way... intersect() is a nice alternative too. Maybe I can make it work with pipes so that I don't have to repeat "mydata" but that's another story. Thank you for the help! Ivan -- Dr. Ivan Calandra TraCEr, laboratory for Traceology and Contr

Re: [R] & and |

2020-08-19 Thread Bert Gunter
Well... wouldn't it be: rep("(ConfoMap.*GuineaPigs)|(GuineaPigs.*ConfoMap)", mydata, value=TRUE) 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" comic strip ) On Wed, Aug 19, 2

Re: [R] & and |

2020-08-19 Thread Ivan Calandra
Thank you Bert for the pointer. So I guess the solution is: grep("ConfoMap.+GuineaPigs", mydata, value=TRUE) This is not the case here, but what if "GuineaPigs" comes before "ConfoMap"? Of course I could do two "grep()" calls, but if there a better solution? Ivan -- Dr. Ivan Calandra TraCEr, la

Re: [R] & and |

2020-08-19 Thread Ivan Calandra
Thank you Eric, I didn't think about intersect(). Now I'm trying to do that in tidyverse with pipes, and I think that's too much for me for now! Ivan -- Dr. Ivan Calandra TraCEr, laboratory for Traceology and Controlled Experiments MONREPOS Archaeological Research Centre and Museum for Human Beh

Re: [R] & and |

2020-08-19 Thread Eric Berger
mydata[ intersect( grep("ConfoMap", mydata), grep("GuineaPigs", mydata) ) ] On Wed, Aug 19, 2020 at 6:13 PM Bert Gunter wrote: > "&" is not a regex metacharacter. > See ?regexp > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things int

Re: [R] & and |

2020-08-19 Thread Bert Gunter
"&" is not a regex metacharacter. See ?regexp 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" comic strip ) On Wed, Aug 19, 2020 at 7:53 AM Ivan Calandra wrote: > Dear useRs,

[R] combine filter() and select()

2020-08-19 Thread Ivan Calandra
Dear useRs, I'm new to the tidyverse world and I need some help on basic things. I have the following tibble: mytbl <- structure(list(files = c("a", "b", "c", "d", "e", "f"), prop = 1:6), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame")) I want to subset the rows with "a" in the

[R] & and |

2020-08-19 Thread Ivan Calandra
Dear useRs, I feel really stupid, but I cannot understand why "&" doesn't work as I expect, while "|" does. I have the following vector: mydata <- c("SSFA-ConfoMap_GuineaPigs_NMPfilled.csv", "SSFA-ConfoMap_Lithics_NMPfilled.csv",  "SSFA-ConfoMap_Sheeps_NMPfilled.csv", "SSFA-Toothfrax_GuineaPigs.x

Re: [R] R Script Modification Questions

2020-08-19 Thread Rasmus Liland
Dear Stephen, I answer inline: On 2020-08-19 12:57 +1000, Jim Lemon wrote: | On Wed, Aug 19, 2020 at 3:09 AM Stephen P. Molnar wrote: | | | | What I would like to do is use | | linetype, rather than color, in line | | 27. You need to specify linetype instead of color in ggplot::aes, like so

Re: [R] Change how minpack.lm:::summary.nls.lm calculates degrees of freedom

2020-08-19 Thread Valerio Leone Sciabolazza
Eric, you are right! If I run the code on a different instance, it works. There must be something in my old R environment that messed this up. Thank you very much for checking this out. Best, Valerio On Wed, Aug 19, 2020 at 11:36 AM Eric Berger wrote: > > Hi Valerio, > I did a copy-paste on your

Re: [R] Change how minpack.lm:::summary.nls.lm calculates degrees of freedom

2020-08-19 Thread Eric Berger
Hi Valerio, I did a copy-paste on your reproducible example and I had no problem with chol(nls.out$hessian). In addition to summary() you can look at str() to display the structure of any R object. > str(nls.out) List of 9 $ par :List of 3 ..$ a: num 8.99 ..$ b: num -1.01 ..$ c: num 6.

[R] Change how minpack.lm:::summary.nls.lm calculates degrees of freedom

2020-08-19 Thread Valerio Leone Sciabolazza
Dear R users, I want to modify how the degrees of freedom are calculated from the summary function of the package minpack.lm My first thought was to replicate how minpack.lm:::summary.nls.lm works, and modify the line of the code that is relevant for my task. However, for some reason I am not able

Re: [R] Binomial PCA Using pcr()

2020-08-19 Thread Ulrik Stervbo via R-help
Hi Prasad, I think this might be a problem with the package, and you can try to contact the package author. The error seem to arise because the pcr() cannot find the 'negative-binomial' distribution ``` library(qualityTools) x <- rnbinom(500, mu = 4, size = 100) pcr(x, distribution = "negat