table(data.o$Var.1[1:6]) #scheme 3
>> >
>> > A B C D
>> > 2 1 2 1
>> >
>> > > table(data.o$Var.1[1:7]) # scheme1
>> > A B C D
>> > 2 1 2 2
>> >
>> > > table(data.o$Var.1[1:8]) # no such scheme, so scheme 1 is chos
Var.1[1:8]) # no such scheme, so scheme 1 is chosen one
> > A B C D
> > 2 1 2 3
> >
> > #Now you need to select values based on scheme 1.
> > # 3A - 3B - 2C - 2D
> >
> > sss <- split(Order, Order$Var.1)
> > selection <- c(3,3,2,2)
> > re
on scheme 1.
> # 3A - 3B - 2C - 2D
>
> sss <- split(Order, Order$Var.1)
> selection <- c(3,3,2,2)
> result <- vector("list", 4)
>
> #I would use loop
>
> for(i in 1:4) {
> result[[i]] <- sss[[i]][1:selection[i],]
> }
>
> Maybe someone com
ult[[i]] <- sss[[i]][1:selection[i],]
}
Maybe someone come with other ingenious solution.
Cheers
Petr
From: Silvano Cesar da Costa
Sent: Monday, August 23, 2021 7:54 PM
To: PIKAL Petr
Cc: r-help@r-project.org
Subject: Re: [R] Selecting elements
Hi,
I apologize for the confusion. I will t
gt; $D
> [1] 39 77 114 141 166 189 209 223 229 232
>
> Highest value is in D so either 3A - 3B - 2C - 2D or 3A - 3B - 2C - 2D
> should be appropriate. And here I am again lost as both sets are same.
> Maybe you need to reconsider your statements.
>
> Cheers
> Petr
>
>
alue is in D so either 3A - 3B - 2C - 2D or 3A - 3B - 2C - 2D should
be appropriate. And here I am again lost as both sets are same. Maybe you need
to reconsider your statements.
Cheers
Petr
From: Silvano Cesar da Costa
Sent: Friday, August 20, 2021 9:28 PM
To: PIKAL Petr
Cc: r-help@r-project.
t; [1] 39 28 25 23 16 15 7 6 5 4
>>
>> $C
>> [1] 40 36 29 26 21 19 18 14 10 9
>>
>> $D
>> [1] 37 34 33 27 24 20 17 13 12 3
>>
>> T inspect highest values. But here I am lost. As C is first and fourth
>> biggest value, you follow third
nal Message-
> > From: R-help On Behalf Of Silvano Cesar
> da
> > Costa
> > Sent: Thursday, August 19, 2021 10:40 PM
> > To: r-help@r-project.org
> > Subject: [R] Selecting elements
> >
> > Hi,
> >
> > I need to select 15 elements, always
ighest A, 3B 2C and 2D?
>
>Or I do not understand at all what you really want to achieve.
>
>Cheers
>Petr
>
>> -Original Message-
>> From: R-help On Behalf Of Silvano Cesar da
>> Costa
>> Sent: Thursday, August 19, 2021 10:40 PM
>> To: r-help@r-
2021 10:40 PM
> To: r-help@r-project.org
> Subject: [R] Selecting elements
>
> Hi,
>
> I need to select 15 elements, always considering the highest values
> (descending order) but obeying the following configuration:
>
> 3A - 4B - 0C - 3D or
> 2A - 5B - 0C - 3D or
>
Hi,
I need to select 15 elements, always considering the highest values
(descending order) but obeying the following configuration:
3A - 4B - 0C - 3D or
2A - 5B - 0C - 3D or
3A - 3B - 2C - 2D
If I have, for example, 5 A elements as the highest values, I can only
choose 3 (first and third choice)
On Feb 4, 2014, at 11:54 AM, Francesca Pancotto wrote:
> Hello A. k.
> thanks for the suggestion.
>
> I tried this but it does not work. I probably use it in the wrong way.
> This is what it tells me,
>
>
> do.call(rbind,lapply(bank.list,function(x) x[x[,"p_made"]==406,]))
>
> Errore in mat
On 02/05/2014 06:54 AM, Francesca Pancotto wrote:
Hello A. k.
thanks for the suggestion.
I tried this but it does not work. I probably use it in the wrong way.
This is what it tells me,
do.call(rbind,lapply(bank.list,function(x) x[x[,"p_made"]==406,]))
Errore in match.names(clabs, names(xi)
Hi,
Looks like the colnames of list elements are not the same.
For e.g.
lst1 <- list(structure(list(bankname = structure(c(1L, 1L, 1L, 1L, 1L,
1L), .Label = "CIB", class = "factor"), date = structure(c(1L,
2L, 3L, 1L, 2L, 3L), .Label = c("10/02/06", "10/23/06", "11/22/06"
), class = "factor"), px
Hello A. k.
thanks for the suggestion.
I tried this but it does not work. I probably use it in the wrong way.
This is what it tells me,
do.call(rbind,lapply(bank.list,function(x) x[x[,"p_made"]==406,]))
Errore in match.names(clabs, names(xi)) :
names do not match previous names
What am I
Hi,
Try:
If `lst1` is the list:
do.call(rbind,lapply(lst1,function(x) x[x[,"p_made"]==406,]))
A.K.
On Tuesday, February 4, 2014 8:53 AM, Francesca
wrote:
Dear Contributors
sorry but the message was sent involuntary.
I am asking some advice on how to solve the following problem.
I have a list
Dear Contributors
sorry but the message was sent involuntary.
I am asking some advice on how to solve the following problem.
I have a list composed of 78 elements, each of which is a matrix of factors
and numbers, similar to the following
bank_name date px_last_CIB Q.Yp_made p_for
1
Dear Contributors
I am asking some advice on how to solve the following problem.
I have a list composed of 78 elements, each of which is a matrix of factors
and numbers, similar to the following
bank_name date px_last_CIB Q.Yp_made p_for
1 CIB 10/02/061.33 p406-q40640
Yes the lapply function sorted it out. Thanks for the advice.
--
View this message in context:
http://r.789695.n4.nabble.com/Selecting-elements-from-all-items-in-a-list-tp4387045p4387505.html
Sent from the R help mailing list archive at Nabble.com.
__
On Feb 14, 2012, at 8:44 AM, geotheory wrote:
Basic question (if you know the answer)... I am dealing with a list
of
commonly-formatted sub-lists, for example:
l <- list("")
l[[1]] <- c("A1","A2","A3")
l[[2]] <- c("B1","B2","B3")
l[[3]] <- c("C1","B2","B3")
Lets say I need to extract every
How about:
l <- list("")
l[[1]] <- c("A1","A2","A3")
l[[2]] <- c("B1","B2","B3")
l[[3]] <- c("C1","B2","B3")
lapply(l, "[[", 2)
or
sapply(l, "[[", 2)
I hope it helps.
Best,
Dimitris
On 2/14/2012 2:44 PM, geotheory wrote:
Basic question (if you know the answer)... I am dealing with a li
Basic question (if you know the answer)... I am dealing with a list of
commonly-formatted sub-lists, for example:
l <- list("")
l[[1]] <- c("A1","A2","A3")
l[[2]] <- c("B1","B2","B3")
l[[3]] <- c("C1","B2","B3")
Lets say I need to extract every 2nd item (i.e. A2, B2, C2). [[]] cannot be
used.
Try this:
!list %in% c("aa", "bb")
On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote:
> Hi everybody,
>
> I have the following problem. I have a vector containing character
> elements,
> such as:
>
> list = c("aa","bb","cc","dd","ee")
>
> I want to create an index which identifies the element
it works!
thank you so much
Mario
On Fri, Jan 14, 2011 at 1:29 PM, Henrique Dallazuanna wrote:
> Try this:
>
> !list %in% c("aa", "bb")
>
> On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote:
>
>> Hi everybody,
>>
>> I have the following problem. I have a vector containing character
>> element
Try this:
!list %in% c("aa", "bb")
On Fri, Jan 14, 2011 at 10:19 AM, A M Lavezzi wrote:
> Hi everybody,
>
> I have the following problem. I have a vector containing character
> elements,
> such as:
>
> list = c("aa","bb","cc","dd","ee")
>
> I want to create an index which identifies the element
Hi everybody,
I have the following problem. I have a vector containing character elements,
such as:
list = c("aa","bb","cc","dd","ee")
I want to create an index which identifies the elements that are different
from, e.g. "aa" and "bb".
When I do the following:
jj = list!="aa" & list!="bb"
> j
aa[order(aa)] is the same as sort, although sort is much quicker and
has lower memory requirements:
> aa <- rnorm(1000)
> all(aa[order(aa)] == sort(aa))
[1] TRUE
> system.time(sort(aa))
user system elapsed
7.270.088.25
> system.time(aa[order(aa)])
user system elapsed
29.58
Yes Johannes - That helped, thank you.
On Sat, Mar 28, 2009 at 11:50 PM, Johannes Huesing wrote:
> Tal Galili [Sat, Mar 28, 2009 at 06:48:36PM CET]:
> > Hello people.
> >
> > I wish to reorder a simple vector of numbers by another vector of the
> order
> > (and then do the same, but with a da
Tal Galili [Sat, Mar 28, 2009 at 06:48:36PM CET]:
> Hello people.
>
> I wish to reorder a simple vector of numbers by another vector of the order
> (and then do the same, but with a data frame rows)
>
> I try this (which doesn't work) :
> > aa <- c(3, 1 ,2 )
> > aa[aa]
> [1] 2 3 1
To my mind, i
Thanks Jorge ,
I mistakingly (and foolishly) confused a vector of ranking, to a vector of
ordering that ranked vector...
Patrick Burns explained to me that I was looking for:
aa[order(aa)]
df[order(df[,1]), ]
Sorry,
Tal
On Sat, Mar 28, 2009 at 9:08 PM, Jorge Ivan Velez
wrote:
>
> Dear Tal,
Dear Tal,
It works as it should. In this code:
# Data
aa <- c(3, 1 ,2 )
aa
[1] 3 1 2
aa[aa]
[1] 2 3 1
you are telling R to do the following: take the vector aa and select the
elements aa (in R language that is aa[aa]). If you look carefully, the third
element of aa is 2, the first is 3 and the
Thanks Patrick,
Sorry to have missed that!
Tal
On Sat, Mar 28, 2009 at 9:01 PM, Patrick Burns wrote:
> I presume you are looking for:
>
> aa[order(aa)]
>
> and
>
> df[order(df[,1]), ]
>
>
> Patrick Burns
> patr...@burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of
> I wish to reorder a simple vector of numbers by another vector of the order
> (and then do the same, but with a data frame rows)
>
> I try this (which doesn't work) :
> > aa <- c(3, 1 ,2 )
> > aa[aa]
> [1] 2 3 1
>
> The same won't work if I try to order a data frame:
> > data.frame(matrix(c(3,1
Hello people.
I wish to reorder a simple vector of numbers by another vector of the order
(and then do the same, but with a data frame rows)
I try this (which doesn't work) :
> aa <- c(3, 1 ,2 )
> aa[aa]
[1] 2 3 1
The same won't work if I try to order a data frame:
> data.frame(matrix(c(3,1,2),
Thanks - that is exactly what I was looking for
Rainer
On Fri, Mar 14, 2008 at 1:10 PM, Henrique Dallazuanna <[EMAIL PROTECTED]> wrote:
> Try this:
>
> x[x %in% y]
>
>
>
> On 14/03/2008, Rainer M Krug <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> > Consider the following code
> >
> > > x <- re
Use %in%:
x [ x %in% y ]
G.
On Fri, Mar 14, 2008 at 12:37:45PM +0200, Rainer M Krug wrote:
> Hi
>
> Consider the following code
>
> > x <- rep(1:13, 13)
>
> > y <- 1:3
>
> I want to select all elements in x which are equal to 1, 2 or 3.
>
> I know that I could use
>
> > sel <- x==y[1] | x=
Try this:
x[x %in% y]
On 14/03/2008, Rainer M Krug <[EMAIL PROTECTED]> wrote:
> Hi
>
> Consider the following code
>
> > x <- rep(1:13, 13)
>
> > y <- 1:3
>
> I want to select all elements in x which are equal to 1, 2 or 3.
>
> I know that I could use
>
> > sel <- x==y[1] | x==y[2] | x==y[3
Hi
Consider the following code
> x <- rep(1:13, 13)
> y <- 1:3
I want to select all elements in x which are equal to 1, 2 or 3.
I know that I could use
> sel <- x==y[1] | x==y[2] | x==y[3]
> x[sel]
to obtain the values, but in my analysis, the y-vector is thousands of
elements long.
Is ther
38 matches
Mail list logo