1 1 1 1
---
A.K.
- Original Message -
From: ben1983
To: r-help@r-project.org
Cc:
Sent: Friday, April 19, 2013 7:21 AM
Subject: [R] Sequence analysis
Hiya,
I am trying to look at the similarities between a number of
sequences, for example
Hiya,
I am trying to look at the similarities between a number of
sequences, for example i am trying to see how similar "ababbbassdaa" is to
"addffggssbbsbbs" I was wondering is the some way for me to see how similar
they are in terms of, for example, number of a's, number of b's, how o
Thanks a lot, it works very well!
Inti
2012/8/21 Rui Barradas
> Hello,
>
> Try the following
>
>
> d <- read.table(text="
>
> id VI
> 1 -10
> 2 -4
> 3 5
> 4 -2
> 5 -5
> 6 -3
> 7 -2
> 8 -1
> 9 4
> 10 8
> ", header = TRUE)
>
>
> fun <- function(n, thres){
> r <- rle(!d$VI < thres)
> in
Rui:
It's much simpler than you propose, which is why I left it to the OP.
Just use the results of rle to create a logical vector to index id.
For example, the solution for the OP's example becomes : (d is the
data frame containing id and VI)
> with(d,{
+ z <- rle(VI < 1)
+ vals <- with(z,values
Hello,
Try the following
d <- read.table(text="
id VI
1 -10
2 -4
3 5
4 -2
5 -5
6 -3
7 -2
8 -1
9 4
10 8
", header = TRUE)
fun <- function(n, thres){
r <- rle(!d$VI < thres)
inx <- which(!r$values & r$lengths >= n)
csum <- cumsum(r$lengths)
from <- ifelse(inx == 1, 1, csum[in
z <- rle(VI<1)
gets you most of the way there. ?rle will tell you what z is so that
you can then use it to go the rest of the way.
-- Bert
On Tue, Aug 21, 2012 at 10:54 AM, inti luna wrote:
> Hello,
>
> I have 2 variable: one is an "id" sequence from 1:1000 and the other is
> variable with real
Hello,
I have 2 variable: one is an "id" sequence from 1:1000 and the other is
variable with real values "VI" from -15.0 to 20.0 and I want to detect id
values that have indicator values less than a certain threshold, for
example (x=1) BUT that are in sequence equal or longer than 5.
For instance
Searching: time series forecasting
on the R website gives quite a few potentially useful options.
hth, Ingmar
On Wed, Nov 16, 2011 at 1:55 PM, Aher wrote:
> I have a data with the sequence of events with millions records and more
> than
> 24 time stamped variables.
>
> sample data:
> 1 2
I have a data with the sequence of events with millions records and more than
24 time stamped variables.
sample data:
1 2 3 4 5 6 7 8 9 10
A A A C C C B B D D
D D D D
Hi
as far as I understand your question it seems to me that
round(5*(1.4^(0:10)))
gives you your sequence
and
cumsum(round(5*(1.4^(0:10
gives you summary sequence.
Regards
Petr
>
> I definitely used too much lines s of code because I still don't know
how to
> do some staff.
> but it
Two general R tips:
1) Don't name variables seq or var. These are two really important R
functions and you can get all sorts of unexpected craziness if you overload
them. Going forward, also watch out for t,c, T, F as well.
2) As others have noted, it's very possible to implement this without an
I definitely used too much lines s of code because I still don't know how to
do some staff.
but it works:
seq=5 #starting value
var=5# starting value
long= 1:10 # length of the vector
for (x in long){
var=var+((var/100)*40)
seq=append(seq,var)
}
seq=round(seq)
seq=cums
On Aug 22, 2011, at 9:53 PM, Claudio Zanettini wrote:
> Thanks guys,
> I did not know the fun cumsum
> I will work on that.
A very compact method would be:
cumsum( round(1.4^(0:20)*rep(5, 21)) )
(And I was wrong about it increasing more rapidly if it had been in
hte mamer I imagined.)
--
D
Thanks guys,
I did not know the fun cumsum
I will work on that.
HVZ
2011/8/22 David Winsemius
>
> On Aug 22, 2011, at 8:36 PM, Claudio Zanettini wrote:
>
> Hello everyone,
>> I would like to generate a sequence
>> such as, starting from 5, every value is
>> 40% of the value before+ all the pr
On Aug 22, 2011, at 8:36 PM, Claudio Zanettini wrote:
Hello everyone,
I would like to generate a sequence
such as, starting from 5, every value is
40% of the value before+ all the preceeding values.
es:
this is the seq of all the value+40% of the preceding value:
5 7101
?cumsum
cumsum(yoursequence)
HTH,
Jorge
On Mon, Aug 22, 2011 at 8:36 PM, Claudio Zanettini <> wrote:
> Hello everyone,
> I would like to generate a sequence
> such as, starting from 5, every value is
> 40% of the value before+ all the preceeding values.
> es:
> this is the seq of all the valu
Hello everyone,
I would like to generate a sequence
such as, starting from 5, every value is
40% of the value before+ all the preceeding values.
es:
this is the seq of all the value+40% of the preceding value:
5 71014192738
5374 103
d to keep my
problem
> short in oder not to consume your valuable time.
>
> Regards
>
> Vince Pyne
>
>
>
> --- On Thu, 12/9/10, Petr PIKAL wrote:
>
> From: Petr PIKAL
> Subject: Re: [R] Sequence generation in a table
> To: "Vincy Pyne"
> Cc
wever if there are number of
> bonds (say 1000) in the portfolio, my method of converting the days
> individually is not practical.
>
> I am extremely sorry for the inconvenience caused. I tried to keep my
> problem short in oder not to consume your valuable time.
>
> Regards
&
On Thu, Dec 9, 2010 at 1:24 PM, Vincy Pyne wrote:
> yy <- lapply(c(257, 520, 110), seq, to=0, by=-100)
>
> yy/360, I get following error.
>
> Error in yy/360 : non-numeric argument to binary operator
>
> On the other hand,
>
> yy[[1]]/365 fetches me
>
> [1] 0.7138889 0.436 0.158
>
, Petr PIKAL wrote:
From: Petr PIKAL
Subject: Re: [R] Sequence generation in a table
To: "Vincy Pyne"
Cc: r-help@r-project.org
Received: Thursday, December 9, 2010, 12:03 PM
Hi
r-help-boun...@r-project.org napsal dne 09.12.2010 12:41:47:
> Dear Sir,
>
> Sorry to bother y
y of me defining individually. So is there any way that I can have all
the
> sequence numbers generated can be accommodated in a single dataframe. I
> sincerely apologize for disturbing you Sir and hope I am able to put up
my
> problem in a proper manner.
>
> Regards
>
> Vin
On Thu, Dec 9, 2010 at 12:41 PM, Vincy Pyne wrote:
> The biggest constraint for me is here as an example I have taken only three
> cases i.e. c(257, 520, 110), however in reality I will be dealing with no of
> cases and that number is unknown. But your code will certainly generate me
> the requ
rbing you Sir and hope I am able to put up my
problem in a proper manner.
Regards
Vincy Pyne
--- On Thu, 12/9/10, Jan van der Laan wrote:
From: Jan van der Laan
Subject: Re: [R] Sequence generation in a table
To: r-help@r-project.org, vincy_p...@yahoo.ca
Received: Thursday, December 9, 2010,
Vincy,
I suppose the following does what you want. yy is now a list which
allows for differing lengths of the vectors.
> yy <- lapply(c(257, 520, 110), seq, to=0, by=-100)
> yy[[1]]
[1] 257 157 57
> yy[[2]]
[1] 520 420 320 220 120 20
Regards,
Jan
On 9-12-2010 11:40, Vincy Pyne wrote:
c(
Dear R helpers
I have following input
f = c(257, 520, 110). I need to generate a decreasing sequence (decreasing by
100) which will give me an input (in a tabular form) like
257, 157, 57
520, 420, 320, 220, 120, 20
110, 10
I tried the following R code
f = c(257, 520, 110)
yy = matrix(da
cal Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Luana Marotta
> Sent: Wednesday, December 01, 2010 9:08 AM
> To: r-help; r-help-request
> S
Luana -
It's probably not the most efficient way, but here's
a solution that's not dependent on the grades being sorted:
grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)
unlist(sapply(rle(grade)$lengths,function(x)seq(1,x)))
[1] 1 2 3 1 2 1 2 3 4 1 2 3 1 2 3 4 5 1 2 3
Hi Luana,
Try this:
ID <- 1:20
grade <- c(4, 4, 4, 5, 5, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10)
d <- data.frame(ID, grade)
d$Sequence <- do.call(c, sapply(rle(grade)$lengths, seq))
d
HTH,
Jorge
On Wed, Dec 1, 2010 at 11:08 AM, Luana Marotta <> wrote:
> Hello fellows,
>
> I would like
the thing itself have purpose? Or do we, what's the word... imbue it."
- Jubal Early, Firefly
r-help-boun...@r-project.org wrote on 12/01/2010 11:08:06 AM:
> [image removed]
>
> [R] Sequence for repeated numbers
>
> Luana Marotta
>
> to:
>
> r-hel
Hello fellows,
I would like to create a sequence for repeated numbers in a dataset. For
example:
ID <- c(1:20)
grade <- c(4,4,4,5,5,7,7,7,7,8,8,8,9,9,9,9,9,10,10,10)
Data:
ID Grade
1 4
2 4
3 4
4 5
5 5
6 7
7 7
8 7
9 7
(...)
I would like to create a variable "sequence":
Data:
enum.list <- function(x,y) {
mylist <- NULL
for(i in 1:length(x)) {
mylist[[i]] <- x[i]:y[i]
}
xx <- unlist(mylist)
}
a <- c(1,2,3)
b <- a+2
(harry <- enum.list(a,b) )
--- On Mon, 7/19/10, Suphajak Ngamlak wrote:
> From: Suphajak Ngamlak
> Subject: [R] Sequence
Hi:
Josh's solution is much simpler (and more practical, no doubt) than the one
below, but I wanted to experiment with creating sequences using a vector of
start indices and a corresponding vector of end indices:
b <- 1:3 # vector of start indices
e <- 3:5 # vector of end indices
The
Hi Suphajak,
There are probably cleaner ways, but you can try this:
a <- c(1,2,3)
c <- unlist(lapply(a, function(x) {seq(from = x, to = x+2)}))
c
[1] 1 2 3 2 3 4 3 4 5
HTH,
Josh
On Mon, Jul 19, 2010 at 8:25 PM, Suphajak Ngamlak
wrote:
> I would like to create a vector that is a sequence from
I would like to create a vector that is a sequence from 2 vectors. Could
anyone provide suggestion on this?
For example
> a<-c(1,2,3)
> b<-a+2
> b
[1] 3 4 5
I would like to have a vector that is a sequence which starting from a
and ending at b
c = c(1:3,2:4,3:5)
c = c(1,2,3,2,3,4,3,4,5)
Thank
Hi Bogdan --
On 04/14/2010 08:19 PM, Bogdan Tanasa wrote:
> Dear all,
>
> please could you suggest any R functions or packages (or external
> programs), that
likely you'll have more luck on the Bioconductor mailing list,
http://bioconductor.org/docs/mailList.html
but...
> a. take as input a la
On Apr 14, 2010, at 11:19 PM, Bogdan Tanasa wrote:
Dear all,
please could you suggest any R functions or packages (or external
programs),
that
a. take as input a large number (> 10 000) of short 20-30 nt
sequences, and
do
sequence assembly, to reconstruct larger (extended) 30-50 sequenc
Dear all,
please could you suggest any R functions or packages (or external programs),
that
a. take as input a large number (> 10 000) of short 20-30 nt sequences, and
do
sequence assembly, to reconstruct larger (extended) 30-50 sequences ?
b. take as input a larger number of sequences (100 000
Here is one way of doing it:
> df<-data.frame(id=c("b","b","a","a","a"),ord=c(2,1,1,3,2))
> dates<-as.Date(c("02/27/92", "02/27/92", "01/14/92", "02/28/92",
+ "02/01/92"),"%m/%d/%y")
> df$dates<-dates
> df$seq <- ave(as.numeric(df$dates), df$id, FUN=order)
> df
id ord dates seq
1 b 2 199
Hello all,
As an example, consider the following dataframe
> df<-data.frame(id=c("b","b","a","a","a"),ord=c(2,1,1,3,2))
> dates<-as.Date(c("02/27/92", "02/27/92", "01/14/92", "02/28/92",
> "02/01/92"),"%m/%d/%y")
> df$dates<-dates
which was ordered with
> df<-df[order(df$id,df$dates),]
Now I
One can also use
formatC()
with the flag option.
-Don
At 10:47 AM -0200 1/25/10, Henrique Dallazuanna wrote:
Try sprintf:
sprintf("%03d", Sequence)
sprintf("file%03d.dat", Sequence)
On Mon, Jan 25, 2010 at 10:39 AM, Îroutík wrote:
Dear R-users,
I'd like to create filenames in a mask
Try sprintf:
sprintf("%03d", Sequence)
sprintf("file%03d.dat", Sequence)
On Mon, Jan 25, 2010 at 10:39 AM, Žroutík wrote:
> Dear R-users,
>
> I'd like to create filenames in a mask "file000.dat" numbered from 1 to e.g.
> 123. The last problem I'm dealing with is creating the sequence of numbe
Dear R-users,
I'd like to create filenames in a mask "file000.dat" numbered from 1 to e.g.
123. The last problem I'm dealing with is creating the sequence of numbers
with equal length, i.e. 001, 002, 023, 024, 122, 123.
The closest I got is by a repetition:
Sequence <- c(1:123)
for(i in
Manuel Jesús López Rodríguez wrote:
Dear all,
I would like to know how could I execute a sequence or orders with just a
function, i.e, that just typing the function name, R gives me all the
parameters I want (for instance, if I want to see the summary, the standard
deviation, the number of val
On 11/30/2009 07:17 AM, Manuel Jesús López Rodríguez wrote:
Dear all,
I would like to know how could I execute a sequence or orders with just a
function, i.e, that just typing the function name, R gives me all the
parameters I want (for instance, if I want to see the summary, the standard
devi
You don't see the standard deviations because
only the final result (the output of summary() in
your case) is output by the function, not the
intermediate results (the results of the apply()
function in your case).
Try this:
resumen<-function(x) {
print( apply(x,2,sd,na.rm=TRUE))
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Manuel Jesús López Rodríguez
> Sent: Sunday, November 29, 2009 12:17 PM
> To: r-help@r-project.org
> Subject: [R] sequence of commands in R
>
> Dear all
Dear all,
I would like to know how could I execute a sequence or orders with just a
function, i.e, that just typing the function name, R gives me all the
parameters I want (for instance, if I want to see the summary, the standard
deviation, the number of valid cases, etc of a dataframe just with
Hi
r-help-boun...@r-project.org napsal dne 29.08.2009 21:49:54:
> On Sat, Aug 29, 2009 at 8:14 PM, njhuang86 wrote:
> >
> > Hey guys,
> >
> > I was wondering how to create this sequence: 1, 2, 3, 1, 2, 3, 1, 2,
3, 1,
> > 2, 3... with the '1, 2, 3' repeated over 10 times.
>
> rep(1:3,10) # rep
Of Barry Rowlingson
> Sent: Saturday, August 29, 2009 1:50 PM
> To: njhuang86
> Cc: r-help@r-project.org
> Subject: Re: [R] Sequence generation
>
> On Sat, Aug 29, 2009 at 8:14 PM, njhuang86 wrote:
> >
> > Hey guys,
> >
> > I was wondering how to create this s
On Sat, Aug 29, 2009 at 8:14 PM, njhuang86 wrote:
>
> Hey guys,
>
> I was wondering how to create this sequence: 1, 2, 3, 1, 2, 3, 1, 2, 3, 1,
> 2, 3... with the '1, 2, 3' repeated over 10 times.
rep(1:3,10) # rep repeats its first argument according to the number
in its second argument
> Also,
On Aug 29, 2009, at 3:14 PM, njhuang86 wrote:
Hey guys,
I was wondering how to create this sequence: 1, 2, 3, 1, 2, 3, 1, 2,
3, 1,
2, 3... with the '1, 2, 3' repeated over 10 times.
As noted earlier
rep(1:3, 10)
Also, is there a simple method to generate 1, 1, 1, 2, 2, 2, 3, 3, 3?
I think should work
rep(c(1,2,3),10)
Alfredo
On Sat Aug 29 15:14:15 EDT 2009, njhuang86
wrote:
Hey guys,
I was wondering how to create this sequence: 1, 2, 3, 1, 2, 3, 1,
2, 3, 1,
2, 3... with the '1, 2, 3' repeated over 10 times.
Also, is there a simple method to generate 1, 1, 1,
Hey guys,
I was wondering how to create this sequence: 1, 2, 3, 1, 2, 3, 1, 2, 3, 1,
2, 3... with the '1, 2, 3' repeated over 10 times.
Also, is there a simple method to generate 1, 1, 1, 2, 2, 2, 3, 3, 3?
Anyways, any help with be greatly appreciated!
--
View this message in context:
http://
> -Original Message-
> From: r-help-boun...@r-project.org
> [mailto:r-help-boun...@r-project.org] On Behalf Of David Freedman
> Sent: Friday, May 01, 2009 11:52 AM
> To: r-help@r-project.org
> Subject: [R] sequence number for 'long format'
>
>
> D
Try this:
ds$seq <- ave(ds$id, ds$id, FUN = seq_along)
On Fri, May 1, 2009 at 2:52 PM, David Freedman <3.14da...@gmail.com> wrote:
>
> Dear R-help list,
>
> I've got a data set in long format - each subject can have several (varying
> in number) measurements, with each record representing one me
Dear R-help list,
I've got a data set in long format - each subject can have several (varying
in number) measurements, with each record representing one measurement. I
want to assign a sequence number to each measurement, starting at 1 for a
person's first measurement. I can do this with the by
one way is the following:
5 - abs(-4:4)
I hope it helps.
Best,
Dimitris
Monte Milanuk wrote:
I hit a minor sticking point working one of the problems in 'Using R'
(Verzani). I'm having difficulty with generating a sequence that goes
1, 2, 3, 4, 5, 4, 3, 2, 1. I can make one that counts up
I hit a minor sticking point working one of the problems in 'Using R'
(Verzani). I'm having difficulty with generating a sequence that goes
1, 2, 3, 4, 5, 4, 3, 2, 1. I can make one that counts up, I can make
one that counts down, etc. but one that counts up then down like this
(short of just
al Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris Oldmeadow
Sent: Tuesday, August 26, 2008 12:42 AM
To: r-help@r-project.org
Subject: [R] sequence with start and stop positions
Hi,
I have a vector of start positions, and another vector of
stop positions,
eg start&
On Tue, 26 Aug 2008, Chris Oldmeadow wrote:
Hi,
I have a vector of start positions, and another vector of stop positions,
eg start<-c(1,20,50)
stop<-c(7,25,53)
Is there a quick way to create a sequence from these vectors?
new<-c(1,2,3,4,5,6,7,20,21,22,23,24,25,50,51,52,53)
Vectorize t
> To: r-help@r-project.org
> Subject: [R] sequence with start and stop positions
>
> Hi,
>
> I have a vector of start positions, and another vector of
> stop positions,
>
> eg start<-c(1,20,50)
> stop<-c(7,25,53)
>
> Is there a quick
ww.cmis.csiro.au/bill.venables/
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Oldmeadow
Sent: Tuesday, 26 August 2008 2:42 PM
To: r-help@r-project.org
Subject: [R] sequence with start and stop positions
Hi,
I have a vector of start positions, and another vecto
Hi,
I have a vector of start positions, and another vector of stop positions,
eg start<-c(1,20,50)
stop<-c(7,25,53)
Is there a quick way to create a sequence from these vectors?
new<-c(1,2,3,4,5,6,7,20,21,22,23,24,25,50,51,52,53)
the way Im doing it at the moment is
pos<-seq(start[1],sto
Well, this is a natural thing to program up using 3 nested 'for',
loops. Alternatively, one could use something like:
> combn <- function( ..., l=list(...) )
+ {
+ lens <- sapply( args, length)
+ ncomb <- prod(lens)
+ retval <- matrix(ncol=length(args), nrow=ncomb)
+ for(i in 1:leng
statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney
-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Marc Bernard
Verzonden: maandag 19 november 2007 16:00
Aan: [EMAIL PROTECTED]
Onderwerp: [R
://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: "Marc Bernard" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 19, 2007 3:59 PM
Subject: [R] sequence of vectors
> Dear All,
>
> I wonder if there is any R fun
?expand.grid should do what you want.
--- Marc Bernard <[EMAIL PROTECTED]> wrote:
> Dear All,
>
> I wonder if there is any R function to generate a
> sequence of vectors from existing ones. For example:
> x 1<- c(1,2,3)
> x2 <- c(4,5)
> x3 <- c(6,7,8)
>
> The desired output is
Dear All,
I wonder if there is any R function to generate a sequence of vectors from
existing ones. For example:
x 1<- c(1,2,3)
x2 <- c(4,5)
x3 <- c(6,7,8)
The desired output is a list of all 3*2*3 = 18 possible combinations of
elements of x1,x2 and x3. One element for example i
69 matches
Mail list logo