Displaying 20 results from an estimated 8000 matches similar to: "A function like sum but with functions other than '+'"
2005 Jan 17
3
iproute2 + iptables - match the connection time or packets sent/recieved
Hello,
I setup iproute2 and iptables on my box, is a P4 2000 Ghz / 1GB memory.
I have setup squid and iptables to be a transparent proxy, with cache.
I''ve read on lartc.org almost everything and i want to ask if there is a u32
match for the connection time or something like that, or an u32 match for
the packet number in a connection.
All i want to do is shape the web traffic for long
2016 May 18
3
sum elements in the vector
Hi Rail,
We used a very simple pattern expansion (actually, not a pattern fragment). For example, for AND, ADD (horizontal sum), OR and XOR of 4 elements we use something like the following TableGen structure:
class HORIZ_Op4<SDNode opc, RegisterClass regVT, ValueType rt, ValueType vt, string asmstr> :
SHAVE_Instr<(outs regVT:$dst), (ins VRF128:$src),
2010 Jan 02
2
help with for loop
Dear useRs,
I want to write a function that generates all the possible combinations of diff().
Example:
If my vector has length 5, I need the diff() until lag=4 ->
c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3), diff(my.vec, lag=4))
If it has length 4, I need until lag=3 ->
c(diff(my.vec), diff(my.vec, lag=2), diff(my.vec, lag=3))
So, it must be until lag=(length(my.vec)-1).
2019 May 31
2
[patch] add sanity checks to quantile()
The attached patch adds some sanity checks to the "type" argument of
quantile(). Output from the following commands show the change of
behavior with the current patch:
vec <- 1:10
quantile(vec, type = c(1, 2))
quantile(vec, type = 10)
quantile(vec, type = "aaa")
quantile(vec, type = NA_real_)
quantile(vec, type = 4.3)
quantile(vec, type = -1)
Current behavior
2008 Dec 16
0
[LLVMdev] Another compiler shootout
On Tuesday 16 December 2008 01:03:36 Evan Cheng wrote:
> FYI. http://leonardo-m.livejournal.com/73732.html
>
> If anyone is motivated, please file bugs for the losing cases. Also,
> it might make sense to incorporate the tests into our nightly tester
> test suite.
FWIW, I just ported my ray tracer benchmark to C and found that llvm-gcc gives
much worse performance than gcc on x86
2008 Mar 13
3
fast way to compare two matrices of combinations
I have a list (length 750), each element containing a vector of unique
strings (unique gene ids), with length up to ~40 (median 15). I want to
compile a matrix of all possible triplets and their frequency within
gene elements. Using combn and a lot of looping, I am accomplishing this
but it is VERY slow.
I've tried to figure out a way to vectorize this, using "match" and
2008 Dec 24
3
Extract values based on indexes without looping?
Dear R-Helpers:
I am a entry level user of R.
Have the following question. Many thanks in advance.
# value.vec stores values
value.vec <- c('a','b','c')
# which.vec stores the locations/indexs of values in value.vec.
which.vec <- c(3, 2, 2, 1)
# How can I obtain the following vector based on the value.vec and which.vec
mentioned above
# vector.I.want <-
2002 Aug 21
1
is.numeric()
Dear R-list
I am having troubles understanding how the function is.numeric() works.
Any help appreciated.
Some commands are given here (the output and my comments are given
below)
vec <- c(1.4, NA, NA, NA)
sapply(vec,FUN=is.numeric)
is.numeric(vec[2])
is.na(vec[2])
is.numeric(NA)
vec <- c(TRUE, FALSE, NA, NA)
sapply(vec,FUN=is.numeric)
is.numeric(vec[2])
is.numeric(vec[3])
2008 Dec 23
1
quotation problem/dataframe names as function input argument.
Dear R friends:
Can someone help me with the following problem? Many thanks in advance.
# Problem Description:
# I want to write functions which take a (character) vector of dataframe
names as input argument.
# For example, I want to extract the number of observations from a number of
dataframes.
# I tried the following:
nobs.fun <- function (dframe.vec)
{
nobs.vec <-
2016 Aug 04
1
findInterval(all.inside=TRUE) for degenerate 'vec' arguments
What should findInterval(x,vec,all.inside=TRUE) return when length(vec)<=1,
so there are no inside intervals?
R-3.3.0 gives a decreasing map of x->output when length(vec)==1 and -1's
when length(vec)==0. Would '0' in all those cases be better?
> findInterval(x=c(10, 11, 12), vec=11, all.inside=TRUE,
rightmost.closed=FALSE, left.open=FALSE)
[1] 1 0 0
>
2009 Sep 01
2
cbind objects using character vectors
Dear list,
I have a character vector such vec.names<- c("a", "b")
It happens that I have also two R objects called "a" and "b" that I would
like to merge. Is it possible to
do something like cbind(vec.names[1], vec.names[2]) ending up with the same
result as cbind(a,b)
Bellow is a reproducible example of what I need to to:
dat<-
2010 Jan 29
2
Explanation w.r.t. rbind, please!
This is what I tried:
> num.vec <- c(12.34,56.78,90.12,34.56)
> names(num.vec)<-c("first","second","third","fourth")
> num.vec
first second third fourth
12.34 56.78 90.12 34.56
> seq<-(1:4)
> num.mat<-rbind(num.vec,seq)
> num.mat
first second third fourth
num.vec
2018 Aug 05
2
MASS::boxcox "object not found"
Hi there,
I wrote a function that wraps MASS::boxcox as:
bc <- function(vec) {
lam <- boxcox(lm(vec ~ 1))
lam <- lam$x[which.max(lam$y)]
(vec^lam - 1)/lam
}
When I invoke it as:
> x <- runif(20)
> bc(x)
Error in eval(predvars, data, env) : object 'vec' not found
I have googled, and rewrote the above function as:
bc <- function(vec) {
dat <<-
2018 Aug 05
2
MASS::boxcox "object not found"
Hi there,
I wrote a function that wraps MASS::boxcox as:
bc <- function(vec) {
lam <- boxcox(lm(vec ~ 1))
lam <- lam$x[which.max(lam$y)]
(vec^lam - 1)/lam
}
When I invoke it as:
> x <- runif(20)
> bc(x)
Error in eval(predvars, data, env) : object 'vec' not found
I have googled, and rewrote the above function as:
bc <- function(vec) {
dat <<-
2009 Sep 04
2
help with functions
Hi all,
I have got 2 function (see bellow) which are simplifications of what I need
to do. These functions are precisely the same, except for the last line.
My question is, why doesn't function testA work in the same way as function
testB.
Both functions produce two objects, "a" and "b" that must merged with rbind.
The difference is that in testA, I specify the name
2009 Jul 04
4
help with dealing with integer(0) returns from grep used within a conditional loop
I am using grep to locate colnames to automate a report build and have
run into a problem when a colname is not found. The use of integer(0)
in a conditional statement seems to be a no no as it has length 0.
Below is a self-contained trivial example. I would like to get
something like "NA" or -1 for the position when it is not found OR
learn a way to use integer(0) or some
2002 Jul 09
3
Error handling
Hi
I wrote a function implementing an algoritm for simulation of spatial
sampling plans (using geoR).
I'm using a range of parameters to perform several simulation and
sometimes this parameters create function errors wich cause the algoritm
to stop.
How can I avoid this ?
Below there's a small example that I made to study the problem but I was
not able to solve it. I've tried
2011 Sep 26
4
Testing for arguments in a function
I don't understand how this function can subset by i when i is missing....
## My function:
myfun = function(vec, i){
ret = vec[i]
ret
}
## My data:
i = 10
vec = 1:100
## Expected input and behavior:
myfun(vec, i)
## Missing an argument, but error is not caught!
## How is subsetting even possible here???
myfun(vec)
Is there a way to check for missing function arguments, *and*
2010 Aug 17
4
replacing values in a vector
Dear helpRs
Does anyone have an elegant way of doing the following:
For a given numeric vector, e.g. vec <- c(3,2,6,4,7)
Create a series of vectors where all but 1 of the values are replaced by
0's, e.g.
vec.a <- c(3,0,0,0,0)
vec.b <- c(0,2,0,0,0)
vec.c <- c(0,0,6,0,0)
vec.d <- c(0,0,0,4,0)
vec.e <- c(0,0,0,0,7)
I have looked at `replace', but can't think of a
2018 Oct 26
1
Rmpfr: build vector sequentially -- c(.) not working
I've been asked in private,
but am answering in public so others can comment / or find this
answer in the future after a web search.
This is about the package 'Rmpfr' (R interface to MPFR,
the GNU C library for arbitrary precise numbers).
> How can you build a vector of mpfr numbers sequentially?
> Typically I would do something like the following (and try to
> replace the