similar to: Finding the distance between ordered integers

Displaying 20 results from an estimated 20000 matches similar to: "Finding the distance between ordered integers"

2009 Apr 15
2
How to Reshuffle a distance object
I would like to randomly shuffle a distance object, such as the one created by ade4{dist.binary} below. My first attempt, using sample(jc.dist) creates a shuffled vector, losing the lower triangular structure of the distance object. How can I Ishuffle the lower triangular part of a distance matrix without losing the structure? Thanks. --Dale x1 <- c(rep(0,4),1) x2 <- c(rep(0,2),rep(1,3))
2007 Oct 03
2
Speeding up simulation of mean nearest neighbor distances
I've written the function below to simulate the mean 1st through nth nearest neighbor distances for a random spatial pattern using the functions nndist() and runifpoint() from spatsat. It works, but runs relatively slowly - would appreciate suggestions on how to speed up this function. Thanks. --Dale library(spatstat) sim.nth.mdist <- function(nth,nsim) { D <- matrix(ncol=nth,
2008 Sep 28
5
birthday problem (factorial limit)
Hi, I tried to calculate the formula for the birthday problem (the probability that at least two people out of a group of n people share the same birthday) But the factorial-function allows me only to calculate factorials up to 170. So is there a way to push that limit? to solve this formula: (factorial(365) / factorial((365-23))) / (365^23) (n=23)
2009 Feb 11
4
Efficent way to create an nxn upper triangular matrix of one's
The code below create an nxn upper triangular matrix of one's. I'm stuck on finding a more efficient vectorized way - Thanks. --Dale n <- 9 data <- matrix(data=NA, nrow=n, ncol=n) data for (i in 1:n) { data[,i] <- c(rep(1,i), rep(0,n-i)) } data
2006 Jan 26
2
Data management problem: convert text string to matrix of 0's and 1's
I have a data management problem which exceeds my meager R programming skills and would greatly appreciate suggestions on how to proceed? The data consists of a series of observation periods. Specific behaviors are recorded for each time period in the order each is observed. Their are 8 possible behaviors, coded as "i" "c" "s" "r" "v"
2007 Oct 11
3
reason for error in small function?
Running the function below, tested using the cardiff dataset from splancs generates the following error. What changes do I need to make to get the function to work? Thanks. --Dale > gen.rpoints(events, poly, 99) > rpoints Error: object "rpoints" not found # test spatial data library(splancs) data(cardiff) attach(cardiff) str(cardiff) events <- as.points(x,y) ###
2000 Apr 25
2
Recursive Computation in R
Hi there, I have written a function to calculate factorials as follows: fact <- function(x) { recurse <- x > 1 x[!recurse] <- 1 if( any(recurse) ) { y <- x[recurse] x[recurse] <- y * fact( y - 1 ) } x } I want to be able to do the famous birthday problem, which will involve the computation of 365!, however it shall get cancelled
2008 Mar 07
1
Finding Interaction and main effects contrasts for two-way ANOVA
I've tried without success to calculate interaction and main effects contrasts using R. I've found the functions C(), contrasts(), se.contrasts() and fit.contrasts() in package gmodels. Given the url for a small dataset and the two-way anova model below, I'd like to reproduce the results from appended SAS code. Thanks. --Dale. ## the dataset (from Montgomery) twoway <-
2009 Mar 13
2
code to find all distinct subsets of size r from a set of size n
I'm doing a permutation test and need to efficiently generate all distinct subsets of size r from a set of size n. P 138 of MASS (4th ed) notes that "The code to generate this efficiently is in the scripts". I was unable to find this code on quick inspection of the \library\MASS\scripts file for Chapter 5 and 'subsets' is not a function in MASS. I did find this problem is
2008 Jan 01
5
Compiling wxruby-1.9.2
Hi, I''m trying to compile wxruby-1.9.2. This is my first time using rake. All I get is the following: (in /bld/lib/wxruby-1.9.2) rake aborted! can''t convert nil into String /bld/lib/wxruby-1.9.2/rakefile:48 (See full trace by running task with --trace) And with --trace: (in /bld/lib/wxruby-1.9.2) rake aborted! can''t convert nil into
2010 Feb 25
2
How to use a 'hidden' function directly?
I would like to be able to use two functions; qansari and pansari which are found in the function ansari.test. How can I evaluate these functions independently? Thanks. --Dale For example, when I load the function ... qansari <- function(p, m, n) { .C(R_qansari, as.integer(length(p)), q = as.double(p), as.integer(m), as.integer(n))$q } and
2006 Oct 11
3
for loop not working in function
I'm trying to write a small function (below) to compute Box & Cox transformations of x for arbitrary values of lambda. I'd like to specify a range of values for lamba (min,max,step) and am having trouble getting the for loop to work. Suggestions? Any pointers to resources for learning to write functions in R for neophyte programmers? Thanks. --Dale boxcox <-
2007 Dec 12
2
problem applying a conditional formula to each element of a matrix
I'm applying a function (Cov.f) defined below to each element of a distance matrix. When I run the code below, I get a warning message (below) and elements of returned matrix [2,3] and [3,2] are not zero as I would expect. Clearly, there is an error... What am I doing wrong? Thanks. --Dale Warning message: In if (h <= phi) { : the condition has length > 1 and only the first element
2008 Jul 12
1
[ESS] Process SAS is not running... error on Ubuntu
It does appear the ess package on CRAN for Ubuntu 8.04 fails to install the file 'ess-sas-sh-command'. This prevents invoking SAS via 'M-x SAS'. http://cran.mirrors.hoobly.com/bin/linux/ubuntu/README.html --Dale On Fri, Jul 11, 2008 at 12:39 PM, Rodney Sparapani <rsparapa at mcw.edu> wrote: > Dale Steele wrote: >> >> I re-installed from Hardy packages on
2008 Jan 08
28
1.9.3 release, rakefile
Hi I''d like to put out a 1.9.3 release perhaps later this week/weekend. If you have a chance to test the build and samples esp with latest rubygems, please do. There are still some bugs on the list, and samples to do, but this should address all the build/install probs that have come up. And it would be good to get some testing and feedback on some of the new classes. A note on the
2010 Feb 25
3
behavior of seq_along
I'm trying to understand the behavior of seq_along in the following example: x <- 1:5; sum(x) y <- 6:10; sum(y) data <- c(x,y) S <- sum( data[seq_along(x)] ) S T <- sum( data[seq_along(y)] ) T Why is T != sum(y) ?
2006 Jan 23
1
proposed pbirthday fix
Recent news articles concerning an article from The Lancet with fabricated data indicate that in the sample containing some 900 or so patients, more than 200 had the same birthday. I was curious and tried out the p and q birthday functions but pbirthday could not handle 250 coincidences with n = 1000. The calculation of upper prior to using uniroot produces NaN, upper<-min(n^k/(c^(k-1)),1)
2010 Apr 22
2
Jonckheere-Terpstra test using coin package?
Is it possible to implement the Jonckheere-Terpstra test for ordered alternatives using the coin package: Conditional Inference Procedures in a Permutation Test Framework? I found jonckheere.test{clinfun}, but it uses a normal approximation when ties are present in the data. To make this concrete, I've include a small dataset. Thanks. --Dale Hollander and Wolfe, 1999 Table 6.6, pg 205
2010 Dec 04
7
Error loading mfc42.dll - failed (error c000007b)
:D Hi, I installed wine on ubuntu 10.10 to run a windows program as reported here (http://appdb.winehq.org/objectManager.php?sClass=version&iId=22133&iTestingId=59338). After few trails I decided to reinstall Wine (now version 1.3.8 ), to configure it as instructed by the guide, and than to install again the windows application, Birthday Reminder. At present the application doesn't
2013 May 02
3
I Know It's A Stupid Question......
........But I'm trying to give my son a "cool-yet-kind-of-geeky" 13th Birthday Present......he hinted he liked the CentOS logo, but where would I find things that are branded with it?....searching the web doesn't really help me much, only because I'm not sure what I need to be looking for...any help would be greatly appreciated! Thanks in advance!! EGO II