Hi R users,
What is the fastest way to replace a(some) value(s) in a (numeric)
vector?
I checked ?replace, but its output is another vector.
1) I wonder if there's any function to perform in-place replacement?
2) Or any other function would do what I'm looking for with faster
speed?
# here is
yes, yes! I'm out of my mind.
Thank you.
-Original Message-
From: hadley wickham [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 20, 2008 5:49 PM
To: Ling, Gary (Electronic Trading)
Cc: r-help@r-project.org
Subject: Re: [R] fast value replacement in (numeric) vector
On Sat, Sep 20
Hi R users, I have a question which is some what related to this thread.
Here is the setup:
z is a list of lists, with no names.
zz is same is z, but with names.
with names on zz, I can crawl on the data with lapply, but I don't know how do
the same on z (without names). Can someone help?
###
YES! many many thanks, Jim.
I know it'd be simple, yet I can't believe it's that simple. =)
-gary
-Original Message-
From: jim holtman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 10, 2008 11:55 AM
To: Ling, Gary (Electronic Trading)
Cc: Peter Dalgaard; r-help@r-project.org
Hi Mark,
How about this?
result - sapply(split(res, res$Volume0)$`TRUE`, mean)
There is one thing I'm not sure: is res$Volume a vector or single
numeric?
-gary
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Altaweel, Mark R.
Sent: Wednesday, August
# between (a,b)
a - 0
b - 1
x - rnorm(10)
x
unclass(cut(x, breaks=c(-Inf,a,b,Inf)))==2
-gary
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Shubha Vishwanath Karanth
Sent: Tuesday, August 12, 2008 7:46 AM
To: [EMAIL PROTECTED]
Subject: [R] Between the
Hi Gary,
Thanks for your reply. This works fine. Is there any way to send the ACF
data to a matrix, so I could analyse the data in excel for e.g.?
Thanks,
rcoder
Ling, Gary (Electronic Trading) wrote:
Hi, here is one possible solution ...
-gary
### example ###
# create
A - matrix(rnorm(16)4,4)
o - c(1,3,2,4)
A[o,o]
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Zhang Yanwei - Princeton-MRAm
Sent: Thursday, August 07, 2008 10:31 AM
To: r-help@r-project.org
Subject: [R] Switch two rows in a matrix
Hi all,
I have a 4
Hi, here is one possible solution ...
-gary
### example ###
# create a 500x3 multi-ts
A - matrix(rnorm(1500),nrow=500)
# misc. graphical setting
par(mfrow=c(ncol(A),1))
# then our friend -- lapply(split(...))
lapply(split(A,col(A)), acf)
#Or
lapply(split(A,col(A)), function(ts) acf(ts,
Hi,
Yes. this is a way, and relatively easy ... Using Reduce. Note: in
order to use Reduce, you need an update-to-date version of R. I'm
using 2.6.2.
First you have to have all the matrices line up with correct dimensions,
i.e. [m_1 x m_2] %*% [m_2 x m_3] %*% ... %*% [m_(n-1) x m_n] (u get my
Here is my attempt. I'm not sure if that's the most efficient way to do
it, cause I'm cheating using the nice features from R, namely
duplicated().
I assume the matrices have same number of rows.
### example ###
### background setup: simulate 2 matrices with some common columns
(A - cbind(1:4,
Hi, just don't turn if off immediately, see example below:
Cheers,
Gary
# example
pdf(file=/home/user/tmp/moreplots.pdf)
for (i in 1:5) plot(rnorm(100))
dev.off()
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Rajasekaramya
Sent: Tuesday, August 05,
Hi Gundala,
You have to reorder the points, like below:
#(your code ...)
g - cbind(x,g.pdf)[order(x),]
points(x=[,1],y=g[,2],type='l',col=red)
Cheers,
gary
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Gundala Viswanath
Sent: Monday, August 04, 2008
13 matches
Mail list logo