Displaying 3 results from an estimated 3 matches for "pfleonard".
Did you mean:
leonard
2003 Jun 09
1
Basic question on applying a function to each row of a da taframe
Another neat way is:
with(DF, foo(x, w))
HTH,
Andy
> -----Original Message-----
> From: peter leonard [mailto:pfleonard at hotmail.com]
> Sent: Sunday, June 08, 2003 4:35 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Basic question on applying a function to each row of a
> dataframe
>
>
> Hi,
>
> I have a function foo(x,y) and a dataframe, DF, comprised of
> two vectors, x
&...
2003 Jun 08
6
Basic question on applying a function to each row of a dataframe
Hi,
I have a function foo(x,y) and a dataframe, DF, comprised of two vectors, x
& w, as follows :
x w
1 1 1
2 2 1
3 3 1
4 4 1
etc
I would like to apply the function foo to each 'pair' within DF e.g
foo(1,1), foo(2,1), foo(3,1) etc
I have tried
>apply(DF,foo)
>apply(DF[,],foo)
>apply(DF[DF$x,DF$w],foo)
However, none of the above worked. Can anyone help ?
2003 May 31
3
function to populate a matrix based on a lookup to another matrix ?
Hi,
This is a beginner R question.
I have a 4x4 matrix named 'lookup' with the following values:
1 2 3 4
1 0.000000 2.828427 5.656854 8.485281
2 2.828427 0.000000 2.828427 5.656854
3 5.656854 2.828427 0.000000 2.828427
4 8.485281 5.656854 2.828427 0.000000
I then create a new empty matrix named 'dd' with specfic row and col names :