Displaying 20 results from an estimated 4000 matches similar to: "Newbie: Combn and scripting"
2007 Jul 27
4
Looping through all possible combinations of cases
Hello!
I have a regular data frame (DATA) with 10 people and 1 column
('variable'). Its cases are people with names ('a', 'b', 'c', 'd',
'e', 'f', etc.). I would like to write a function that would sum up
the values on 'variable' of all possible combinations of people, i.e.
1. I would like to write a loop - in such a way that it
2009 Jan 29
1
Multiple tables
Dear list,
I have a set of 100+ variables. I would like to have one by one crosstables for each variable. I started with
table(variable1, variable2)
table(variable1, variable3)
table(variable1, variable4)
...
table(variable2, variable3)
table(variable2, variable4)
...
It seems rather tedious.
Any better ideas around?
Thanks for any help!
Gerit
--
NUR NOCH BIS 31.01.! GMX FreeDSL -
2006 May 09
1
combn(n, k, ...) and all its re-inventions
It seems people are reinventing the wheel here:
The goal is to generate all combinations of 1:n of size k.
This (typically) results in a matrix of size k * choose(n,k)
i.e. needs O(n ^ k) space, hence is only applicable to
relatively small k.
Then alternatives have been devised to generate the combinations
"one by one", and I think I remember there has been a
quiz/challenge about 20
2009 Mar 20
2
A category reduction problem
I am trying to print out a list of strings of length 11 based on
integers 0 through 10. The rules as given to me for the ordering are:
The first digit must be 0.
The 2nd digit must be 0 or 1.
The 3rd digit must equal the 2nd digit or the 2nd digit +1.
...
Given the final digit, n, all digits 0 through n must appear in a given
sequence.
So the final 1024 item list should look like
0 1 2 3 4 5
2010 Apr 24
2
multiple paired t-tests without loops
I am new to R and I suspect my problem is easily solved, but I haven't
been able to figure it out without using loops. I am trying to
implement Blair & Karniski's (1993) permutation test. I've included a
sample data frame below. This data frame represents the conditional
means (C1, C2) for 3 subjects in 2 consecutive samples of a continuous
data set (e.g. ERP waveform).
2010 Mar 26
2
More efficient alternative to combn()?
Hi,
i am working on a problem where i need to compute the products of all
possible combinations of size m of the elements of a vector. I know that
this can be achieved using the function combn(), e.g.:
> vector <- 1:6
> combn(x = vector, m = 3, FUN = function(y) prod(y))
In my case the vector has 2000 elements and i need to compute the values
specified above for m = 32. Using combn() i
2012 Nov 16
1
pairing data using combn with criteria
Dear All,
I have a dataframe made up of individual beetles consisting of individual
number, family number, mother's family number, father's family number, and
sex of the beetle. I would like to pair up the individuals for breeding. I
would, however, like to avoid breeding beetles of the same sex (obviously),
the same family, and with the same mother's family or father's family,
2010 Apr 07
1
combn with factors
Dear list,
I have come across this issue:
combn(letters[1:5], 3)
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] "a" "a" "a" "a" "a" "a" "b" "b" "b" "c"
[2,] "b" "b" "b" "c" "c" "d" "c"
2011 Oct 16
1
multicore combn
This is a 'rather than re-invent the wheel' post. Has anyone out there
re-written combn so that it can be parallelized - with multicore, snow, or
otherwise? I have a job that requires large numbers of combinations, and
rather than get all of the index values, then crank it through mclapply, I
was wondering if there was a way to just do this natively within a function.
Just curious.
2012 Sep 10
2
pairwise comparisions
Hi ,
I am new to R . I am facing difficulty how to make pairwise comparisions.
For example. I have a file which looks like below
a b c d
x 3 6 7 6
y 7 8 6 5
z 5 4 7 8
Here I need to look for the each pairwise comparisions (ab,ac,ad,bc,bd,cd
for each row)
For instance ,looking at first row, for x i need to look for ab values and
take the min(3,6) >5 ,if its satistfies the count should be
2013 Jan 24
2
Please help R error message "masked from 'package:utils':combn"
Hi
The message occurred from R, when I was selected of "optimization > block
diagonal Fhiser matrix" and used the attached file on PFIM.
Could you please advise me about the following message?
*****************************
Loading required pakage: combinat
Attaching package:'combinat'
The following object(s) are masked from 'package:utils':combn
2011 Jan 10
1
Using combn
Dear list,
I want to apply the "table" function to every pair of variables in df
and the return should be a list.
setwd(123)
asd <- data.frame(a1=sample(1:4, 20, replace=TRUE),
a2=sample(1:4, 20, replace=TRUE),
a3=sample(1:4, 20, replace=TRUE),
a4=sample(1:4, 20, replace=TRUE))
with(asd, table(a1, a2))
with(asd, table(a1,
2008 Feb 08
2
Applying lm to data with combn
http://www.nabble.com/file/p15359204/test.data.csv
http://www.nabble.com/file/p15359204/test.data.csv test.data.csv
Hi,
I have used apply to have certian combinations, but when I try to use these
combinations I get the error
[Error in eval(expr, envir, enclos) : object "X.GDAXI" not found]. being a
novice I donot understand that after applying combination to the data I cant
access
2009 Sep 21
2
Combine vectors in order to form matrixes with combn
Hello!
I've a problem with the combn function and a set of vector. I
would like to make a simple combination where, instead of scalars, i
would like to combine vector, in order to form matrixes.
In other
words, i have nineteen 6-items vectors (for example coef1-coef19), that
i would like to combine in n!/k!(n-k)! 6x6 matrixes.
I tried with a
code like this
mma <-
2007 Jan 19
2
combn implementation
Hi,
I was checking the source code to the function combn that "generates
all combinations of the elements of 'x' taken 'm' at a time.",
because I wished to modify it. I have a doubt about a statement.
This is the main loop.
._1 <- 1:1
nmmp1 <- n - m + ._1
while (a[1] != nmmp1) {
if (e < n - h) {
h <- ._1
e <-
2008 Jul 31
1
combinations with replications
Dear all,
Is there a way to compute and list all combinations with replication of two
elements in sets of 8 elemnts?
For example, I've two elements, 0 and 1, and I would to get all possible
combinations with replication such as, for example, 00000000, 00000001,
00000010, and so on. They are 2^8 and it's very hard to list handly!!
Thank you
Marina
--
View this message in context:
2012 Jul 20
6
Speeding up a loop
General problem: I have 20 projects that can be invested in and I need to
decide which combinations meet a certain set of standards. The total
possible combinations comes out to 2^20. However I know for a fact that the
number of projects must be greater than 5 and less than 13. So far the the
code below is the best I can come up with for iteratively creating a set to
check against my set of
2012 Aug 26
3
Two selections from Bag A
All, I am looking at an example in Aliaga's Interactive Statistics. Bag A has
the following vouchers.
BagA <- c(-1000,10,10,10,10,10,10,
10,20,20,20,20,20,20,30,
30,40,40,50,60)
Bag B has the following vouchers.
BagB <- c(10,20,30,30,40,40,50,50,
50,50,50,50,60,60,60,60,
60,60,60,1000)
Two values are selected (from BagA or BagB) without
2012 Nov 18
1
identical matrices
Dear R users,
I want to check matrices when i change the order of the rows or/and the order of the columns or/and the combination of them
i will give an example what i want
1 -1 1 1 1 1 1 1
-1 -1 -1 -1 -1 -1 -1 -1
1 1 1 1 1 -1 1 1
these 2 matrices are identical because i change the first row and make it third
1 -1 1 1 -1 1 1 1
-1 -1 -1
2010 Mar 26
2
R loop help
Hi,
I am tring to write a loop to compute this,
==========================
x1=c(
rep(-1,4),
rep(1,4)
)
x2=c(
rep(c(-1,-1,1,1),2)
)
x3=c(
rep(c(-1,1),4)
)
x1*x2
x1*x3
x2*x3
========================
suppose i have x1,x2,x3
i want to compute their ' two factor interactions', x1x2,x1x3 and x2x3,
I wrote
========================
for(i in 1:2){
for( j in i+1:3){
xij=c()