Re: [R] Easy 'apply' question

2011-03-11 Thread Aaron Polhamus
)[1]})) Hope this helps, Josh On Thu, Mar 10, 2011 at 5:11 PM, Aaron Polhamus aaronpolha...@gmail.com wrote: Dear list, I couldn't find a solution for this problem online, as simple as it seems. Here's the problem: #Construct test dataframe tf - data.frame(1:3,4:6,c

[R] Easy 'apply' question

2011-03-10 Thread Aaron Polhamus
Dear list, I couldn't find a solution for this problem online, as simple as it seems. Here's the problem: #Construct test dataframe tf - data.frame(1:3,4:6,c(A,A,A)) #Try the apply function I'm trying to use test - apply(tf,2,function(x) if(is.numeric(x)) mean(x) else unique(x)[1]) #Look at

[R] Difficult with round() function

2011-01-17 Thread Aaron Polhamus
, for whatever reason R doesn't read it that way. I would be very grateful for any advice on how I can either alter my approach entirely (I am sure there is a far more elegant way to regrid data in R) or a simple fix for this rounding error. Many thanks in advance, Aaron -- Aaron Polhamus aaronpolha

[R] Arrange elements on a matrix according to rowSums + short 'apply' Q

2010-12-02 Thread Aaron Polhamus
Greetings, My goal is to create a Markov transition matrix (probability of moving from one state to another) with the 'highest traffic' portion of the matrix occupying the top-left section. Consider the following sample: inputData - c( c(5, 3, 1, 6, 7), c(9, 7, 3, 10, 11), c(1, 2, 3,

Re: [R] Arrange elements on a matrix according to rowSums + short 'apply' Q

2010-12-02 Thread Aaron Polhamus
),] For the second, I don't know! HTH, Ivan Le 12/2/2010 09:46, Aaron Polhamus a écrit : Greetings, My goal is to create a Markov transition matrix (probability of moving from one state to another) with the 'highest traffic' portion of the matrix occupying the top-left section