Re: [R] Bug? plot.formula does need support plot.first / plot.last param in plot.default

2024-07-07 Thread Erez Shomron
Thank you Ivan,

Yes I meant `panel.first`.
I fumbled the title and the examples, but the end result is the same:

```
# Works
with(mtcars, plot(wt, mpg, panel.first = {
arrows(3, 15, 4, 30)
}))

# Doesn't work
plot(mpg ~ wt, data = mtcars, panel.first = {
arrows(3, 15, 4, 30)
})

```

I saw the bug reported 13 years ago after-the-fact, and the paragraph I missed 
for the manual entry.
Thanks for clarifying both.

I do think making these arguments lazy evaluate would be a welcome change. It's 
especially confusing for new R users trying to use base graphics to plot their 
linear model. But I also understand this would be low priority as user 
workaround is simple (don't use the formula method), and because of the testing 
effort that would be required.

Maybe a warning would be nice, telling users that `panel.first` and 
`panel.last` are evaluated before plotting. I think users would check `?plot` 
before `?plot.formula` and would not see any reason not to try and pass these 
arguments.

Kind Regards,
Erez

On Sat, Jul 6, 2024, at 5:24 PM, Ivan Krylov wrote:
> В Fri, 05 Jul 2024 14:35:40 +0300
> "Erez Shomron"  пишет:
> 
> > This works as expected:
> 
> > with(mtcars, plot(wt, mpg, plot.first = {
> > plot.window(range(wt), range(mpg))
> > arrows(3, 15, 4, 30)
> > }))
> 
> I think you meant panel.first, not plot.first. At least I cannot find
> any mention of plot.first in the R source code. In this example,
> plot.first ends up being an argument of an internal call from
> plot.default() to plot.window(), which evaluates its ellipsis
> arguments. If your plot.first expression returned a non-NULL value, you
> would also have received a warning:
> 
> plot.window(0:1, 0:1, plot.first = message('hello'))
> # hello
> plot.window(0:1, 0:1, plot.first = 123)
> # Warning message:
> # In plot.window(0:1, 0:1, plot.first = 123) :
> #   "plot.first" is not a graphical parameter
> 
> It is indeed documented that "passing [panel.first] from other ‘plot’
> methods may well not work since it may be evaluated too early". The
> plot.formula method deliberately evaluates the arguments in the
> ellipsis, and the workaround suggested in
> https://bugs.r-project.org/show_bug.cgi?id=14591 doesn't help because
> the expression is then evaluated in an undesired environment (parent
> frame, not data).
> 
> You are correct that plot.formula tries to evaluate all its remaining
> arguments in the context of the data passed to the method. In order for
> the lazy evaluation to work, plot.formula would have to (1) know and
> skip all such arguments by name on line 6, minding partial matching, (2)
> rewrite them into the form evalq(original_argument_expression,
> model_frame, parent_frame) so that they would be able to access both
> the data and the variables visible in the frame of the caller, and (3)
> give these expressions to do.call() in place of the original ones.
> 
> (1) sounds especially brittle since plot.formula() may dispatch to
> other plot.* methods. Additionally, great care will need to be taken
> not to break existing code that calls plot.formula, even if it's
> already full of workarounds for plot.formula's behaviour.
> 
> -- 
> Best regards,
> Ivan
> 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug? plot.formula does need support plot.first / plot.last param in plot.default

2024-07-06 Thread Ivan Krylov via R-help
В Fri, 05 Jul 2024 14:35:40 +0300
"Erez Shomron"  пишет:

> This works as expected:

> with(mtcars, plot(wt, mpg, plot.first = {
> plot.window(range(wt), range(mpg))
> arrows(3, 15, 4, 30)
> }))

I think you meant panel.first, not plot.first. At least I cannot find
any mention of plot.first in the R source code. In this example,
plot.first ends up being an argument of an internal call from
plot.default() to plot.window(), which evaluates its ellipsis
arguments. If your plot.first expression returned a non-NULL value, you
would also have received a warning:

plot.window(0:1, 0:1, plot.first = message('hello'))
# hello
plot.window(0:1, 0:1, plot.first = 123)
# Warning message:
# In plot.window(0:1, 0:1, plot.first = 123) :
#   "plot.first" is not a graphical parameter

It is indeed documented that "passing [panel.first] from other ‘plot’
methods may well not work since it may be evaluated too early". The
plot.formula method deliberately evaluates the arguments in the
ellipsis, and the workaround suggested in
https://bugs.r-project.org/show_bug.cgi?id=14591 doesn't help because
the expression is then evaluated in an undesired environment (parent
frame, not data).

You are correct that plot.formula tries to evaluate all its remaining
arguments in the context of the data passed to the method. In order for
the lazy evaluation to work, plot.formula would have to (1) know and
skip all such arguments by name on line 6, minding partial matching, (2)
rewrite them into the form evalq(original_argument_expression,
model_frame, parent_frame) so that they would be able to access both
the data and the variables visible in the frame of the caller, and (3)
give these expressions to do.call() in place of the original ones.

(1) sounds especially brittle since plot.formula() may dispatch to
other plot.* methods. Additionally, great care will need to be taken
not to break existing code that calls plot.formula, even if it's
already full of workarounds for plot.formula's behaviour.

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug? plot.formula does need support plot.first / plot.last param in plot.default

2024-07-06 Thread Erez Shomron
Thanks for your answer.

Should I report in Bugzilla at least so it's tracked?

I can point that the issue is with line 6 of the function body:
```
dots <- lapply(m$..., eval, md, eframe)
```

I assume the intention was to evaluate the arguments with the context of data 
passed to the function.
But the expression in panel.first / panel.last gets evaluated before plot.new 
is called (as the error indicates).

I believe the fix would be to somehow not evaluate line 6, or replace with 
`dots <- m$...`, and when `plot` is later called, to somehow evaluate it with 
the data passed to the function. I tried to add `envir` argument to `do.call` 
but it does not work as I expected.

I would've liked to contribute a patch but my R knowledge is limited and and 
this `plot.formula` code is a bit of my head frankly.

Kindly,
Erez


On Sat, Jul 6, 2024, at 1:05 AM, Duncan Murdoch wrote:
> That definitely looks like a bug, but not one that anyone will be eager 
> to fix.  It's very old code that tried to be clever, and that's the 
> hardest kind of code to fix.
> 
> Remember Kernighan's Law:  "Everyone knows that debugging is twice as 
> hard as writing a program in the first place. So if you’re as clever as 
> you can be when you write it, how will you ever debug it?"
> 
> Duncan Murdoch
> 
> On 2024-07-05 7:35 a.m., Erez Shomron wrote:
> > Is the following a bug in your opinion? I think so.
> > 
> > This works as expected:
> > 
> > ```
> > with(mtcars, plot(wt, mpg, plot.first = {
> >  plot.window(range(wt), range(mpg))
> >  arrows(3, 15, 4, 30)
> > }))
> > ```
> > 
> > This does not.
> > 
> > ```
> > plot(mpg ~ wt, data = mtcars, plot.first = {
> >  plot.window(range(wt), range(mpg))
> >  arrows(3, 15, 4, 30)
> > })
> > ```
> > 
> > With error:
> > ```
> > Error in arrows(3, 15, 4, 30) : plot.new has not been called yet
> > ```
> > 
> > The second example should work.
> > 
> >  From the docs:
> > 
> > ?plot.formula
> > " For the ‘plot’ method the formula can be of the form ‘~ z + y +
> >   z’: the variables specified on the right-hand side are collected
> >   into a data frame, subsetted if specified, and displayed by
> >   ‘plot.data.frame’.
> > "
> > 
> > ?plot.data.frame
> > " ...: further arguments to ‘stripchart’, ‘plot.default’ or ‘pairs’.
> > "
> > 
> > And plot.default has both plot.first and plot.last
> > 
> > It seems very arbitrary you can't use these parameters with the 
> > plot.formula method specifically.
> > 
> >> sessionInfo()
> > R version 4.4.1 (2024-06-14)
> > Platform: x86_64-suse-linux-gnu
> > Running under: openSUSE Tumbleweed
> > [...]
> > 
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug? plot.formula does need support plot.first / plot.last param in plot.default

2024-07-05 Thread Duncan Murdoch
That definitely looks like a bug, but not one that anyone will be eager 
to fix.  It's very old code that tried to be clever, and that's the 
hardest kind of code to fix.


Remember Kernighan's Law:  "Everyone knows that debugging is twice as 
hard as writing a program in the first place. So if you’re as clever as 
you can be when you write it, how will you ever debug it?"


Duncan Murdoch

On 2024-07-05 7:35 a.m., Erez Shomron wrote:

Is the following a bug in your opinion? I think so.

This works as expected:

```
with(mtcars, plot(wt, mpg, plot.first = {
 plot.window(range(wt), range(mpg))
 arrows(3, 15, 4, 30)
}))
```

This does not.

```
plot(mpg ~ wt, data = mtcars, plot.first = {
 plot.window(range(wt), range(mpg))
 arrows(3, 15, 4, 30)
})
```

With error:
```
Error in arrows(3, 15, 4, 30) : plot.new has not been called yet
```

The second example should work.

 From the docs:

?plot.formula
" For the ‘plot’ method the formula can be of the form ‘~ z + y +
  z’: the variables specified on the right-hand side are collected
  into a data frame, subsetted if specified, and displayed by
  ‘plot.data.frame’.
"

?plot.data.frame
" ...: further arguments to ‘stripchart’, ‘plot.default’ or ‘pairs’.
"

And plot.default has both plot.first and plot.last

It seems very arbitrary you can't use these parameters with the plot.formula 
method specifically.


sessionInfo()

R version 4.4.1 (2024-06-14)
Platform: x86_64-suse-linux-gnu
Running under: openSUSE Tumbleweed
[...]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug? plot.formula does need support plot.first / plot.last param in plot.default

2024-07-05 Thread Erez Shomron
Is the following a bug in your opinion? I think so.

This works as expected:

```
with(mtcars, plot(wt, mpg, plot.first = {
plot.window(range(wt), range(mpg))
arrows(3, 15, 4, 30)
}))
```

This does not.

```
plot(mpg ~ wt, data = mtcars, plot.first = {
plot.window(range(wt), range(mpg))
arrows(3, 15, 4, 30)
})
```

With error:
```
Error in arrows(3, 15, 4, 30) : plot.new has not been called yet
```

The second example should work.

>From the docs:

?plot.formula
" For the ‘plot’ method the formula can be of the form ‘~ z + y +
 z’: the variables specified on the right-hand side are collected
 into a data frame, subsetted if specified, and displayed by
 ‘plot.data.frame’.
"

?plot.data.frame
" ...: further arguments to ‘stripchart’, ‘plot.default’ or ‘pairs’.
"

And plot.default has both plot.first and plot.last

It seems very arbitrary you can't use these parameters with the plot.formula 
method specifically.

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-suse-linux-gnu
Running under: openSUSE Tumbleweed
[...]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug with writeClipboard in {utils}

2024-06-21 Thread Ivan Krylov via R-help
В Thu, 20 Jun 2024 18:39:34 +0300
Ivan Krylov via R-help  пишет:

> > Is there a way to test this patch or will there soon be a published
> > patched R version available for download?  
> 
> Not directly.

Now that the bug is fixed in R-devel (thanks Tomas!), a Windows build
of the development version of R with the fix is available:
https://cran.r-project.org/bin/windows/base/rdevel.html

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug with writeClipboard in {utils}

2024-06-21 Thread Barthelemy Tanguy via R-help
Hello,

Thank you for your research and your bug report.
At the end of your bug report 
(https://bugs.r-project.org/show_bug.cgi?id=18747) you mentioned that "the 
problem doesn't reappear with the attached patch".

Is there a way to test this patch or will there soon be a published patched R 
version available for download?

Thank you again

Tanguy BARTHELEMY




De : Ivan Krylov 
Envoyé : mercredi 19 juin 2024 16:07
À : r-help@r-project.org
Cc : Barthelemy Tanguy
Objet : Re: [R] Bug with writeClipboard in {utils}

« Ce courriel provient d’un expéditeur extérieur à l’Insee. Compte tenu du 
contexte de menace cyber actuel il convient d’être extrêmement vigilant sur 
l’émetteur et son contenu avant d’ouvrir une pièce jointe, de cliquer sur un 
lien internet présent dans ce message ou d'y répondre. »


В Tue, 18 Jun 2024 10:12:04 +
Barthelemy Tanguy via R-help  пишет:

> #> [1] "plot(AirPassengers)" "⤀攀"
> #> [1] "plot(AirPassengers)" "\u0a00"
> #> [1] "plot(AirPassengers)" "\xed\xb0\x80ư"

Thanks for showing an example!

I was able to reproduce it both with R-4.3.1 on Windows 7 and with a
fresh R-devel build on Windows 10. Bug reported at
<https://bugs.r-project.org/show_bug.cgi?id=18747>.

--
Best regards,
Ivan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug with writeClipboard in {utils}

2024-06-21 Thread Barthelemy Tanguy via R-help
Hello,

Thank you for your different tests.

You have that you didn't find any errors with Rscript or with R but I have the 
impression that your test with R (second test) showed additional and unwanted 
characters (second line of the output)?

Thank you again

Tanguy BARTHELEMY



De : Rui Barradas 
Envoyé : mercredi 19 juin 2024 19:26
À : Barthelemy Tanguy; r-help@r-project.org
Objet : Re: [R] Bug with writeClipboard in {utils}

« Ce courriel provient d’un expéditeur extérieur à l’Insee. Compte tenu du 
contexte de menace cyber actuel il convient d’être extrêmement vigilant sur 
l’émetteur et son contenu avant d’ouvrir une pièce jointe, de cliquer sur un 
lien internet présent dans ce message ou d'y répondre. »


Às 11:12 de 18/06/2024, Barthelemy Tanguy via R-help escreveu:
> Hello,
>
> I'm encountering what seems to be a bug when using the `writeClipboard()` 
> function in the R {utils} package.
> When I try to copy text to the clipboard, I notice that I get extra 
> characters when I try to paste it (by hand with CTRL+V or with the 
> `readClipboard()` function from R packages {utils}).
>
> Here's my example:
>
> ``` r
> utils::writeClipboard("plot(AirPassengers)")
> for (k in 1:10) {
>  print(utils::readClipboard())
> }
> #> [1] "plot(AirPassengers)" "⤀攀"
> #> [1] "plot(AirPassengers)" "\u0a00"
> #> [1] "plot(AirPassengers)" "\xed\xb0\x80ư"
> #> [1] "plot(AirPassengers)"
> #> [1] "plot(AirPassengers)"
> #> [1] "plot(AirPassengers)"
> #> [1] "plot(AirPassengers)"
> #> [1] "plot(AirPassengers)"
> #> [1] "plot(AirPassengers)" "⤀"
> #> [1] "plot(AirPassengers)"
> Message d'avis :
> Dans utils::readClipboard() : unpaired surrogate Unicode point dc00
> ```
>
> So I don't always get the same result.
> I opened a problem in the {clipr} GitHub repository before realizing it's a 
> {tools} problem: https://github.com/mdlincoln/clipr/issues/68
>
> Is this a bug or something I haven't configured properly?
>
>
> Thank you very much
>
>
> Tanguy BARTHELEMY
>
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Hello,

I have reproduced part of the behavior in the OP but it will depend on
the GUI or command line used.

With Rscript or with R I haven't found any errors.
With Rgui or with RStudio, yes, the output was not the expected output.

All code run in R 4.4.0 on Windows 11.

The script rscript.R is


utils::capture.output({
utils::writeClipboard("plot(AirPassengers)")
for (k in 1:10) {
   print(utils::readClipboard())
}
sessionInfo()
}, file = "rhelp.txt")


---

Here are the results I got.

1) Command:

Rscript rscript.R

Output:

[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8
LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C

[5] LC_TIME=Portuguese_Portugal.utf8

time zone: Europe/Lisbon
tzcode source: internal

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

loaded via a namespace (and not attached):
[1] compiler_4.4.0

---

2) Command:
R -q -f rscript.R

Output:

 > utils::writeClipboard("plot(AirPassengers)")
 > for (k in 1:10) {
+ print(utils::readClipboard())
+ }
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)" "㨀Ǐ\005"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
 > sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8
LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C

[5]

Re: [R] Bug with writeClipboard in {utils}

2024-06-20 Thread Ivan Krylov via R-help
В Thu, 20 Jun 2024 13:21:38 +
Barthelemy Tanguy  пишет:

> Is there a way to test this patch or will there soon be a published
> patched R version available for download?

Not directly. If you're willing to follow the partially manual process
yourself, the instructions at [1] describe how to download R-devel and
compile the program. It's not spelled out anywhere how to apply patches
(some work is in progress at [2]), so feel free to ask additional
questions about `svn patch` if you would like to go this way.

Alternatively, taking a patch and submitting it as a pull request to
https://github.com/r-devel/r-svn will result in several checks being
run on it, one of which builds an R installer (e.g. see the artifacts
at [3]).

The remaining option is to wait for the bug to be fixed. Allocating
enough space for the terminator is probably necessary, but the R
developers may also decide to make readClipboard() more robust against
missing terminators.

Some fixes can be backported to R-patched; snapshots of R-patched
compiled for Windows are available from CRAN. R-patched may eventually
become R-4.4.2. If not backported, the fix will appear in the next
version of R.

-- 
Best regards,
Ivan

[1]
https://cran.r-project.org/bin/windows/base/howto-R-devel.html#building-r-from-source-using-rtools44

[2]
https://github.com/r-devel/rdevguide/issues/170

[3]
https://github.com/r-devel/r-svn/actions/runs/8749727418

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug with writeClipboard in {utils}

2024-06-20 Thread Rui Barradas

Hello,

Inline.

Às 14:15 de 20/06/2024, Barthelemy Tanguy escreveu:

Hello,

Thank you for your different tests.

You have that you didn't find any errors with Rscript or with R but I have the 
impression that your test with R (second test) showed additional and unwanted 
characters (second line of the output)?


You are right, in the case I posted there were unwanted characters.
Most of the tests I ran there were no additional, unwanted charcters, 
though.

This is definitely unstable, that's all I can say.

Hope this helps,

Rui Barradas


Thank you again

Tanguy BARTHELEMY



De : Rui Barradas 
Envoyé : mercredi 19 juin 2024 19:26
À : Barthelemy Tanguy; r-help@r-project.org
Objet : Re: [R] Bug with writeClipboard in {utils}

« Ce courriel provient d’un expéditeur extérieur à l’Insee. Compte tenu du 
contexte de menace cyber actuel il convient d’être extrêmement vigilant sur 
l’émetteur et son contenu avant d’ouvrir une pièce jointe, de cliquer sur un 
lien internet présent dans ce message ou d'y répondre. »


Às 11:12 de 18/06/2024, Barthelemy Tanguy via R-help escreveu:

Hello,

I'm encountering what seems to be a bug when using the `writeClipboard()` 
function in the R {utils} package.
When I try to copy text to the clipboard, I notice that I get extra characters 
when I try to paste it (by hand with CTRL+V or with the `readClipboard()` 
function from R packages {utils}).

Here's my example:

``` r
utils::writeClipboard("plot(AirPassengers)")
for (k in 1:10) {
  print(utils::readClipboard())
}
#> [1] "plot(AirPassengers)" "⤀攀"
#> [1] "plot(AirPassengers)" "\u0a00"
#> [1] "plot(AirPassengers)" "\xed\xb0\x80ư"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)" "⤀"
#> [1] "plot(AirPassengers)"
Message d'avis :
Dans utils::readClipboard() : unpaired surrogate Unicode point dc00
```

So I don't always get the same result.
I opened a problem in the {clipr} GitHub repository before realizing it's a 
{tools} problem: https://github.com/mdlincoln/clipr/issues/68

Is this a bug or something I haven't configured properly?


Thank you very much


Tanguy BARTHELEMY


   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Hello,

I have reproduced part of the behavior in the OP but it will depend on
the GUI or command line used.

With Rscript or with R I haven't found any errors.
With Rgui or with RStudio, yes, the output was not the expected output.

All code run in R 4.4.0 on Windows 11.

The script rscript.R is


utils::capture.output({
utils::writeClipboard("plot(AirPassengers)")
for (k in 1:10) {
print(utils::readClipboard())
}
sessionInfo()
}, file = "rhelp.txt")


---

Here are the results I got.

1) Command:

Rscript rscript.R

Output:

[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8
LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C

[5] LC_TIME=Portuguese_Portugal.utf8

time zone: Europe/Lisbon
tzcode source: internal

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

loaded via a namespace (and not attached):
[1] compiler_4.4.0

---

2) Command:
R -q -f rscript.R

Output:

  > utils::writeClipboard("plot(AirPassengers)")
  > for (k in 1:10) {
+ print(utils::readClipboard())
+ }
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)" "㨀Ǐ\005"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
  > sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8
LC_CTYPE=

Re: [R] Bug with writeClipboard in {utils}

2024-06-19 Thread Rui Barradas

Às 11:12 de 18/06/2024, Barthelemy Tanguy via R-help escreveu:

Hello,

I'm encountering what seems to be a bug when using the `writeClipboard()` 
function in the R {utils} package.
When I try to copy text to the clipboard, I notice that I get extra characters 
when I try to paste it (by hand with CTRL+V or with the `readClipboard()` 
function from R packages {utils}).

Here's my example:

``` r
utils::writeClipboard("plot(AirPassengers)")
for (k in 1:10) {
 print(utils::readClipboard())
}
#> [1] "plot(AirPassengers)" "⤀攀"
#> [1] "plot(AirPassengers)" "\u0a00"
#> [1] "plot(AirPassengers)" "\xed\xb0\x80ư"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)" "⤀"
#> [1] "plot(AirPassengers)"
Message d'avis :
Dans utils::readClipboard() : unpaired surrogate Unicode point dc00
```

So I don't always get the same result.
I opened a problem in the {clipr} GitHub repository before realizing it's a 
{tools} problem: https://github.com/mdlincoln/clipr/issues/68

Is this a bug or something I haven't configured properly?


Thank you very much


Tanguy BARTHELEMY


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Hello,

I have reproduced part of the behavior in the OP but it will depend on 
the GUI or command line used.


With Rscript or with R I haven't found any errors.
With Rgui or with RStudio, yes, the output was not the expected output.

All code run in R 4.4.0 on Windows 11.

The script rscript.R is


utils::capture.output({
utils::writeClipboard("plot(AirPassengers)")
for (k in 1:10) {
  print(utils::readClipboard())
}
sessionInfo()
}, file = "rhelp.txt")


---

Here are the results I got.

1) Command:

Rscript rscript.R

Output:

[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8 
LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C 


[5] LC_TIME=Portuguese_Portugal.utf8

time zone: Europe/Lisbon
tzcode source: internal

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

loaded via a namespace (and not attached):
[1] compiler_4.4.0

---

2) Command:
R -q -f rscript.R

Output:

> utils::writeClipboard("plot(AirPassengers)")
> for (k in 1:10) {
+ print(utils::readClipboard())
+ }
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)" "㨀Ǐ\005"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
> sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8 
LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C 


[5] LC_TIME=Portuguese_Portugal.utf8

time zone: Europe/Lisbon
tzcode source: internal

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

loaded via a namespace (and not attached):
[1] compiler_4.4.0
>

---

3) GUI: RStudio
Output:

[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)" "礀摟瑡扡獡e"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)" "봀翿"
[1] "plot(AirPassengers)" "礀摟瑡扡獡e"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
[2] "礀摟瑡扡獡eX泙瑢ᄀ耀㜰戲扡捤㔭挷ⴱ㘴㍦戭㜱ⴰ慣㈶㜸㍥捣攳Ȁ"
[1] "plot(AirPassengers)" "촀˖"
[1] "plot(AirPassengers)"
[1] "plot(AirPassengers)"
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=Portuguese_Portugal.utf8 
LC_CTYPE=Portuguese_Portugal.utf8
[3] LC_MONETARY=Portuguese_Portugal.utf8 LC_NUMERIC=C 


[5] LC_TIME=Portuguese_Portugal.utf8

time zone: Europe/Lisbon
tzcode source: internal

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

loaded via a namespace (and not attached):
 [1] gtable_0.3.4 tensorA_0.36.2.1 ggplot2_3.5.0
 [4] QuickJSR_1.1.3   processx_3.8.3   inline_0.3.19
 [7] lattice_0.22-5   tzdb_0.4.0   callr_3.7.5
[10] vctrs_0.6.5  tools_4.4.0  ps_1.7.6
[13] generics_0.1.3   stats4_4.4.0 curl_5.2.1
[16] 

Re: [R] Bug with writeClipboard in {utils}

2024-06-19 Thread Ivan Krylov via R-help
В Tue, 18 Jun 2024 10:12:04 +
Barthelemy Tanguy via R-help  пишет:

> #> [1] "plot(AirPassengers)" "⤀攀"
> #> [1] "plot(AirPassengers)" "\u0a00"
> #> [1] "plot(AirPassengers)" "\xed\xb0\x80ư"

Thanks for showing an example!

I was able to reproduce it both with R-4.3.1 on Windows 7 and with a
fresh R-devel build on Windows 10. Bug reported at
.

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug with writeClipboard in {utils}

2024-06-19 Thread Barthelemy Tanguy via R-help
Hello,

I'm encountering what seems to be a bug when using the `writeClipboard()` 
function in the R {utils} package.
When I try to copy text to the clipboard, I notice that I get extra characters 
when I try to paste it (by hand with CTRL+V or with the `readClipboard()` 
function from R packages {utils}).

Here's my example:

``` r
utils::writeClipboard("plot(AirPassengers)")
for (k in 1:10) {
print(utils::readClipboard())
}
#> [1] "plot(AirPassengers)" "⤀攀"
#> [1] "plot(AirPassengers)" "\u0a00"
#> [1] "plot(AirPassengers)" "\xed\xb0\x80ư"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)"
#> [1] "plot(AirPassengers)" "⤀"
#> [1] "plot(AirPassengers)"
Message d'avis :
Dans utils::readClipboard() : unpaired surrogate Unicode point dc00
```

So I don't always get the same result.
I opened a problem in the {clipr} GitHub repository before realizing it's a 
{tools} problem: https://github.com/mdlincoln/clipr/issues/68

Is this a bug or something I haven't configured properly?


Thank you very much


Tanguy BARTHELEMY


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug report for package foreign anf functon write.foreign

2024-06-06 Thread Kevin Thorpe
I haven’t used this function in a long time, but it sounds like the issue is 
the format names for the formats catalog, not the variable names.

You might try the haven package as it can create SAS datasets directly, 
although there are limitations (I think).

> On Jun 6, 2024, at 4:45 AM, Julien JOLY  wrote:
> 
> [Vous ne recevez pas souvent de courriers de julien.j...@inserm.fr. D?couvrez 
> pourquoi ceci est important ? https://aka.ms/LearnAboutSenderIdentification ]
> 
> Dear all,
> 
> First of all, I thank you for the creation of the package.
> 
> I write this message concerning the write.foreign() function from the foreign 
> package and a bug that I discovered.
> When we want to save our dataset as a .sas file, the limit of variable names 
> character is 8 by default. In SAS this limit is 32 character and an argument 
> in the function, validvarname, can theorically switch the default from 8 to 
> 32 by selecting validvarname = "V7".
> 
> However, it did not work and show the error "Cannot uniquely abbreviate 
> format names to conform to eight-character limit and not ending in a digit" 
> that show the limit is still 8 characters.
> 
> By looking at the script at 
> https://github.com/cran/foreign/blob/master/R/writeForeignSAS.R , I realized 
> that the line 39, in the function make.SAS.formats, can be the reason of the 
> nonfunctioning argument :
> "if(any(nchar(x) > 8L) || any(duplicated(x)))" which is correct if the length 
> of the variable has a limit of 8, but it does not take in consideration when 
> the limit is at 32 defined by validvarnames = "V7".
> 
> A solution can be to add the argument validvarname in the definition of the 
> function and add these few lines :
>  validvarname <- match.arg(validvarname)
>  nmax <- if(validvarname == "V7") 32L else 8L
>  if(any(nchar(x) > nmax) || any(duplicated(x)))
> 
> 
> I hope I send the message to the good place and that it will help you improve 
> the package.
> 
> Kind regards,
> 
> 
> 
> Julien Joly
> 
> Biostatisticien et Data manager
> 
> 
> 
> 
> 
>[[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Kevin E. Thorpe
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.tho...@utoronto.ca  Tel: 416-946-8083


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug report for package foreign anf functon write.foreign

2024-06-06 Thread Julien JOLY
Dear all,

First of all, I thank you for the creation of the package.

I write this message concerning the write.foreign() function from the foreign 
package and a bug that I discovered.
When we want to save our dataset as a .sas file, the limit of variable names 
character is 8 by default. In SAS this limit is 32 character and an argument in 
the function, validvarname, can theorically switch the default from 8 to 32 by 
selecting validvarname = "V7".

However, it did not work and show the error "Cannot uniquely abbreviate format 
names to conform to eight-character limit and not ending in a digit" that show 
the limit is still 8 characters.

By looking at the script at 
https://github.com/cran/foreign/blob/master/R/writeForeignSAS.R , I realized 
that the line 39, in the function make.SAS.formats, can be the reason of the 
nonfunctioning argument :
"if(any(nchar(x) > 8L) || any(duplicated(x)))" which is correct if the length 
of the variable has a limit of 8, but it does not take in consideration when 
the limit is at 32 defined by validvarnames = "V7".

A solution can be to add the argument validvarname in the definition of the 
function and add these few lines :
  validvarname <- match.arg(validvarname)
  nmax <- if(validvarname == "V7") 32L else 8L
  if(any(nchar(x) > nmax) || any(duplicated(x)))


I hope I send the message to the good place and that it will help you improve 
the package.

Kind regards,



Julien Joly

Biostatisticien et Data manager





[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in print for data frames?

2023-11-03 Thread peter dalgaard
It's still kind of weird; embedded 2-column data frames print differently than 
1-column ones:

> d <- data.frame(a=1, b=I(data.frame(d=1,e=2)))
> d
  a b.d b.e
1 1   1   2
> str(d)
'data.frame':   1 obs. of  2 variables:
 $ a: num 1
 $ b:Classes 'AsIs' and 'data.frame':   1 obs. of  2 variables:
  ..$ d: num 1
  ..$ e: num 2
> names(d)
[1] "a" "b"
> d <- data.frame(a=1, b=I(data.frame(d=1)))
> d
  a d
1 1 1
> str(d)
'data.frame':   1 obs. of  2 variables:
 $ a: num 1
 $ b:Classes 'AsIs' and 'data.frame':   1 obs. of  1 variable:
  ..$ d: num 1
> names(d)
[1] "a" "b"

It is happening inside format.data.frame() or as.data.frame.list() but I can't 
figure out the logic at this point.

-pd


> On 26 Oct 2023, at 10:55 , Duncan Murdoch  wrote:
> 
> On 25/10/2023 2:18 a.m., Christian Asseburg wrote:
>> Hi! I came across this unexpected behaviour in R. First I thought it was a 
>> bug in the assignment operator <- but now I think it's maybe a bug in the 
>> way data frames are being printed. What do you think?
>> Using R 4.3.1:
>>> x <- data.frame(A = 1, B = 2, C = 3)
>>> y <- data.frame(A = 1)
>>> x
>>   A B C
>> 1 1 2 3
>>> x$B <- y$A # works as expected
>>> x
>>   A B C
>> 1 1 1 3
>>> x$C <- y[1] # makes C disappear
>>> x
>>   A B A
>> 1 1 1 1
>>> str(x)
>> 'data.frame':   1 obs. of  3 variables:
>>  $ A: num 1
>>  $ B: num 1
>>  $ C:'data.frame':  1 obs. of  1 variable:
>>   ..$ A: num 1
>> Why does the print(x) not show "C" as the name of the third element? I did 
>> mess up the data frame (and this was a mistake on my part), but finding the 
>> bug was harder because print(x) didn't show the C any longer.
> 
> y[1] is a dataframe with one column, i.e. it is identical to y.  To get the 
> result you expected, you should have used y[[1]], to extract column 1.
> 
> Since dataframes are lists, you can assign them as columns of other 
> dataframes, and you'll create a single column in the result whose rows are 
> the columns of the dataframe you're assigning.  This means that
> 
> x$C <- y[1]
> 
> replaces the C column of x with a dataframe.  It retains the name C (you can 
> see this if you print names(x) ), but since the column contains a dataframe, 
> it chooses to use the column name of y when printing.
> 
> If you try
> 
> x$D <- x
> 
> you'll see it generate new names when printing, but the names within x remain 
> as A, B, C, D.
> 
> This is a situation where tibbles do a better job than dataframes:  if you 
> created x and y as tibbles instead of dataframes and executed your code, 
> you'd see this:
> 
>  library(tibble)
>  x <- tibble(A = 1, B = 2, C = 3)
>  y <- tibble(A = 1)
>  x$C <- y[1]
>  x
>  #> # A tibble: 1 × 3
>  #>   A B   C$A
>  #> 
>  #> 1 1 2 1
> 
> Duncan Murdoch
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in print for data frames?

2023-11-02 Thread Ivan Krylov
В Wed, 25 Oct 2023 09:18:26 +0300
"Christian Asseburg"  пишет:

> > str(x)  
> 'data.frame':   1 obs. of  3 variables:
>  $ A: num 1
>  $ B: num 1
>  $ C:'data.frame':  1 obs. of  1 variable:
>   ..$ A: num 1
> 
> Why does the print(x) not show "C" as the name of the third element?

Interesting problem.

print.data.frame() calls format.data.frame() to prepare its argument
for printing, which in turn calls as.data.frame.list() to reconstruct a
data.frame from the formatted arguments, which in turn uses
data.frame() to actually construct the object.

data.frame() is able to return combined column names, but only if the
inner data.frame has more than one column:

names(data.frame(A = 1:3, B = data.frame(C = 4:6, D = 7:9)))
# [1] "A"   "B.C" "B.D"
names(data.frame(A = 1:3, B = data.frame(C = 4:6)))
# [1] "A" "C"

This matches the behaviour documented in ?data.frame:

>> For a named or unnamed matrix/list/data frame argument that contains
>> a single column, the column name in the result is the column name in
>> the argument.

Still, changing the presentational code like print.data.frame() or
format.data.frame() could be safe. I've tried writing a patch for
format.data.frame(), but it looks clumsy and breaks regression tests
(that do actually check capture.output()):

--- src/library/base/R/format.R (revision 85459)
+++ src/library/base/R/format.R (working copy)
@@ -243,8 +243,16 @@
 if(!nc) return(x) # 0 columns: evade problems, notably for nrow() > 0
 nr <- .row_names_info(x, 2L)
 rval <- vector("list", nc)
-for(i in seq_len(nc))
+for(i in seq_len(nc)) {
rval[[i]] <- format(x[[i]], ..., justify = justify)
+   # avoid data.frame(foo = data.frame(bar = ...)) overwriting
+   # the single column name
+   if (
+   identical(ncol(rval[[i]]), 1L) &&
+   !is.null(colnames(rval[[i]])) &&
+   colnames(rval[[i]]) != ''
+   ) colnames(rval[[i]]) <- paste(names(x)[[i]], colnames(rval[[i]]), sep 
= '.')
+}
 lens <- vapply(rval, NROW, 1)
 if(any(lens != nr)) { # corrupt data frame, must have at least one column
warning("corrupt data frame: columns will be truncated or
padded with NAs")

Is it worth changing the behaviour of {print,format}.data.frame() (and
fixing the regression tests to accept the new behaviour), or would that
break too much?

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in print for data frames?

2023-10-26 Thread Christian Asseburg
Dear R users! Thank you for your excellent replies. I didn't know that the 
print.data.frame expands matrix-like values in this way. Why doesn't it call 
the column in my example C.A? I understand that something like that happens 
when the data.frame in position three has multiple columns. But your answers 
have helped me understand this better.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in print for data frames?

2023-10-26 Thread Rui Barradas

Hello,

Inline.

Às 13:32 de 26/10/2023, Ebert,Timothy Aaron escreveu:

The "problem" goes away if you use

x$C <- y[1,]


Actually, if I understand correctly, the OP wants the column:


x$C <- y[,1]


In this case it will produce the same output because y is a df with only 
one row. But that is a very special case, the general case would be to 
extract the column.


Hope this helps,

Rui Barradas



If you have another row in your x, say:
x <- data.frame(A=c(1,4), B=c(2,5), C=c(3,6))

then your code
x$C <- y[1]
returns an error.

If y has the same number of rows as x$C then R has the same outcome as in your 
example.

It looks like your code tells R to replace all of column C (including the name) 
with all of vector y.

Maybe unexpected, but not a bug. It is consistent.


-Original Message-
From: R-help  On Behalf Of Rui Barradas
Sent: Thursday, October 26, 2023 6:43 AM
To: Christian Asseburg ; r-help@r-project.org
Subject: Re: [R] Bug in print for data frames?

[External Email]

Às 07:18 de 25/10/2023, Christian Asseburg escreveu:

Hi! I came across this unexpected behaviour in R. First I thought it was a bug in 
the assignment operator <- but now I think it's maybe a bug in the way data 
frames are being printed. What do you think?

Using R 4.3.1:


x <- data.frame(A = 1, B = 2, C = 3)
y <- data.frame(A = 1)
x

A B C
1 1 2 3

x$B <- y$A # works as expected
x

A B C
1 1 1 3

x$C <- y[1] # makes C disappear
x

A B A
1 1 1 1

str(x)

'data.frame':   1 obs. of  3 variables:
   $ A: num 1
   $ B: num 1
   $ C:'data.frame':  1 obs. of  1 variable:
..$ A: num 1

Why does the print(x) not show "C" as the name of the third element? I did mess 
up the data frame (and this was a mistake on my part), but finding the bug was harder 
because print(x) didn't show the C any longer.

Thanks. With best wishes -

. . . Christian

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat/
.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu
%7C237aa7be3de54af710be08dbd61056a4%7C0d4da0f84a314d76ace60a62331e1b84
%7C0%7C0%7C638339137898359565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
ta=fgR6iFifXQpRCv0WqIu4S%2Bnctg%2F0v6j7AXftxrfQGPk%3D=0
PLEASE do read the posting guide
http://www.r/
-project.org%2Fposting-guide.html=05%7C01%7Ctebert%40ufl.edu%7C23
7aa7be3de54af710be08dbd61056a4%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
7C0%7C638339137898359565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=FN
CYM6%2FbpqThk76Zug%2Bm5x8o1Y2S1Z1S0ajAzPePIms%3D=0
and provide commented, minimal, self-contained, reproducible code.

Hello,

To expand on the good answers already given, I will present two other example 
data sets.

Example 1. Imagine that instead of assigning just one column from y to x$C you 
assign two columns. The result is a data.frame column. See what is displayed as 
the columns names.
And unlike what happens with `[`, when asssigning columns 1:2, the operator 
`[[` doesn't work. You will have to extract the columns y$A and y$B one by one.



x <- data.frame(A = 1, B = 2, C = 3)
y <- data.frame(A = 1, B = 4)
str(y)
#> 'data.frame':1 obs. of  2 variables:
#>  $ A: num 1
#>  $ B: num 4

x$C <- y[1:2]
x
#>   A B C.A C.B
#> 1 1 2   1   4

str(x)
#> 'data.frame':1 obs. of  3 variables:
#>  $ A: num 1
#>  $ B: num 2
#>  $ C:'data.frame':   1 obs. of  2 variables:
#>   ..$ A: num 1
#>   ..$ B: num 4

x[[1:2]]  # doesn't work
#> Error in .subset2(x, i, exact = exact): subscript out of bounds



Example 2. Sometimes it is usefull to get a result like this first and then 
correct the resulting df. For instance, when computing more than one summary 
statistics.

str(agg)  below shows that the result summary stats is a matrix, so you have a 
column-matrix. And once again the displayed names reflect that.

The trick to make the result a df is to extract all but the last column as a 
sub-df, extract the last column's values as a matrix (which it is) and then 
cbind the two together.

cbind is a generic function. Since the first argument to cbind is a sub-df, the 
method called is cbind.data.frame and the result is a df.



df1 <- data.frame(A = rep(c("a", "b", "c"), 5L), X = 1:30)

# the anonymous function computes more than one summary statistics # note that it 
returns a named vector agg <- aggregate(X ~ A, df1, \(x) c(Mean = mean(x), S = 
sd(x))) agg
#>   AX.Mean   X.S
#> 1 a 14.50  9.082951
#> 2 b 15.50  9.082951
#> 3 c 16.50  9.082951

# similar effect as in the OP, The difference is that the last # column is a 
matrix, not a data.frame
str(agg)
#> 'data.frame':3 obs. of  2 variables:
#>  $ A: chr  "a" "b&quo

Re: [R] Bug in print for data frames?

2023-10-26 Thread Ebert,Timothy Aaron
The "problem" goes away if you use

x$C <- y[1,]

If you have another row in your x, say:
x <- data.frame(A=c(1,4), B=c(2,5), C=c(3,6))

then your code
x$C <- y[1]
returns an error.

If y has the same number of rows as x$C then R has the same outcome as in your 
example.

It looks like your code tells R to replace all of column C (including the name) 
with all of vector y.

Maybe unexpected, but not a bug. It is consistent.


-Original Message-
From: R-help  On Behalf Of Rui Barradas
Sent: Thursday, October 26, 2023 6:43 AM
To: Christian Asseburg ; r-help@r-project.org
Subject: Re: [R] Bug in print for data frames?

[External Email]

Às 07:18 de 25/10/2023, Christian Asseburg escreveu:
> Hi! I came across this unexpected behaviour in R. First I thought it was a 
> bug in the assignment operator <- but now I think it's maybe a bug in the way 
> data frames are being printed. What do you think?
>
> Using R 4.3.1:
>
>> x <- data.frame(A = 1, B = 2, C = 3)
>> y <- data.frame(A = 1)
>> x
>A B C
> 1 1 2 3
>> x$B <- y$A # works as expected
>> x
>A B C
> 1 1 1 3
>> x$C <- y[1] # makes C disappear
>> x
>A B A
> 1 1 1 1
>> str(x)
> 'data.frame':   1 obs. of  3 variables:
>   $ A: num 1
>   $ B: num 1
>   $ C:'data.frame':  1 obs. of  1 variable:
>..$ A: num 1
>
> Why does the print(x) not show "C" as the name of the third element? I did 
> mess up the data frame (and this was a mistake on my part), but finding the 
> bug was harder because print(x) didn't show the C any longer.
>
> Thanks. With best wishes -
>
> . . . Christian
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat/
> .ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu
> %7C237aa7be3de54af710be08dbd61056a4%7C0d4da0f84a314d76ace60a62331e1b84
> %7C0%7C0%7C638339137898359565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
> MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C
> ta=fgR6iFifXQpRCv0WqIu4S%2Bnctg%2F0v6j7AXftxrfQGPk%3D=0
> PLEASE do read the posting guide
> http://www.r/
> -project.org%2Fposting-guide.html=05%7C01%7Ctebert%40ufl.edu%7C23
> 7aa7be3de54af710be08dbd61056a4%7C0d4da0f84a314d76ace60a62331e1b84%7C0%
> 7C0%7C638339137898359565%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL
> CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=FN
> CYM6%2FbpqThk76Zug%2Bm5x8o1Y2S1Z1S0ajAzPePIms%3D=0
> and provide commented, minimal, self-contained, reproducible code.
Hello,

To expand on the good answers already given, I will present two other example 
data sets.

Example 1. Imagine that instead of assigning just one column from y to x$C you 
assign two columns. The result is a data.frame column. See what is displayed as 
the columns names.
And unlike what happens with `[`, when asssigning columns 1:2, the operator 
`[[` doesn't work. You will have to extract the columns y$A and y$B one by one.



x <- data.frame(A = 1, B = 2, C = 3)
y <- data.frame(A = 1, B = 4)
str(y)
#> 'data.frame':1 obs. of  2 variables:
#>  $ A: num 1
#>  $ B: num 4

x$C <- y[1:2]
x
#>   A B C.A C.B
#> 1 1 2   1   4

str(x)
#> 'data.frame':1 obs. of  3 variables:
#>  $ A: num 1
#>  $ B: num 2
#>  $ C:'data.frame':   1 obs. of  2 variables:
#>   ..$ A: num 1
#>   ..$ B: num 4

x[[1:2]]  # doesn't work
#> Error in .subset2(x, i, exact = exact): subscript out of bounds



Example 2. Sometimes it is usefull to get a result like this first and then 
correct the resulting df. For instance, when computing more than one summary 
statistics.

str(agg)  below shows that the result summary stats is a matrix, so you have a 
column-matrix. And once again the displayed names reflect that.

The trick to make the result a df is to extract all but the last column as a 
sub-df, extract the last column's values as a matrix (which it is) and then 
cbind the two together.

cbind is a generic function. Since the first argument to cbind is a sub-df, the 
method called is cbind.data.frame and the result is a df.



df1 <- data.frame(A = rep(c("a", "b", "c"), 5L), X = 1:30)

# the anonymous function computes more than one summary statistics # note that 
it returns a named vector agg <- aggregate(X ~ A, df1, \(x) c(Mean = mean(x), S 
= sd(x))) agg
#>   AX.Mean   X.S
#> 1 a 14.50  9.082951
#> 2 b 15.50  9.082951
#> 3 c 16.50  9.082951

# similar effect as in the OP, The difference is that the last # column is a 
matrix, not a data.frame
str(agg)
#> 'data.frame':3 obs. of  2 variables:
#>  $ A: chr  "a" "b" "c"
#>  $ X: num [1:3, 1:2] 14.5 15.5 16.5 9.08 9.08 ...
#>   ..- attr(*, &qu

Re: [R] Bug in print for data frames?

2023-10-26 Thread Rui Barradas

Às 07:18 de 25/10/2023, Christian Asseburg escreveu:

Hi! I came across this unexpected behaviour in R. First I thought it was a bug in 
the assignment operator <- but now I think it's maybe a bug in the way data 
frames are being printed. What do you think?

Using R 4.3.1:


x <- data.frame(A = 1, B = 2, C = 3)
y <- data.frame(A = 1)
x

   A B C
1 1 2 3

x$B <- y$A # works as expected
x

   A B C
1 1 1 3

x$C <- y[1] # makes C disappear
x

   A B A
1 1 1 1

str(x)

'data.frame':   1 obs. of  3 variables:
  $ A: num 1
  $ B: num 1
  $ C:'data.frame':  1 obs. of  1 variable:
   ..$ A: num 1

Why does the print(x) not show "C" as the name of the third element? I did mess 
up the data frame (and this was a mistake on my part), but finding the bug was harder 
because print(x) didn't show the C any longer.

Thanks. With best wishes -

. . . Christian

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Hello,

To expand on the good answers already given, I will present two other 
example data sets.


Example 1. Imagine that instead of assigning just one column from y to 
x$C you assign two columns. The result is a data.frame column. See what 
is displayed as the columns names.
And unlike what happens with `[`, when asssigning columns 1:2, the 
operator `[[` doesn't work. You will have to extract the columns y$A and 
y$B one by one.




x <- data.frame(A = 1, B = 2, C = 3)
y <- data.frame(A = 1, B = 4)
str(y)
#> 'data.frame':1 obs. of  2 variables:
#>  $ A: num 1
#>  $ B: num 4

x$C <- y[1:2]
x
#>   A B C.A C.B
#> 1 1 2   1   4

str(x)
#> 'data.frame':1 obs. of  3 variables:
#>  $ A: num 1
#>  $ B: num 2
#>  $ C:'data.frame':   1 obs. of  2 variables:
#>   ..$ A: num 1
#>   ..$ B: num 4

x[[1:2]]  # doesn't work
#> Error in .subset2(x, i, exact = exact): subscript out of bounds



Example 2. Sometimes it is usefull to get a result like this first and 
then correct the resulting df. For instance, when computing more than 
one summary statistics.


str(agg)  below shows that the result summary stats is a matrix, so you 
have a column-matrix. And once again the displayed names reflect that.


The trick to make the result a df is to extract all but the last column 
as a sub-df, extract the last column's values as a matrix (which it is) 
and then cbind the two together.


cbind is a generic function. Since the first argument to cbind is a 
sub-df, the method called is cbind.data.frame and the result is a df.




df1 <- data.frame(A = rep(c("a", "b", "c"), 5L), X = 1:30)

# the anonymous function computes more than one summary statistics
# note that it returns a named vector
agg <- aggregate(X ~ A, df1, \(x) c(Mean = mean(x), S = sd(x)))
agg
#>   AX.Mean   X.S
#> 1 a 14.50  9.082951
#> 2 b 15.50  9.082951
#> 3 c 16.50  9.082951

# similar effect as in the OP, The difference is that the last
# column is a matrix, not a data.frame
str(agg)
#> 'data.frame':3 obs. of  2 variables:
#>  $ A: chr  "a" "b" "c"
#>  $ X: num [1:3, 1:2] 14.5 15.5 16.5 9.08 9.08 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : NULL
#>   .. ..$ : chr [1:2] "Mean" "S"

# nc is just a convenience, avoids repeated calls to ncol
nc <- ncol(agg)
cbind(agg[-nc], agg[[nc]])
#>   A MeanS
#> 1 a 14.5 9.082951
#> 2 b 15.5 9.082951
#> 3 c 16.5 9.082951

# all is well
cbind(agg[-nc], agg[[nc]]) |> str()
#> 'data.frame':3 obs. of  3 variables:
#>  $ A   : chr  "a" "b" "c"
#>  $ Mean: num  14.5 15.5 16.5
#>  $ S   : num  9.08 9.08 9.08



If the anonymous function hadn't returned a named vetor, the new column 
names would have been "1". "2", try it.



Hope this helps,

Rui Barradas



--
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença 
de vírus.
www.avg.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in print for data frames?

2023-10-26 Thread Duncan Murdoch

On 25/10/2023 2:18 a.m., Christian Asseburg wrote:

Hi! I came across this unexpected behaviour in R. First I thought it was a bug in 
the assignment operator <- but now I think it's maybe a bug in the way data 
frames are being printed. What do you think?

Using R 4.3.1:


x <- data.frame(A = 1, B = 2, C = 3)
y <- data.frame(A = 1)
x

   A B C
1 1 2 3

x$B <- y$A # works as expected
x

   A B C
1 1 1 3

x$C <- y[1] # makes C disappear
x

   A B A
1 1 1 1

str(x)

'data.frame':   1 obs. of  3 variables:
  $ A: num 1
  $ B: num 1
  $ C:'data.frame':  1 obs. of  1 variable:
   ..$ A: num 1

Why does the print(x) not show "C" as the name of the third element? I did mess 
up the data frame (and this was a mistake on my part), but finding the bug was harder 
because print(x) didn't show the C any longer.


y[1] is a dataframe with one column, i.e. it is identical to y.  To get 
the result you expected, you should have used y[[1]], to extract column 1.


Since dataframes are lists, you can assign them as columns of other 
dataframes, and you'll create a single column in the result whose rows 
are the columns of the dataframe you're assigning.  This means that


 x$C <- y[1]

replaces the C column of x with a dataframe.  It retains the name C (you 
can see this if you print names(x) ), but since the column contains a 
dataframe, it chooses to use the column name of y when printing.


If you try

 x$D <- x

you'll see it generate new names when printing, but the names within x 
remain as A, B, C, D.


This is a situation where tibbles do a better job than dataframes:  if 
you created x and y as tibbles instead of dataframes and executed your 
code, you'd see this:


  library(tibble)
  x <- tibble(A = 1, B = 2, C = 3)
  y <- tibble(A = 1)
  x$C <- y[1]
  x
  #> # A tibble: 1 × 3
  #>   A B   C$A
  #> 
  #> 1 1 2 1

Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in print for data frames?

2023-10-26 Thread Iris Simmons
I would say this is not an error, but I think what you wrote isn't
what you intended to do anyway.

y[1] is a data.frame which contains only the first column of y, which
you assign to x$C, so now x$C is a data.frame.

R allows data.frame to be plain vectors as well as matrices and
data.frames, basically anything as long as it has the correct length
or nrow.

When the data.frame is formatted for printing, each column C is
formatted then column-bound into another data.frame using
as.data.frame.list, so it takes the name A because that's the name of
the column from y.

I think what you meant to do is x$C <- y[[1]]  ## double brackets
instead of single

On Thu, Oct 26, 2023 at 4:14 AM Christian Asseburg  wrote:
>
> Hi! I came across this unexpected behaviour in R. First I thought it was a 
> bug in the assignment operator <- but now I think it's maybe a bug in the way 
> data frames are being printed. What do you think?
>
> Using R 4.3.1:
>
> > x <- data.frame(A = 1, B = 2, C = 3)
> > y <- data.frame(A = 1)
> > x
>   A B C
> 1 1 2 3
> > x$B <- y$A # works as expected
> > x
>   A B C
> 1 1 1 3
> > x$C <- y[1] # makes C disappear
> > x
>   A B A
> 1 1 1 1
> > str(x)
> 'data.frame':   1 obs. of  3 variables:
>  $ A: num 1
>  $ B: num 1
>  $ C:'data.frame':  1 obs. of  1 variable:
>   ..$ A: num 1
>
> Why does the print(x) not show "C" as the name of the third element? I did 
> mess up the data frame (and this was a mistake on my part), but finding the 
> bug was harder because print(x) didn't show the C any longer.
>
> Thanks. With best wishes -
>
> . . . Christian
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug in print for data frames?

2023-10-26 Thread Christian Asseburg
Hi! I came across this unexpected behaviour in R. First I thought it was a bug 
in the assignment operator <- but now I think it's maybe a bug in the way data 
frames are being printed. What do you think?

Using R 4.3.1:

> x <- data.frame(A = 1, B = 2, C = 3)
> y <- data.frame(A = 1)
> x
  A B C
1 1 2 3
> x$B <- y$A # works as expected
> x
  A B C
1 1 1 3
> x$C <- y[1] # makes C disappear
> x
  A B A
1 1 1 1
> str(x)
'data.frame':   1 obs. of  3 variables:
 $ A: num 1
 $ B: num 1
 $ C:'data.frame':  1 obs. of  1 variable:
  ..$ A: num 1

Why does the print(x) not show "C" as the name of the third element? I did mess 
up the data frame (and this was a mistake on my part), but finding the bug was 
harder because print(x) didn't show the C any longer.

Thanks. With best wishes -

. . . Christian

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in internal 'tar' implementation?

2023-01-31 Thread Duncan Murdoch

Or directly to bugs.r-project.org .  It definitely looks to me like a bug.

Instructions for bug reports are here: 
https://www.r-project.org/bugs.html .  David might need to set up a 
Bugzilla account according to those instructions before reporting.


Duncan Murdoch

On 31/01/2023 1:40 p.m., Bert Gunter wrote:

This post should probably go to R-devel rather than here.

-- Bert

On Tue, Jan 31, 2023 at 9:47 AM David Engster  wrote:


I think I found a bug in the internal implementation of 'tar', but
before bothering the R maintainers, I was advised to ask here to make
sure I'm not missing something.

Fortunately, it can be very easily reproduced on a Linux system. In an
empty temporary directory, execute the following code:

cat("foobar", file="test.txt")
file.symlink("test.txt", "test_link.txt")
tar("test.tar", c("test_link.txt", "test.txt"), tar="internal")
system2("tar", c("tf", "test.tar"))

This file create a file "test.txt" and a symbolic link "test_link.txt"
pointing to that file. Those two are then put into "test.tar" using R's
internal tar implementation, and then the system's 'tar' binary (usually
GNU tar) will be used to display the contents of that archive.

On my system (Debian 11, GNU tar 1.34), this gives me the following
output:

[1] TRUE
test_link.txt
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

Not that *extracting* the archive with 'tar xf' (fortunately) works
fine, it's just displaying its contents that fails. After looking into
the hexdump of 'test.tar' and R's internal tar() code, I found out the
reason for this is that a wrong size for the link is put into the tar
header: it should be zero, but the size of the linked file is put in
there instead. This leads to 'tar tf' jumping over too many blocks after
displaying the link filename and hence aborting.

While I'm aware the 'tar()' help says to avoid links for portability
reasons, it also says that it supports symbolic links on OSes that
support them, which Linux of course does, so do you agree this should be
fixed? (It's a very simple one-line change.)

Best,
David

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in internal 'tar' implementation?

2023-01-31 Thread Bert Gunter
This post should probably go to R-devel rather than here.

-- Bert

On Tue, Jan 31, 2023 at 9:47 AM David Engster  wrote:

> I think I found a bug in the internal implementation of 'tar', but
> before bothering the R maintainers, I was advised to ask here to make
> sure I'm not missing something.
>
> Fortunately, it can be very easily reproduced on a Linux system. In an
> empty temporary directory, execute the following code:
>
> cat("foobar", file="test.txt")
> file.symlink("test.txt", "test_link.txt")
> tar("test.tar", c("test_link.txt", "test.txt"), tar="internal")
> system2("tar", c("tf", "test.tar"))
>
> This file create a file "test.txt" and a symbolic link "test_link.txt"
> pointing to that file. Those two are then put into "test.tar" using R's
> internal tar implementation, and then the system's 'tar' binary (usually
> GNU tar) will be used to display the contents of that archive.
>
> On my system (Debian 11, GNU tar 1.34), this gives me the following
> output:
>
> [1] TRUE
> test_link.txt
> tar: Skipping to next header
> tar: Exiting with failure status due to previous errors
>
> Not that *extracting* the archive with 'tar xf' (fortunately) works
> fine, it's just displaying its contents that fails. After looking into
> the hexdump of 'test.tar' and R's internal tar() code, I found out the
> reason for this is that a wrong size for the link is put into the tar
> header: it should be zero, but the size of the linked file is put in
> there instead. This leads to 'tar tf' jumping over too many blocks after
> displaying the link filename and hence aborting.
>
> While I'm aware the 'tar()' help says to avoid links for portability
> reasons, it also says that it supports symbolic links on OSes that
> support them, which Linux of course does, so do you agree this should be
> fixed? (It's a very simple one-line change.)
>
> Best,
> David
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug in internal 'tar' implementation?

2023-01-31 Thread David Engster
I think I found a bug in the internal implementation of 'tar', but
before bothering the R maintainers, I was advised to ask here to make
sure I'm not missing something.

Fortunately, it can be very easily reproduced on a Linux system. In an
empty temporary directory, execute the following code:

cat("foobar", file="test.txt")
file.symlink("test.txt", "test_link.txt")
tar("test.tar", c("test_link.txt", "test.txt"), tar="internal")
system2("tar", c("tf", "test.tar"))

This file create a file "test.txt" and a symbolic link "test_link.txt"
pointing to that file. Those two are then put into "test.tar" using R's
internal tar implementation, and then the system's 'tar' binary (usually
GNU tar) will be used to display the contents of that archive.

On my system (Debian 11, GNU tar 1.34), this gives me the following
output:

[1] TRUE
test_link.txt
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

Not that *extracting* the archive with 'tar xf' (fortunately) works
fine, it's just displaying its contents that fails. After looking into
the hexdump of 'test.tar' and R's internal tar() code, I found out the
reason for this is that a wrong size for the link is put into the tar
header: it should be zero, but the size of the linked file is put in
there instead. This leads to 'tar tf' jumping over too many blocks after
displaying the link filename and hence aborting.

While I'm aware the 'tar()' help says to avoid links for portability
reasons, it also says that it supports symbolic links on OSes that
support them, which Linux of course does, so do you agree this should be
fixed? (It's a very simple one-line change.)

Best,
David

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-Help Archives?

2023-01-27 Thread Sorkin, John
My apologies,
I did not mean to be part of the discussion. If there is such a thing as a 
pocket email (similar to a pocket dial) the email would be classified as a 
pocket email.
John


From: R-help  on behalf of Rui Barradas 

Sent: Friday, January 27, 2023 10:15 AM
To: Ivan Krylov
Cc: R-help Mailing List
Subject: Re: [R] Bug in R-Help Archives?

Às 07:36 de 27/01/2023, Ivan Krylov escreveu:
> On Fri, 27 Jan 2023 13:01:39 +0530
> Deepayan Sarkar  wrote:
>
>>  From looking at the headers in John Sorkin's mail, my guess is that he
>> just replied to the other thread rather than starting a fresh email,
>> and in his attempts to hide that, was outsmarted by Outlook.
>
> That's 100% correct. The starting "Pipe operator" e-mail has
> In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the
> message with this Message-ID is the one from Mukesh Ghanshyamdas
> Lekhrajani with the subject "Re: [R] R Certification" that's
> immediately above the message by John Sorkin.
>
Thanks, I was searching the archives for something else, stumbled on
that and forgot to look at the heders.
Good news there's nothing wrong with R-Help.

Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7CJSorkin%40som.umaryland.edu%7Ca90bca3f346f470c472808db007a65cd%7C717009a620de461a88940312a395cac9%7C0%7C0%7C638104297929279937%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=8CGlDg%2Fdkx28raPOalXjZ7NqN%2BP%2BoWo9UFL%2Boc6NBRU%3D=0
PLEASE do read the posting guide 
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=05%7C01%7CJSorkin%40som.umaryland.edu%7Ca90bca3f346f470c472808db007a65cd%7C717009a620de461a88940312a395cac9%7C0%7C0%7C638104297929279937%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=mira%2F3jlC1V3jAJvBiqw53EpaCJknQ1W77NY7jTzfyA%3D=0
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-Help Archives?

2023-01-27 Thread Rui Barradas

Às 07:36 de 27/01/2023, Ivan Krylov escreveu:

On Fri, 27 Jan 2023 13:01:39 +0530
Deepayan Sarkar  wrote:


 From looking at the headers in John Sorkin's mail, my guess is that he
just replied to the other thread rather than starting a fresh email,
and in his attempts to hide that, was outsmarted by Outlook.


That's 100% correct. The starting "Pipe operator" e-mail has
In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the
message with this Message-ID is the one from Mukesh Ghanshyamdas
Lekhrajani with the subject "Re: [R] R Certification" that's
immediately above the message by John Sorkin.

Thanks, I was searching the archives for something else, stumbled on 
that and forgot to look at the heders.

Good news there's nothing wrong with R-Help.

Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-Help Archives?

2023-01-27 Thread Rui Barradas

Às 07:31 de 27/01/2023, Deepayan Sarkar escreveu:

 From looking at the headers in John Sorkin's mail, my guess is that he
just replied to the other thread rather than starting a fresh email,
and in his attempts to hide that, was outsmarted by Outlook.

This is based on references to domains such as yahoo.com,
dcn.davis.ca.us, and precheza.cz in the header, which were all
involved in the certification thread.

-Deepayan

On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas  wrote:


Às 06:39 de 27/01/2023, Rui Barradas escreveu:

Hello,

When consulting the R-Help Archives today I've noticed that the thread

Pipe operator

started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another
thread,

R Certification

started by Mukesh Ghanshyamdas Lekhrajani.

Isn't this a bug in the filing system?

Thanks to the list maintainer  Martin Maechler and ETH Zurich for
organizing and hosting the list for all of us. It's an invaluable tool
that has served so many R users along the years and that surely gives a
lot of work organizing and eventual headaches. I hope this is not one of
them.

Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Maybe the attached screen capture makes it more clear.

Rui Barradas


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Thanks, I had missed that.

Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-Help Archives?

2023-01-26 Thread Jeff Newmiller
Every email thread (mailing list or not) gets a hidden identifier that is used 
to identify that thread. It is not that Outlook outsmarted John... any email 
program would have done the same.

John... please don't reply to existing posts with a new subject... many mailing 
list users may be using the threaded view in their email program and never see 
your question at all if they were not interested in the original thread.

On January 26, 2023 11:31:39 PM PST, Deepayan Sarkar 
 wrote:
>From looking at the headers in John Sorkin's mail, my guess is that he
>just replied to the other thread rather than starting a fresh email,
>and in his attempts to hide that, was outsmarted by Outlook.
>
>This is based on references to domains such as yahoo.com,
>dcn.davis.ca.us, and precheza.cz in the header, which were all
>involved in the certification thread.
>
>-Deepayan
>
>On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas  wrote:
>>
>> Às 06:39 de 27/01/2023, Rui Barradas escreveu:
>> > Hello,
>> >
>> > When consulting the R-Help Archives today I've noticed that the thread
>> >
>> > Pipe operator
>> >
>> > started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another
>> > thread,
>> >
>> > R Certification
>> >
>> > started by Mukesh Ghanshyamdas Lekhrajani.
>> >
>> > Isn't this a bug in the filing system?
>> >
>> > Thanks to the list maintainer  Martin Maechler and ETH Zurich for
>> > organizing and hosting the list for all of us. It's an invaluable tool
>> > that has served so many R users along the years and that surely gives a
>> > lot of work organizing and eventual headaches. I hope this is not one of
>> > them.
>> >
>> > Rui Barradas
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> Maybe the attached screen capture makes it more clear.
>>
>> Rui Barradas
>>
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-Help Archives?

2023-01-26 Thread Ivan Krylov
On Fri, 27 Jan 2023 13:01:39 +0530
Deepayan Sarkar  wrote:

> From looking at the headers in John Sorkin's mail, my guess is that he
> just replied to the other thread rather than starting a fresh email,
> and in his attempts to hide that, was outsmarted by Outlook.

That's 100% correct. The starting "Pipe operator" e-mail has
In-Reply-To: <047e01d91ed5$577e42a0$067ac7e0$@yahoo.com>, and the
message with this Message-ID is the one from Mukesh Ghanshyamdas
Lekhrajani with the subject "Re: [R] R Certification" that's
immediately above the message by John Sorkin.

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-Help Archives?

2023-01-26 Thread Deepayan Sarkar
>From looking at the headers in John Sorkin's mail, my guess is that he
just replied to the other thread rather than starting a fresh email,
and in his attempts to hide that, was outsmarted by Outlook.

This is based on references to domains such as yahoo.com,
dcn.davis.ca.us, and precheza.cz in the header, which were all
involved in the certification thread.

-Deepayan

On Fri, Jan 27, 2023 at 12:26 PM Rui Barradas  wrote:
>
> Às 06:39 de 27/01/2023, Rui Barradas escreveu:
> > Hello,
> >
> > When consulting the R-Help Archives today I've noticed that the thread
> >
> > Pipe operator
> >
> > started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another
> > thread,
> >
> > R Certification
> >
> > started by Mukesh Ghanshyamdas Lekhrajani.
> >
> > Isn't this a bug in the filing system?
> >
> > Thanks to the list maintainer  Martin Maechler and ETH Zurich for
> > organizing and hosting the list for all of us. It's an invaluable tool
> > that has served so many R users along the years and that surely gives a
> > lot of work organizing and eventual headaches. I hope this is not one of
> > them.
> >
> > Rui Barradas
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> Maybe the attached screen capture makes it more clear.
>
> Rui Barradas
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-Help Archives?

2023-01-26 Thread Rui Barradas

Às 06:39 de 27/01/2023, Rui Barradas escreveu:

Hello,

When consulting the R-Help Archives today I've noticed that the thread

Pipe operator

started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another 
thread,


R Certification

started by Mukesh Ghanshyamdas Lekhrajani.

Isn't this a bug in the filing system?

Thanks to the list maintainer  Martin Maechler and ETH Zurich for 
organizing and hosting the list for all of us. It's an invaluable tool 
that has served so many R users along the years and that surely gives a 
lot of work organizing and eventual headaches. I hope this is not one of 
them.


Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


Maybe the attached screen capture makes it more clear.

Rui Barradas


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug in R-Help Archives?

2023-01-26 Thread Rui Barradas

Hello,

When consulting the R-Help Archives today I've noticed that the thread

Pipe operator

started by John Sorkin, Tue Jan 3 17:48:30 CET 2023 is under another thread,

R Certification

started by Mukesh Ghanshyamdas Lekhrajani.

Isn't this a bug in the filing system?

Thanks to the list maintainer  Martin Maechler and ETH Zurich for 
organizing and hosting the list for all of us. It's an invaluable tool 
that has served so many R users along the years and that surely gives a 
lot of work organizing and eventual headaches. I hope this is not one of 
them.


Rui Barradas

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in packages.

2022-07-13 Thread Ivan Krylov
On Wed, 13 Jul 2022 16:19:59 -0400
Charles-Édouard Giguère  wrote:

> Is there a mechanism to report a bug in someone package? I plan to
> email the author, but I was wondering if there is an official way
> like the issue function in github.

Try running bug.report(package='...'). It should either follow the link
designated by the package maintainer to report bugs, or open your mail
app to contact the maintainer.

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in packages.

2022-07-13 Thread Bert Gunter
https://www.r-project.org/bugs.html

for info on bug reporting.

Bert

On Wed, Jul 13, 2022 at 1:49 PM Charles-Édouard Giguère
 wrote:
>
> Hello everyone,
> Is there a mechanism to report a bug in someone package? I plan to email the 
> author, but I was wondering if there is an official way like the issue 
> function in github.
> Thank you,
> Charles-Édouard
>
> Charles-Édouard Giguère
> Analyste statisticien
> Centre de recherche de l´Institut universitaire en santé mentale de Montréal 
> (CR-IUSMM)
> 514−251-4015, poste 3516
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-install -- sysdata.rda

2022-03-21 Thread Ivan Krylov
On Mon, 21 Mar 2022 11:33:36 +
Manu goswami  wrote:

> It's really a maze just getting any sort of developer related help
> for r. I am still not able to understand where to post what.

We don't have an "R administration" mailing list, so R-devel
 seems to be a good bet.

Two bits of advice (but we should really continue in R-devel):

1. You're on Windows 10, so if you really need R running in a
Linux-like environment ASAP (why else run Cygwin?), consider Windows
Subsystem for Linux. It's not as slow as a virtual machine. 

2. Have you tried following the cygport for R-4.1.2? If you download
the source package (R-4.1.2-1-src.tar.xz) from your preferred mirror,
there's a few patches that may be needed to adjust the compiler flags to
get your build of R working.

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-install -- sysdata.rda

2022-03-20 Thread Jeff Newmiller
Please don't post to multiple lists at once... this is widely frowned on by 
many mailing lists. If you simply read the Posting Guide it will inform you 
that you should post questions "related to compiling" on r-devel.

I also recommend that you read the R Administration and Installation manual, 
because I don't think cygwin is actually a supported platform... the Rtools 
development tool chain is the supported approach for building on Windows.

On March 20, 2022 12:54:59 AM PDT, Manu goswami  wrote:
>Dear R Developers,
>
>Building R from source has never been straight forward but now it has become 
>impossible. Even when one compiles and links all files
>Still below error is stopping completing build process. This certainly is 
>deplorably mischievous. Please support to resolve immediately.
>
>Cygwin  + win 10 -> error installing sysdata.rda , 64 BIT.
>
>
>make[4]: Entering directory '/cygdrive/c/ons_1/e2/4.1.2/src/library/tools'
>installing 'sysdata.rda'
>
>*** caught segfault ***
>address 0x18, cause 'memory not mapped'
>
>Traceback:
>1: .Call(PS_sigs, 1L)
>2: eval(exprs[i], envir)
>3: eval(exprs[i], envir)
>4: sys.source(codeFile, env, keep.source = keep.source, keep.parse.data = 
>keep.parse.data)
>5: doTryCatch(return(expr), name, parentenv, handler)
>6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
>7: tryCatchList(expr, classes, parentenv, handlers)
>8: tryCatch(expr, error = function(e) {call <- conditionCall(e)if 
>(!is.null(call)) {if (identical(call[[1L]], quote(doTryCatch)))
> call <- sys.call(-4L)dcall <- deparse(call, nlines = 1L)
>prefix <- paste("Error in", dcall, ": ")LONG <- 75Lsm <- 
>strsplit(conditionMessage(e), "\n")[[1L]]w <- 14L + nchar(dcall, type 
>= "w") + nchar(sm[1L], type = "w")if (is.na(w)) w <- 14L + 
>nchar(dcall, type = "b") + nchar(sm[1L], type = "b")if 
>(w > LONG) prefix <- paste0(prefix, "\n  ")}else prefix <- 
>"Error : "msg <- paste0(prefix, conditionMessage(e), "\n")
>.Internal(seterrmessage(msg[1L]))if (!silent && 
>isTRUE(getOption("show.error.messages"))) {cat(msg, file = outFile)
>.Internal(printDeferredWarnings())}invisible(structure(msg, class 
>= "try-error", condition = e))})
>9: try(sys.source(codeFile, env, keep.source = keep.source, keep.parse.data = 
>keep.parse.data))
>10: loadNamespace(x)
>An irrecoverable exception occurred. R is aborting now ...
>/bin/sh: line 1: 52047 Doneecho 
>"tools:::sysdata2LazyLoadDB(\"./R/sysdata.rda\",\"../../../library/tools/R\")"
> 52048 Segmentation fault  (core dumped) | R_DEFAULT_PACKAGES=NULL 
> LC_ALL=C R_ENABLE_JIT=0 TZ=UTC ../../../bin/R --vanilla --no-echo
>make[4]: *** [../../../share/make/basepkg.mk:151: sysdata] Error 139
>make[4]: Leaving directory '/cygdrive/c/ons_1/e2/4.1.2/src/library/tools'
>make[3]: *** [Makefile:36: all] Error 2
>make[3]: Leaving directory '/cygdrive/c/ons_1/e2/4.1.2/src/library/tools'
>make[2]: *** [Makefile:37: R] Error 1
>make[2]: Leaving directory '/cygdrive/c/ons_1/e2/4.1.2/src/library'
>make[1]: *** [Makefile:28: R] Error 1
>make[1]: Leaving directory '/cygdrive/c/ons_1/e2/4.1.2/src'
>make: *** [Makefile:61: R] Error 1
>
>Warm Regards,
>Manu
>Sent from Mail for Windows
>
>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R-install -- sysdata.rda

2022-03-20 Thread Manu goswami
Dear R Developers,

Building R from source has never been straight forward but now it has become 
impossible. Even when one compiles and links all files
Still below error is stopping completing build process. This certainly is 
deplorably mischievous. Please support to resolve immediately.

Cygwin  + win 10 -> error installing sysdata.rda , 64 BIT.


make[4]: Entering directory '/cygdrive/c/ons_1/e2/4.1.2/src/library/tools'
installing 'sysdata.rda'

*** caught segfault ***
address 0x18, cause 'memory not mapped'

Traceback:
1: .Call(PS_sigs, 1L)
2: eval(exprs[i], envir)
3: eval(exprs[i], envir)
4: sys.source(codeFile, env, keep.source = keep.source, keep.parse.data = 
keep.parse.data)
5: doTryCatch(return(expr), name, parentenv, handler)
6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
7: tryCatchList(expr, classes, parentenv, handlers)
8: tryCatch(expr, error = function(e) {call <- conditionCall(e)if 
(!is.null(call)) {if (identical(call[[1L]], quote(doTryCatch))) 
call <- sys.call(-4L)dcall <- deparse(call, nlines = 1L)
prefix <- paste("Error in", dcall, ": ")LONG <- 75Lsm <- 
strsplit(conditionMessage(e), "\n")[[1L]]w <- 14L + nchar(dcall, type = 
"w") + nchar(sm[1L], type = "w")if (is.na(w)) w <- 14L + 
nchar(dcall, type = "b") + nchar(sm[1L], type = "b")if 
(w > LONG) prefix <- paste0(prefix, "\n  ")}else prefix <- 
"Error : "msg <- paste0(prefix, conditionMessage(e), "\n")
.Internal(seterrmessage(msg[1L]))if (!silent && 
isTRUE(getOption("show.error.messages"))) {cat(msg, file = outFile) 
   .Internal(printDeferredWarnings())}invisible(structure(msg, class = 
"try-error", condition = e))})
9: try(sys.source(codeFile, env, keep.source = keep.source, keep.parse.data = 
keep.parse.data))
10: loadNamespace(x)
An irrecoverable exception occurred. R is aborting now ...
/bin/sh: line 1: 52047 Doneecho 
"tools:::sysdata2LazyLoadDB(\"./R/sysdata.rda\",\"../../../library/tools/R\")"
 52048 Segmentation fault  (core dumped) | R_DEFAULT_PACKAGES=NULL 
LC_ALL=C R_ENABLE_JIT=0 TZ=UTC ../../../bin/R --vanilla --no-echo
make[4]: *** [../../../share/make/basepkg.mk:151: sysdata] Error 139
make[4]: Leaving directory '/cygdrive/c/ons_1/e2/4.1.2/src/library/tools'
make[3]: *** [Makefile:36: all] Error 2
make[3]: Leaving directory '/cygdrive/c/ons_1/e2/4.1.2/src/library/tools'
make[2]: *** [Makefile:37: R] Error 1
make[2]: Leaving directory '/cygdrive/c/ons_1/e2/4.1.2/src/library'
make[1]: *** [Makefile:28: R] Error 1
make[1]: Leaving directory '/cygdrive/c/ons_1/e2/4.1.2/src'
make: *** [Makefile:61: R] Error 1

Warm Regards,
Manu
Sent from Mail for Windows



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug in Windows implementation of nlme::groupedData

2022-01-07 Thread John Fox

Dear Melissa,

It seems strange to me that your code would work on any platform (it 
doesn't on my Mac) because the data frame you create shouldn't contain a 
matrix named "X" but rather columns including those originating from X. 
To illustrate:


> X <- matrix(1:12, 4, 3)
> colnames(X) <- c("a", "b", "c")
> X
 a b  c
[1,] 1 5  9
[2,] 2 6 10
[3,] 3 7 11
[4,] 4 8 12

> y <- 1:4

> (D <- data.frame(y, X))
  y a b  c
1 1 1 5  9
2 2 2 6 10
3 3 3 7 11
4 4 4 8 12

> str(D)
'data.frame':   4 obs. of  4 variables:
 $ y: int  1 2 3 4
 $ a: int  1 2 3 4
 $ b: int  5 6 7 8
 $ c: int  9 10 11 12

My session info:

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.1

Matrix products: default
LAPACK: 
/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib


locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] nlme_3.1-153 HRW_1.0-5

loaded via a namespace (and not attached):
[1] compiler_4.1.2 tools_4.1.2KernSmooth_2.23-20 
splines_4.1.2

[5] grid_4.1.2 lattice_0.20-45

I hope this helps,
 John

--
John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/

On 2022-01-07 11:23 a.m., Key, Melissa wrote:

I am trying to replicate a semi-parametric analysis described in Harezlak, 
Jaroslaw, David Ruppert, and Matt P. Wand. Semiparametric regression with R. 
New York, NY: Springer, 2018. 
(https://link.springer.com/book/10.1007%2F978-1-4939-8853-2).

I can successfully run the analysis, but now I'm trying to move it into my 
workflow, which requires that the analysis be conducted within a function 
(using targets package), and the `groupedData` function now fails with an error 
that it cannot find the `X` matrix (see reprex below).  I've tried the reprex 
on both my personal Mac (where it works??) and on windows machines (where it 
does not) - so the problem is likely specific to Windows computers (yes, this 
seems weird to me too).
All packages have been updated, and I'm running the latest version of R on all 
machines.

Reprex:

library(HRW) # contains example data and ZOSull function
library(nlme)

data(growthIndiana)


analyze_this <- function(df) {

   mean.x <- mean(df$age)
   mean.y <- mean(df$height)
   sd.x <- sd(df$age)
   sd.y <- sd(df$height)

   df$x <- (df$age - mean.x) / sd.x
   df$y <- (df$height - mean.y) / sd.y

   X <- model.matrix(~ x * male * black, data = df)
   dummyID <- rep(1, length(nrow(X)))

   grouped_data <- groupedData(y ~ X[,-1]|rep(1, length = nrow(X)), data = 
data.frame(y = df$y, X, dummyID))

}


# doesn't work on Windows machine, does work on the Mac
analyze_this(growthIndiana)
#> Error in eval(aux[[2]], object): object 'X' not found

# does work

df <- growthIndiana

mean.x <- mean(df$age)
mean.y <- mean(df$height)
sd.x <- sd(df$age)
sd.y <- sd(df$height)

df$x <- (df$age - mean.x) / sd.x
df$y <- (df$height - mean.y) / sd.y

X <- model.matrix(~ x * male * black, data = df)
dummyID <- rep(1, length(nrow(X)))

grouped_data <- groupedData(y ~ X[,-1]|rep(1, length = nrow(X)), data = 
data.frame(y = df$y, X, dummyID))


# attempted work-around.

analyze_this2 <- function(df) {
   num.global.knots = 20
   num.subject.knots = 10

   mean.x <- mean(df$age)
   mean.y <- mean(df$height)
   sd.x <- sd(df$age)
   sd.y <- sd(df$height)

   df$x <- (df$age - mean.x) / sd.x
   df$y <- (df$height - mean.y) / sd.y

   X <- model.matrix(~ x * male * black, data = df)
   dummyID <- rep(1, length(nrow(X)))

   # grouped_data <- groupedData(y ~ X[,-1]|rep(1, length = nrow(X)), data = 
data.frame(y = df$y, X, dummyID))

   global.knots = quantile(unique(df$x), seq(0, 1, length = num.global.knots + 
2)[-c(1, num.global.knots + 2)])
   subject.knots = quantile(unique(df$x), seq(0, 1, length = num.subject.knots 
+ 2)[-c(1, num.subject.knots + 2)])

   Z.global <- ZOSull(df$x, range.x = range(df$x), global.knots)
   Z.group <- df$black * Z.global
   Z.subject <- ZOSull(df$x, range.x = range(df$x), subject.knots)

   Zblock <- list(
 dummyID = pdIdent(~ 0 + Z.global),
 dummyID = pdIdent(~ 0 + Z.group),
 idnum = pdSymm(~ x),
 idnum = pdIdent(~ 0 + Z.subject)
   )

   df$dummyID <- dummyID
   tmp_data <- c(
 df,
 X = list(X),
 Z.global = list(Z.global),
 Z.group = list(Z.global),
 Z.subject = list(Z.subject)
   )

   fit <- lme(y ~ 0 + X,
 data = tmp_data,
 random = Zblock
   )

}

# this works (warning - lme takes awhile to fit)
analyze_this2(growthIndiana)

sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 22000)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_United States.1252
#> [2] LC_CTYPE=English_United States.1252
#> [3] 

[R] bug in Windows implementation of nlme::groupedData

2022-01-07 Thread Key, Melissa
I am trying to replicate a semi-parametric analysis described in Harezlak, 
Jaroslaw, David Ruppert, and Matt P. Wand. Semiparametric regression with R. 
New York, NY: Springer, 2018. 
(https://link.springer.com/book/10.1007%2F978-1-4939-8853-2).

I can successfully run the analysis, but now I'm trying to move it into my 
workflow, which requires that the analysis be conducted within a function 
(using targets package), and the `groupedData` function now fails with an error 
that it cannot find the `X` matrix (see reprex below).  I've tried the reprex 
on both my personal Mac (where it works??) and on windows machines (where it 
does not) - so the problem is likely specific to Windows computers (yes, this 
seems weird to me too).
All packages have been updated, and I'm running the latest version of R on all 
machines.

Reprex:

library(HRW) # contains example data and ZOSull function
library(nlme)

data(growthIndiana)


analyze_this <- function(df) {

  mean.x <- mean(df$age)
  mean.y <- mean(df$height)
  sd.x <- sd(df$age)
  sd.y <- sd(df$height)

  df$x <- (df$age - mean.x) / sd.x
  df$y <- (df$height - mean.y) / sd.y

  X <- model.matrix(~ x * male * black, data = df)
  dummyID <- rep(1, length(nrow(X)))

  grouped_data <- groupedData(y ~ X[,-1]|rep(1, length = nrow(X)), data = 
data.frame(y = df$y, X, dummyID))

}


# doesn't work on Windows machine, does work on the Mac
analyze_this(growthIndiana)
#> Error in eval(aux[[2]], object): object 'X' not found

# does work

df <- growthIndiana

mean.x <- mean(df$age)
mean.y <- mean(df$height)
sd.x <- sd(df$age)
sd.y <- sd(df$height)

df$x <- (df$age - mean.x) / sd.x
df$y <- (df$height - mean.y) / sd.y

X <- model.matrix(~ x * male * black, data = df)
dummyID <- rep(1, length(nrow(X)))

grouped_data <- groupedData(y ~ X[,-1]|rep(1, length = nrow(X)), data = 
data.frame(y = df$y, X, dummyID))


# attempted work-around.

analyze_this2 <- function(df) {
  num.global.knots = 20
  num.subject.knots = 10

  mean.x <- mean(df$age)
  mean.y <- mean(df$height)
  sd.x <- sd(df$age)
  sd.y <- sd(df$height)

  df$x <- (df$age - mean.x) / sd.x
  df$y <- (df$height - mean.y) / sd.y

  X <- model.matrix(~ x * male * black, data = df)
  dummyID <- rep(1, length(nrow(X)))

  # grouped_data <- groupedData(y ~ X[,-1]|rep(1, length = nrow(X)), data = 
data.frame(y = df$y, X, dummyID))

  global.knots = quantile(unique(df$x), seq(0, 1, length = num.global.knots + 
2)[-c(1, num.global.knots + 2)])
  subject.knots = quantile(unique(df$x), seq(0, 1, length = num.subject.knots + 
2)[-c(1, num.subject.knots + 2)])

  Z.global <- ZOSull(df$x, range.x = range(df$x), global.knots)
  Z.group <- df$black * Z.global
  Z.subject <- ZOSull(df$x, range.x = range(df$x), subject.knots)

  Zblock <- list(
dummyID = pdIdent(~ 0 + Z.global),
dummyID = pdIdent(~ 0 + Z.group),
idnum = pdSymm(~ x),
idnum = pdIdent(~ 0 + Z.subject)
  )

  df$dummyID <- dummyID
  tmp_data <- c(
df,
X = list(X),
Z.global = list(Z.global),
Z.group = list(Z.global),
Z.subject = list(Z.subject)
  )

  fit <- lme(y ~ 0 + X,
data = tmp_data,
random = Zblock
  )

}

# this works (warning - lme takes awhile to fit)
analyze_this2(growthIndiana)

sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 22000)
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=English_United States.1252
#> [2] LC_CTYPE=English_United States.1252
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=English_United States.1252
#>
#> attached base packages:
#> [1] stats graphics  grDevices utils datasets  methods   base
#>
#> other attached packages:
#> [1] nlme_3.1-153 HRW_1.0-5
#>
#> loaded via a namespace (and not attached):
#>  [1] lattice_0.20-45digest_0.6.29  withr_2.4.3grid_4.1.2
#>  [5] magrittr_2.0.1 reprex_2.0.1   evaluate_0.14  
KernSmooth_2.23-20
#>  [9] highr_0.9  stringi_1.7.6  rlang_0.4.12   cli_3.1.0
#> [13] rstudioapi_0.13fs_1.5.2   rmarkdown_2.11 splines_4.1.2
#> [17] tools_4.1.2stringr_1.4.0  glue_1.6.0 xfun_0.29
#> [21] yaml_2.2.1 fastmap_1.1.0  compiler_4.1.2 htmltools_0.5.2
#> [25] knitr_1.37

Created on 2022-01-07 by the [reprex package](https://reprex.tidyverse.org) 
(v2.0.1)

 Here's the session Info for the Mac:

sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.1

Matrix products: default
LAPACK: 
/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] nlme_3.1-153  targets_0.8.1 HRW_1.0-5

loaded via a namespace (and not attached):
 [1] compiler_4.1.2 pillar_1.6.4   

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Andrew Simmons
I've tried a bunch of different R versions, I can't seem to replicate what
you described. Here's the code I used:


R.pattern <- paste0("^R-", .standard_regexps()$valid_R_system_version, "$")
x <- list.files(dirname(R.home()), pattern = R.pattern, full.names = TRUE)
x <- x[file.info(x, extra_cols = FALSE)$isdir]
x <- file.path(x, "bin", "x64", "Rscript")
commands <- shQuote(x)
args <- c("--default-packages=NULL", "--vanilla",
"-e", shQuote(r"{
x <- list.files(c(
"./" ,
"C:/",
"C:/Windows/"
), full.names = TRUE)
x <- x[grepl("//", x, fixed = TRUE)]
if (length(x))
print(x)
}"))
for (command in commands) {
command <- paste(c(command, args), collapse = " ")
cat(command, "\n", sep = "")
system(command)
cat("\n")
}


which should (theoretically) open every version of R you have installed and
try the code you ran. When I ran it, I found no files with two slashes in a
row:


"C:/PROGRA~1/R/R-2.15.3/bin/x64/Rscript" --default-packages=NULL --vanilla
-e "
x <- list.files(c(
\"./\" ,
\"C:/\",
\"C:/Windows/\"
), full.names = TRUE)
x <- x[grepl(\"//\", x, fixed = TRUE)]
if (length(x))
print(x)
"

"C:/PROGRA~1/R/R-3.5.3/bin/x64/Rscript" --default-packages=NULL --vanilla
-e "
x <- list.files(c(
\"./\" ,
\"C:/\",
\"C:/Windows/\"
), full.names = TRUE)
x <- x[grepl(\"//\", x, fixed = TRUE)]
if (length(x))
print(x)
"

"C:/PROGRA~1/R/R-3.6.3/bin/x64/Rscript" --default-packages=NULL --vanilla
-e "
x <- list.files(c(
\"./\" ,
\"C:/\",
\"C:/Windows/\"
), full.names = TRUE)
x <- x[grepl(\"//\", x, fixed = TRUE)]
if (length(x))
print(x)
"

"C:/PROGRA~1/R/R-4.0.2/bin/x64/Rscript" --default-packages=NULL --vanilla
-e "
x <- list.files(c(
\"./\" ,
\"C:/\",
\"C:/Windows/\"
), full.names = TRUE)
x <- x[grepl(\"//\", x, fixed = TRUE)]
if (length(x))
print(x)
"

"C:/PROGRA~1/R/R-4.1.0/bin/x64/Rscript" --default-packages=NULL --vanilla
-e "
x <- list.files(c(
\"./\" ,
\"C:/\",
\"C:/Windows/\"
), full.names = TRUE)
x <- x[grepl(\"//\", x, fixed = TRUE)]
if (length(x))
print(x)
"

"C:/PROGRA~1/R/R-4.1.1/bin/x64/Rscript" --default-packages=NULL --vanilla
-e "
x <- list.files(c(
\"./\" ,
\"C:/\",
\"C:/Windows/\"
), full.names = TRUE)
x <- x[grepl(\"//\", x, fixed = TRUE)]
if (length(x))
print(x)
"

"C:/PROGRA~1/R/R-4.1.2/bin/x64/Rscript" --default-packages=NULL --vanilla
-e "
x <- list.files(c(
\"./\" ,
\"C:/\",
\"C:/Windows/\"
), full.names = TRUE)
x <- x[grepl(\"//\", x, fixed = TRUE)]
if (length(x))
print(x)
"


I can't offer much more, sorry about that. Maybe your session information
could be helpful? utils::sessionInfo()

On Sun, Dec 19, 2021 at 6:40 AM Mario Reutter  wrote:

> Dear everybody,
>
> I'm a researcher in the field of psychology and a passionate R user. After
> having updated to the newest version, I experienced a problem with
> list.files() if the parameter full.names is set to TRUE.
> A path separator "/" is now always appended to path in the output even if
> path %>% endsWith("/"). This breaks backwards compatibility in case path
> ends with a path separator. The problem occurred somewhere between R
> version 3.6.1 (2019-07-05) and 4.1.2 (2021-11-01).
>
> Example:
> >> list.files("C:/Data/", full.names=T)
> C:/Data//file.csv
>
> Expected behavior:
> Either a path separator should never be appended in accordance with
> the documentation: "full.names
> a logical value. If TRUE, the directory path is prepended to the file names
> to give a relative file path."
> Or it could only be appended if path doesn't already end with a path
> separator.
>
> My question would now be if this warrants a bug report? And if you agree,
> could someone issue the report since I'm not a member on Bugzilla?
>
> Thank you and best regards,
> Mario Reutter
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list 

Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Bill Dunlap
> grep(value=TRUE, invert=TRUE, "$", strsplit(Sys.getenv("PATH"),
";")[[1]])
 [1] "C:\\rtools40\\usr\\bin"
 [2] "C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath"
 [3] "C:\\Program Files\\ImageMagick-7.0.11-Q16-HDRI"
 [4] "C:\\WINDOWS\\system32"
 [5] "C:\\WINDOWS"
 [6] "C:\\WINDOWS\\System32\\Wbem"
 [7] "C:\\ProgramData\\chocolatey\\bin"
 [8] "C:\\Program Files\\Git\\cmd"
 [9] "C:\\Program Files\\TortoiseSVN\\bin"
[10] "C:\\Program Files\\Docker\\Docker\\resources\\bin"
[11] "C:\\ProgramData\\DockerDesktop\\version-bin"
[12] "C:\\Users\\willi\\AppData\\Local\\Microsoft\\WindowsApps"
[13] "C:\\Users\\willi\\AppData\\Local\\Programs\\Microsoft VS Code\\bin"
[14] "C:\\Users\\willi\\AppData\\Roaming\\npm"
[15] "C:\\Users\\willi\\AppData\\Local\\GitHubDesktop\\bin"
> table(grepl("$", strsplit(Sys.getenv("PATH"), ";")[[1]])) # c. 2:1
against terminal backslash

FALSE  TRUE
   15 8


On Mon, Dec 20, 2021 at 9:30 AM Martin Maechler 
wrote:

> > Bill Dunlap
> > on Mon, 20 Dec 2021 08:40:04 -0800 writes:
>
> >>
> >> > Why would one ever *add* a final unneeded path separator,
> >> > unless one wanted it?
> >>
>
> > Good question, but it is common for Windows installer programs to
> add a
> > terminal backslash to PATH entries.  E.g., on my Windows laptop I get
>
> >> grep(value=TRUE, "$", strsplit(Sys.getenv("PATH"), ";")[[1]])
> > [1] "C:\\Python39\\Scripts\\"
> > [2] "C:\\Python39\\"
> > [3] "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\"
> > [4] "C:\\WINDOWS\\System32\\OpenSSH\\"
> > [5] "C:\\Program Files\\nodejs\\"
> > [6] "C:\\Program Files\\Pandoc\\"
> > [7] "C:\\Program Files\\MiKTeX\\miktex\\bin\\x64\\"
> > [8] "C:\\Program Files\\PuTTY\\"
>
> > I did not add those entries by hand; all were added by installer
> programs.
>
> > -Bill
>
> Thanks a lot, Bill,  for giving this part of the picture
> (even though you did not show how many there were in your PATH which
>  did *not* end in `\\` ..)
>
> However the reason for my 2nd post was that I could *not* at all
> confirm what Mario reported, but rather I saw
> having a final "/" and not having it
> to give the *same* behavior on R for Windows versions
> from 3.6.1 to 4.1.2 on our M$ Windows terminal server (2016)
> and now, as I just checked, it also *still* has the same Windows-specific
> behavior in R-devel-ucrt (the one from Tomas Kalibera) :
>
> If I use a trailing `/` or `\\` it is *kept*, but no additional
> fsep (i.e. '/' or `\\`) is added (on Windows) when I use
>
>  list.files(dir, full.names=TRUE)
>
> contrary to what Mario reported (to happen in R 4.1.2, but not R 3.6.1)
>
> Martin
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Martin Maechler
> Bill Dunlap 
> on Mon, 20 Dec 2021 08:40:04 -0800 writes:

>> 
>> > Why would one ever *add* a final unneeded path separator,
>> > unless one wanted it?
>> 

> Good question, but it is common for Windows installer programs to add a
> terminal backslash to PATH entries.  E.g., on my Windows laptop I get

>> grep(value=TRUE, "$", strsplit(Sys.getenv("PATH"), ";")[[1]])
> [1] "C:\\Python39\\Scripts\\"
> [2] "C:\\Python39\\"
> [3] "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\"
> [4] "C:\\WINDOWS\\System32\\OpenSSH\\"
> [5] "C:\\Program Files\\nodejs\\"
> [6] "C:\\Program Files\\Pandoc\\"
> [7] "C:\\Program Files\\MiKTeX\\miktex\\bin\\x64\\"
> [8] "C:\\Program Files\\PuTTY\\"

> I did not add those entries by hand; all were added by installer programs.

> -Bill

Thanks a lot, Bill,  for giving this part of the picture
(even though you did not show how many there were in your PATH which
 did *not* end in `\\` ..)

However the reason for my 2nd post was that I could *not* at all
confirm what Mario reported, but rather I saw
having a final "/" and not having it
to give the *same* behavior on R for Windows versions
from 3.6.1 to 4.1.2 on our M$ Windows terminal server (2016)
and now, as I just checked, it also *still* has the same Windows-specific
behavior in R-devel-ucrt (the one from Tomas Kalibera) :

If I use a trailing `/` or `\\` it is *kept*, but no additional
fsep (i.e. '/' or `\\`) is added (on Windows) when I use

 list.files(dir, full.names=TRUE)

contrary to what Mario reported (to happen in R 4.1.2, but not R 3.6.1)

Martin

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Bill Dunlap
>
> > Why would one ever *add* a final unneeded path separator,
> > unless one wanted it?
>

Good question, but it is common for Windows installer programs to add a
terminal backslash to PATH entries.  E.g., on my Windows laptop I get

> grep(value=TRUE, "$", strsplit(Sys.getenv("PATH"), ";")[[1]])
[1] "C:\\Python39\\Scripts\\"
[2] "C:\\Python39\\"
[3] "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\"
[4] "C:\\WINDOWS\\System32\\OpenSSH\\"
[5] "C:\\Program Files\\nodejs\\"
[6] "C:\\Program Files\\Pandoc\\"
[7] "C:\\Program Files\\MiKTeX\\miktex\\bin\\x64\\"
[8] "C:\\Program Files\\PuTTY\\"

I did not add those entries by hand; all were added by installer programs.

-Bill

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Jorgen Harmse via R-help
There is a possibly related problem in file.path. As Murdoch says, it's ugly 
even if the OS accepts it, and I don't see that the base version is any better 
than paste(sep=fsep, ...). Pasting the result into emacs wouldn't work. I wrote 
my own version to remove trailing fsep from all but the last argument.

> base::file.path('foo/','bar')
[1] "foo//bar"
> file.path('foo/','bar')
[1] "foo/bar"

Incidentally, I don't like T & F for Booleans (or t for transpose) in 
production code. Single letters are too useful for local variables, so I would 
say TRUE, FALSE, & base::t.

Jorgen Harmse.



Message: 1
Date: Sat, 18 Dec 2021 15:55:37 +0100
From: Mario Reutter 
To: r-help@r-project.org
Subject: [R] Bug in list.files(full.names=T)
Message-ID:

Content-Type: text/plain; charset="utf-8"

Dear everybody,

I'm a researcher in the field of psychology and a passionate R user. After
having updated to the newest version, I experienced a problem with
list.files() if the parameter full.names is set to TRUE.
A path separator "/" is now always appended to path in the output even if
path %>% endsWith("/"). This breaks backwards compatibility in case path
ends with a path separator. The problem occurred somewhere between R
version 3.6.1 (2019-07-05) and 4.1.2 (2021-11-01).

Example:
>> list.files("C:/Data/", full.names=T)
C:/Data//file.csv

Expected behavior:
Either a path separator should never be appended in accordance with
the documentation: "full.names
a logical value. If TRUE, the directory path is prepended to the file names
to give a relative file path."
Or it could only be appended if path doesn't already end with a path
separator.

My question would now be if this warrants a bug report? And if you agree,
could someone issue the report since I'm not a member on Bugzilla?

Thank you and best regards,
Mario Reutter

[[alternative HTML version deleted]]




--



Message: 3
Date: Sun, 19 Dec 2021 07:24:06 -0500
    From: Duncan Murdoch 
To: Mario Reutter , r-help@r-project.org
Subject: Re: [R] Bug in list.files(full.names=T)
Message-ID: <67096ee7-054d-0e89-cc44-6ca702307...@gmail.com>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

I don't know the answer to your question, but I see the same behaviour 
on MacOS, e.g. list.files("./") includes ".//R" in the results on my 
system.  Both "./R" and ".//R" are legal ways to express that path on 
MacOS, so it's not a serious bug, but it does look ugly.

Duncan Murdoch

...


------

Message: 10
Date: Mon, 20 Dec 2021 09:46:23 +0100
From: Martin Maechler 
To: Mario Reutter 
Cc: 
Subject: Re: [R] Bug in list.files(full.names=T)
Message-ID: <25024.17119.584361.442...@stat.math.ethz.ch>
Content-Type: text/plain; charset="us-ascii"

...

This expected behavior has never been documented AFAIK.
I tried R 3.6.1 on Linux  and it already behaved like that:  If
you append a path separator  it is kept in addition to the new
one even though it's not needed:

> list.files("/tmp", "^[abc]", full.names = TRUE)
[1] "/tmp/check_proc__localuser"

> list.files("/tmp/", "^[abc]", full.names = TRUE)
[1] "/tmp//check_proc__localuser"

Why would one ever *add* a final unneeded path separator, unless
one wanted it?

Note that the default is  ".",  not "./"  ..

I think the change you see made R-for-Windows compatible
to the rest of the univeRse where list.files() aka dir() always
behaved like this.

I agree that ideally this would have been mentioned in some of
the NEWS; maybe it *is* mentioned in the rw-faw (R for Windows
FAQ) or other R for Windows news.. ?


> My question would now be if this warrants a bug report?

I don't think so.
As I'm saying above, I think this has rather been a bug fix,
making R more universal / less platform-dependent.

Last but not least: You'd ideally update more than every 2.5 years...

Best,
Martin Maechler




__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Martin Maechler
> Martin Maechler 
> on Mon, 20 Dec 2021 09:46:23 +0100 writes:

> Mario Reutter 
> on Sat, 18 Dec 2021 15:55:37 +0100 writes:

>> Dear everybody,

>> I'm a researcher in the field of psychology and a
>> passionate R user. After having updated to the newest
>> version, I experienced a problem with list.files() if the
>> parameter full.names is set to TRUE.  A path separator
>> "/" is now always appended to path in the output even if
>> path %>% endsWith("/"). This breaks backwards
>> compatibility in case path ends with a path
>> separator. The problem occurred somewhere between R
>> version 3.6.1 (2019-07-05) and 4.1.2 (2021-11-01).

>> Example:
 list.files("C:/Data/", full.names=T)
>> C:/Data//file.csv

>> Expected behavior: Either a path separator should never
>> be appended in accordance with the documentation:
>> "full.names a logical value. If TRUE, the directory path
>> is prepended to the file names to give a relative file
>> path."  Or it could only be appended if path doesn't
>> already end with a path separator.

> This expected behavior has never been documented AFAIK.  I
> tried R 3.6.1 on Linux and it already behaved like that:
> If you append a path separator it is kept in addition to
> the new one even though it's not needed:

>> list.files("/tmp", "^[abc]", full.names = TRUE)
> [1] "/tmp/check_proc__localuser"

>> list.files("/tmp/", "^[abc]", full.names = TRUE)
> [1] "/tmp//check_proc__localuser"

> Why would one ever *add* a final unneeded path separator,
> unless one wanted it?

> Note that the default is ".", not "./" ..

> I think the change you see made R-for-Windows compatible
> to the rest of the univeRse where list.files() aka dir()
> always behaved like this.

> I agree that ideally this would have been mentioned in
> some of the NEWS; maybe it *is* mentioned in the rw-faw (R
> for Windows FAQ) or other R for Windows news.. ?

On the other hand, now that I tried it,
on the Windows Terminal Server 2016 I've access to,
I see what you said *was* your previous behavior, i.e.,
I see this {R code with comments for what I see} :

##
str(c0 <- list.files("C:/"))
## chr [1:23] "$Recycle.Bin" "536F22AB9746" "Boot" "bootmgr" "BOOTNxsXT" ...
str(c1 <- list.files("C:/Boot", full.names=TRUE))
str(c1s <- list.files("C:/Boot/", full.names=TRUE))# extra '/' at end
## but even here, the extra trailing '/' does *not* harm
all(c1 == c1s) ## TRUE !

The above, using ESS and plain RGui Windows *and* Rstudio;
for ESS in the following of my (dozen or so on Windows server) R versions :
R 3.6.1, 4.0.0, 4.1.1, 4.1.2

... so I remain quite a bit puzzled...

Maybe other R-on-Windows users can have a look?
Martin

>> My question would now be if this warrants a bug report?

> I don't think so.  As I'm saying above, I think this has
> rather been a bug fix, making R more universal / less
> platform-dependent.

> Last but not least: You'd ideally update more than every
> 2.5 years...

> Best, Martin Maechler



>> And if you agree, could someone issue the report since
>> I'm not a member on Bugzilla?

>> Thank you and best regards, Mario Reutter

> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and
> more, see https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide
> commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in list.files(full.names=T)

2021-12-20 Thread Martin Maechler
> Mario Reutter 
> on Sat, 18 Dec 2021 15:55:37 +0100 writes:

> Dear everybody,

> I'm a researcher in the field of psychology and a
> passionate R user. After having updated to the newest
> version, I experienced a problem with list.files() if the
> parameter full.names is set to TRUE.  A path separator "/"
> is now always appended to path in the output even if path
> %>% endsWith("/"). This breaks backwards compatibility in
> case path ends with a path separator. The problem occurred
> somewhere between R version 3.6.1 (2019-07-05) and 4.1.2
> (2021-11-01).

> Example:
>>> list.files("C:/Data/", full.names=T)
> C:/Data//file.csv

> Expected behavior: Either a path separator should never be
> appended in accordance with the documentation: "full.names
> a logical value. If TRUE, the directory path is prepended
> to the file names to give a relative file path."  Or it
> could only be appended if path doesn't already end with a
> path separator.

This expected behavior has never been documented AFAIK.
I tried R 3.6.1 on Linux  and it already behaved like that:  If
you append a path separator  it is kept in addition to the new
one even though it's not needed:

> list.files("/tmp", "^[abc]", full.names = TRUE)
[1] "/tmp/check_proc__localuser"

> list.files("/tmp/", "^[abc]", full.names = TRUE)
[1] "/tmp//check_proc__localuser"

Why would one ever *add* a final unneeded path separator, unless
one wanted it?

Note that the default is  ".",  not "./"  ..

I think the change you see made R-for-Windows compatible
to the rest of the univeRse where list.files() aka dir() always
behaved like this.

I agree that ideally this would have been mentioned in some of
the NEWS; maybe it *is* mentioned in the rw-faw (R for Windows
FAQ) or other R for Windows news.. ?


> My question would now be if this warrants a bug report?

I don't think so.
As I'm saying above, I think this has rather been a bug fix,
making R more universal / less platform-dependent.

Last but not least: You'd ideally update more than every 2.5 years...

Best,
Martin Maechler



> And if you agree, could someone issue the report since I'm
> not a member on Bugzilla?

> Thank you and best regards, Mario Reutter

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in list.files(full.names=T)

2021-12-19 Thread Duncan Murdoch
I don't know the answer to your question, but I see the same behaviour 
on MacOS, e.g. list.files("./") includes ".//R" in the results on my 
system.  Both "./R" and ".//R" are legal ways to express that path on 
MacOS, so it's not a serious bug, but it does look ugly.


Duncan Murdoch

On 18/12/2021 9:55 a.m., Mario Reutter wrote:

Dear everybody,

I'm a researcher in the field of psychology and a passionate R user. After
having updated to the newest version, I experienced a problem with
list.files() if the parameter full.names is set to TRUE.
A path separator "/" is now always appended to path in the output even if
path %>% endsWith("/"). This breaks backwards compatibility in case path
ends with a path separator. The problem occurred somewhere between R
version 3.6.1 (2019-07-05) and 4.1.2 (2021-11-01).

Example:

list.files("C:/Data/", full.names=T)

C:/Data//file.csv

Expected behavior:
Either a path separator should never be appended in accordance with
the documentation: "full.names
a logical value. If TRUE, the directory path is prepended to the file names
to give a relative file path."
Or it could only be appended if path doesn't already end with a path
separator.

My question would now be if this warrants a bug report? And if you agree,
could someone issue the report since I'm not a member on Bugzilla?

Thank you and best regards,
Mario Reutter

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug in list.files(full.names=T)

2021-12-19 Thread Mario Reutter
Dear everybody,

I'm a researcher in the field of psychology and a passionate R user. After
having updated to the newest version, I experienced a problem with
list.files() if the parameter full.names is set to TRUE.
A path separator "/" is now always appended to path in the output even if
path %>% endsWith("/"). This breaks backwards compatibility in case path
ends with a path separator. The problem occurred somewhere between R
version 3.6.1 (2019-07-05) and 4.1.2 (2021-11-01).

Example:
>> list.files("C:/Data/", full.names=T)
C:/Data//file.csv

Expected behavior:
Either a path separator should never be appended in accordance with
the documentation: "full.names
a logical value. If TRUE, the directory path is prepended to the file names
to give a relative file path."
Or it could only be appended if path doesn't already end with a path
separator.

My question would now be if this warrants a bug report? And if you agree,
could someone issue the report since I'm not a member on Bugzilla?

Thank you and best regards,
Mario Reutter

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug? Index output of C functions R_qsort_I and R_qsort_int_I is not modified

2021-04-16 Thread Evangelos Evangelou via R-help
Thanks for your input Bill.

I also realised that the second argument must be initialised to 1:n, which is 
not mentioned in the documentation. So, if I define
void mysort2i (int *x, int *i, int *n)
{
  R_qsort_int_I(x,i,1,*n);
}

Then

> .C("mysort2i",4:1,integer(4),4L)
[[1]]
[1] 1 2 3 4

[[2]]
[1] 0 0 0 0

[[3]]
[1] 4

but

> .C("mysort2i",4:1,1:4,4L)
[[1]]
[1] 1 2 3 4

[[2]]
[1] 4 3 2 1

[[3]]
[1] 4



From: Bill Dunlap 
Sent: 16 April 2021 04:50
To: Evangelos Evangelou 
Cc: r-help@r-project.org 
Subject: Re: [R] Bug? Index output of C functions R_qsort_I and R_qsort_int_I 
is not modified




R_ext/Utils.h:void R_qsort_int_I(int *iv, int *II, int i, int j);

The last 2 arguments are int, not int*.  .C() passes pointers to vectors so you 
cannot call this function directly from .C().

-Bill

On Thu, Apr 15, 2021 at 3:15 PM Evangelos Evangelou via R-help 
mailto:r-help@r-project.org>> wrote:
Hi all.

Reading the documentation of these two functions
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Utility-functions<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcran.r-project.org%2Fdoc%2Fmanuals%2Fr-release%2FR-exts.html%23Utility-functions=04%7C01%7Cee224%40bath.ac.uk%7C10bfc437aa4c4a1de23208d9008ad510%7C377e3d224ea1422db0ad8fcc89406b9e%7C0%7C0%7C637541418550685457%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=vIt2tF%2BtNP%2B8t%2FNmUtNsP0JGRoOyo30jy1hWD%2BQI2vk%3D=0>
"The ..._I() versions also return the sort.index() vector in I."
I can't find anything in the documentation about sort.index(), but I'm guessing 
that I is the index that makes the input sorted, as in R's order(). However 
running the following code on
R version 4.0.5 (2021-03-31) Platform: x86_64-pc-linux-gnu (64-bit)
does not give me that. It just gives me the original input.

Rlib = file.path(Sys.getenv("R_HOME"), "lib", paste0("libR", 
.Platform$dynlib.ext))
dyn.load(Rlib)
n = 4L
ix = n:1
i = integer(n)
cc = .C("R_qsort_int_I", ix, i, 1L, n)
cc[[2]]

I expect 4 3 2 1, but I get 0 0 0 0. Is this a bug or have I misunderstood 
something?

Best,
Vangelis

[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=04%7C01%7Cee224%40bath.ac.uk%7C10bfc437aa4c4a1de23208d9008ad510%7C377e3d224ea1422db0ad8fcc89406b9e%7C0%7C0%7C637541418550685457%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=h1Rb1vobBq49NzofsNBgZfwSqa1ZSqVhQbZT%2BBpq2ac%3D=0>
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html<https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=04%7C01%7Cee224%40bath.ac.uk%7C10bfc437aa4c4a1de23208d9008ad510%7C377e3d224ea1422db0ad8fcc89406b9e%7C0%7C0%7C637541418550695414%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000=yY8ALqCrEoBvQftAibVu7urh9%2FNHgmAGPgcauW%2Ff9Mo%3D=0>
and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug? Index output of C functions R_qsort_I and R_qsort_int_I is not modified

2021-04-15 Thread Bill Dunlap
R_ext/Utils.h:void R_qsort_int_I(int *iv, int *II, int i, int j);

The last 2 arguments are int, not int*.  .C() passes pointers to vectors so
you cannot call this function directly from .C().

-Bill

On Thu, Apr 15, 2021 at 3:15 PM Evangelos Evangelou via R-help <
r-help@r-project.org> wrote:

> Hi all.
>
> Reading the documentation of these two functions
>
> https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Utility-functions
> "The ..._I() versions also return the sort.index() vector in I."
> I can't find anything in the documentation about sort.index(), but I'm
> guessing that I is the index that makes the input sorted, as in R's
> order(). However running the following code on
> R version 4.0.5 (2021-03-31) Platform: x86_64-pc-linux-gnu (64-bit)
> does not give me that. It just gives me the original input.
>
> Rlib = file.path(Sys.getenv("R_HOME"), "lib", paste0("libR",
> .Platform$dynlib.ext))
> dyn.load(Rlib)
> n = 4L
> ix = n:1
> i = integer(n)
> cc = .C("R_qsort_int_I", ix, i, 1L, n)
> cc[[2]]
>
> I expect 4 3 2 1, but I get 0 0 0 0. Is this a bug or have I misunderstood
> something?
>
> Best,
> Vangelis
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug? Index output of C functions R_qsort_I and R_qsort_int_I is not modified

2021-04-15 Thread Evangelos Evangelou via R-help
Hi all.

Reading the documentation of these two functions
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Utility-functions
"The ..._I() versions also return the sort.index() vector in I."
I can't find anything in the documentation about sort.index(), but I'm guessing 
that I is the index that makes the input sorted, as in R's order(). However 
running the following code on
R version 4.0.5 (2021-03-31) Platform: x86_64-pc-linux-gnu (64-bit)
does not give me that. It just gives me the original input.

Rlib = file.path(Sys.getenv("R_HOME"), "lib", paste0("libR", 
.Platform$dynlib.ext))
dyn.load(Rlib)
n = 4L
ix = n:1
i = integer(n)
cc = .C("R_qsort_int_I", ix, i, 1L, n)
cc[[2]]

I expect 4 3 2 1, but I get 0 0 0 0. Is this a bug or have I misunderstood 
something?

Best,
Vangelis

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug or just me

2020-05-30 Thread Eric Berger
Hi Martin,
This is a known bug. Definitely related to Ubuntu (debian), libopenblas and
possibly specific hardware.
Here's a bug report on the Debian list

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=961725

Best,
Eric


On Sun, May 31, 2020 at 4:38 AM Bert Gunter  wrote:

> No clue.
>
> Worked fine in R 4.0.0
> I would try updating R.Maybe your BLAS got corrupted.
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Sat, May 30, 2020 at 5:57 PM Martin Møller Skarbiniks Pedersen <
> traxpla...@gmail.com> wrote:
>
> > Hi,
> >   Is this a bug or just me doing something stupid?
> >   solve(m) never returns and eats 100% CPU.
> >
> > > sessionInfo()
> > R version 3.6.3 (2020-02-29)
> > Platform: x86_64-pc-linux-gnu (64-bit)
> > Running under: Ubuntu 20.04 LTS
> >
> > Matrix products: default
> > BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
> > LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
> >
> > Random number generation:
> >  RNG: Mersenne-Twister
> >  Normal:  Inversion
> >  Sample:  Rounding
> >
> > locale:
> >  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
> >  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
> >  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
> >  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
> >  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
> >
> > attached base packages:
> > [1] stats graphics  grDevices utils datasets  methods   base
> >
> > loaded via a namespace (and not attached):
> > [1] compiler_3.6.3
> > > set.seed(1)
> > > m <- matrix(sample(1:25), nrow=5)
> > > solve(m)
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bug or just me

2020-05-30 Thread Bert Gunter
No clue.

Worked fine in R 4.0.0
I would try updating R.Maybe your BLAS got corrupted.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Sat, May 30, 2020 at 5:57 PM Martin Møller Skarbiniks Pedersen <
traxpla...@gmail.com> wrote:

> Hi,
>   Is this a bug or just me doing something stupid?
>   solve(m) never returns and eats 100% CPU.
>
> > sessionInfo()
> R version 3.6.3 (2020-02-29)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 20.04 LTS
>
> Matrix products: default
> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3
>
> Random number generation:
>  RNG: Mersenne-Twister
>  Normal:  Inversion
>  Sample:  Rounding
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.6.3
> > set.seed(1)
> > m <- matrix(sample(1:25), nrow=5)
> > solve(m)
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] bug or just me

2020-05-30 Thread Martin Møller Skarbiniks Pedersen
Hi,
  Is this a bug or just me doing something stupid?
  solve(m) never returns and eats 100% CPU.

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

Random number generation:
 RNG: Mersenne-Twister
 Normal:  Inversion
 Sample:  Rounding

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] compiler_3.6.3
> set.seed(1)
> m <- matrix(sample(1:25), nrow=5)
> solve(m)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in function arguments autocomplete and ellipsis?

2020-05-08 Thread Roman Olson
Dear All,

Thanks for clarifying this. Now I know that this is expected behavior, and will 
try to place … before the rest of the arguments.

Stay home and stay safe!
-Roman

> 2020. 5. 9. 오전 1:24, Bert Gunter  작성:
> 
> The R
> Language Definition


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in function arguments autocomplete and ellipsis?

2020-05-08 Thread Bert Gunter
It would help if you consulted the docs, in this case, **The R
Language Definition** and, in particular, 4.3.2 on argument matching.
I won't repeat what it is there, but I believe it will suffice to
dispel your confusion.


Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Fri, May 8, 2020 at 7:49 AM Roman Olson  wrote:
>
> Dear All,
>
> I am wondering whether function arguments autocomplete causes a bug when 
> additional ellipsis arguments are used.
>
> Example:
> a = function(robot) {
> cat(robot, "\n")
>  }
> a(r=5) prints 5, meaning that r is autocompleted to “robot”. Not sure if this 
> is normal behavior, but this does not cause problems.
>
> This would be fine, but somehow causes problems when there is an additional 
> ellipsis argument that can be used to autocomplete an already existing 
> argument. In the example below, when we are calling sens.analysis.all, 
> everything starting with q is an additional argument (…). Now, k is missed 
> completely. And that is because there is another actual argument that starts 
> with k — key.legend.axes (it is assigned to 4 instead). If “k=4” is changed 
> to “kk=4” the problem disappears.
>
> sens.analysis.all <- function(func, outgrid, parvec, parmin, parmax,
>   length.pgrid, outvname, zlim, plabs,
>   gridlab, mylog, outlog=FALSE, ytick=NULL,
>   xline=NULL, yline=NULL, mypal=topo.colors,
>   key.legend.axes=NULL, plot.guidance=FALSE, ... 
> ) {
>
>cat(..1, "\n")
>cat(..2, "\n")
>cat(..3, "\n")
>
>out=1
>out
> }
>
> out = sens.analysis.all(numer.wait.times.wrps, NA,
>  c(5.4, 0.008, 1.5), c(4.9, 0.0079, 2.0), c(5.5, 0.0090, 3.5),
>length.pgrid=10, outvname="cvs", zlim=c(0.3, 2),
>plabs=c("mu", "lambda", "b"), gridlab="Soil Moisture [mm]",
>mylog=FALSE, outlog=FALSE, yline=2, plot.guidance=FALSE, q=3.1, k=4, 
> y.c=670,
>realgrid=seq(630, 670, by=4), myseed=0,
>nt=100, burnin=30, bin.cutoff=500,
>bdW.prelim=prec.struct.Mal)
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in function arguments autocomplete and ellipsis?

2020-05-08 Thread Duncan Murdoch

On 07/05/2020 3:46 a.m., Roman Olson wrote:

Dear All,

I am wondering whether function arguments autocomplete causes a bug when 
additional ellipsis arguments are used.

Example:
a = function(robot) {
 cat(robot, "\n")
  }
a(r=5) prints 5, meaning that r is autocompleted to “robot”. Not sure if this 
is normal behavior, but this does not cause problems.

This would be fine, but somehow causes problems when there is an additional 
ellipsis argument that can be used to autocomplete an already existing 
argument. In the example below, when we are calling sens.analysis.all, 
everything starting with q is an additional argument (…). Now, k is missed 
completely. And that is because there is another actual argument that starts 
with k — key.legend.axes (it is assigned to 4 instead). If “k=4” is changed to 
“kk=4” the problem disappears.

sens.analysis.all <- function(func, outgrid, parvec, parmin, parmax,
   length.pgrid, outvname, zlim, plabs,
   gridlab, mylog, outlog=FALSE, ytick=NULL,
   xline=NULL, yline=NULL, mypal=topo.colors,
   key.legend.axes=NULL, plot.guidance=FALSE, ... ) 
{

cat(..1, "\n")
cat(..2, "\n")
cat(..3, "\n")
  
out=1

out
}

out = sens.analysis.all(numer.wait.times.wrps, NA,
  c(5.4, 0.008, 1.5), c(4.9, 0.0079, 2.0), c(5.5, 0.0090, 3.5),
length.pgrid=10, outvname="cvs", zlim=c(0.3, 2),
plabs=c("mu", "lambda", "b"), gridlab="Soil Moisture [mm]",
mylog=FALSE, outlog=FALSE, yline=2, plot.guidance=FALSE, q=3.1, k=4, 
y.c=670,
realgrid=seq(630, 670, by=4), myseed=0,
nt=100, burnin=30, bin.cutoff=500,
bdW.prelim=prec.struct.Mal)


I'm afraid I don't understand what you find surprising here.  In your 
first example, the "r" gets attached to "robot" because of partial 
matching.  In the second example, the "k" gets attached to 
"key.legend.axes" for the same reason.  This is expected behaviour.  If 
you don't want to allow  partial matching to arguments, they need to be 
placed *after* the ellipsis.  Those arguments will need to be spelled 
out in full.


Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug in function arguments autocomplete and ellipsis?

2020-05-08 Thread Roman Olson
Dear All,

I am wondering whether function arguments autocomplete causes a bug when 
additional ellipsis arguments are used.

Example:
a = function(robot) {
cat(robot, "\n")
 }
a(r=5) prints 5, meaning that r is autocompleted to “robot”. Not sure if this 
is normal behavior, but this does not cause problems.

This would be fine, but somehow causes problems when there is an additional 
ellipsis argument that can be used to autocomplete an already existing 
argument. In the example below, when we are calling sens.analysis.all, 
everything starting with q is an additional argument (…). Now, k is missed 
completely. And that is because there is another actual argument that starts 
with k — key.legend.axes (it is assigned to 4 instead). If “k=4” is changed to 
“kk=4” the problem disappears.  

sens.analysis.all <- function(func, outgrid, parvec, parmin, parmax,
  length.pgrid, outvname, zlim, plabs,
  gridlab, mylog, outlog=FALSE, ytick=NULL,
  xline=NULL, yline=NULL, mypal=topo.colors,
  key.legend.axes=NULL, plot.guidance=FALSE, ... ) {

   cat(..1, "\n")
   cat(..2, "\n")
   cat(..3, "\n")
 
   out=1
   out
} 

out = sens.analysis.all(numer.wait.times.wrps, NA,
 c(5.4, 0.008, 1.5), c(4.9, 0.0079, 2.0), c(5.5, 0.0090, 3.5),
   length.pgrid=10, outvname="cvs", zlim=c(0.3, 2),
   plabs=c("mu", "lambda", "b"), gridlab="Soil Moisture [mm]",
   mylog=FALSE, outlog=FALSE, yline=2, plot.guidance=FALSE, q=3.1, k=4, 
y.c=670,
   realgrid=seq(630, 670, by=4), myseed=0,
   nt=100, burnin=30, bin.cutoff=500,
   bdW.prelim=prec.struct.Mal)
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug (?): file.copy() erases 'from' file if the "to" file already exists and is a symlinked file

2019-09-13 Thread peter dalgaard
However, notice that cat doesn't protect you in the same way:

Peters-iMac:tst pd$ echo stuff > A
Peters-iMac:tst pd$ ln -s A B
Peters-iMac:tst pd$ ls -l
total 8
-rw-r--r--  1 pd  staff  6 Sep 13 15:20 A
lrwxr-xr-x  1 pd  staff  1 Sep 13 15:20 B -> A
Peters-iMac:tst pd$ cp A B
cp: B and A are identical (not copied).
Peters-iMac:tst pd$ ls -l
total 8
-rw-r--r--  1 pd  staff  6 Sep 13 15:20 A
lrwxr-xr-x  1 pd  staff  1 Sep 13 15:20 B -> A
Peters-iMac:tst pd$ cat A > B
Peters-iMac:tst pd$ ls -l
total 0
-rw-r--r--  1 pd  staff  0 Sep 13 15:20 A
lrwxr-xr-x  1 pd  staff  1 Sep 13 15:20 B -> A

(& I suspect that cp did likewise in early Unices). Bug or not, it would be 
good if we could detect when "from" and "to" refer to the same file, but I'm 
not sure how to do that.

-pd

> On 13 Sep 2019, at 11:56 , Marc Girondot via R-help  
> wrote:
> 
> If file.copy() is used to replace a symlinked file, it erases the original 
> file and does not copy the file. The original file is lost.
> 
> > version
>  _
> platform x86_64-apple-darwin15.6.0
> arch x86_64
> os darwin15.6.0
> system x86_64, darwin15.6.0
> status Patched
> major?? 3
> minor?? 6.1
> year 2019
> month?? 09
> day?? 06
> svn rev?? 77160
> language R
> version.string R version 3.6.1 Patched (2019-09-06 r77160)
> nickname Action of the Toes
> 
> #
> 
> Here is a reproducible example:
> 
> A <- 10
> save(A, file="A.Rdata")
> file.symlink(from="A.Rdata", to="B.Rdata")
> rm(A)
> 
> load(file="B.Rdata")
> print(A)?? # Perfect
> 
> system("ls -l")
> ## -rw-r--r--?? 1 marcgirondot?? staff?? 70 13 sep 11:44 A.Rdata
> ## lrwxr-xr-x?? 1 marcgirondot?? staff 7 13 sep 11:44 B.Rdata -> 
> A.Rdata
> 
> file.copy(from="A.Rdata", to="B.Rdata", overwrite = TRUE)
> 
> system("ls -l")
> ## -rw-r--r--?? 1 marcgirondot?? staff 0 13 sep 11:44 A.Rdata
> ## lrwxr-xr-x?? 1 marcgirondot?? staff 7 13 sep 11:44 B.Rdata -> 
> A.Rdata
> 
> ###
> 
> A.Rdata becomes empty: 0B
> The content of A.Rdata is lost
> 
> 
> In terminal the problem does not occur
> 
> 
> marcgirondot$ ls
> A.Rdata
> marcgirondot$ ln -s A.Rdata B.Rdata
> marcgirondot$ ls -l
> -rw-r--r--?? 1 marcgirondot?? staff?? 70 13 sep 11:38 A.Rdata
> lrwxr-xr-x?? 1 marcgirondot?? staff 7 13 sep 11:38 B.Rdata -> 
> A.Rdata
> marcgirondot$ cp A.Rdata B.Rdata
> cp: B.Rdata and A.Rdata are identical (not copied).
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug (?): file.copy() erases 'from' file if the "to" file already exists and is a symlinked file

2019-09-13 Thread Marc Girondot via R-help
If file.copy() is used to replace a symlinked file, it erases the 
original file and does not copy the file. The original file is lost.


> version
 _
platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status Patched
major?? 3
minor?? 6.1
year 2019
month?? 09
day?? 06
svn rev?? 77160
language R
version.string R version 3.6.1 Patched (2019-09-06 r77160)
nickname Action of the Toes

#

Here is a reproducible example:

A <- 10
save(A, file="A.Rdata")
file.symlink(from="A.Rdata", to="B.Rdata")
rm(A)

load(file="B.Rdata")
print(A)?? # Perfect

system("ls -l")
## -rw-r--r--?? 1 marcgirondot?? staff?? 70 13 sep 11:44 A.Rdata
## lrwxr-xr-x?? 1 marcgirondot?? staff 7 13 sep 11:44 B.Rdata -> 
A.Rdata

file.copy(from="A.Rdata", to="B.Rdata", overwrite = TRUE)

system("ls -l")
## -rw-r--r--?? 1 marcgirondot?? staff 0 13 sep 11:44 A.Rdata
## lrwxr-xr-x?? 1 marcgirondot?? staff 7 13 sep 11:44 B.Rdata -> 
A.Rdata

###

A.Rdata becomes empty: 0B
The content of A.Rdata is lost


In terminal the problem does not occur


marcgirondot$ ls
A.Rdata
marcgirondot$ ln -s A.Rdata B.Rdata
marcgirondot$ ls -l
-rw-r--r--?? 1 marcgirondot?? staff?? 70 13 sep 11:38 A.Rdata
lrwxr-xr-x?? 1 marcgirondot?? staff 7 13 sep 11:38 B.Rdata -> 
A.Rdata
marcgirondot$ cp A.Rdata B.Rdata
cp: B.Rdata and A.Rdata are identical (not copied).

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug in "==" with empty data frames

2019-09-05 Thread Rainer M Krug
Hi

The following code results in an error:


###
> x <- data.frame(x = integer(0), y = integer(0))
> x == x
Error in matrix(if (is.null(value)) logical() else value, nrow = nr, dimnames = 
list(rn,  :
  length of 'dimnames' [2] not equal to array extent
>
###

I would expect that it returns logical(0) as both have the same structure and 
both are empty, or even TRUE?

But definitely not an error.

Cheers,

Rainer

###
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin17.7.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS:   
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: 
/System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
[1] compiler_3.6.1
###

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, 
UCT), Dipl. Phys. (Germany)

Orcid ID: -0002-7490-0066

Department of Evolutionary Biology and Environmental Studies
University of Zürich
Office Y34-J-74
Winterthurerstrasse 190
8075 Zürich
Switzerland

Office: +41 (0)44 635 47 64
Cell:   +41 (0)78 630 66 57
email:  rainer.k...@uzh.ch
rai...@krugs.de
Skype: RMkrug

PGP: 0x0F52F982

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R 3.6.0?

2019-04-30 Thread Martin Maechler
> Morgan Morgan 
> on Mon, 29 Apr 2019 21:42:36 +0100 writes:

> Hi,
> I am using the R 3.6.0 on windows. The issue that I report below does not
> exist with previous version of R.
> In order to reproduce the error you must install a package of your choice
> from source (tar.gz).

> -Create a .Rprofile file with the following command in it : setwd("D:/")
> -Close your R session and re-open it. Your working directory must be now 
set
> to D:
> -Install a package of your choice from source, example :
> install.packages("data.table",type="source")

> In my case the package fail to install and I get the following error
> message:

> ** R
> ** inst
> ** byte-compile and prepare package for lazy loading
> Error in tools:::.read_description(file) :
> file 'DESCRIPTION' does not exist
> Calls: suppressPackageStartupMessages ... withCallingHandlers ->
> .getRequiredPackages ->  -> 
> Execution halted
> ERROR: lazy loading failed for package 'data.table'
> * removing 'C:/Users/Morgan/Documents/R/win-library/3.6/data.table'
> * restoring previous
> 'C:/Users/Morgan/Documents/R/win-library/3.6/data.table'
> Warning in install.packages :
> installation of package ‘data.table’ had non-zero exit status

> Now remove the .Rprofile file, restart your R session and try to install 
th
e
> package with the same command.
> In that case everything should be installed just fine.

> FYI the issue happens on macOS as well and I suspect it also does on all
> linux systems.

> My question: Is this expected or is it a bug?

It is a bug, thank you very much for reporting it.

I've been told privately by Ömer An (thank you!) who's been
affected as well, that this problem seems to affect others, and
that there's a thread about this over at the Rstudio support site

https://support.rstudio.com/hc/en-us/community/posts/200704708-Build-tool-does-not-recognize-DESCRIPTION-file

There, users mention that (all?) packages are affected which
have a multiline 'Description:' field in their DESCRIPTION file.
Of course, many if not most packages have this property.

Indeed, I can reproduce the problem (e.g. with my 'sfsmisc'
package) if I ("silly enough to") add a setwd() call to my
Rprofile file  (the one I set via env.var  R_PROFILE or R_PROFILE_USER). 

This is clearly a bug, and indeed a bad one.

It seems all R core (and other R expert users who have tried R
3.6.0 alpha, beta, and RC versions) have *not* seen the bug as they
are intuitively smart not to mess with R's working directory in
a global R profile file ...

For now you definitively have to work around by not doing what's
the problem : do *NOT* setwd() in your  ~/.Rprofile or other
such R init files.

Best,
Martin Maechler
ETH Zurich and  R Core Team

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug in R 3.6.0?

2019-04-30 Thread ocjt
Hello,

I have exactly the same problem when I install one of my own packages:

Error in tools:::.read_description(file) :
  file 'DESCRIPTION' does not exist
Calls: suppressPackageStartupMessages ... withCallingHandlers -> 
.getRequiredPackages ->  -> 
Exécution arrêtée
ERROR: lazy loading failed for package 'RRegArch'

Best,
Ollivier


-Message d'origine-
De : R-help  De la part de Morgan Morgan
Envoyé : lundi 29 avril 2019 22:43
À : r-help@r-project.org
Objet : [R] Bug in R 3.6.0?

Hi,

I am using the R 3.6.0 on windows. The issue that I report below does not exist 
with previous version of R.
In order to reproduce the error you must install a package of your choice from 
source (tar.gz).

-Create a .Rprofile file with the following command in it : setwd("D:/") -Close 
your R session and re-open it. Your working directory must be now set to D:
-Install a package of your choice from source, example :
install.packages("data.table",type="source")

In my case the package fail to install and I get the following error
message:

** R
** inst
** byte-compile and prepare package for lazy loading Error in 
tools:::.read_description(file) :
  file 'DESCRIPTION' does not exist
Calls: suppressPackageStartupMessages ... withCallingHandlers -> 
.getRequiredPackages ->  ->  Execution halted
ERROR: lazy loading failed for package 'data.table'
* removing 'C:/Users/Morgan/Documents/R/win-library/3.6/data.table'
* restoring previous
'C:/Users/Morgan/Documents/R/win-library/3.6/data.table'
Warning in install.packages :
  installation of package ‘data.table’ had non-zero exit status

Now remove the .Rprofile file, restart your R session and try to install the 
package with the same command.
In that case everything should be installed just fine.

FYI the issue happens on macOS as well and I suspect it also does on all linux 
systems.

My question: Is this expected or is it a bug?

Thank you
Best regards,
Morgan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug in R 3.6.0?

2019-04-30 Thread Morgan Morgan
Hi,

I am using the R 3.6.0 on windows. The issue that I report below does not
exist with previous version of R.
In order to reproduce the error you must install a package of your choice
from source (tar.gz).

-Create a .Rprofile file with the following command in it : setwd("D:/")
-Close your R session and re-open it. Your working directory must be now set
to D:
-Install a package of your choice from source, example :
install.packages("data.table",type="source")

In my case the package fail to install and I get the following error
message:

** R
** inst
** byte-compile and prepare package for lazy loading
Error in tools:::.read_description(file) :
  file 'DESCRIPTION' does not exist
Calls: suppressPackageStartupMessages ... withCallingHandlers ->
.getRequiredPackages ->  -> 
Execution halted
ERROR: lazy loading failed for package 'data.table'
* removing 'C:/Users/Morgan/Documents/R/win-library/3.6/data.table'
* restoring previous
'C:/Users/Morgan/Documents/R/win-library/3.6/data.table'
Warning in install.packages :
  installation of package ‘data.table’ had non-zero exit status

Now remove the .Rprofile file, restart your R session and try to install the
package with the same command.
In that case everything should be installed just fine.

FYI the issue happens on macOS as well and I suspect it also does on all
linux systems.

My question: Is this expected or is it a bug?

Thank you
Best regards,
Morgan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Potential R bug in identical

2019-01-17 Thread Layik Hama
Ivan,


Thank you for digging into the string. I can confirm that the `hexdump` shows 
extra characters on bash, too.


The question would then be:


Why would `identical(str, "Accident_Index", ignore.case = TRUE)` behave 
differently on Linux/MacOS vs Windows?


Thanks


---

Layik Hama
Research Fellow

Leeds Institute for Data Analytics
Room 11.70, Worsley Building,
University of Leeds

From: Ivan Krylov 
Sent: 17 January 2019 20:40:32
To: Layik Hama
Cc: r-help@r-project.org
Subject: Re: [R] Potential R bug in identical

On Thu, 17 Jan 2019 14:55:18 +
Layik Hama  wrote:

> There seems to be some weird and unidentifiable (to me) characters in
> front of the `Accidents_Index` column name there causing the length
> to be 17 rather than 14 characters.

Repeating the reproduction steps described at the linked pull request,

$ curl -o acc2017.zip
http://data.dft.gov.uk.s3.amazonaws.com/road-accidents-safety-data/dftRoadSafetyData_Accidents_2017.zip
$ unzip acc2017.zip
$ head -n 1 Acc.csv | hd | head -n 2
  ef bb bf 41 63 63 69 64  65 6e 74 5f 49 6e 64 65  |...Accident_Inde|
0010  78 2c 4c 6f 63 61 74 69  6f 6e 5f 45 61 73 74 69  |x,Location_Easti|

The document begins with a U+FEFF BYTE ORDER MARK, encoded in UTF-8.
Not sure which encoding R chooses on Windows by default, but
explicitly passing encoding="UTF-8" (or is it fileEncoding?) might
help decode it as such. (Sorry, cannot test my advice on Windows right
now.)

--
Best regards,
Ivan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Potential R bug in identical

2019-01-17 Thread Ivan Krylov
On Thu, 17 Jan 2019 21:05:07 +
Layik Hama  wrote:

> Why would `identical(str, "Accident_Index", ignore.case = TRUE)`
> behave differently on Linux/MacOS vs Windows?

Because str is different from "Accident_Index" on Windows: it was
decoded from bytes to characters according to different rules when file
was read.

Default encoding for files being read is specified by 'encoding'
options. On both Windows and Linux I get:

> options('encoding')
$encoding
[1] "native.enc"

For which ?file says (in section "Encoding"):

>> ‘""’ and ‘"native.enc"’ both mean the ‘native’ encoding, that is the
>> internal encoding of the current locale and hence no translation is
>> done.

Linux version of R has a UTF-8 locale (AFAIK, macOS does too) and
decodes the files as UTF-8 by default:

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

locale:
 [1] LC_CTYPE=ru_RU.utf8   LC_NUMERIC=C 
 [3] LC_TIME=ru_RU.utf8LC_COLLATE=ru_RU.utf8
 [5] LC_MONETARY=ru_RU.utf8LC_MESSAGES=ru_RU.utf8   
 [7] LC_PAPER=ru_RU.utf8   LC_NAME=C
 [9] LC_ADDRESS=C  LC_TELEPHONE=C   
[11] LC_MEASUREMENT=ru_RU.utf8 LC_IDENTIFICATION=C

While on Windows R uses a single-byte encoding dependent on the locale:

> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Russian_Russia.1251  LC_CTYPE=Russian_Russia.1251   
[3] LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C   
[5] LC_TIME=Russian_Russia.1251

> readLines('test.txt')[1]
[1] "п»їAccident_Index"
> nchar(readLines('test.txt')[1])
[1] 17

R on Windows can be explicitly told to decode the file as UTF-8:

> nchar(readLines(file('test.txt',encoding='UTF-8'))[1])
[1] 15

The first character of the string is the invisible byte order mark.
Thankfully, there is an easy fix for that, too. ?file additionally
says:

>> As from R 3.0.0 the encoding ‘"UTF-8-BOM"’ is accepted for
>> reading and will remove a Byte Order Mark if present (which it
>> often is for files and webpages generated by Microsoft applications).

So this is how we get the 14-character column name we'd wanted:

> nchar(readLines(file('test.txt',encoding='UTF-8-BOM'))[1])
[1] 14

For our original task, this means:

> names(read.csv('Acc.csv'))[1] # might produce incorrect results
[1] "п.їAccident_Index"
> names(read.csv('Acc.csv', fileEncoding='UTF-8-BOM'))[1] # correct
[1] "Accident_Index"

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Potential R bug in identical

2019-01-17 Thread Ivan Krylov
On Thu, 17 Jan 2019 14:55:18 +
Layik Hama  wrote:

> There seems to be some weird and unidentifiable (to me) characters in
> front of the `Accidents_Index` column name there causing the length
> to be 17 rather than 14 characters.

Repeating the reproduction steps described at the linked pull request,

$ curl -o acc2017.zip
http://data.dft.gov.uk.s3.amazonaws.com/road-accidents-safety-data/dftRoadSafetyData_Accidents_2017.zip
$ unzip acc2017.zip
$ head -n 1 Acc.csv | hd | head -n 2
  ef bb bf 41 63 63 69 64  65 6e 74 5f 49 6e 64 65  |...Accident_Inde|
0010  78 2c 4c 6f 63 61 74 69  6f 6e 5f 45 61 73 74 69  |x,Location_Easti|

The document begins with a U+FEFF BYTE ORDER MARK, encoded in UTF-8.
Not sure which encoding R chooses on Windows by default, but
explicitly passing encoding="UTF-8" (or is it fileEncoding?) might
help decode it as such. (Sorry, cannot test my advice on Windows right
now.)

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Potential R bug in identical

2019-01-17 Thread Layik Hama
Hi,


My first email to r-help and as I am not sure about the issue, I wanted to ask 
for help first.

The comments under this thread  
outline a particular string from a dataset which seems to be read by R on 
Windows differently to Linux and MacOS and also to bash on Ubuntu Bionic. There 
seems to be some weird and unidentifiable (to me) characters in front of the 
`Accidents_Index` column name there causing the length to be 17 rather than 14 
characters.


I have inspected the string as best as I could and cannot see why we see the 
output from a Windows machine.


Is it an issue in `read.table()`?


Thanks


---

Layik Hama
Research Fellow

Leeds Institute for Data Analytics
Room 11.70, Worsley Building,
University of Leeds

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug (?): reading binary files in Windows 10

2018-12-07 Thread Kate Stone
Ah wow, that answers many questions, thanks!

On Thu, Dec 6, 2018 at 4:41 PM Jeff Newmiller 
wrote:

> AFAIK this receiver-side responsibility to specify the text/binary status
> of the file is particularly a problem with the "ftp://; protocol because
> it does not use MIME file encoding (which "http://; uses). MIME allows
> the sending end of the connection to communicate whether the file is text
> or binary, though it uses more bandwidth for the transfer. If the server
> offers you a choice in these days of high bandwidth connections, you may be
> better off sticking with http/https.
>
> Note that MIME is not magic... if the sender is improperly configured then
> the client can potentially receive corrupt data. Fortunately the most
> typical MIME misconfigurations cause the file to be unchanged in all cases,
> leaving it to the receiver to deal with any text file newline decoding
> choice/task after the file transfer is completed.
>
> On December 6, 2018 7:03:48 AM PST, Duncan Murdoch <
> murdoch.dun...@gmail.com> wrote:
> >On 06/12/2018 7:45 AM, Kate Stone wrote:
> >> Hello r-help,
> >>
> >> Could you help me determine whether this is an R bug or not?
> >>
> >> I've been trying to read this binary file in R:
> >>
> >>
> >download.file("
> ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/preprocessing_erp/s04.eeg
> ","s04.eeg")
> >>
> >> and I get a different length file (i.e. much longer) in Windows  >= 8
> >> x64 (build 9200) than in Ubuntu. I've tested it with different R
> >> versions in Windows and different package versions with the same
> >> incorrect result. Other colleagues have tested it on the same
> >> Windows/Ubuntu builds and got the correct length.
> >>
> >> I'm not sure whether this is an R problem or something to do with my
> >> OS specifically, or even with the file itself. Any ideas?? I've
> >> attached a small script demonstrating the issue.
> >
> >On Windows, the `mode = "wb"` argument to download.file() is important,
> >
> >otherwise it is assumed to be a text file, and LF is changed to CR LF.
> >There may also be handling of EOF marks, I forget.
> >
> >Duncan Murdoch
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>


-- 
Kate Stone
PhD candidate
Vasishth Lab | Department of Linguistics
Potsdam University, 14467 Potsdam, Germany
https://auskate.github.io

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug (?): reading binary files in Windows 10

2018-12-06 Thread Jeff Newmiller
AFAIK this receiver-side responsibility to specify the text/binary status of 
the file is particularly a problem with the "ftp://; protocol because it does 
not use MIME file encoding (which "http://; uses). MIME allows the sending end 
of the connection to communicate whether the file is text or binary, though it 
uses more bandwidth for the transfer. If the server offers you a choice in 
these days of high bandwidth connections, you may be better off sticking with 
http/https.

Note that MIME is not magic... if the sender is improperly configured then the 
client can potentially receive corrupt data. Fortunately the most typical MIME 
misconfigurations cause the file to be unchanged in all cases, leaving it to 
the receiver to deal with any text file newline decoding choice/task after the 
file transfer is completed.

On December 6, 2018 7:03:48 AM PST, Duncan Murdoch  
wrote:
>On 06/12/2018 7:45 AM, Kate Stone wrote:
>> Hello r-help,
>> 
>> Could you help me determine whether this is an R bug or not?
>> 
>> I've been trying to read this binary file in R:
>> 
>>
>download.file("ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/preprocessing_erp/s04.eeg","s04.eeg;)
>> 
>> and I get a different length file (i.e. much longer) in Windows  >= 8
>> x64 (build 9200) than in Ubuntu. I've tested it with different R
>> versions in Windows and different package versions with the same
>> incorrect result. Other colleagues have tested it on the same
>> Windows/Ubuntu builds and got the correct length.
>> 
>> I'm not sure whether this is an R problem or something to do with my
>> OS specifically, or even with the file itself. Any ideas?? I've
>> attached a small script demonstrating the issue.
>
>On Windows, the `mode = "wb"` argument to download.file() is important,
>
>otherwise it is assumed to be a text file, and LF is changed to CR LF. 
>There may also be handling of EOF marks, I forget.
>
>Duncan Murdoch
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug (?): reading binary files in Windows 10

2018-12-06 Thread Duncan Murdoch

On 06/12/2018 7:45 AM, Kate Stone wrote:

Hello r-help,

Could you help me determine whether this is an R bug or not?

I've been trying to read this binary file in R:

download.file("ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/preprocessing_erp/s04.eeg","s04.eeg;)

and I get a different length file (i.e. much longer) in Windows  >= 8
x64 (build 9200) than in Ubuntu. I've tested it with different R
versions in Windows and different package versions with the same
incorrect result. Other colleagues have tested it on the same
Windows/Ubuntu builds and got the correct length.

I'm not sure whether this is an R problem or something to do with my
OS specifically, or even with the file itself. Any ideas?? I've
attached a small script demonstrating the issue.


On Windows, the `mode = "wb"` argument to download.file() is important, 
otherwise it is assumed to be a text file, and LF is changed to CR LF. 
There may also be handling of EOF marks, I forget.


Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug (?): reading binary files in Windows 10

2018-12-06 Thread Omar André Gonzáles Díaz
Hi,

this is what i got, just with base R:

> a <- download.file("
ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/preprocessing_erp/s04.eeg
","s04.eeg")
probando la URL '
ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/preprocessing_erp/s04.eeg
'
Content type 'unknown' length 142773760 bytes (136.2 MB)
==
> a
[1] 0
> length(a)
[1] 1

Information about the session:

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=es_ES.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=es_ES.UTF-8LC_COLLATE=es_ES.UTF-8
 [5] LC_MONETARY=es_ES.UTF-8LC_MESSAGES=es_ES.UTF-8
 [7] LC_PAPER=es_ES.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION=C

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

loaded via a namespace (and not attached):
[1] compiler_3.4.4 tools_3.4.4yaml_2.2.0


El jue., 6 dic. 2018 a las 8:51, Albrecht Kauffmann ()
escribió:

> Dear Kate,
>
> I cannot find your small script, but I downloaded the file using your
> command line. It has the size of  142773760 bytes (136.2 MB).
>
> Hth,
> Albrecht
>
> --
>   Albrecht Kauffmann
>   alkau...@fastmail.fm
>
> Am Do, 6. Dez 2018, um 13:45, schrieb Kate Stone:
> > Hello r-help,
> >
> > Could you help me determine whether this is an R bug or not?
> >
> > I've been trying to read this binary file in R:
> >
> > download.file("
> ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/preprocessing_erp/s04.eeg
> ","s04.eeg")
> >
> > and I get a different length file (i.e. much longer) in Windows  >= 8
> > x64 (build 9200) than in Ubuntu. I've tested it with different R
> > versions in Windows and different package versions with the same
> > incorrect result. Other colleagues have tested it on the same
> > Windows/Ubuntu builds and got the correct length.
> >
> > I'm not sure whether this is an R problem or something to do with my
> > OS specifically, or even with the file itself. Any ideas?? I've
> > attached a small script demonstrating the issue.
> >
> > Many thanks,
> > Kate
> >
> > --
> > Kate Stone
> > PhD candidate
> > Vasishth Lab | Department of Linguistics
> > Potsdam University, 14467 Potsdam, Germany
> > https://auskate.github.io
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug (?): reading binary files in Windows 10

2018-12-06 Thread Albrecht Kauffmann
Dear Kate,

I cannot find your small script, but I downloaded the file using your command 
line. It has the size of  142773760 bytes (136.2 MB).

Hth,
Albrecht

-- 
  Albrecht Kauffmann
  alkau...@fastmail.fm

Am Do, 6. Dez 2018, um 13:45, schrieb Kate Stone:
> Hello r-help,
> 
> Could you help me determine whether this is an R bug or not?
> 
> I've been trying to read this binary file in R:
> 
> download.file("ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/preprocessing_erp/s04.eeg","s04.eeg;)
> 
> and I get a different length file (i.e. much longer) in Windows  >= 8
> x64 (build 9200) than in Ubuntu. I've tested it with different R
> versions in Windows and different package versions with the same
> incorrect result. Other colleagues have tested it on the same
> Windows/Ubuntu builds and got the correct length.
> 
> I'm not sure whether this is an R problem or something to do with my
> OS specifically, or even with the file itself. Any ideas?? I've
> attached a small script demonstrating the issue.
> 
> Many thanks,
> Kate
> 
> -- 
> Kate Stone
> PhD candidate
> Vasishth Lab | Department of Linguistics
> Potsdam University, 14467 Potsdam, Germany
> https://auskate.github.io
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug (?): reading binary files in Windows 10

2018-12-06 Thread Kate Stone
Hello r-help,

Could you help me determine whether this is an R bug or not?

I've been trying to read this binary file in R:

download.file("ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/preprocessing_erp/s04.eeg","s04.eeg;)

and I get a different length file (i.e. much longer) in Windows  >= 8
x64 (build 9200) than in Ubuntu. I've tested it with different R
versions in Windows and different package versions with the same
incorrect result. Other colleagues have tested it on the same
Windows/Ubuntu builds and got the correct length.

I'm not sure whether this is an R problem or something to do with my
OS specifically, or even with the file itself. Any ideas?? I've
attached a small script demonstrating the issue.

Many thanks,
Kate

-- 
Kate Stone
PhD candidate
Vasishth Lab | Department of Linguistics
Potsdam University, 14467 Potsdam, Germany
https://auskate.github.io
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)

2018-10-05 Thread hmh

Nope.


This IS a bug:

_*The negative auto-correlation mostly disappear when I randomize small 
samples using the R function '*__*sample*__*'.*_



Please check thoroughly the code of the 1st mail I sent, there should be 
no difference between the two R functions I wrote to illustrate the bug.


The two functions that should produce the same output if there would be 
no bug are 'DistributionAutocorrelation_Unexpected' and 
'DistributionAutocorrelation_Expected'.


_/Please take the time to compare there output!!/_

The finite-sample bias in the sample autocorrelation coefficient you 
mention should affect them in the same manner. This bias is not the only 
phenomenon at work, *_there is ALSO as BUG !_*



Thanks


The first mail I sent is below :

_ _ _

Hi,


I just noticed the following bug:

When we draw a random sample using the function stats::rnorm, there 
should be not auto-correlation in the sample. But their is some 
auto-correlation _when the sample that is drawn is small_.


I describe the problem using two functions:

DistributionAutocorrelation_Unexpected which as the wrong behavior : 
_when drawing some small samples using rnorm, there is generally a 
strong negative auto-correlation in the sample_.


and

DistributionAutocorrelation_Expected which illustrate the expected behavior



*Unexpected : *

DistributionAutocorrelation_Unexpected = function(SampleSize){
  Cor = NULL
  for(repetition in 1:1e5){
    X = rnorm(SampleSize)
    Cor[repetition] = cor(X[-1],X[-length(X)])
  }
  return(Cor)
}

par(mfrow=c(3,3))
for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){
hist(DistributionAutocorrelation_Unexpected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_)) 
; abline(v=0,col=2)

}

output:


*Expected**:*

DistributionAutocorrelation_Expected = function(SampleSize){
  Cor = NULL
  for(repetition in 1:1e5){
    X = rnorm(SampleSize)
*    Cor[repetition] = cor(sample(X[-1]),sample(X[-length(X)]))*
  }
  return(Cor)
}

par(mfrow=c(3,3))
for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){
hist(DistributionAutocorrelation_Expected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_)) 
; abline(v=0,col=2)

}




Some more information you might need:


packageDescription("stats")
Package: stats
Version: 3.5.1
Priority: base
Title: The R Stats Package
Author: R Core Team and contributors worldwide
Maintainer: R Core Team 
Description: R statistical functions.
License: Part of R 3.5.1
Imports: utils, grDevices, graphics
Suggests: MASS, Matrix, SuppDists, methods, stats4
NeedsCompilation: yes
Built: R 3.5.1; x86_64-pc-linux-gnu; 2018-07-03 02:12:37 UTC; unix

Thanks for correcting that.

fill free to ask any further information you would need.

cheers,

hugo






On 05/10/2018 09:58, Annaert Jan wrote:

On 05/10/2018, 09:45, "R-help on behalf of hmh"  wrote:

 Hi,
 
 Thanks William for this fast answer, and sorry for sending the 1st mail

 to r-help instead to r-devel.
 
 
 I noticed that bug while I was simulating many small random walks using

 c(0,cumsum(rnorm(10))). Then the negative auto-correlation was inducing
 a muchsmaller space visited by the random walks than expected if there
 would be no auto-correlation in the samples.
 
 
 The code I provided and you optimized was only provided to illustrated

 and investigate that bug.
 
 
 It is really worrying that most of the R distributions are affected by

 this bug 
 
 What I did should have been one of the first check done for _*each*_

 distributions by the developers of these functions !
 
 
 And if as you suggested this is a "tolerated" _error_ of the algorithm,

 I do think this is a bad choice, but any way, this should have been
 mentioned in the documentations of the functions !!
 
 
 cheers,
 
 hugo
  
This is not a bug. You have simply rediscovered the finite-sample bias in the sample autocorrelation coefficient, known at least since

Kendall, M. G. (1954). Note on bias in the estimation of autocorrelation. 
Biometrika, 41(3-4), 403-404.

The bias is approximately -1/T, with T sample size, which explains why it seems 
to disappear in the larger sample sizes you consider.

Jan



--
- no title specified

Hugo Mathé-Hubert

ATER

Laboratoire Interdisciplinaire des Environnements Continentaux (LIEC)

UMR 7360 CNRS -  Bât IBISE

Université de Lorraine  -  UFR SciFA

8, Rue du Général Delestraint

F-57070 METZ

+33(0)9 77 21 66 66
- - - - - - - - - - - - - - - - - -
Les réflexions naissent dans les doutes et meurent dans les certitudes. 
Les doutes sont donc un signe de force et les certitudes un signe de 
faiblesse. La plupart des gens sont pourtant certains du contraire.

- - - - - - - - - - - - - - - - - -
Thoughts appear from doubts and die in convictions. Therefore, doubts 
are an indication of strength and convictions an indication of weakness. 
Yet, most people believe the opposite.



Re: [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)

2018-10-05 Thread hmh
I got it !


thanks and sorry for annoying you with that.


have a nice day,

hugo


On 05/10/2018 11:16, Deepayan Sarkar wrote:
> On Fri, Oct 5, 2018 at 2:07 PM hmh  wrote:
>> On 05/10/2018 10:28, Annaert Jan wrote:
>>> you discard any time series structure;
>> But that is PRECISELY what a call a bug:
>> There should not be any "time series structure" in the output or rnorm,
>> runif and so on but there is one.
>>
>> rnorm(N,0,1)
>> should give on average the same output as
>> sample(rnorm(N,0,1))
> Agreed, but that is not what your code is testing. You seem to think
> that something much more specific should be true; namely,
>
> X[1:10] ~ iid normal, then
>
> cor(X[1:9], X[2:10])
>
> and
>
> cor(sample(X[-1]), sample(X[-10]))
>
> should have the same distribution. This is not at all obvious, and in
> fact not true.
>
> Please check the reference you have been pointed to. Here is a related
> article in the same volume:
>
> https://www.jstor.org/stable/2332719
>
> -Deepayan
>
>
>> Which is not the case. rnorm(N,0,1) should draw INDEPENDENT samples i.e.
>> without time series structure !
>>
>>
>> --
>> - no title specified
>>
>> Hugo Mathé-Hubert
>>
>> ATER
>>
>> Laboratoire Interdisciplinaire des Environnements Continentaux (LIEC)
>>
>> UMR 7360 CNRS -  Bât IBISE
>>
>> Université de Lorraine  -  UFR SciFA
>>
>> 8, Rue du Général Delestraint
>>
>> F-57070 METZ
>>
>> +33(0)9 77 21 66 66
>> - - - - - - - - - - - - - - - - - -
>> Les réflexions naissent dans les doutes et meurent dans les certitudes.
>> Les doutes sont donc un signe de force et les certitudes un signe de
>> faiblesse. La plupart des gens sont pourtant certains du contraire.
>> - - - - - - - - - - - - - - - - - -
>> Thoughts appear from doubts and die in convictions. Therefore, doubts
>> are an indication of strength and convictions an indication of weakness.
>> Yet, most people believe the opposite.
>>
>>
>>  [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

-- 
- no title specified

Hugo Mathé-Hubert

ATER

Laboratoire Interdisciplinaire des Environnements Continentaux (LIEC)

UMR 7360 CNRS -  Bât IBISE

Université de Lorraine  -  UFR SciFA

8, Rue du Général Delestraint

F-57070 METZ

+33(0)9 77 21 66 66
- - - - - - - - - - - - - - - - - -
Les réflexions naissent dans les doutes et meurent dans les certitudes. 
Les doutes sont donc un signe de force et les certitudes un signe de 
faiblesse. La plupart des gens sont pourtant certains du contraire.
- - - - - - - - - - - - - - - - - -
Thoughts appear from doubts and die in convictions. Therefore, doubts 
are an indication of strength and convictions an indication of weakness. 
Yet, most people believe the opposite.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)

2018-10-05 Thread Deepayan Sarkar
On Fri, Oct 5, 2018 at 2:07 PM hmh  wrote:
>
> On 05/10/2018 10:28, Annaert Jan wrote:
> > you discard any time series structure;
> But that is PRECISELY what a call a bug:
> There should not be any "time series structure" in the output or rnorm,
> runif and so on but there is one.
>
> rnorm(N,0,1)
> should give on average the same output as
> sample(rnorm(N,0,1))

Agreed, but that is not what your code is testing. You seem to think
that something much more specific should be true; namely,

X[1:10] ~ iid normal, then

cor(X[1:9], X[2:10])

and

cor(sample(X[-1]), sample(X[-10]))

should have the same distribution. This is not at all obvious, and in
fact not true.

Please check the reference you have been pointed to. Here is a related
article in the same volume:

https://www.jstor.org/stable/2332719

-Deepayan


> Which is not the case. rnorm(N,0,1) should draw INDEPENDENT samples i.e.
> without time series structure !
>
>
> --
> - no title specified
>
> Hugo Mathé-Hubert
>
> ATER
>
> Laboratoire Interdisciplinaire des Environnements Continentaux (LIEC)
>
> UMR 7360 CNRS -  Bât IBISE
>
> Université de Lorraine  -  UFR SciFA
>
> 8, Rue du Général Delestraint
>
> F-57070 METZ
>
> +33(0)9 77 21 66 66
> - - - - - - - - - - - - - - - - - -
> Les réflexions naissent dans les doutes et meurent dans les certitudes.
> Les doutes sont donc un signe de force et les certitudes un signe de
> faiblesse. La plupart des gens sont pourtant certains du contraire.
> - - - - - - - - - - - - - - - - - -
> Thoughts appear from doubts and die in convictions. Therefore, doubts
> are an indication of strength and convictions an indication of weakness.
> Yet, most people believe the opposite.
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)

2018-10-05 Thread hmh
On 05/10/2018 10:28, Annaert Jan wrote:
> you discard any time series structure;
But that is PRECISELY what a call a bug:
There should not be any "time series structure" in the output or rnorm, 
runif and so on but there is one.

rnorm(N,0,1)
should give on average the same output as
sample(rnorm(N,0,1))

Which is not the case. rnorm(N,0,1) should draw INDEPENDENT samples i.e. 
without time series structure !


-- 
- no title specified

Hugo Mathé-Hubert

ATER

Laboratoire Interdisciplinaire des Environnements Continentaux (LIEC)

UMR 7360 CNRS -  Bât IBISE

Université de Lorraine  -  UFR SciFA

8, Rue du Général Delestraint

F-57070 METZ

+33(0)9 77 21 66 66
- - - - - - - - - - - - - - - - - -
Les réflexions naissent dans les doutes et meurent dans les certitudes. 
Les doutes sont donc un signe de force et les certitudes un signe de 
faiblesse. La plupart des gens sont pourtant certains du contraire.
- - - - - - - - - - - - - - - - - -
Thoughts appear from doubts and die in convictions. Therefore, doubts 
are an indication of strength and convictions an indication of weakness. 
Yet, most people believe the opposite.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)

2018-10-05 Thread Annaert Jan
On 05/10/2018, 09:45, "R-help on behalf of hmh"  wrote:

Hi,

Thanks William for this fast answer, and sorry for sending the 1st mail 
to r-help instead to r-devel.


I noticed that bug while I was simulating many small random walks using 
c(0,cumsum(rnorm(10))). Then the negative auto-correlation was inducing 
a muchsmaller space visited by the random walks than expected if there 
would be no auto-correlation in the samples.


The code I provided and you optimized was only provided to illustrated 
and investigate that bug.


It is really worrying that most of the R distributions are affected by 
this bug 

What I did should have been one of the first check done for _*each*_ 
distributions by the developers of these functions !


And if as you suggested this is a "tolerated" _error_ of the algorithm, 
I do think this is a bad choice, but any way, this should have been 
mentioned in the documentations of the functions !!


cheers,

hugo
 
This is not a bug. You have simply rediscovered the finite-sample bias in the 
sample autocorrelation coefficient, known at least since
Kendall, M. G. (1954). Note on bias in the estimation of autocorrelation. 
Biometrika, 41(3-4), 403-404. 

The bias is approximately -1/T, with T sample size, which explains why it seems 
to disappear in the larger sample sizes you consider.

Jan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)

2018-10-05 Thread hmh
Hi,

Thanks William for this fast answer, and sorry for sending the 1st mail 
to r-help instead to r-devel.


I noticed that bug while I was simulating many small random walks using 
c(0,cumsum(rnorm(10))). Then the negative auto-correlation was inducing 
a muchsmaller space visited by the random walks than expected if there 
would be no auto-correlation in the samples.


The code I provided and you optimized was only provided to illustrated 
and investigate that bug.


It is really worrying that most of the R distributions are affected by 
this bug 

What I did should have been one of the first check done for _*each*_ 
distributions by the developers of these functions !


And if as you suggested this is a "tolerated" _error_ of the algorithm, 
I do think this is a bad choice, but any way, this should have been 
mentioned in the documentations of the functions !!


cheers,

hugo


On 05/10/2018 01:52, William Bell wrote:
> Hi Hugo,
>
> I've been able to replicate your bug, including for other 
> distributions (runif, rexp, rgamma, etc) which shouldn't be surprising 
> since they're probably all drawing from the same pseudo-random number 
> generator.  Interestingly, it does not seem to depend on the choice of 
> seed, I am not sure why that is the case.
>
> I'll point out first of all that the R-devel mailing list is perhaps 
> better suited for this query, I'm fairly sure we're supposed to direct 
> bug reports, etc there.
>
> It is possible this is a known quantity but is tolerated, I could 
> think of many reasons why that might be the case, not least of which 
> being that as far as I know, the vast majority of Monte Carlo methods 
> involve >>40 trials (which seems to be enough for the effect to 
> disappear), with the possible exception of procedures for testing the 
> power of statistical tests on small samples?
>
> There might be more to be said, but I thought I'd just add what I 
> could from playing around with it a little bit.
>
> For anyone who wishes to give it a try, I suggest this implementation 
> of the autocorrelation tester which is about 80 times faster:
>
> DistributionAutocorrelation_new <- function(SampleSize){
>     Cor <- replicate(1e5, function() {X <- rnorm(SampleSize)
>     return(cor(X[-1], X[-length(X)]))})
>     return(Cor)
> }
>
> I have the same Stats package version installed.
>
> - (Thomas) William Bell
> Hons BSc Candidate (Biology and Mathematics)
> BA Candidate (Philosophy)
> McMaster University
>
> # Hi,
> #
> #
> # I just noticed the following bug:
> #
> #   When we draw a random sample using the function stats::rnorm, there
> # should be not auto-correlation in the sample. But their is some
> # auto-correlation _when the sample that is drawn is small_.
> #
> # I describe the problem using two functions:
> #
> #   DistributionAutocorrelation_Unexpected which as the wrong behavior :
> #   _when drawing some small samples using rnorm, there is generally a
> # strong negative auto-correlation in the sample_.
> #
> # and
> #
> # DistributionAutocorrelation_Expected which illustrate the expected 
> behavior
> #
> #
> #
> # *Unexpected : *
> #
> #   DistributionAutocorrelation_Unexpected = function(SampleSize){
> #     Cor = NULL
> #     for(repetition in 1:1e5){
> #       X = rnorm(SampleSize)
> #       Cor[repetition] = cor(X[-1],X[-length(X)])
> #     }
> #     return(Cor)
> #   }
> #
> # par(mfrow=c(3,3))
> # for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){
> # 
> hist(DistributionAutocorrelation_Unexpected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_))
>  
>
> #   ; abline(v=0,col=2)
> # }
> #
> # output:
> #
> #
> #   *Expected**:*
> #
> #   DistributionAutocorrelation_Expected = function(SampleSize){
> #     Cor = NULL
> #     for(repetition in 1:1e5){
> #       X = rnorm(SampleSize)
> #       *    Cor[repetition] = cor(sample(X[-1]),sample(X[-length(X)]))*
> #     }
> #     return(Cor)
> #   }
> #
> # par(mfrow=c(3,3))
> # for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){
> # 
> hist(DistributionAutocorrelation_Expected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_))
>  
>
> #   ; abline(v=0,col=2)
> # }
> #
> #
> #
> #
> # Some more information you might need:
> #
> #
> #   packageDescription("stats")
> # Package: stats
> # Version: 3.5.1
> # Priority: base
> # Title: The R Stats Package
> # Author: R Core Team and contributors worldwide
> # Maintainer: R Core Team 
> #   Description: R statistical functions.
> # License: Part of R 3.5.1
> # Imports: utils, grDevices, graphics
> # Suggests: MASS, Matrix, SuppDists, methods, stats4
> # NeedsCompilation: yes
> # Built: R 3.5.1; x86_64-pc-linux-gnu; 2018-07-03 02:12:37 UTC; unix
> #
> # Thanks for correcting that.
> #
> # fill free to ask any further information you would need.
> #
> # cheers,
> #
> # hugo
> #
> #
> # --
> #   - no title specified
> #
> # Hugo Mathé-Hubert
> #
> # ATER
> #
> # Laboratoire Interdisciplinaire des Environnements Continentaux (LIEC)
> #
> # UMR 7360 

Re: [R] Bug : Autocorrelation in sample drawn from stats::rnorm (hmh)

2018-10-04 Thread William Bell via R-help
Hi Hugo,
I've been able to replicate your bug, including for other distributions (runif, 
rexp, rgamma, etc) which shouldn't be surprising since they're probably all 
drawing from the same pseudo-random number generator.  Interestingly, it does 
not seem to depend on the choice of seed, I am not sure why that is the case.
I'll point out first of all that the R-devel mailing list is perhaps better 
suited for this query, I'm fairly sure we're supposed to direct bug reports, 
etc there.
It is possible this is a known quantity but is tolerated, I could think of many 
reasons why that might be the case, not least of which being that as far as I 
know, the vast majority of Monte Carlo methods involve >>40 trials (which seems 
to be enough for the effect to disappear), with the possible exception of 
procedures for testing the power of statistical tests on small samples?
There might be more to be said, but I thought I'd just add what I could from 
playing around with it a little bit.
For anyone who wishes to give it a try, I suggest this implementation of the 
autocorrelation tester which is about 80 times faster:
DistributionAutocorrelation_new <- function(SampleSize){
    Cor <- replicate(1e5, function() {X <- rnorm(SampleSize)    
return(cor(X[-1], X[-length(X)]))})    return(Cor)}
I have the same Stats package version installed.
- (Thomas) William BellHons BSc Candidate (Biology and Mathematics)BA Candidate 
(Philosophy)McMaster University
# Hi,# # # I just noticed the following bug:#   #   When we draw a random 
sample using the function stats::rnorm, there # should be not auto-correlation 
in the sample. But their is some # auto-correlation _when the sample that is 
drawn is small_.# # I describe the problem using two functions:#   #   
DistributionAutocorrelation_Unexpected which as the wrong behavior : #   _when 
drawing some small samples using rnorm, there is generally a # strong negative 
auto-correlation in the sample_.# # and# # DistributionAutocorrelation_Expected 
which illustrate the expected behavior# # # # *Unexpected : *#   #   
DistributionAutocorrelation_Unexpected = function(SampleSize){#     Cor = NULL# 
    for(repetition in 1:1e5){#       X = rnorm(SampleSize)#       
Cor[repetition] = cor(X[-1],X[-length(X)])#     }#     return(Cor)#   }# # 
par(mfrow=c(3,3))# for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){#   
hist(DistributionAutocorrelation_Unexpected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_))
 #   ; abline(v=0,col=2)# }# # output:#   #   #   *Expected**:*#   #   
DistributionAutocorrelation_Expected = function(SampleSize){#     Cor = NULL#   
  for(repetition in 1:1e5){#       X = rnorm(SampleSize)#       *    
Cor[repetition] = cor(sample(X[-1]),sample(X[-length(X)]))*#     }#     
return(Cor)#   }# # par(mfrow=c(3,3))# for(SampleSize_ in 
c(4,5,6,7,8,10,15,20,50)){#   
hist(DistributionAutocorrelation_Expected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_))
 #   ; abline(v=0,col=2)# }# # # # # Some more information you might need:#   # 
  #   packageDescription("stats")# Package: stats# Version: 3.5.1# Priority: 
base# Title: The R Stats Package# Author: R Core Team and contributors 
worldwide# Maintainer: R Core Team #   Description: R 
statistical functions.# License: Part of R 3.5.1# Imports: utils, grDevices, 
graphics# Suggests: MASS, Matrix, SuppDists, methods, stats4# NeedsCompilation: 
yes# Built: R 3.5.1; x86_64-pc-linux-gnu; 2018-07-03 02:12:37 UTC; unix# # 
Thanks for correcting that.# # fill free to ask any further information you 
would need.# # cheers,# # hugo# # # -- #   - no title specified# # Hugo 
Mathé-Hubert# # ATER# # Laboratoire Interdisciplinaire des Environnements 
Continentaux (LIEC)# # UMR 7360 CNRS -  Bât IBISE# # Université de Lorraine  -  
UFR SciFA# # 8, Rue du Général Delestraint# # F-57070 METZ# # +33(0)9 77 21 66 
66# - - - - - - - - - - - - - - - - - -#   Les réflexions naissent dans les 
doutes et meurent dans les certitudes. # Les doutes sont donc un signe de force 
et les certitudes un signe de # faiblesse. La plupart des gens sont pourtant 
certains du contraire.# - - - - - - - - - - - - - - - - - -#   Thoughts appear 
from doubts and die in convictions. Therefore, doubts # are an indication of 
strength and convictions an indication of weakness. # Yet, most people believe 
the opposite.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug : Autocorrelation in sample drawn from stats::rnorm

2018-10-04 Thread Annaert Jan

Did you take into account that the sample serial correlation coefficient has a 
bias of approximately -1/T (with T the sample size)? Its variance is 
approximately 1/T.
Jan Annaert



-Original Message-
From: R-help  On Behalf Of hmh
Sent: donderdag 4 oktober 2018 12:09
To: R 
Subject: [R] Bug : Autocorrelation in sample drawn from stats::rnorm

Hi,


I just noticed the following bug:

When we draw a random sample using the function stats::rnorm, there should be 
not auto-correlation in the sample. But their is some auto-correlation _when 
the sample that is drawn is small_.

I describe the problem using two functions:

DistributionAutocorrelation_Unexpected which as the wrong behavior : 
_when drawing some small samples using rnorm, there is generally a strong 
negative auto-correlation in the sample_.

and

DistributionAutocorrelation_Expected which illustrate the expected behavior



*Unexpected : *

DistributionAutocorrelation_Unexpected = function(SampleSize){
   Cor = NULL
   for(repetition in 1:1e5){
     X = rnorm(SampleSize)
     Cor[repetition] = cor(X[-1],X[-length(X)])
   }
   return(Cor)
}

par(mfrow=c(3,3))
for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){
hist(DistributionAutocorrelation_Unexpected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_))
; abline(v=0,col=2)
}

output:


*Expected**:*

DistributionAutocorrelation_Expected = function(SampleSize){
   Cor = NULL
   for(repetition in 1:1e5){
     X = rnorm(SampleSize)
*    Cor[repetition] = cor(sample(X[-1]),sample(X[-length(X)]))*
   }
   return(Cor)
}

par(mfrow=c(3,3))
for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){
hist(DistributionAutocorrelation_Expected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_))
; abline(v=0,col=2)
}




Some more information you might need:


packageDescription("stats")
Package: stats
Version: 3.5.1
Priority: base
Title: The R Stats Package
Author: R Core Team and contributors worldwide
Maintainer: R Core Team 
Description: R statistical functions.
License: Part of R 3.5.1
Imports: utils, grDevices, graphics
Suggests: MASS, Matrix, SuppDists, methods, stats4
NeedsCompilation: yes
Built: R 3.5.1; x86_64-pc-linux-gnu; 2018-07-03 02:12:37 UTC; unix

Thanks for correcting that.

fill free to ask any further information you would need.

cheers,

hugo


-- 
- no title specified

Hugo Mathé-Hubert

ATER

Laboratoire Interdisciplinaire des Environnements Continentaux (LIEC)

UMR 7360 CNRS -  Bât IBISE

Université de Lorraine  -  UFR SciFA

8, Rue du Général Delestraint

F-57070 METZ

+33(0)9 77 21 66 66
- - - - - - - - - - - - - - - - - -
Les réflexions naissent dans les doutes et meurent dans les certitudes. 
Les doutes sont donc un signe de force et les certitudes un signe de 
faiblesse. La plupart des gens sont pourtant certains du contraire.
- - - - - - - - - - - - - - - - - -
Thoughts appear from doubts and die in convictions. Therefore, doubts 
are an indication of strength and convictions an indication of weakness. 
Yet, most people believe the opposite.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug : Autocorrelation in sample drawn from stats::rnorm

2018-10-04 Thread hmh

Hi,


I just noticed the following bug:

When we draw a random sample using the function stats::rnorm, there 
should be not auto-correlation in the sample. But their is some 
auto-correlation _when the sample that is drawn is small_.


I describe the problem using two functions:

DistributionAutocorrelation_Unexpected which as the wrong behavior : 
_when drawing some small samples using rnorm, there is generally a 
strong negative auto-correlation in the sample_.


and

DistributionAutocorrelation_Expected which illustrate the expected behavior



*Unexpected : *

DistributionAutocorrelation_Unexpected = function(SampleSize){
  Cor = NULL
  for(repetition in 1:1e5){
    X = rnorm(SampleSize)
    Cor[repetition] = cor(X[-1],X[-length(X)])
  }
  return(Cor)
}

par(mfrow=c(3,3))
for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){
hist(DistributionAutocorrelation_Unexpected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_)) 
; abline(v=0,col=2)

}

output:


*Expected**:*

DistributionAutocorrelation_Expected = function(SampleSize){
  Cor = NULL
  for(repetition in 1:1e5){
    X = rnorm(SampleSize)
*    Cor[repetition] = cor(sample(X[-1]),sample(X[-length(X)]))*
  }
  return(Cor)
}

par(mfrow=c(3,3))
for(SampleSize_ in c(4,5,6,7,8,10,15,20,50)){
hist(DistributionAutocorrelation_Expected(SampleSize_),col='grey',main=paste0('SampleSize=',SampleSize_)) 
; abline(v=0,col=2)

}




Some more information you might need:


packageDescription("stats")
Package: stats
Version: 3.5.1
Priority: base
Title: The R Stats Package
Author: R Core Team and contributors worldwide
Maintainer: R Core Team 
Description: R statistical functions.
License: Part of R 3.5.1
Imports: utils, grDevices, graphics
Suggests: MASS, Matrix, SuppDists, methods, stats4
NeedsCompilation: yes
Built: R 3.5.1; x86_64-pc-linux-gnu; 2018-07-03 02:12:37 UTC; unix

Thanks for correcting that.

fill free to ask any further information you would need.

cheers,

hugo


--
- no title specified

Hugo Mathé-Hubert

ATER

Laboratoire Interdisciplinaire des Environnements Continentaux (LIEC)

UMR 7360 CNRS -  Bât IBISE

Université de Lorraine  -  UFR SciFA

8, Rue du Général Delestraint

F-57070 METZ

+33(0)9 77 21 66 66
- - - - - - - - - - - - - - - - - -
Les réflexions naissent dans les doutes et meurent dans les certitudes. 
Les doutes sont donc un signe de force et les certitudes un signe de 
faiblesse. La plupart des gens sont pourtant certains du contraire.

- - - - - - - - - - - - - - - - - -
Thoughts appear from doubts and die in convictions. Therefore, doubts 
are an indication of strength and convictions an indication of weakness. 
Yet, most people believe the opposite.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [bug] spdep package?

2018-07-23 Thread Jeremie Juste


Many thanks for the info.

I see the point but I'll think calling the spData would be a cheaper
price to pay. If each package one load provide access to their variables
things are likely to get messy.

I guess many R users would like to control the variables in their global
environment.

And since it is not trival to protect variables inside a function from
the parent environment this is potentially dangerous.

Best wishes,

Jeremie










Henrik Bengtsson  writes:

> This is intended/expected because the spdep package *depends* on the
> spData package (see https://cran.r-project.org/web/packages/spdep/),
> which means that the maintainer of spdep intends also spData to be
> *attached* whenever spdep is attached.If they would have only
> imported it, then spData would only be *loaded* (but not attached),
> and you would not get 'spData' on your search() path and therefore not
> see 'x' either.
>
> Example:
>
> ## Loading spData
>> loadNamespace("spData")
> 
>
>> loadedNamespaces()
> [1] "compiler"  "graphics"  "utils" "grDevices" "stats" "datasets"
> [7] "methods"   "spData""base"
>
> ## The search path used to find objects
>> search()
> [1] ".GlobalEnv""package:stats" "package:graphics"
> [4] "package:grDevices" "package:utils" "package:datasets"
> [7] "package:methods"   "Autoloads" "package:base"
>
> ## So, spData::x is not found
>> x
> Error: object 'x' not found
>
> ## But is still there
>> spData::x
>  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>
> ## Attaching spData, which also happens when you do library(spdat)
>> library(spData)
> To access larger datasets in this package, install the spDataLarge
> package with: `install.packages('spDataLarge',
> repos='https://nowosad.github.io/drat/', type='source'))
>
>> loadedNamespaces()
> [1] "compiler"  "graphics"  "utils" "grDevices" "stats" "datasets"
> [7] "methods"   "spData""base"
>
> ## Now, spData is on the search path
>> search()
>  [1] ".GlobalEnv""package:spData""package:stats"
>  [4] "package:graphics"  "package:grDevices" "package:utils"
>  [7] "package:datasets"  "package:methods"   "Autoloads"
> [10] "package:base
>
>> x
>  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>
>> find("x")
> [1] "package:spData"
>
> /Henrik
> On Mon, Jul 23, 2018 at 2:01 PM Jeremie Juste  wrote:
>>
>>
>> Helllo,
>>
>> Thanks for the info. I still think these variables should not be loaded
>> when library(spdep) is called.
>>
>> But I'll handle it following your suggestion.
>>
>> Thanks,
>>
>> Jeremie
>>
>>
>>
>>
>>
>>
>> > It turns out that that 'x' comes from the spData package and lives
>> > inside that package (part of its namespace).
>> >
>> >> spData::x
>> >  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>> >
>> > This is conceptually no different from other objects in package
>> > namespace, although we are more used to seeing functions and not data
>> > object.  Another well-known example of this is:
>> >
>> >> base::pi
>> > [1] 3.141593
>> >
>> > So, this 'x' is *not* in your global workspace and you cannot remove
>> > it without unloading the package.
>> >
>> > /Henrik
>>
>>
>> >>
>> >>
>> >> I found a dangerous issue in the library spdep. I get variables x and y
>> >> that cannot be removed by rm() and I don't don't how they show up. Can
>> >> anyone reproduce this?
>> >>
>> >> ~$ R --vanilla
>> >> > rm(list=ls())
>> >> > library(spdep)
>> >> > x
>> >> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>> >> > rm(list=ls())
>> >> > x
>> >> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>> >>
>> >>
>> >>
>> >> > Sys.info()
>> >>
>> >> sysname"Linux"
>> >> release"4.9.0-6-amd64"
>> >> version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
>> >> nodename   "freegnu"
>> >> machine"x86_64"
>> >>
>> >>
>> >> > Session
>> >>
>> >>
>> >> > sessionInfo()
>> >>
>> >> R version 3.4.1 (2017-06-30)
>> >> Platform: x86_64-pc-linux-gnu (64-bit)
>> >> Running under: Debian GNU/Linux 9 (stretch)
>> >>
>> >> Matrix products: default
>> >> BLAS: /usr/local/lib/R/lib/libRblas.so
>> >> LAPACK: /usr/local/lib/R/lib/libRlapack.so
>> >>
>> >> locale:
>> >>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>> >>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>> >>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>> >>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>> >>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
>> >> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>> >>
>> >> attached base packages:
>> >> [1] stats graphics  grDevices utils datasets  methods   base
>> >>
>> >> loaded via a namespace (and not attached):
>> >> [1] compiler_3.4.1
>> >>
>> >> __
>> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the 

Re: [R] [bug] spdep package?

2018-07-23 Thread Henrik Bengtsson
This is intended/expected because the spdep package *depends* on the
spData package (see https://cran.r-project.org/web/packages/spdep/),
which means that the maintainer of spdep intends also spData to be
*attached* whenever spdep is attached.If they would have only
imported it, then spData would only be *loaded* (but not attached),
and you would not get 'spData' on your search() path and therefore not
see 'x' either.

Example:

## Loading spData
> loadNamespace("spData")


> loadedNamespaces()
[1] "compiler"  "graphics"  "utils" "grDevices" "stats" "datasets"
[7] "methods"   "spData""base"

## The search path used to find objects
> search()
[1] ".GlobalEnv""package:stats" "package:graphics"
[4] "package:grDevices" "package:utils" "package:datasets"
[7] "package:methods"   "Autoloads" "package:base"

## So, spData::x is not found
> x
Error: object 'x' not found

## But is still there
> spData::x
 [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450


## Attaching spData, which also happens when you do library(spdat)
> library(spData)
To access larger datasets in this package, install the spDataLarge
package with: `install.packages('spDataLarge',
repos='https://nowosad.github.io/drat/', type='source'))

> loadedNamespaces()
[1] "compiler"  "graphics"  "utils" "grDevices" "stats" "datasets"
[7] "methods"   "spData""base"

## Now, spData is on the search path
> search()
 [1] ".GlobalEnv""package:spData""package:stats"
 [4] "package:graphics"  "package:grDevices" "package:utils"
 [7] "package:datasets"  "package:methods"   "Autoloads"
[10] "package:base

> x
 [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450

> find("x")
[1] "package:spData"

/Henrik
On Mon, Jul 23, 2018 at 2:01 PM Jeremie Juste  wrote:
>
>
> Helllo,
>
> Thanks for the info. I still think these variables should not be loaded
> when library(spdep) is called.
>
> But I'll handle it following your suggestion.
>
> Thanks,
>
> Jeremie
>
>
>
>
>
>
> > It turns out that that 'x' comes from the spData package and lives
> > inside that package (part of its namespace).
> >
> >> spData::x
> >  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> >
> > This is conceptually no different from other objects in package
> > namespace, although we are more used to seeing functions and not data
> > object.  Another well-known example of this is:
> >
> >> base::pi
> > [1] 3.141593
> >
> > So, this 'x' is *not* in your global workspace and you cannot remove
> > it without unloading the package.
> >
> > /Henrik
>
>
> >>
> >>
> >> I found a dangerous issue in the library spdep. I get variables x and y
> >> that cannot be removed by rm() and I don't don't how they show up. Can
> >> anyone reproduce this?
> >>
> >> ~$ R --vanilla
> >> > rm(list=ls())
> >> > library(spdep)
> >> > x
> >> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> >> > rm(list=ls())
> >> > x
> >> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> >>
> >>
> >>
> >> > Sys.info()
> >>
> >> sysname"Linux"
> >> release"4.9.0-6-amd64"
> >> version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
> >> nodename   "freegnu"
> >> machine"x86_64"
> >>
> >>
> >> > Session
> >>
> >>
> >> > sessionInfo()
> >>
> >> R version 3.4.1 (2017-06-30)
> >> Platform: x86_64-pc-linux-gnu (64-bit)
> >> Running under: Debian GNU/Linux 9 (stretch)
> >>
> >> Matrix products: default
> >> BLAS: /usr/local/lib/R/lib/libRblas.so
> >> LAPACK: /usr/local/lib/R/lib/libRlapack.so
> >>
> >> locale:
> >>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
> >>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
> >>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
> >>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
> >>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> >> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
> >>
> >> attached base packages:
> >> [1] stats graphics  grDevices utils datasets  methods   base
> >>
> >> loaded via a namespace (and not attached):
> >> [1] compiler_3.4.1
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [bug] spdep package?

2018-07-23 Thread Jeremie Juste


Helllo,

Thanks for the info. I still think these variables should not be loaded
when library(spdep) is called.

But I'll handle it following your suggestion.

Thanks,

Jeremie






> It turns out that that 'x' comes from the spData package and lives
> inside that package (part of its namespace).
>
>> spData::x
>  [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>
> This is conceptually no different from other objects in package
> namespace, although we are more used to seeing functions and not data
> object.  Another well-known example of this is:
>
>> base::pi
> [1] 3.141593
>
> So, this 'x' is *not* in your global workspace and you cannot remove
> it without unloading the package.
>
> /Henrik


>>
>>
>> I found a dangerous issue in the library spdep. I get variables x and y
>> that cannot be removed by rm() and I don't don't how they show up. Can
>> anyone reproduce this?
>>
>> ~$ R --vanilla
>> > rm(list=ls())
>> > library(spdep)
>> > x
>> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>> > rm(list=ls())
>> > x
>> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>>
>>
>>
>> > Sys.info()
>>
>> sysname"Linux"
>> release"4.9.0-6-amd64"
>> version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
>> nodename   "freegnu"
>> machine"x86_64"
>>
>>
>> > Session
>>
>>
>> > sessionInfo()
>>
>> R version 3.4.1 (2017-06-30)
>> Platform: x86_64-pc-linux-gnu (64-bit)
>> Running under: Debian GNU/Linux 9 (stretch)
>>
>> Matrix products: default
>> BLAS: /usr/local/lib/R/lib/libRblas.so
>> LAPACK: /usr/local/lib/R/lib/libRlapack.so
>>
>> locale:
>>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats graphics  grDevices utils datasets  methods   base
>>
>> loaded via a namespace (and not attached):
>> [1] compiler_3.4.1
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [bug] spdep package?

2018-07-23 Thread Henrik Bengtsson
It turns out that that 'x' comes from the spData package and lives
inside that package (part of its namespace).

> spData::x
 [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450

This is conceptually no different from other objects in package
namespace, although we are more used to seeing functions and not data
object.  Another well-known example of this is:

> base::pi
[1] 3.141593

So, this 'x' is *not* in your global workspace and you cannot remove
it without unloading the package.

/Henrik

On Mon, Jul 23, 2018 at 12:30 PM Jeremie Juste  wrote:
>
>
>
> Hello,
>
>
> I found a dangerous issue in the library spdep. I get variables x and y
> that cannot be removed by rm() and I don't don't how they show up. Can
> anyone reproduce this?
>
> ~$ R --vanilla
> > rm(list=ls())
> > library(spdep)
> > x
> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> > rm(list=ls())
> > x
> [1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
>
>
>
> > Sys.info()
>
> sysname"Linux"
> release"4.9.0-6-amd64"
> version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
> nodename   "freegnu"
> machine"x86_64"
>
>
> > Session
>
>
> > sessionInfo()
>
> R version 3.4.1 (2017-06-30)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Debian GNU/Linux 9 (stretch)
>
> Matrix products: default
> BLAS: /usr/local/lib/R/lib/libRblas.so
> LAPACK: /usr/local/lib/R/lib/libRlapack.so
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.4.1
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [bug] spdep package?

2018-07-23 Thread Jeremie Juste



Hello,


I found a dangerous issue in the library spdep. I get variables x and y
that cannot be removed by rm() and I don't don't how they show up. Can
anyone reproduce this?

~$ R --vanilla
> rm(list=ls())
> library(spdep)
> x
[1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450
> rm(list=ls())
> x
[1]   0  30  60  90 120 150 180 210 240 270 300 330 360 390 420 450



> Sys.info()

sysname"Linux" 
release"4.9.0-6-amd64" 
version"#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07)"
nodename   "freegnu"   
machine"x86_64"


> Session


> sessionInfo()

R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS: /usr/local/lib/R/lib/libRblas.so
LAPACK: /usr/local/lib/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C  
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C 
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C   

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

loaded via a namespace (and not attached):
[1] compiler_3.4.1

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug report: override stopifnot() ?

2018-03-12 Thread Duncan Murdoch

On 12/03/2018 2:43 PM, Bert Gunter wrote:

Please stop this line of queries/"suggestions/speculations and read the
relevant docs **carefully**.

For example, from ?"=="

"Note

Do not use == and != for tests, such as in if expressions, where you must
get a single TRUE or FALSE. Unless you are absolutely sure that nothing
unusual can happen, you should use the identical
 function instead.
"


But stopifnot(expr) is not a test where you must get a single TRUE or 
FALSE.  See the Details section on its help page, or read its 
Description carefully (where "all" is used in the technical sense of the 
all() function), ignoring the final few words which seem to suggest that 
c(TRUE, TRUE) is not okay.


Duncan Murdoch



So you have already violated that specific warning, which led to the
confusion you evidence. Specifically:

Matrix(1)== Matrix(1)

1 x 1 Matrix of class "lsyMatrix"
  [,1]
[1,] TRUE

That is, the result is not a logical but a (S4) object of class "lsyMatrix"
that contains a logical. Whence your (expected) error message.

Cheers,

Bert





Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Mar 12, 2018 at 10:53 AM, Stepan Kasal  wrote:


Hello,

On Mon, Mar 12, 2018 at 09:30:59AM -0700, William Dunlap wrote:

Why don't you use
stopifnot( all(m1 == m2) )
?


good question.  Even though I use
aseert np.all(m1 == m2)
when working with NumPy, I got accustomed to the "handy shortcut"
that I can omit all() with R vectors and matrices.

Then I got trapped with the thing I reported.

On a second thought, omitting all() might have been bad idea from
the beginning; I should rather write all() routinely.
(It also reminds me that all.equal() is the right one in most cases.)

Is it true that using stopifnot() with non-scalar is considerd bad style?

If yes, could be perhaps stopifnot() enhanced to issue a warning to
teach new users of R, at least when they start using library(Matrix)?

If not, then enhancing stopifnot() to handle the case may be a good idea.

I also noticed the following:


a <- Matrix(1)
stopifnot(a == a)

Error: a == a is not TRUE

if(a==a)print(1)

Error in if (a == a) print(1) : argument is not interpretable as logical

Neither does work, but the first error message is much more confusing.

When thinking about it, stopifnot() should really issue a better error
message in this case.  Patch attached.  But I should perhaps send
it also to R-devel.

Stepan Kasal



On Mon, Mar 12, 2018 at 8:15 AM, Stepan Kasal  wrote:


Hello,
I stumbled over a problem:
stopifnot(m1 == m2)

It works with vector or matrix, but does not work for classes from

Matrix

package.

In the source of stopifnot(), there is all(m1 == m2) that would just

work,

but there is also is.logical(m1 == m2) that id FALSE.

Would it be possible if Matrix package redefined stopifnot() ?

(If there is a bug tracking database for package Matrix, I would be

happy

to insert this report there.)

Thank you very much for the package,
 Stepan Kasal

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug report: override stopifnot() ?

2018-03-12 Thread Bert Gunter
Please stop this line of queries/"suggestions/speculations and read the
relevant docs **carefully**.

For example, from ?"=="

"Note

Do not use == and != for tests, such as in if expressions, where you must
get a single TRUE or FALSE. Unless you are absolutely sure that nothing
unusual can happen, you should use the identical
 function instead.
"

So you have already violated that specific warning, which led to the
confusion you evidence. Specifically:
> Matrix(1)== Matrix(1)
1 x 1 Matrix of class "lsyMatrix"
 [,1]
[1,] TRUE

That is, the result is not a logical but a (S4) object of class "lsyMatrix"
that contains a logical. Whence your (expected) error message.

Cheers,

Bert





Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Mar 12, 2018 at 10:53 AM, Stepan Kasal  wrote:

> Hello,
>
> On Mon, Mar 12, 2018 at 09:30:59AM -0700, William Dunlap wrote:
> > Why don't you use
> >stopifnot( all(m1 == m2) )
> > ?
>
> good question.  Even though I use
>aseert np.all(m1 == m2)
> when working with NumPy, I got accustomed to the "handy shortcut"
> that I can omit all() with R vectors and matrices.
>
> Then I got trapped with the thing I reported.
>
> On a second thought, omitting all() might have been bad idea from
> the beginning; I should rather write all() routinely.
> (It also reminds me that all.equal() is the right one in most cases.)
>
> Is it true that using stopifnot() with non-scalar is considerd bad style?
>
> If yes, could be perhaps stopifnot() enhanced to issue a warning to
> teach new users of R, at least when they start using library(Matrix)?
>
> If not, then enhancing stopifnot() to handle the case may be a good idea.
>
> I also noticed the following:
>
> > a <- Matrix(1)
> > stopifnot(a == a)
> Error: a == a is not TRUE
> > if(a==a)print(1)
> Error in if (a == a) print(1) : argument is not interpretable as logical
>
> Neither does work, but the first error message is much more confusing.
>
> When thinking about it, stopifnot() should really issue a better error
> message in this case.  Patch attached.  But I should perhaps send
> it also to R-devel.
>
> Stepan Kasal
>
>
> > On Mon, Mar 12, 2018 at 8:15 AM, Stepan Kasal  wrote:
> >
> > > Hello,
> > > I stumbled over a problem:
> > >stopifnot(m1 == m2)
> > >
> > > It works with vector or matrix, but does not work for classes from
> Matrix
> > > package.
> > >
> > > In the source of stopifnot(), there is all(m1 == m2) that would just
> work,
> > > but there is also is.logical(m1 == m2) that id FALSE.
> > >
> > > Would it be possible if Matrix package redefined stopifnot() ?
> > >
> > > (If there is a bug tracking database for package Matrix, I would be
> happy
> > > to insert this report there.)
> > >
> > > Thank you very much for the package,
> > > Stepan Kasal
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide http://www.R-project.org/
> > > posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug report: override stopifnot() ?

2018-03-12 Thread Stepan Kasal
Hello,
I'm sorry that I aswer to my own mail; I forgot to attach the patch.
Patch below,
   Stepan Kasal

On Mon, Mar 12, 2018 at 06:53:00PM +0100, Stepan Kasal wrote:
> When thinking about it, stopifnot() should really issue a better error
> message in this case.  Patch attached.  But I should perhaps send
> it also to R-devel.


--- stopifnot-orig.r2018-03-12 18:49:01.439484100 +0100
+++ stopifnot.r 2018-03-12 18:48:55.721846700 +0100
@@ -1,16 +1,20 @@
-function (...)
+function (...) 
 {
   n <- length(ll <- list(...))
-  if (n == 0L)
+  if (n == 0L) 
 return(invisible())
   mc <- match.call()
-  for (i in 1L:n) if (!(is.logical(r <- ll[[i]]) && !anyNA(r) &&
+  for (i in 1L:n) if (!(is.logical(r <- ll[[i]]) && !anyNA(r) && 
 all(r))) {
 ch <- deparse(mc[[i + 1]], width.cutoff = 60L)
-if (length(ch) > 1L)
+if (length(ch) > 1L) 
   ch <- paste(ch[1L], "")
-stop(sprintf(ngettext(length(r), "%s is not TRUE", "%s are not all TRUE"),
-  ch), call. = FALSE, domain = NA)
+if (is.logical(r)) {
+  msg <- ngettext(length(r), "%s is not TRUE", "%s are not all TRUE")
+} else {
+  msg <- gettext("%s is not of type \"logical\"")
+}
+stop(sprintf(msg, ch), call. = FALSE, domain = NA)
   }
   invisible()
 }

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug report: override stopifnot() ?

2018-03-12 Thread Stepan Kasal
Hello,

On Mon, Mar 12, 2018 at 09:30:59AM -0700, William Dunlap wrote:
> Why don't you use
>stopifnot( all(m1 == m2) )
> ?

good question.  Even though I use
   aseert np.all(m1 == m2)
when working with NumPy, I got accustomed to the "handy shortcut"
that I can omit all() with R vectors and matrices.

Then I got trapped with the thing I reported.

On a second thought, omitting all() might have been bad idea from
the beginning; I should rather write all() routinely.
(It also reminds me that all.equal() is the right one in most cases.)

Is it true that using stopifnot() with non-scalar is considerd bad style?

If yes, could be perhaps stopifnot() enhanced to issue a warning to
teach new users of R, at least when they start using library(Matrix)?

If not, then enhancing stopifnot() to handle the case may be a good idea.

I also noticed the following:

> a <- Matrix(1)
> stopifnot(a == a)
Error: a == a is not TRUE
> if(a==a)print(1)
Error in if (a == a) print(1) : argument is not interpretable as logical

Neither does work, but the first error message is much more confusing.

When thinking about it, stopifnot() should really issue a better error
message in this case.  Patch attached.  But I should perhaps send
it also to R-devel.

Stepan Kasal


> On Mon, Mar 12, 2018 at 8:15 AM, Stepan Kasal  wrote:
> 
> > Hello,
> > I stumbled over a problem:
> >stopifnot(m1 == m2)
> >
> > It works with vector or matrix, but does not work for classes from Matrix
> > package.
> >
> > In the source of stopifnot(), there is all(m1 == m2) that would just work,
> > but there is also is.logical(m1 == m2) that id FALSE.
> >
> > Would it be possible if Matrix package redefined stopifnot() ?
> >
> > (If there is a bug tracking database for package Matrix, I would be happy
> > to insert this report there.)
> >
> > Thank you very much for the package,
> > Stepan Kasal
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> > posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug report: override stopifnot() ?

2018-03-12 Thread William Dunlap via R-help
Why don't you use
   stopifnot( all(m1 == m2) )
?

Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Mar 12, 2018 at 8:15 AM, Stepan Kasal  wrote:

> Hello,
> I stumbled over a problem:
>stopifnot(m1 == m2)
>
> It works with vector or matrix, but does not work for classes from Matrix
> package.
>
> In the source of stopifnot(), there is all(m1 == m2) that would just work,
> but there is also is.logical(m1 == m2) that id FALSE.
>
> Would it be possible if Matrix package redefined stopifnot() ?
>
> (If there is a bug tracking database for package Matrix, I would be happy
> to insert this report there.)
>
> Thank you very much for the package,
> Stepan Kasal
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug report: override stopifnot() ?

2018-03-12 Thread Stepan Kasal
Hello,
I stumbled over a problem:
   stopifnot(m1 == m2)

It works with vector or matrix, but does not work for classes from Matrix 
package.

In the source of stopifnot(), there is all(m1 == m2) that would just work,
but there is also is.logical(m1 == m2) that id FALSE.

Would it be possible if Matrix package redefined stopifnot() ?

(If there is a bug tracking database for package Matrix, I would be happy to 
insert this report there.)

Thank you very much for the package,
Stepan Kasal

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Bug?

2017-08-08 Thread William Dunlap via R-help
I think the help file for apply() warns you that if you give it a
data.frame, the data.frame will be converted to a matrix, with X <-
as.matrix(X), before FUN is called on its rows or columns.  Look at what
as.matrix does to your data: since there is a non-numeric column it
produces a character matrix and since in the second example some numbers
have 2 digits, the other numbers have a leading space.

> as.matrix(a[1:2,])
  row column assayplate
1 "B" "2""Assay1" "1"
2 "C" "2""Assay1" "1"
> as.matrix(a[1:3,])
  row column assayplate
1 "B" " 2"   "Assay1" "1"
2 "C" " 2"   "Assay1" "1"
3 "B" "10"   "Assay1" "1"

I avoid using apply() on data.frames.


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Tue, Aug 8, 2017 at 11:39 AM, Ramiro Barrantes <
ram...@precisionbioassay.com> wrote:

> Hello,
>
> In my code I found something that looks like an anomaly, I found a
> reproducible example in which I am just trying to compare each row in a
> data frame against the first row:
>
> a<-data.frame(row=c("B","C","B"),column=c(2,2,10),assay=c("
> Assay1","Assay1","Assay1"),plate=c(1,1,1),stringsAsFactors=FALSE)
> apply(a[1:2,],1,function(x) { all(x==a[1,]) })
> apply(a[1:3,],1,function(x) { all(x==a[1,]) })
> > > 1 2
>  TRUE FALSE
> > 1 2 3
> FALSE FALSE FALSE
> >
>
> The second result is not right, it should be TRUE FALSE FALSE
>
> Am I doing something wrong or is this a bug?  With other inputs it seems
> to work ok
>
> Here is my sessionInfo()
> > sessionInfo()
> R version 3.2.5 (2016-04-14)
> Platform: x86_64-redhat-linux-gnu (64-bit)
> Running under: CentOS release 6.9 (Final)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> >
>
> Thank you,
> Ramiro
>
>
>
> Ramiro Barrantes Ph.D.
> Precision Bioassay, Inc.
> 431 Pine St., Suite 110
> Burlington, VT 05401
> 802 865 0155
> 802 861 2365 FAX
> www.precisionbioassay.com net/owa/redir.aspx?SURL=wN3KzpoKXAcetH7sTOTnSyfg-
> iAXFIinpPUtRcduCFCtkgZrUSDTCGgAdAB0AHAAOgAvAC8AdwB3AHcALgBwA
> HIAZQBjAGkAcwBpAG8AbgBiAGkAbwBhAHMAcwBhAHkALgBjAG8AbQA.=
> http%3a%2f%2fwww.precisionbioassay.com>
> ram...@precisionbioassay.com
>
> CONFIDENTIALITY NOTICE: This email, including any attach...{{dropped:9}}
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug?

2017-08-08 Thread Ramiro Barrantes
Hello,

In my code I found something that looks like an anomaly, I found a reproducible 
example in which I am just trying to compare each row in a data frame against 
the first row:

a<-data.frame(row=c("B","C","B"),column=c(2,2,10),assay=c("Assay1","Assay1","Assay1"),plate=c(1,1,1),stringsAsFactors=FALSE)
apply(a[1:2,],1,function(x) { all(x==a[1,]) })
apply(a[1:3,],1,function(x) { all(x==a[1,]) })
> > 1 2
 TRUE FALSE
> 1 2 3
FALSE FALSE FALSE
>

The second result is not right, it should be TRUE FALSE FALSE

Am I doing something wrong or is this a bug?  With other inputs it seems to 
work ok

Here is my sessionInfo()
> sessionInfo()
R version 3.2.5 (2016-04-14)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: CentOS release 6.9 (Final)

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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

Thank you,
Ramiro



Ramiro Barrantes Ph.D.
Precision Bioassay, Inc.
431 Pine St., Suite 110
Burlington, VT 05401
802 865 0155
802 861 2365 FAX
www.precisionbioassay.com
ram...@precisionbioassay.com

CONFIDENTIALITY NOTICE: This email, including any attach...{{dropped:9}}

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Bug in the triMat( ) function in the deldir package.

2017-04-22 Thread Rolf Turner


Yesterday Jay Call drew to my attention the fact that the triMat() 
function was giving wrong answers in some instances.  Wrong answers 
occur if the union of three contiguous Delaunay triangles happens to 
constitute another triangle.  This latter triangle appeared in the list 
of triangles produced by triMat() but is *not* itself a Delaunay 
triangle (and hence should not appear in the list).


I have swatted this bug (at least I think/hope that I have!) and have 
uploaded a revised version of deldir (version 0.1-14) to CRAN.  The 
revision contains other amendments and innovations in addition to this 
bug fix.


If you have in the past used triMat(), you should check your results 
from that usage against those produced by the triMat() function from the 
revised version.


Sorry 'bout that.

cheers,

Rolf Turner

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


  1   2   3   4   5   >