This is Circle 8.1.47 of 'The R Inferno'.
http://www.burns-stat.com/documents/books/the-r-inferno/
Pat
On 14/05/2013 09:52, Luca Nanetti wrote:
Dear experts,
I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a
bug, it is per spec, but it is so counterintuitive that I
t(apply(test,1,sample)) will also do.
As the OP noted, the results are simply transposed. So if an operation is
to be applied to rows, yielding modified rows, simply transpose the results.
Cheers,
Tsjerk
On Tue, May 14, 2013 at 12:07 PM, Ted Harding wrote:
> On 14-May-2013 09:46:32 Duncan Murd
On Tue, May 14, 2013 at 4:52 AM, Luca Nanetti wrote:
> Dear experts,
>
> I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a
> bug, it is per spec, but it is so counterintuitive that I thought it could
> be interesting.
>
> I have an array, let's say "test", dim=c(7,5).
>
>
On 14-May-2013 09:46:32 Duncan Murdoch wrote:
> On 13-05-14 4:52 AM, Luca Nanetti wrote:
>> Dear experts,
>>
>> I wanted to signal a peculiar, unexpected behaviour of 'apply'.
>> It is not a bug, it is per spec, but it is so counterintuitive
>> that I thought it could be interesting.
>>
>> I have a
Hello,
The problem is that apply returns the results vector by vector and in R
vectors are column vectors. This is not exclusive of apply with sample
as the function to be called, but of apply in general. Try, for instance
apply(test, 1, identity) # transposes the array
The rows are returne
On Tue, 14 May 2013, Luca Nanetti writes:
> Dear experts,
>
> I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a
> bug, it is per spec, but it is so counterintuitive that I thought it could
> be interesting.
>
> I have an array, let's say "test", dim=c(7,5).
>
>> test <-
On 13-05-14 4:52 AM, Luca Nanetti wrote:
Dear experts,
I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a
bug, it is per spec, but it is so counterintuitive that I thought it could
be interesting.
I have an array, let's say "test", dim=c(7,5).
test <- array(1:35, dim=
Dear experts,
I wanted to signal a peculiar, unexpected behaviour of 'apply'. It is not a
bug, it is per spec, but it is so counterintuitive that I thought it could
be interesting.
I have an array, let's say "test", dim=c(7,5).
> test <- array(1:35, dim=c(7, 5))
> test
[,1] [,2] [,3] [,4]
8 matches
Mail list logo