[Rd] linking R.dll 32bit in Win64

2014-01-10 Thread Иван Мартовский
 I've a usual installation of R (the both versions 32 et 64) on Win7 64 bit are 
installed.
I'm trying to link my dll (32bit) to R.dll (32bit) from the folder C:\Program 
Files\R\R-2.15.3\bin\i386
when, from 32bit version of R, loading the package containing my dll (32bit) 
which is linked to R.dll (32bit), there is OnLoad() error.
because R.dll (32bit) cannot find appropriate windows dlls of 32bit 
(kernel32.dll, msvcrt.dll,...)
I attached the screenshot of dependency walker for more detail.
From this picture we can see that R.dll is linked to 64bit windows dlls.

My question : how have I to build my 32bit dll ? which linker options to use ? 
/DELAYLOAD ?

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] proposal: stats::as.matrix.ftable method

2014-01-10 Thread Michael Friendly
Following some discussion on R-help, I'd like to propose that an 
as.matrix method be added
to those available for ftable objects.  The reason for this is that 
there are a variety of situations
where one needs to flatten a 3+ way table, but then use that for 
analysis as a matrix, not just for
pretty-printing.  There is an as.table method to turn the result back to 
a table, but an as.matrix

method is missing.

> methods(class="ftable")
[1] as.data.frame.ftable* as.table.ftable* format.ftable*
[4] head.ftable*  print.ftable tail.ftable*

   Non-visible functions are asterisked
>

The function below was proposed by William Dunlop:

# as.matrix method for flattened tables

# modified from Willaim Dunlop, , R-Help, 01-09-2014
as.matrix.ftable <- function(x, sep="_", ...) {
makeDimNames <- function(vars) {
structure(
list(do.call(paste, c(rev(expand.grid(rev(vars))), 
list(sep=sep,

names = paste(collapse=sep, names(vars))
)
}
structure(
unclass(x),
dimnames=c(makeDimNames(attr(x, "row.vars")),
   makeDimNames(attr(x, "col.vars"))),
row.vars=NULL,
col.vars=NULL)
}

Some test cases:

> UCB <- UCBAdmissions
> as.matrix(ftable(Dept ~ Admit + Gender, data=UCB))
 Dept
Admit_GenderA   B   C   D   E   F
  Admitted_Male   512 353 120 138  53  22
  Admitted_Female  89  17 202 131  94  24
  Rejected_Male   313 207 205 279 138 351
  Rejected_Female  19   8 391 244 299 317
> as.matrix(ftable(Dept ~ ., data=UCB))
 Dept
Admit_GenderA   B   C   D   E   F
  Admitted_Male   512 353 120 138  53  22
  Admitted_Female  89  17 202 131  94  24
  Rejected_Male   313 207 205 279 138 351
  Rejected_Female  19   8 391 244 299 317
> as.matrix(ftable(Admit + Gender ~ Dept, data=UCB))
Admit_Gender
Dept Admitted_Male Admitted_Female Rejected_Male Rejected_Female
   A   512  89   313  19
   B   353  17   207   8
   C   120 202   205 391
   D   138 131   279 244
   E53  94   138 299
   F22  24   351 317
> as.matrix(ftable(Admit ~ ., data=UCB))
   Admit
Gender_Dept Admitted Rejected
   Male_A512  313
   Male_B353  207
   Male_C120  205
   Male_D138  279
   Male_E 53  138
   Male_F 22  351
   Female_A   89   19
   Female_B   178
   Female_C  202  391
   Female_D  131  244
   Female_E   94  299
   Female_F   24  317
>

Related functions: The vcd package defines a more extensive suite of 
similar structable functions,
including as.matrix.structable;  however that function doesn't supply 
appropriate dimnames for

the dimensions.  Given as.matrix.ftable(), that is easy to correct:

# use as.matrix.ftable, but
# need to remove other attributes: dnames, split_vertical
library(vcd)
as.matrix.structable <- function(x, sep="_", ...) {
structure(
as.matrix.ftable(x, sep, ...),
dnames = NULL,
split_vertical = NULL
)
}

Test:

> as.matrix(structable(Gender ~ Admit + Dept, data=UCB))
Gender
Admit_Dept   Male Female
  Admitted_A  512 89
  Admitted_B  353 17
  Admitted_C  120202
  Admitted_D  138131
  Admitted_E   53 94
  Admitted_F   22 24
  Rejected_A  313 19
  Rejected_B  207  8
  Rejected_C  205391
  Rejected_D  279244
  Rejected_E  138299
  Rejected_F  351317
> as.matrix(structable(Gender + Admit ~ Dept, data=UCB))
Gender_Admit
Dept Male_Admitted Male_Rejected Female_Admitted Female_Rejected
   A   512   313  89  19
   B   353   207  17   8
   C   120   205 202 391
   D   138   279 131 244
   E53   138  94 299
   F22   351  24 317
>

--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University  Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] linking R.dll 32bit in Win64

2014-01-10 Thread Prof Brian Ripley

On 10/01/2014 10:09, Иван Мартовский wrote:

  I've a usual installation of R (the both versions 32 et 64) on Win7 64 bit 
are installed.
I'm trying to link my dll (32bit) to R.dll (32bit) from the folder C:\Program 
Files\R\R-2.15.3\bin\i386
when, from 32bit version of R, loading the package containing my dll (32bit) 
which is linked to R.dll (32bit), there is OnLoad() error.
because R.dll (32bit) cannot find appropriate windows dlls of 32bit 
(kernel32.dll, msvcrt.dll,...)
I attached the screenshot of dependency walker for more detail.
 From this picture we can see that R.dll is linked to 64bit windows dlls.

My question : how have I to build my 32bit dll ? which linker options to use ? 
/DELAYLOAD ?


There was no screenshot by the time this was distributed.  See the 
posting guide at http://www.r-project.org/posting-guide.html .


But Windows automatically finds the correct system DLLs - see the MSDN 
documentation for LoadLibrary.   So we have nothing at all to go on 
here, and no special options are needed nor used.



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel