Displaying 20 results from an estimated 10000 matches similar to: "sequence with start and stop positions"
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
2008 Dec 16
8
sliding window over a large vector
Hi all,
I have a very large binary vector, I wish to calculate the number of
1's over sliding windows.
this is my very slow function
slide<-function(seq,window){
n<-length(seq)-window
tot<-c()
tot[1]<-sum(seq[1:window])
for (i in 2:n) {
tot[i]<- tot[i-1]-seq[i-1]+seq[i]
}
return(tot)
}
this works well for for reasonably sized vectors. Does
2008 Oct 07
3
vectorized sub, gsub, grep, etc.
R pattern-matching and replacement functions are
vectorized: they can operate on vectors of targets.
However, they can only use one pattern and replacement.
Here is code to apply a different pattern and replacement
for every target. My question: can it be done better?
sub2 <- function(pattern, replacement, x) {
len <- length(x)
if (length(pattern) == 1)
pattern <-
2010 Jun 24
1
?to calculate sth for groups defined between points in one variable (string), / value separating/ spliting variable into groups by i.e. between start, NA, NA, stop1, start2, NA, stop2
Dear useRs,
Thanks for any advices
# I do not know where are the examples how to mark groups
# based on signal occurence in the additional variable: cf. variable c2,
# How to calculate different calculations for groups defined by (split by occurence of c2 characteristic data)
#First example of simple data
#mexample 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
2007 Jan 23
3
Matrix operations in a list
I have matrices stored within a list like something as follows:
a <- list(matrix(rnorm(50), ncol=5), matrix(rnorm(50), ncol=5))
b <- list(matrix(rnorm(50), nrow=5), matrix(rnorm(50), nrow=5))
I don't recall how to perform matrix multiplication on each list element
such that the result is a new list
result <- list(a[[1]]%*%b[[1]], a[[2]]%*%b[[2]])
I think I'm close with
2009 Jan 06
5
Using apply for two datasets
I can run one-sample t-test on an array, for example a matrix myData1,
with the following
apply(myData1, 2, t.test)
Is there a similar fashion using apply() or something else to run
2-sample t-test with datasets from two groups, myData1 and myData2,
without looping?
TIA,
Gang
2007 Nov 08
2
mapply, coxph, and model formula
Hello -
I am wanting to create some Cox PH models with coxph (in package
survival) using different datasets.
The code below illustrates my current approach and problem with
completing this.
### BEGIN R SAMPLE CODE ##############################
library(survival)
#Define a function to make test data
makeTestDF <- function(n) {
times <- sample(1:200, n, replace = TRUE)
event
2006 Feb 02
2
Titles in plots generated within tapply
How would one go about putting titles in each of several plots
that are generated from within a call to tapply? For example I'd
like the following two barplots to have titles 'Group 1' and
'Group 2', where '1' and '2' come from the levels of 'group'.
group <- gl(2, 10)
result <- sample(c('A', 'B'), size=length(group),
2012 Feb 08
4
String position character replacement
Hi,
Is there a way to efficiently replace specified indices in a string with another character? For example, if I had a vector of strings such as
[1] "hellohowareyoudoing"
[2] "imgoodhowareyou"
[3] "goodandyou"
[4] "yesimgoodijusttoldyou"
[5] "ohyesthatsright"
and had a list of positions that I want to replace with the character "-"
2007 Oct 11
2
Operating matrix positions
I have two equally long lists of equally large matrices . I now want to
generate a column that consists of the differences between position [i,j] in
matrix k in each list. That is, the first position in this new column is
'position [1,1] in matrix 1 (of list 1)' minus 'position [1,1] in matrix 1
(of list 2)', and so on, continuing to the next matrix as soon as the
current one is
2008 Jun 27
1
finding the suitable distribution
Dear R-users,
Attach with is my data..what i want to do is finding a suitable distribution for my data..I want to run a few test like the poisson and the exponential distribution. Please help me on how to find the p-value for poisson as well as the exponential distribution without knowing the parameter. Is it possible?? Thanks in advance.
love,
Anisah
-------------- next
2009 Feb 23
1
trade-off between speed and storage in matrix multiplications
Dear R-users,
I coded two equivalent ways to perform (in a simplified version)
some matrix multiplications I would like to use in a more general
framework.
In the first case I used Kronecker product and vectorization of a
certain matrix. This approach takes less time, but, as you may guess, I
run out of memory when dimensions are large.
In the second approach, I profited of sparseness and
2010 Jul 01
4
left end or right end
Dear all,
I am a biologist. I have two sets of distance P(start1, end1) and Q(start2,
end2).
The distance will be like this.
P ------------------------
Q ----------------------------------------
I want to know whether P falls closely to the right end or left end of Q.
P and Q are of different lengths for each data point. There are more than
10000 pairs of P and Q.
Is there any test or
2006 Oct 24
2
Plotmath expression
Hello,
I've been trying to plot a subscript in a text formula using plotmath but I
haven't been able to do so.
In my example below I would like the text label to show
X[min] = 10.1 +/- 5.5
Here is the code:
ll <- c(x=10.1, sde=5.5)
plot(1:10)
text(x=9, y=2, pos=2, expression(paste(X[min], "=", paste(ll,
collapse="+/-"))))
This works fine up to the inner paste
2012 Dec 27
5
[LLVMdev] Can simplifycfg kill llvm.lifetime intrinsics?
>> Oh, I was reading "precedes/following" as having static (dominance)
>> meaning. That is, in the above example you could not delete the store
>> since it is not true that
>> llvm.lifetime.end dominates it.
>>
>> Nick, is this what you had in mind? If not, then we must delete a
>> matching llvm.lifetime.end, but it is not clear how we define
2012 Dec 28
2
[LLVMdev] Can simplifycfg kill llvm.lifetime intrinsics?
> Suppose you have four lifetime operations on the same address in memory,
> with loads and stores all around them:
>
> start1--end1 .. start2--end2
>
> If you remove start1 then you have a bare pointer, the memory came from
> somewhere and you lose the optimization that loads before start1 become
> undef, but you don't miscompile.
This is assuming no looping after
2009 Dec 14
1
RPART - printing full splitting rule number on tree plot
Dear R-users
I am using RPART package to get regression trees. However having trouble getting the text function to put the full splitting rule number on the plot, instead to puts it in scientific notation. When a covariate has 1e4 or greater number of digits then the splitting rule number displayed on the plot is in scientific notation. But print.rpart displays the splitting rules in full.
2013 Dec 06
2
Using assign with mapply
I have a data frame whose first colum contains the names of the variables
and whose second colum contains the values to assign to them:
: kkk <- data.frame(vars=c("var1", "var2", "var3"),
vals=c(10, 20, 30), stringsAsFactors=F)
If I do
: assign(kkk$vars[1], kkk$vals[1])
it works
: var1
[1] 10
However, if I try with mapply
2012 Dec 28
0
[LLVMdev] Can simplifycfg kill llvm.lifetime intrinsics?
On 12/27/2012 12:35 PM, Rafael EspĂndola wrote:
>>> Oh, I was reading "precedes/following" as having static (dominance)
>>> meaning. That is, in the above example you could not delete the store
>>> since it is not true that
>>> llvm.lifetime.end dominates it.
>>>
>>> Nick, is this what you had in mind? If not, then we must delete a
2010 May 26
5
(no subject)
Dear group,
Here is my data frame:
> dput(u)
structure(list(DESCRIPTION = structure(c(2L, 5L, 6L, 7L, 9L,
11L, 12L, 15L, 14L, 16L, 1L, 10L, 3L, 4L, 13L, 8L, 17L), .Label = c("COFFEE
C Jul/10",
"COPPER May/10", "CORN Jul/10", "CORN May/10", "COTTON NO.2 Jul/10",
"CRUDE OIL miNY May/10", "GOLD Jun/10", "HENRY HUB