[Rd] file.link on Windows 7

2012-12-08 Thread Rui Barradas

Hello,

A post to R-Help by Oliver Soong reports what seems to be a bug specific 
to Windows (I'm on Windows 7).

The original post is as follows:


from: Oliver Soong 
to: r-help 
date: Fri, 7 Dec 2012 22:07:49 -0800
subject: [R] file.link fails on NTFS

Windows 7 64-bit, R 2.15.2 i386.  Working directory is on an NTFS drive.


writeLines("", "file.txt")
file.link("file.txt", "link.txt")


Warning in file.link("file.txt", "link.txt") :
  cannot link 'link.txt' to 'link.txt', reason 'The system cannot find
the file specified'

No link is created.  The 'link.txt' to 'link.txt' is suspicious.  Does
this happen to anybody else?  I didn't find anything in my searches.

Oliver


The above code runs with no problems on Ubuntu 12.04/ R 2.15.2, 
file.link returns TRUE.
I've checked the sources and .Internal calls "file.link", executing 
do_filelink(). The segment in file src/main/platform.c seems right, not 
mistaking argument 'from' for 'to':


#ifdef Win32
wchar_t *from, *to;

from = filenameToWchar(STRING_ELT(f1, i%n1), TRUE);
to = filenameToWchar(STRING_ELT(f2, i%n2), TRUE);
LOGICAL(ans)[i] = CreateHardLinkW(to, from, NULL) != 0;
if(!LOGICAL(ans)[i]) {
warning(_("cannot link '%ls' to '%ls', reason '%s'"),
from, to, formatError(GetLastError()));
}
#else


But there's something going on. The link is not created and the warning 
message is wrong.


Bug report? (Why CreateHardLinkW, and not CreateHardLink?)

Rui Barradas

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


Re: [Rd] file.link on Windows 7

2012-12-08 Thread Rui Barradas

Sorry, forgot the session info.

> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252 LC_CTYPE=Portuguese_Portugal.1252
[3] LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Portugal.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base


Rui Barradas
Em 08-12-2012 11:38, Rui Barradas escreveu:

Hello,

A post to R-Help by Oliver Soong reports what seems to be a bug 
specific to Windows (I'm on Windows 7).

The original post is as follows:


from: Oliver Soong 
to: r-help 
date: Fri, 7 Dec 2012 22:07:49 -0800
subject: [R] file.link fails on NTFS

Windows 7 64-bit, R 2.15.2 i386.  Working directory is on an NTFS drive.


writeLines("", "file.txt")
file.link("file.txt", "link.txt")


Warning in file.link("file.txt", "link.txt") :
  cannot link 'link.txt' to 'link.txt', reason 'The system cannot find
the file specified'

No link is created.  The 'link.txt' to 'link.txt' is suspicious. Does
this happen to anybody else?  I didn't find anything in my searches.

Oliver


The above code runs with no problems on Ubuntu 12.04/ R 2.15.2, 
file.link returns TRUE.
I've checked the sources and .Internal calls "file.link", executing 
do_filelink(). The segment in file src/main/platform.c seems right, 
not mistaking argument 'from' for 'to':


#ifdef Win32
wchar_t *from, *to;

from = filenameToWchar(STRING_ELT(f1, i%n1), TRUE);
to = filenameToWchar(STRING_ELT(f2, i%n2), TRUE);
LOGICAL(ans)[i] = CreateHardLinkW(to, from, NULL) != 0;
if(!LOGICAL(ans)[i]) {
warning(_("cannot link '%ls' to '%ls', reason '%s'"),
from, to, formatError(GetLastError()));
}
#else


But there's something going on. The link is not created and the 
warning message is wrong.


Bug report? (Why CreateHardLinkW, and not CreateHardLink?)

Rui Barradas

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


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


Re: [Rd] file.link on Windows 7

2012-12-08 Thread Duncan Murdoch

On 12-12-08 6:38 AM, Rui Barradas wrote:

Hello,

A post to R-Help by Oliver Soong reports what seems to be a bug specific
to Windows (I'm on Windows 7).
The original post is as follows:


I see the bug, and will fix it.

Duncan Murdoch




from: Oliver Soong 
to: r-help 
date: Fri, 7 Dec 2012 22:07:49 -0800
subject: [R] file.link fails on NTFS

Windows 7 64-bit, R 2.15.2 i386.  Working directory is on an NTFS drive.


writeLines("", "file.txt")
file.link("file.txt", "link.txt")


Warning in file.link("file.txt", "link.txt") :
cannot link 'link.txt' to 'link.txt', reason 'The system cannot find
the file specified'

No link is created.  The 'link.txt' to 'link.txt' is suspicious.  Does
this happen to anybody else?  I didn't find anything in my searches.

Oliver


The above code runs with no problems on Ubuntu 12.04/ R 2.15.2,
file.link returns TRUE.
I've checked the sources and .Internal calls "file.link", executing
do_filelink(). The segment in file src/main/platform.c seems right, not
mistaking argument 'from' for 'to':

#ifdef Win32
  wchar_t *from, *to;

  from = filenameToWchar(STRING_ELT(f1, i%n1), TRUE);
  to = filenameToWchar(STRING_ELT(f2, i%n2), TRUE);
  LOGICAL(ans)[i] = CreateHardLinkW(to, from, NULL) != 0;
  if(!LOGICAL(ans)[i]) {
  warning(_("cannot link '%ls' to '%ls', reason '%s'"),
  from, to, formatError(GetLastError()));
  }
#else


But there's something going on. The link is not created and the warning
message is wrong.

Bug report? (Why CreateHardLinkW, and not CreateHardLink?)

Rui Barradas

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



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


[Rd] C function, double problem

2012-12-08 Thread mpietro
Hi everybody,

here's my problem:

i call a C function which calculates a large number of double values and
puts them into an array which is passed from R as a parameter in the
function (like  .C("function", other parameters, result =  as.double( c ( 1
: quantity ) ). 
When the values come back to R in the result array, they are all truncated
to their integer value (i.e. I lose the decimal parts). 
I think that the problem is that this calculated double numbers are actually
too long, with many decimals, because i changed in code  the calculated
values with arbitrary double values with a few decimals and it works.

Has anybody any idea of where the problem is?

Thanks in advance!



--
View this message in context: 
http://r.789695.n4.nabble.com/C-function-double-problem-tp4652537.html
Sent from the R devel mailing list archive at Nabble.com.

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


Re: [Rd] C function, double problem

2012-12-08 Thread Rui Barradas

Hello,

The double in R and the double in C are the same type, with the same 
number of decimals (64 bits), so it's not because the numbers are too long.

Try calling .C("function", other parameters, result = double(quantity)).
Or maybe the error is in the C code, of which we know nothing about.

Rui Barradas
Em 08-12-2012 02:26, mpietro escreveu:

Hi everybody,

here's my problem:

i call a C function which calculates a large number of double values and
puts them into an array which is passed from R as a parameter in the
function (like  .C("function", other parameters, result =  as.double( c ( 1
: quantity ) ).
When the values come back to R in the result array, they are all truncated
to their integer value (i.e. I lose the decimal parts).
I think that the problem is that this calculated double numbers are actually
too long, with many decimals, because i changed in code  the calculated
values with arbitrary double values with a few decimals and it works.

Has anybody any idea of where the problem is?

Thanks in advance!



--
View this message in context: 
http://r.789695.n4.nabble.com/C-function-double-problem-tp4652537.html
Sent from the R devel mailing list archive at Nabble.com.

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


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


Re: [Rd] C function, double problem

2012-12-08 Thread Dirk Eddelbuettel

That is great example of why folks should NOT use the .C() interface.

Rcpp can help here, __even if you do not use any Rcpp language features__.
Below is a showcase for the recent sourceCpp() function which takes a C++
file (shown below), converts it and optionally runs the embedded R
code. Think of as something like Sweave for mixing C++ and R rather than
Latex and R.

Source file is shown via cat on the cmdline:

edd@max:/tmp$ cat dblvec.cpp 

#include 

#include 

// [[Rcpp::export]]
std::vector dbl(std::vector x) {
  std::vector y(x.size());
  for (unsigned int i=0; i library(Rcpp); sourceCpp("dblvec.cpp")

R> myx <- seq(1.1, 5.5, by = 1.1)

R> print(dbl(myx))
[1]  2.2  4.4  6.6  8.8 11.0
R> 
R> 
edd@max:/tmp$ 

No make, compiler invocation, linking, ... which all happen behind the
scenes.  We just enjoy the C++ function to double the content of a double
vector. 


Hope this helps,  Dirk

-- 
Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com

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


[Rd] namespace S3 and S4 generic imports cannot both be satisfied:

2012-12-08 Thread Martin Morgan
PkgA wishes to write a method for 'unique' on S4 class 'A'. ?Methods indicates 
that one should


  setGeneric("unique")

  setClass("A")
  unique.A <- function(x, incomparables=FALSE, ...) {}
  setMethod(unique, "A", unique.A)

Both S3 and S4 methods need to be exported in the NAMESPACE

  import(methods)
  S3method(unique, A)
  exportMethods(unique)

PkgB introduces a new class and method

  setClass("B")
  unique.B <- function(x, incomparables=FALSE, ...) {}
  setMethod(unique, "B", unique.B)

and in the NAMESPACE has

  import(methods)
  importFrom(PkgA, unique)
  S3method(unique, B)
  exportMethods(unique)

Unfortuantely, R CMD check says that

* checking whether package 'PkgB' can be installed ... WARNING
Found the following significant warnings:
  Warning: found an S4 version of 'unique' so it has not been imported correctly
See '/home/mtmorgan/tmp/PkgB.Rcheck/00install.out' for details.

This is from (svn r61253) R-devel/src/library/base/R/namespace.R:1339, where the 
code finds the S4 generic, but not the S3 generic. Obviously the namespace 
cannot have both the S3 and S4 symbols defined, but this seems to be required? A 
workaround might extend the check to include getGeneric(genname)@default.


This scenario is reproducible in the attached tarball

  tar xzf PkgAB.tar.gz
  R CMD INSTALL PkgA
  R CMD check PkgB

Martin Morgan
--
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793


PkgAB.tar.gz
Description: GNU Zip compressed data
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel