CTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Rossi, Peter E.
> Sent: Friday, January 06, 2006 1:56 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] vectorization of groups of dot products
>
>
> I have a set of n vectors, x_1, ..., x_n, of the same length.
> I would like to fo
I have a set of n vectors, x_1, ..., x_n, of the same length.
I would like to form the vector of dot products -- x_1'x_1, ..., x_n'x_n
the fastest way I can think to do this is to put the vectors into a
matrix
and do
diag(crossprod(X))
however, this seems to be very wasteful since this comput
Hi,
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Dimitri Joe
> Sent: Friday, June 17, 2005 7:01 PM
> To: R-Help
> Subject: [R] vectorization
>
> Hi there,
>
> I have a data frame (mydata) with 1 numeric var
<[EMAIL PROTECTED]To: "R-Help"
.br> cc:
64150 b 54937.5
Is this what you wanted?
Kevin
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Dimitri Joe
Sent: Friday, June 17, 2005 10:01 AM
To: R-Help
Subject: [R] vectorization
Hi there,
I have a data frame (mydata) with 1 numeric variable
imitri Joe
Sent: Friday, June 17, 2005 1:01 PM
To: R-Help
Subject: [R] vectorization
Hi there,
I have a data frame (mydata) with 1 numeric variable (income) and 1 factor
(education). I want a new column in this data with the median income for
each education level. A obviously inneficient way to d
Here I go again with ave():
mydata$md <- ave(mydata$income, mydata$education, FUN=median, na.rm=TRUE)
IMHO it's one of the most under-rated helper functions in R.
Andy
> From: Dimitri Joe
>
> Hi there,
>
> I have a data frame (mydata) with 1 numeric variable (income)
> and 1 factor (educatio
Hi there,
I have a data frame (mydata) with 1 numeric variable (income) and 1 factor
(education). I want a new column in this data with the median income for each
education level. A obviously inneficient way to do this is
for ( k in 1: nrow(mydata) ){
l <- mydata$education[k]
mydata
Greetings,
Can anyone suggest me if we can vectorize the following problem
effectively?
I have two datasets, one dataset is portfolio of stocks returns on a
historical basis and another dataset consist of a bunch of factors (again on
a historical basis). I intend to compute a rolling n-day
great! many thanks, Phil
Cheers
christoph
Phil Spector wrote:
Christoph -
I think reshape is the function you're looking for:
tt <- data.frame(cbind(c(1,1,1,1,1,2,2,2,3,3,3,3),
+ c(10,12,8,33,34,3,27,77,34,45,4,39), c('a', 'b', 'b', 'a', 'c', 'c', 'c',
+ 'a', 'b', 'a', 'b', 'c')))
reshape(aggre
On Tue, 2005-02-01 at 23:28 +0100, Christoph Lehmann wrote:
> Hi
> I have a simple question:
>
> the following data.frame
>
> id iwv type
> 1 1 1a
> 2 1 2b
> 3 1 11b
> 4 1 5a
> 5 1 6c
> 6 2 4c
> 7 2 3c
> 8 2 10a
> 9 3 6b
>
Hi
I have a simple question:
the following data.frame
id iwv type
1 1 1a
2 1 2b
3 1 11b
4 1 5a
5 1 6c
6 2 4c
7 2 3c
8 2 10a
9 3 6b
10 3 9a
11 3 8b
12 3 7c
shall be aggregated into the form:
id t.a t.b t.
Thank you very much to Tony Plate for his really clear explanation, and to
Prof Ripley for his time solving this deficiency (IMHO)
On Friday 15 August 2003 08:44, Martin Maechler wrote:
>
> Thank you, Tony. This certainly was the most precise
> explanation on this thread.
>
> Everyone note howe
> "Tony" == Tony Plate <[EMAIL PROTECTED]>
> on Thu, 14 Aug 2003 11:43:11 -0600 writes:
Tony> From ?data.frame:
>> Details:
>>
>> A data frame is a list of variables of the same length with unique
>> row names, given class `"data.frame"'.
Tony> Your example co
ter off using data.matrix, as
> data.matrix(x)
V1 V2 V3 V4
1 1 5 9 0
2 2 6 10 0
3 3 7 11 0
4 4 8 12 0
HTH,
Andy
> -Original Message-
> From: Alberto Murta [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 14, 2003 12:50 PM
> To: [EMAIL PROTECTED]
> Subject: [R]
Dear all
I recently noticed the following error when cohercing a data.frame into a
matrix:
> example <- matrix(1:12,4,3)
> example <- as.data.frame(example)
> example$V4 <- 0
> example
V1 V2 V3 V4
1 1 5 9 0
2 2 6 10 0
3 3 7 11 0
4 4 8 12 0
> example <- as.matrix(example)
Error in
From ?data.frame:
Details:
A data frame is a list of variables of the same length with unique
row names, given class `"data.frame"'.
Your example constructs an object that does not conform to the definition
of a data frame (the new column is not the same length as the old
columns). So
g data.matrix, as
>
> > data.matrix(x)
>
> V1 V2 V3 V4
> 1 1 5 9 0
> 2 2 6 10 0
> 3 3 7 11 0
> 4 4 8 12 0
>
> HTH,
> Andy
>
> > -Original Message-
> > From: Alberto Murta [mailto:[EMAIL PROTECTED]
> > Sent: Thursday,
18 matches
Mail list logo