Displaying 20 results from an estimated 4000 matches similar to: "Permutations"
2007 Oct 15
1
Distance matrix in SpDep-package
Hello everybody,
I would like to use the SpDep-package (especially the Local Moran index
analysis and the Getis-Ord statistics) in R for analysing my data. However,
I don't have x-y coordinates, but my data is in a distance matrix format. Is
it possible to use the SpDep package with predefined distances as well
instead of letting the program determining the distance itself by the
function
2009 Jul 14
1
Error when sampling from SpatialLines
Dear forum,
I am working in R 2.9.1 and I am trying to sample locations from a network file. Reading in nor plotting is a problem, however when I am trying to sample from the file I get the following message:
nwlim<-readShapeLines("C:/Limburg_nwshape", proj4string=CRS("+init=epsg:31300"))
plot(nwlim)
randacc<-spsample(nwlim,n=1000,"random")
2007 Dec 17
1
polygon class in splancs package
Dear forum,
I would like to use the kernel2d or spkernel2d in the Splancs-package, but
it does not recognize my polygon data.
"Error in kernel2d(as.points(ptsbin), polygonprov, h0 = 2, nx = 100, : " is
the error message.
Invalid poly argument
The data are defined as follows:
polgonprov<-list(x=polyprov$X, y=polyprov$Y) with X and Y coordinates in the
Lambert1972
2009 Mar 14
2
permutations in R
Hi. Does anyone know of a function which will take as input a number n (or a
set of n letters) and will give out, one at a time, the permutations of n
(or of those n letters) as a vector?
So that I can use the permutations one at a time. And such that it will
exhaust all the permutations with no repeats.
For example if n is 3, I would want a function which I could use in a loop
and the first time
2009 Dec 18
2
Generating permutations that always include one specific element
Dear R community,
I am trying to create a matrix of permutations of a vector:
bands <- c("AL", "B", "DB", "DG", "G", "K", "LB", "LG", "MG", "O", "P",
"PI", "PK", "PU", "R", "V", "W", "Y")
Each permutation must be 4
2006 Aug 02
2
listing of permutations
Dear R People:
Suppose I have the 4 numbers: 1,2,3,4.
I would like to create a listing of the permutations
of 4 items taken 4 at a time.
Is there a built in function for that, please?
Thanks in advance!
R 2-3-1 for Windows or Linux
Sincerely,
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgess at gator.uhd.edu
2012 Oct 31
3
expand.grip for permutations
if i were to have a block size of 4 people and i want to assign a treatment
combination to the entire block, there would be 16 different treatment
combinations (TTTT, TTTP, TTPP, PTTP, etc.)
i am trying to get all 16 permutations and i am able to use this code below.
drugs=c('P','T');
comb=expand.grid(drugs,drugs,drugs,drugs)
for a block size of 3 the code would be
2002 Jan 16
2
exhaustive permutations
Hello R-help Readers
I'm currently in the process of trying to write a permutation test
procedure for looking at differences between groups with a multivariate
data set (something equivalent to ANOSIM - analaysis of similarities for
those familiar with this test). As with other permutation tests, for
cases where there are large numbers of possible permutations, randomly
sampling from these
2010 Jan 18
2
permutations from vectors out of a matrix
Dear R-Users,
I'm relativley new to R and have the following problem. I need all
permutations of the vectors created by the collumns of a matrix. I will
give a small example:
p=3
n=2^p-1
#number of obtainable vectors
mat=matrix(0,p,p)
for(i in 1:p)
{
mat[i:1,i]=1/i
}
mat is now a
2009 Oct 10
1
permutations
Question 1.
I would calculate all the permutations of numbers (23,46,70,71,89)
How can I write correctly the code?
(Load gregmisc)
> permutations (..?...)
______________________
Question 2.
It's possible permute a string?
..for example:
EIGER
EGIER
EREGI
etc..etc..
Thanks,
E.
--
View this message in context: http://www.nabble.com/permutations-tp25834463p25834463.html
Sent from the R
2008 Nov 24
3
Help With Permutations
I have a problem with permutations functions in R
I just started using R so maybe it is an easy question
I need to obtain all the 9.somthingExp 157 permutations that can be
given from the number from 1 to 100
I wrote the following commands:
> library(gregmisc)
>options(expressions=1e5)
cmat <- combinations(300,2)
dim(cmat) # 44850 by 2
>permutations(n=100, r=100)
2008 Nov 14
1
Generating unique permutations of a vector
Hi all,
I try to generate sets of strategies that contain probability
distributions for a defined number of elements, e.g. imagine an
animal that can produce 5 different types of offspring and I want to
figure out which percentage of each type it should produce in order to
maximize its fitness. In order to do so, I need to calculate the fitness
for all potential strategies. As an example, if I
2006 Aug 18
1
Permutations with replacement
Is there a simple function or process that will create a matrix of
permutations with replacement?
I know that using the combinat package
###### begin R code ######
> library(combinat)
> m <- t(array(unlist(permn(3)), dim = c(3, 6)))
# we can get the permutations, for example 3!=6
# gives us
> m
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 1 3 2
[3,] 3 1 2
[4,]
2006 May 08
3
Non repetitive permutations/combinations of elements
Hello all,
I am trying to create a matrix of 1s and -1s without any repetitions for a
specified number of columns.
e.g. 1s and -1s for 3 columns can be done uniquely in 2^3 ways.
-1 -1 -1
-1 -1 1
-1 1 -1
-1 1 1
1 -1 -1
1 -1 1
1 1 -1
1 1 1
and for 4 columns in 2^4 ways and so on.
I finally used the function combn([0 1],3) that I found at the following link
2008 Jan 14
2
Permutations of variables in a dataframe
Hallo All,
I would like to apply a function to all permutations of variables in a
dataframe (except the first). What is the best way to achieve this?
I produce the permutations using:
nvar <- ncol(dat) - 1
perms <- as.matrix( expand.grid(rep( list(1:0) , nvar ))[ , nvar:1] )
Thanks in advance
Serguei
Test-dataframe, comma-delimited:
code,wav,w,area,gdp,def,pop,coast,milspend,agr
2008 Apr 06
3
Multiset Permutations
Dear R users,
I want to perform an exact permutation of multisets. I have looked at the
coin package, but it doesn't seem to offer what I am looking for. I want to
perform permutations (exact - without duplications) on multisets of scalars
(e.g., the multiset 0,0,1,2,2). I want to output all the possible
permutations into a data frame so that each multiset permutation occupies a
row (or
2000 Sep 26
1
Permutations
Hi,
this is maybe not a real R problem but I want to solve this in R ;-)
Consider the set of all permutations of 1:N (=: S, say) and a fixed
element a from S. I now need to compute the number of permutations s from
S which are elementwise less or equal to a: | { s \in S | s <= a } |
Of cource, backtracking using a tree structure is possible. Does anyone
know an efficient way?
Torsten
2010 Jan 14
2
Fixed size permutations
I'm using functions to return a matrix of all permutations of a
specified size from a larger list for predictor selection.
For each predictor size I use a seperate function like this:
bag2 <- function(n) {
rl <- c()
for (i1 in seq(n)) {
for (i2 in seq(n)) {
if (length(unique(c(i1,i2)))==1) {next}
rl <- cbind(rl,matrix(c(i1,i2)))
}
}
2017 Dec 08
2
Curiously short cycles in iterated permutations with the same seed
I have noticed that when I iterate permutations of short vectors with the same seed, the cycle lengths are much shorter than I would expect by chance. For example:
X <- 1:10
Xorig <- X
start <- 112358
N <- 10
for (i in 1:N) {
seed <- start + i
for (j in 1:1000) { # Maximum cycle length to consider
set.seed(seed) # Re-seed RNG to same initial state
X <- sample(X)
2000 Dec 17
1
AW: Permutations
Niels Waller wrote:
> Does anyone know of an R (or S-PLUS) function for delineating all possible
> combinations and permutations?
The following function delivers all permutations of 1:n.
all.perm <- function(n) {
p <- matrix(1, ncol = 1)
for (i in 2:n) {
p <- pp <- cbind(p, i)
v <- c(1:i, 1:(i - 1))
for (j in 2:i) {
v <- v[-1]