similar to: count sequence of integers

Displaying 20 results from an estimated 20000 matches similar to: "count sequence of integers"

2008 Jan 14
2
knnFinder package
Dear all, I have found some serious bugs in the knnFinder package (which supports data structures and algorithms for both exact and approximate nearest neighbor searching in arbitrarily high dimensions) that may trigger segmentation faults. I have fixed them but I had troubles to contact its maintainer Samuel E. Kemp (previously with the University of Glamorgan, UK). Do someone know where I
2004 Apr 14
4
binary numbers
Hi, Is there a function in R that lets one represent an integer in binary format for a given number of bits? So an example would be.... > binary.function(num=5, num.of.bits=8) > "00000101" Or, is this something I have to write myself? Any help would be appreciated. Cheers, Sam.
2003 Nov 14
2
bad performance of a function
Dear all I need to find a length of true sequences in logical vector (see example 1). I found a possible solution which is good but if I use it on a larger data set I experience a substantial decrease in performance (example 2). Example 1 set.seed(111) x <- sample(c(T,F),50, replace=T) system.time(cetnost <- as.numeric(table(which(x)-cumsum(x[which(x)])))) [1] 0.00 0.00 0.03 NA NA
2004 Jun 01
4
S/R programming books
Hi, I have been using R for a few months now and I am confident that the language has everything I will need to complete my PhD. I can create functions, script files and packages, but I would like to write my programs more efficiently (maybe using OO). Can anyone recommend a good book on the "art" of good R programming? Kind Regards, Sam.
2006 Feb 26
2
subtotal, submean, aggregate
Dear All, I would like to make partial sums (or means or any other function) of the values in intervals along a sequence (spatial transect) where groups are defined. For instance: habitats<-rep(c("meadow","forest","meadow","pasture"),c(10,5,12,6)) observations<-rpois(length(habitats),2)
2004 Sep 28
1
package error message
Hi, I am trying to make my own package in Windows XP with R 1.9.1. using Rcmd build/ Rcmd. The initial Rcmd build compiles ok with no error messages. However, when I run Rcmd check it runs ok up until * checking for file 'GammaTest/DESCRIPTION' ... OK * checking if this is a source package ... OK * checking whether package 'GammaTest' can be installed ... ERROR Installation
2006 Mar 29
3
Sub-vector
Dear list, Given a vector of logical values, say >a <- c(TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE,TRUE,TRUE,TRUE) Are there any R functions that can tell whether there are two or more "TRUE" in a row in this vector? Thanks, Wuming
2006 Sep 30
1
counting a sequence of charactors or numbers
I have the following sequence of characters. These could be integers as well. For this problem, only two values are valid. S S S S S S W W W W W W W W S S S S S S S S W W W W W W W W S S S S S S S S S S S S S W W W W W W W W W I need to determine the count of the classes/groups in sequence. as 6,8,8,8,13,9 where the sum of these equal my total observations. Any help is greatly appreciated.
2004 Dec 08
2
memory problem
Hi, I am trying to run a very computationally expensive procedure in R-2.0.0. and the process always gets killed after approx 8 minutes. This procedure calls some of my own C++ code - in case it was this code causing a memory leak I unload and then reload the .so file every time, however I still get the same problem. The procedure is run 16000 times and always calls the lm() function. My
2004 Oct 01
2
Rnewsletter article example
Hi, I am trying to write an article for the Rnewsletter, but keep getting errors. I have googled around for some decent examples that contain figures, maths, etc but with no joy. Would any be so kind as to send me an example article in latex code? Cheers, Sam.
2004 Mar 01
2
dynamic linking
Hi, I want to set up a dynamic link between a library e.g. myLibrary.a and a C++ file myProgram.cc to use in R. Is this possible? If so how does one go about doing it? Any help will be greatly appreciated. Cheers, Sam.
2004 Mar 04
2
adding trend to an arima model
Hi, Does anyone know a method for adding a linear/polynominal trend to a simulated arima model using the arima.sim function? Any help will be greatly appreciated. Cheers, Sam.
2006 Mar 13
1
Help on interfacing C++ with R
Hi, I am trying to set up a C++ library for my R code. I followed the R-extension manual but found out that the example of "X.cpp, X_main.cpp" is somewhat too simple. Here is my code: //lib4R.h testing for interfacing C++ with R -- using C++ library in R #include <iostream> using namespace std; class lib4R { public: lib4R(); ~lib4R(); int
2010 Nov 11
1
Count continuous dates
Dear List, I have a series of dates and I am needing to know the greatest length of continuous dates - i.e. the number of dates before a break in the series.? For example, below there are three continuous series of dates with lengths 4, 6, and 8.? How can I count the number of continuous dates?? rle() will do it for constant integers, but I can't figure a way to modify it for continuous
2004 Jan 14
1
univariant time series
Hi, I am trying to use the stl function in the ts package. It requires that the data is a univariant time series at the moment my data is in a vector. I have coerced it to a time series using.... crimets <- ts(crimeData) However, this does not work. Does anyone have any suggestions? Cheers, Sam. p.s. I am fairly new to R so apologies if this is a stupid posting.
2011 Oct 13
5
Counting the number of integers at one swoop
Dear R users, I'd like to count the number of integers in a vector y. Here is an example. y <- c(0,1,1,3,3,3,5,5,6) In fact, I know how to count the number of specific number in y. sum(y==0) -> 1 sum(y==1) -> 2 sum(y==2) -> 0 sum(y==3) -> 3 sum(y==4) -> 0 sum(y==5) -> 2 sum(y==6) -> 1 However, in one computation I want to get this vector [1,2,0,3,0,2,1]. Thank
2005 Jan 07
3
R packages on Mac
Hi, I am considering whether or not to buy an apple mac. I have noticed on one of the R FAQs for Mac OS X that you cannot install packages from other OS's if C++ code is contained. My question is: Is it possible to build the package sources containing C++ code on the Mac and then install them? Thanks in advance, Sam.
2008 May 27
4
help with simple function
I have a matrix of frequency counts from 0-160. x<-as.matrix(c(0,1,0,0,1,0,0,0,1,0,0,0,0,1)) I would like to apply a function creating a new column (x[,2])containing values equal to: a) log(x[m,1]) if x[m,1] > 0; and b) for all x[m,1]= 0, log(next x[m,1] > 0 / count of preceding zero values +1) for example, x[1,2] should equal log(x[2,1]/2) = log(1/2) = -0.6931472 whereas x[3,2] should
2007 Oct 09
2
window (x,y) co-ordinates of datapoints
Hi, In the getGraphicsEvent function the (x,y) co-ordinates returned from the mouse move are in relation to where the mouse is located within the device window (i.e. the lower left corner of the window is '(0,0)', the upper right is '(1,1)'). Is there a way of returning the (x,y) co-ordinates of data points plotted where instead of x and y being the actual data points they are
2009 Jul 07
2
rle
Hallo, I have an other problem, I have this vector signData with an alternation of 1 and -1 that corrispond to the duration of two different percepts. I extracted the durations like this: signData<- scan("dataTR10.txt") dur<-rle(signData)$length Now I would like to extract only the positive duration, e.g. signData <- c(1,1,1,1,-1,-1,-1,1,1,-1,-1) posduration <- c(4,2) I