On Thu, 23 Oct 2014, Sebastien Vauban wrote:

"Charles C. Berry" wrote:
On Thu, 23 Oct 2014, Sebastien Vauban wrote:

The following code does return a corrupted answer, while it's supposed
to return a sorted dataframe.

Not so. See below.

So, that's RStudio that's wrong, in some way?


Hmmm. Not exactly wrong.

There are a few wrinkles:

org-babel-R-write-object-command specifies a call to 'write.table(object)', where `object' is what is to be printed.

`write.table' coerces whatever it is trying to print to a `data.frame'. See ?write.table

There is a method for `table' in `as.data.frame'. Try

 as.data.frame(table(1:3))

in the console or R gui to get a sense of what happens.

There is also an `array' method for `as.data.frame', but with a one dimensional array it passes control to the `vector' method. Try:

as.data.frame(sort(table(1:3)))

So it is really differences in the result of as.data.frame() that you were seeing.

I DK what RStudio does, but it must try harder a little harder to present 1 dimensional arrays.

HTH,

Chuck



Reply via email to