similar to: behavior of seq_along

Displaying 20 results from an estimated 10000 matches similar to: "behavior of seq_along"

2007 Apr 03
1
Behavior of seq_along (was: Create a new var reflecting the order of subjects in existing var)
I am moving this from r-help to r-devel. Based on offline communications with Jim, suppose dat is defined as follows: set.seed(123) dat <- data.frame(ID= c(rep(1,2),rep(2,3), rep(3,3), rep(4,4), rep(5,5)), var1 =rnorm(17, 35,2), var2=runif(17,0,1)) # Then this ave call works as expected: ave(dat$ID, dat$ID, FUN = function(x) seq_along(x)) # but this apparently identical calculation
2009 Jul 09
1
bug in seq_along
Using the IRanges package from Bioconductor and somewhat recent R-2.9.1. ov = IRanges(1:3, 4:6) length(ov) # 3 seq(along = ov) # 1 2 3 as wanted seq_along(ov) # 1! I had expected that the last line would yield 1:3. My guess is that somehow seq_along don't utilize that ov is an S4 class with a length method. The last line of the *Details* section of ?seq has a typeo. Currently it is
2012 Jan 06
1
seq_along and rep_along
Hi all, A couple of ideas for improving seq_along: * It would be really useful to have a second argument dim: seq_along(mtcars, 1) seq_along(mtcars, 2) # equivalent to seq_len(dim(mtcars)[1]) seq_len(dim(mtcars)[2]) I often find myself wanting to iterate over the rows or column of a data frame, and there isn't a particularly nice idiom if you want to avoid problems
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
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
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) ###
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 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
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"
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
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))
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 <-
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
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
2009 Jan 22
1
Finding the distance between ordered integers
I'm stuck on how best to of find the distance between ordered integers (presented below as a birthday problem). Given the vector x, how do I most efficiently generate the vector x[i+1] - x[i]? Thanks. --Dale For example... set.seed(555) x <- sample(1:365, 10, replace=TRUE) x <- sort(x) x x[i+1]-x[i] --- --------------- 14 14 0 75 61 136 61 197 61 236 39 253 17 310 57 323
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
2007 Jul 30
2
Tracking file activity
Hey List, I was wondering if and how one would go about tracking file activity on a Samba server, for basic auditing purposes. I'd ideally like to see what files where edited, by whom and when. I've done some RTFM and a bit of searching around the 'net, but haven't found anything yet. Even pointers to documentation on the subject would be welcome. Thanks in advance for
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
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 <-
2012 Nov 30
1
xts indexed with Date class
Hi I see a changed behaviour in xts indexed on class Date in the latest versions, versus 2. It seems to be related to changes to/from daylight savings time, happens those weekends. Is it not intended that class Date be used like this, or is this new behaviour incorrect? Giles Example: > a<-as.Date(15423:15426) > x<-xts(seq_along(a),a) > print(x) [,1] 2012-03-24