Skip to content
Prev 54288 / 63424 Next

Cannot Compute Box's M (Three Days Trying...)

On 28/10/2017 8:59 AM, Morkus wrote:
The last column in iris is actually a factor.  That's stored as an 
S3-classed integer vector with an attribute listing the levels.  Using 
strings instead can cause problems in a few R functions (they want 
factors, and don't do automatic conversions), but the errors you're 
seeing seem more fundamental.
That sounds like it could be serious.  Dataframe names shouldn't be 
particularly complicated, so there shouldn't be a problem evaluating 
them.  (But maybe this is just hard in Java for some reason.  As I've 
mentioned, I'm not familiar with the R Java interface.)  If there really 
is a problem with the way the names have been constructed, that would 
explain the error in str(), and would lead to lots of other weird problems.

Another way to look at R objects from within R is to use 
.Internal(inspect( x )).  For example,

 > .Internal(inspect(names(iris)))
@7f898ff9e2e8 16 STRSXP g0c4 [NAM(2)] (len=5, tl=0)
   @7f8992c41878 09 CHARSXP g0c2 [gp=0x61,ATT] [ASCII] [cached] 
"Sepal.Length"
   @7f8992c41840 09 CHARSXP g0c2 [gp=0x61] [ASCII] [cached] "Sepal.Width"
   @7f8992c41808 09 CHARSXP g0c2 [gp=0x61,ATT] [ASCII] [cached] 
"Petal.Length"
   @7f898ba99f78 09 CHARSXP g0c2 [gp=0x61,ATT] [ASCII] [cached] 
"Petal.Width"
   @7f898b9a3468 09 CHARSXP g0c1 [gp=0x61,ATT] [ASCII] [cached] "Species"

You can also look at R objects while in a debugger like gdb using the 
R_PV() function; see Writing R Extensions for details if this is 
something available to you.
I don't know anyone who does that.  It seems like a bad idea just 
because it's always easiest to do what everyone else does.

I think it's more common to call Java from R than the reverse.

Duncan Murdoch
Message-ID: <abe44eb4-e08a-087a-1870-dc73d1e59da4@gmail.com>
In-Reply-To: <9BD27QZMzsNhYUSXQNpmzB6M1_eswp75Vyk6vgZ67jKV3Mf8H3ji_fE_YVPRSOl9Pb7XZDy1nfJCHyqt5J8hzVCzg9JxsJ-piLcIeu_7JZ4=@protonmail.com>