Re: [R] extract rows based on column value in a data frame

2015-12-02 Thread Ragia Ibrahim
lots of thanks  Ragia > Date: Wed, 2 Dec 2015 14:12:46 -0800 > Subject: Re: [R] extract rows based on column value in a data frame > From: bgunter.4...@gmail.com > To: dwinsem...@comcast.net > CC: ragi...@hotmail.com; r-help@r-project.org > > ... > Perhaps

Re: [R] extract rows based on column value in a data frame

2015-12-02 Thread Bert Gunter
... Perhaps also worth mentioning -- David's solution works even if there are less than 3 rows per group, whereas mine will fail. Cheers, Bert Bert Gunter "Data is not information. Information is not knowledge. And knowledge is certainly not wisdom." -- Clifford Stoll On Wed, Dec 2, 2015 a

Re: [R] extract rows based on column value in a data frame

2015-12-02 Thread Bert Gunter
... or perhaps using rep() to do the indexing directly instead of matching: dfrm[ ave(dfrm$v1, dfrm$v1, FUN = function(x)rep(c(TRUE,FALSE),c(3,length(x)-3))), ] There's probably another 6 dozen ways to do it, especially if you access packages like data.table, plyr, etc. Cheers, Bert Bert Gunte

Re: [R] fill the area outside a polygon

2015-12-02 Thread Michael Sumner
On Wed, 2 Dec 2015 at 23:10 Adrian Dușa wrote: > Dear All, > > I know how to fill a polygon, using a basic R graphics device: > > par(mai=c(0, 0, 0, 0)) > plot(1:100, type="n") > polygon(c(20, 80, 80, 20), c(20, 20, 80, 80), col="lightblue") > > > But let's say I have an outer polygon like this:

Re: [R] fill the area outside a polygon

2015-12-02 Thread Greg Snow
Adrian, Draw the polygon once without the border and the whole in it, then go back and draw the border around the outer polygon without any fill. On Wed, Dec 2, 2015 at 9:31 AM, Adrian Dușa wrote: > On Wed, Dec 2, 2015 at 5:19 PM, David L Carlson wrote: >> >> Using only base graphics, one solut

Re: [R] extract rows based on column value in a data frame

2015-12-02 Thread David Winsemius
> On Dec 2, 2015, at 10:09 AM, Ragia Ibrahim wrote: > > Dear Group, > I have a data frame that such as > > v1 v2v3v4 > 1 1 3 6 > 1 1 5 6 > 1 1 8 0 > 1 2 6 1 > 1 2 4 0 > 1 3 4 4 > 1 3

Re: [R] Error in model.frame.default… variable lengths differ (Without NA's)

2015-12-02 Thread William Dunlap
In your > ordinalmodel <- polr(eduattain ~ dadedu, data = workdataset, weights = > "SPFWT0", Hess = TRUE) take the quotation marks off of SPFWT0. Like the subset argument, weights is a literal expression, evaluated in the context of the data argument, not a character string naming a column in the

Re: [R] Looping through multiple sub elements of a list to compare to multiple components of a vector

2015-12-02 Thread Adams, Jean
First, a couple posting tips. It's helpful to provide some example data people can work with. Also, please post in plain text (not html). If you have a single standard for comparison, you might find an approach like this helpful. # example data mylist <- c("AAEBCC", "AABDCC", "AABBCD") list.2 <

[R] Error in model.frame.default… variable lengths differ (Without NA's)

2015-12-02 Thread Jorge Cimentada
Hello everyone, I'm running an ordinal logistic and I keep getting this error: Error in model.frame.default(formula = eduattain ~ dadedu, data = workdataset, : variable lengths differ (found for '(weights)') I looked at several similar questions on the internet and ended up deleting all the N

Re: [R] Passing variable names in quotes to a function

2015-12-02 Thread phgrosjean
> On 02 Dec 2015, at 16:09, Brant Inman wrote: > > Thank you for your response. Here is the problem that I find with your code > (which I had tried). When you pass a value to the subset argument of the > function, it will not hold the quotes on the subsetting variable’s value. > > For examp

Re: [R] fill the area outside a polygon

2015-12-02 Thread Adrian Dușa
On Wed, Dec 2, 2015 at 5:19 PM, David L Carlson wrote: > > Using only base graphics, one solution would be to embed the inner polygon in the outer one and turn off the border: > > par(mai=c(0, 0, 0, 0)) > plot(1:100, type="n") > polygon(c(0, 100, 100, 0, 0, 20, 80, 80, 20, 20, 0), > c(0, 0, 1

[R] Significance level for glm.cluster

2015-12-02 Thread Lorenz, Jennifer
Hi everyone, I have a question with reference to "glm.cluster" from the package "miceadds" and hope that someone can help me. I am trying to calculate cluster-robust standard errors for a glm-model with multiply imputed datasets. Everything works just fine with glm.cluster but in the end I just

[R] Looping through multiple sub elements of a list to compare to multiple components of a vector

2015-12-02 Thread debra ragland via R-help
I think I am making this problem harder than it has to be and so I keep getting stuck on what might be a trivial problem.  I have used the seqinr package to load a protein sequence alignment containing 15 protein sequences;     > library(seqinr)    > x = read.alignment("proteins.fasta",format="f

Re: [R] fill the area outside a polygon

2015-12-02 Thread David L Carlson
Using only base graphics, one solution would be to embed the inner polygon in the outer one and turn off the border: par(mai=c(0, 0, 0, 0)) plot(1:100, type="n") polygon(c(0, 100, 100, 0, 0, 20, 80, 80, 20, 20, 0), c(0, 0, 100, 100, 0, 20, 20, 80, 80, 20, 0), col="lightblue", border=NA) --

Re: [R] Passing variable names in quotes to a function

2015-12-02 Thread Brant Inman
Thank you for your response. Here is the problem that I find with your code (which I had tried). When you pass a value to the subset argument of the function, it will not hold the quotes on the subsetting variable’s value. For example, if I want the function to do Y[Z==‘skinny’] so that we us

Re: [R] Passing variable names in quotes to a function

2015-12-02 Thread phgrosjean
Your example and explanation are not complete, but I have the gut feeling that you could do all this both more efficiently *and* more R-ish. First of all, why would you pass Y and X separately, to ultimately build the Y ~ X formula within the body of your function? Secondly, it seems to me that

[R] fill the area outside a polygon

2015-12-02 Thread Adrian Dușa
Dear All, I know how to fill a polygon, using a basic R graphics device: par(mai=c(0, 0, 0, 0)) plot(1:100, type="n") polygon(c(20, 80, 80, 20), c(20, 20, 80, 80), col="lightblue") But let's say I have an outer polygon like this: polygon(c(0,100,100,0), c(0,0,100,100)) Is it possible to fill t