Displaying 20 results from an estimated 10000 matches similar to: "question R regarding consecutive numbers"
2011 Oct 28
1
Gap in solution
Hi David,
In the general case, there is still a gap in your solution >sum( tbl["1",
2:ncol(tbl)] ). This solution refers to a specific column number (here:
column number 2) and not to the actual length of the run, doesn't it? That
is, in this simple example the column number 2 actually corresponds to the
length "2", but this must not be the case in general. For
2011 Oct 12
1
exclude columns with at least three consecutive zeros
Hi everyone,
I have a large data set with about 3'000 columns and I would like to exclude
all columns which include three or more consecutive zeros (see below
example). A further issue is that it should just jump NA values if any. How
can I do this?
In the below example R should exclude column C and D (since in D jumping the
NA leaves three consecutive zeros).
I would appreciate
2009 Oct 28
1
Need help locating the longest series of consecutive numbers in a matrix
I need to determine the length of the longest series of consecutive numbers
(1's to be specific) and the start time of that series. For example, in the
following sample, the first column is "time" and the second column indicates
the presence of the target behavior.
I would like a function that would return "21" as the start time and "17" as
the length.
sample
2011 Sep 16
3
question concerning the acf function
Hi everyone,
I've got a question concerning the function acf(.) in R for calculating the
autocorrelation in my data.
I have a table with daily returns of several stocks over time and I would
like to calculate the autocorrelation for all the series (not only for one
time series). How can I do this?
After that I want to apply an autoregressive model based on the estimated
lag in the
2012 Mar 08
3
Calculating length of consecutive sequences within a vector
Hi all,
I have a nx1 logical array of zeros and ones and I want to calculate the individual lengths of all 1-consecutive sequences contained in it. Is there an easy quick way to do this in R? So, if I have a vector such as
111001101000011111110
I would like to get (1) 3, (2) 2, (3) 1, (4) 7
Any help would be appreciated! thanks!
Jorge
[[alternative HTML version deleted]]
2011 Sep 27
4
Question concerning Box.test
Hi everyone,
I've got a question concerning the function Box.test for testing
autocorrelation in my data.
My data consist of (daily) returns of several stocks over time (first
row=time, all other rows=stock returns). I intend to perform a Box-Ljung
test for my returns (for each stock). Since I have about 3000 stocks in my
list, I'm not able to perform the test individually for each
2008 Apr 29
1
Consecutive zeros in a vector
Suppose X is a long vector of integers (typically about 30000 elements). Is
there an efficient way to detect whether there are at least N consecutive
zeros in X, and if yes, where does this occur?
for example, suppose X is:
1 2 3 4 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 4 2 0 1 2 0 0 0 2 2 2 2 2 ...
and N is 10. I would like a foo(X, 10) to return something like c(6,19)
(start and end positions in X
2008 Jun 02
4
NOT-SO-SIMPLE function!
I am trying to set up a function which processes my data according to the
following rules:
1. if (x[i]==0) NA
2. if (x[i]>0) log(x[i]/(number of consecutive zeros immediately preceding
it +1))
The data this will apply to include a variety of whole numbers not limited
to 1 & 0, a number of which may appear consecutively and not separated by
zeros. Below is an example with a detailed
2013 Apr 29
3
Counting number of consecutive occurrences per rows
Hi,
I would appreciate if somebody could help me with following calculation.
I have a dataframe, by 10 minutes time, for mostly one year data. This is
small example:
> dput(test)
structure(list(jul = structure(c(14655, 14655, 14655, 14655,
14655, 14655, 14655, 14655, 14655, 14655, 14655, 14655, 14655,
14655, 14655, 14655), origin = structure(0, class = "Date")),
time =
2010 Oct 28
2
Determining a basal correct count
Here's another interesting problem: if you recall I have a data frame (LCvars1) that consists of about 1500 cases (rows) of data from kids who took a test of listening comprehension. The columns are their scores (1 = correct, 0 = incorrect, . = missing) on 140 test items. The items are numbered sequentially and are ordered by increasing difficulty as you go from left to right across the
2008 May 13
2
Max consecutive increase in sequence
Hi all R helpers,
I'm trying to comeup with nice and elegant way of "detecting" consecutive
increases/decreases in the sequence of numbers. I'm trying with combination
of which() and diff() functions but unsuccesifuly.
For example:
sq <- c(1, 2, 3, 4, 4, 4, 5, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1);
I'd like to find way to calculate
a) maximum consecutive increase = 3 (from 1
2011 Sep 08
2
problems with function read.table
Hello everyone
I have a couple of questions about the usage of the R function
"read.table(.)". My point of departure is that I want to import a matrix
(consisting of time and daily stock returns of many stocks) in R. Most of
the data is numeric, however some values are missing (blanks) and in other
cases I have the character "#DIV/0!" (from excel). My goal is to do some
2008 Aug 28
2
sample consecutive integers efficiently
Hi all,
I have some rough code to sample consecutive integers with length
according to a vector of lengths
#sample space (representing positions)
pos<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20)
#sample lengths
lengths<-c(2,3,2)
From these two vectors I need a vector of sampled positions.
the sampling is without replacement, making things tough as the sampled
integers need
2009 Oct 29
1
How to turn individual consecutive information into survival objects?
Dear R List,
I have a dataset with the following structure:
"""personal_id, p_0, p_1, p_2, .... , p_36, p_37
1, NA, 1, 4, .... , 1, NA
2, NA, NA, NA, .... , 4, NA
.
.
.
6020, NA, 3, 3, ...., NA, NA
6021, NA, 2, 2, ...., 4, NA
"""
I used some made-up data. It is just meant to show the structure of the dataset.
The variables of interest are p_0, ... p_37.
2010 Jul 22
4
Drop firms in unbalanced panel if not more than 5 observations in consecutive years for all variables
Dear R-user,
a few weeks ago I consulted the list-serve with a similar question.
However, my task changed a little but sufficiently to get lost again. So
I would appreciate any help on the following issue.
I use the plm package and work with firm-level data in a panel. I would
like to eliminate all firms that do not fulfill the requirement of
having an observation in every variable used for at
2007 Dec 04
3
Inserting a subsequence between values of a vector
Hallo,
suppose I have a vector:
x <- c(1,1,1,2,2,3,3,3,3,3,4)
How can I generate a vector/sequence in which a fixed number of zeroes (say
3) is inserted between the consecutive values, so I get
1,1,1,0,0,0,2,2,0,0,0,3,3,3,3,3,0,0,0,4
thanks a lot,
Serguei
[[alternative HTML version deleted]]
2011 Oct 25
1
question regarding intersect function
Hi
I have probably a very simple question but I'm going crazy trying to find
the solution.
I have two data.frames with headers and I'm doing an intersection between
them by names, such that the intersected data.frames are returned by:
df1[intersect(names (df1), names(df2))] and the same for df2
Now, I want to have all the opposite data that did not intersect. I tried to
do:
2007 Jan 18
4
How to optimize this loop ?
Dear R Users,
I request your help to optimize a loop.
Given a series of observations, I want to know how many consecutive past
observations are below the last one.
e.g :
my_series <- c(3, 4, 10,14,8,3,4,6,9)
As the last number (9) is higher than the four preceding numbers (6, 4, 3, 8),
this function should return 4.
my_series <- c(3, 4, 10,14,8,3,4,11,9)
Here, it should return 0, as 9
2011 Oct 31
2
rle for non concecutive
Dear all,
I would like to task you if you know a rle version that can work also in a non consecutive way too.
B.R
Alex
[[alternative HTML version deleted]]
2002 May 20
1
how does one apply Western Electric / AT&T rules to R plots?
I have searched for info on how to apply the Western Electric rules for
process control, to data and plots I have in R, but I have not been able
to learn how.
Any help would be greatly appreciated.
Thank you,
sjcrauhut at agere.com
05/20/02
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read