Re: [R] Warning msg after reinstall?

2021-11-07 Thread Ivan Krylov
On Sun, 7 Nov 2021 17:07:20 -0500
Brian Lunergan  wrote:

> I run R on Linux Mint 19.3.

If my advice below doesn't help, let's continue this in the other
mailing list, r-sig-deb...@r-project.org
.

> Warning messages:
> 1: In readLines(file, skipNul = TRUE) :
>   cannot open compressed file
> '/usr/lib/R/site-library/labelled/DESCRIPTION', probable reason 'No
> such file or directory'
> 2: In readLines(file, skipNul = TRUE) :
>   cannot open compressed file
> '/usr/lib/R/site-library/TH.data/DESCRIPTION', probable reason 'No
> such file or directory'

It seems that you've been installing packages into the system-wide
library. Could you try removing all R-related deb packages from your
system, wiping the directories /usr/lib/R and /usr/share/R, then
installing R again? Alternatively, write a script to search files and
directories in /usr/lib/R and /usr/share/R, use `dpkg -S` to see if
it's owned by a package and move it away if not. Both options are quite
a bit dangerous, though.

On second thought, what is in /usr/lib/R/site-library/labelled
and /usr/lib/R/site-library/TH.data? If the two directories are empty,
you can just remove them.

-- 
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] Warning msg after reinstall?

2021-11-07 Thread Brian Lunergan
On 2021-11-07 5:17 p.m., Jeff Newmiller wrote:
> The topic here is R language, not operating system surgery. You probably 
> shouldn't hold your breath for a solution to this here.
> 
> That said, compiling and running without installing for access by the whole 
> system is always an option if you can fix the support libraries.
> 
> On November 7, 2021 2:07:20 PM PST, Brian Lunergan  wrote:
>> Evening gents:
>>
>> First to quickly try and set the scene.
>>
>> I run R on Linux Mint 19.3. I had version 3.5 installed, but wanted to
>> try and upgrade to 4.1. So... I deleted all R stuff I could find, setup
>> the software sources file, and tried to install. Didn't work. I suppose
>> it needs a more recent edition of Mint. Backpedalled as best I could.
>> Now 3.5 was uncooperative. Finally found some notes describing how to
>> install 3.6. That worked. So now I again have a functioning copy of R,
>> with a current edition of Rstudio as my principle access tool. Adding
>> pkgs through the software manager doesn't seem to be work, but as long
>> as I fire it up using the sudo command I can add them through Rstudio.
>>
>> The puzzle comes at the end of an install round. It seems I may have
>> taken out something I shouldn't have as I get the following warning.
>>
>> Warning messages:
>> 1: In readLines(file, skipNul = TRUE) :
>>  cannot open compressed file
>> '/usr/lib/R/site-library/labelled/DESCRIPTION', probable reason 'No such
>> file or directory'
>> 2: In readLines(file, skipNul = TRUE) :
>>  cannot open compressed file
>> '/usr/lib/R/site-library/TH.data/DESCRIPTION', probable reason 'No such
>> file or directory'
>>
>> I'm not really sure. I assume I got sloppy withe deletions. I ask for
>> assistance to solve this. What does it mean? What can I do to correct
>> the error? Thanks in advance.

Point taken Jeff, IF it were a Linux msg. But it's not, having appeared
within an active R session following the install of some pkgs, so I
thought here was a logical place to start. The directory is present but
apparently the file is not. No doubt I approached things in a
disorganized way and deleted it when I should have left it alone. So
perhaps you or one of the other group members could suggest how to
replace what R is seeking or, if not here, what R group I might approach
to find an answer for this R problem,

-- 
Brian Lunergan
Pavillon Marionville
Russell, Ontario
Canada



OpenPGP_signature
Description: OpenPGP digital signature
__
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] Warning msg after reinstall?

2021-11-07 Thread Jeff Newmiller
The topic here is R language, not operating system surgery. You probably 
shouldn't hold your breath for a solution to this here.

That said, compiling and running without installing for access by the whole 
system is always an option if you can fix the support libraries.

On November 7, 2021 2:07:20 PM PST, Brian Lunergan  wrote:
>Evening gents:
>
>First to quickly try and set the scene.
>
>I run R on Linux Mint 19.3. I had version 3.5 installed, but wanted to
>try and upgrade to 4.1. So... I deleted all R stuff I could find, setup
>the software sources file, and tried to install. Didn't work. I suppose
>it needs a more recent edition of Mint. Backpedalled as best I could.
>Now 3.5 was uncooperative. Finally found some notes describing how to
>install 3.6. That worked. So now I again have a functioning copy of R,
>with a current edition of Rstudio as my principle access tool. Adding
>pkgs through the software manager doesn't seem to be work, but as long
>as I fire it up using the sudo command I can add them through Rstudio.
>
>The puzzle comes at the end of an install round. It seems I may have
>taken out something I shouldn't have as I get the following warning.
>
>Warning messages:
>1: In readLines(file, skipNul = TRUE) :
>  cannot open compressed file
>'/usr/lib/R/site-library/labelled/DESCRIPTION', probable reason 'No such
>file or directory'
>2: In readLines(file, skipNul = TRUE) :
>  cannot open compressed file
>'/usr/lib/R/site-library/TH.data/DESCRIPTION', probable reason 'No such
>file or directory'
>
>I'm not really sure. I assume I got sloppy withe deletions. I ask for
>assistance to solve this. What does it mean? What can I do to correct
>the error? Thanks in advance.
>
>ttyl...

-- 
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.


[R] Warning msg after reinstall?

2021-11-07 Thread Brian Lunergan
Evening gents:

First to quickly try and set the scene.

I run R on Linux Mint 19.3. I had version 3.5 installed, but wanted to
try and upgrade to 4.1. So... I deleted all R stuff I could find, setup
the software sources file, and tried to install. Didn't work. I suppose
it needs a more recent edition of Mint. Backpedalled as best I could.
Now 3.5 was uncooperative. Finally found some notes describing how to
install 3.6. That worked. So now I again have a functioning copy of R,
with a current edition of Rstudio as my principle access tool. Adding
pkgs through the software manager doesn't seem to be work, but as long
as I fire it up using the sudo command I can add them through Rstudio.

The puzzle comes at the end of an install round. It seems I may have
taken out something I shouldn't have as I get the following warning.

Warning messages:
1: In readLines(file, skipNul = TRUE) :
  cannot open compressed file
'/usr/lib/R/site-library/labelled/DESCRIPTION', probable reason 'No such
file or directory'
2: In readLines(file, skipNul = TRUE) :
  cannot open compressed file
'/usr/lib/R/site-library/TH.data/DESCRIPTION', probable reason 'No such
file or directory'

I'm not really sure. I assume I got sloppy withe deletions. I ask for
assistance to solve this. What does it mean? What can I do to correct
the error? Thanks in advance.

ttyl...
-- 
Brian Lunergan
Pavillon Marionville
Russell, Ontario
Canada



OpenPGP_signature
Description: OpenPGP digital signature
__
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] Environmental oddity.

2021-11-07 Thread Rolf Turner
On Sun, 7 Nov 2021 13:11:10 -0500
Duncan Murdoch  wrote:

> I've submitted a bug report and patch:
> 
>   https://bugs.r-project.org/show_bug.cgi?id=18232

Thanks Duncan.  It's good to know that the anomaly wasn't just a result
of my doing something stupid.

cheers,

Rolf


-- 
Honorary Research Fellow
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.


Re: [R] Environmental oddity.

2021-11-07 Thread Duncan Murdoch

I've submitted a bug report and patch:

 https://bugs.r-project.org/show_bug.cgi?id=18232

Duncan Murdoch

On 07/11/2021 12:20 p.m., Duncan Murdoch wrote:

Here's how to construct a similar deparsing error:

# e1 and e2 are obviously different expressions
e1 <- quote(5 * if (TRUE) 2 else 3/4)
e2 <- quote(5 * (if (TRUE) 2 else 3)/4)
# and they evaluate differently
eval(e1)
#> [1] 10
eval(e2)
#> [1] 2.5

# We can make an equivalent version of e2 by messing around in it
e3 <- e2
as.list(e3[[c(2,3)]])
#> [[1]]
#> `(`
#>
#> [[2]]
#> if (TRUE) 2 else 3
e3[[c(2,3)]] <- e3[[c(2,3,2)]]

# Now e3 looks like e1
e1
#> 5 * if (TRUE) 2 else 3/4
e3
#> 5 * if (TRUE) 2 else 3/4

# But it doesn't evaluate that way
eval(e1)
#> [1] 10
eval(e3)
#> [1] 2.5

Duncan Murdoch

On 07/11/2021 6:27 a.m., Duncan Murdoch wrote:

On 06/11/2021 11:32 p.m., Deepayan Sarkar wrote:

On Sun, Nov 7, 2021 at 6:05 AM Rolf Turner  wrote:



I have two functions which appear to differ only in their environments.
They look like:


d1
function (x, mean = 0, sd = 1, log = FALSE)
(((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd



and


d2
function (x, mean = 0, sd = 1, log = FALSE)
(((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd


Typing "environment(d1)" gives





and typing "environment(d2)" gives





The d2() function however gives an incorrect result:


d1(1,0,3,TRUE)
[1] -0.2962963
d2(1,0,3,TRUE)
[1] -0.889


It can't be as simple as that. I get the same result (as your d2) with
the following:

d <- function (x, mean = 0, sd = 1, log = FALSE) {
   (((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd) / sd
}
d(1, 0, 3, TRUE)
environment(d)
environment(d) <- as.environment("package:stats")
d(1, 0, 3, TRUE)


In d2() the result of the if() statement does not get divided
by the final "sd" whereas in d1() it does (which is the desired/correct
result).

Of course the code is ridiculously kludgy (it was produced by "symbolic
differentiation").  That's not the point.  I'm just curious (idly?) as
to *why* the association of the namespace:stats environment with d1()
causes it to "do the right thing".


This sounds like a difference in precedence. The expression

if (log) 1 else dnorm(x, mean, sd) / sd

is apparently being interpreted differently as

d1: (if (log) 1 else dnorm(x, mean, sd)) / sd
d2: if (log) 1 else (dnorm(x, mean, sd)) / sd)

It's unclear how environments could affect this, so it would be very
helpful to have a reproducible example.



Rolf said these were automatically produced functions.  Those don't
always deparse properly, because manipulating expressions can produce
things that can never be produced by the parser.  I'm not sure this
happened in this case.  You'd need to examine the parse trees of d1 and
d2 to see.

There's also a possibility that the srcref attached to them is lying,
and we're not seeing the deparsed versions of the functions.  Printing
removeSource(d1) and removeSource(d2) should reveal that.

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] Environmental oddity.

2021-11-07 Thread Duncan Murdoch

Here's how to construct a similar deparsing error:

# e1 and e2 are obviously different expressions
e1 <- quote(5 * if (TRUE) 2 else 3/4)
e2 <- quote(5 * (if (TRUE) 2 else 3)/4)
# and they evaluate differently
eval(e1)
#> [1] 10
eval(e2)
#> [1] 2.5

# We can make an equivalent version of e2 by messing around in it
e3 <- e2
as.list(e3[[c(2,3)]])
#> [[1]]
#> `(`
#>
#> [[2]]
#> if (TRUE) 2 else 3
e3[[c(2,3)]] <- e3[[c(2,3,2)]]

# Now e3 looks like e1
e1
#> 5 * if (TRUE) 2 else 3/4
e3
#> 5 * if (TRUE) 2 else 3/4

# But it doesn't evaluate that way
eval(e1)
#> [1] 10
eval(e3)
#> [1] 2.5

Duncan Murdoch

On 07/11/2021 6:27 a.m., Duncan Murdoch wrote:

On 06/11/2021 11:32 p.m., Deepayan Sarkar wrote:

On Sun, Nov 7, 2021 at 6:05 AM Rolf Turner  wrote:



I have two functions which appear to differ only in their environments.
They look like:


d1
function (x, mean = 0, sd = 1, log = FALSE)
(((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd



and


d2
function (x, mean = 0, sd = 1, log = FALSE)
(((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd


Typing "environment(d1)" gives





and typing "environment(d2)" gives





The d2() function however gives an incorrect result:


d1(1,0,3,TRUE)
[1] -0.2962963
d2(1,0,3,TRUE)
[1] -0.889


It can't be as simple as that. I get the same result (as your d2) with
the following:

d <- function (x, mean = 0, sd = 1, log = FALSE) {
  (((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd) / sd
}
d(1, 0, 3, TRUE)
environment(d)
environment(d) <- as.environment("package:stats")
d(1, 0, 3, TRUE)


In d2() the result of the if() statement does not get divided
by the final "sd" whereas in d1() it does (which is the desired/correct
result).

Of course the code is ridiculously kludgy (it was produced by "symbolic
differentiation").  That's not the point.  I'm just curious (idly?) as
to *why* the association of the namespace:stats environment with d1()
causes it to "do the right thing".


This sounds like a difference in precedence. The expression

if (log) 1 else dnorm(x, mean, sd) / sd

is apparently being interpreted differently as

d1: (if (log) 1 else dnorm(x, mean, sd)) / sd
d2: if (log) 1 else (dnorm(x, mean, sd)) / sd)

It's unclear how environments could affect this, so it would be very
helpful to have a reproducible example.



Rolf said these were automatically produced functions.  Those don't
always deparse properly, because manipulating expressions can produce
things that can never be produced by the parser.  I'm not sure this
happened in this case.  You'd need to examine the parse trees of d1 and
d2 to see.

There's also a possibility that the srcref attached to them is lying,
and we're not seeing the deparsed versions of the functions.  Printing
removeSource(d1) and removeSource(d2) should reveal that.

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] Environmental oddity.

2021-11-07 Thread Duncan Murdoch

On 06/11/2021 11:32 p.m., Deepayan Sarkar wrote:

On Sun, Nov 7, 2021 at 6:05 AM Rolf Turner  wrote:



I have two functions which appear to differ only in their environments.
They look like:


d1
function (x, mean = 0, sd = 1, log = FALSE)
(((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd



and


d2
function (x, mean = 0, sd = 1, log = FALSE)
(((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd)/sd


Typing "environment(d1)" gives





and typing "environment(d2)" gives





The d2() function however gives an incorrect result:


d1(1,0,3,TRUE)
[1] -0.2962963
d2(1,0,3,TRUE)
[1] -0.889


It can't be as simple as that. I get the same result (as your d2) with
the following:

d <- function (x, mean = 0, sd = 1, log = FALSE) {
 (((x - mean)/sd)^2 - 1) * if (log) 1 else dnorm(x, mean, sd) / sd
}
d(1, 0, 3, TRUE)
environment(d)
environment(d) <- as.environment("package:stats")
d(1, 0, 3, TRUE)


In d2() the result of the if() statement does not get divided
by the final "sd" whereas in d1() it does (which is the desired/correct
result).

Of course the code is ridiculously kludgy (it was produced by "symbolic
differentiation").  That's not the point.  I'm just curious (idly?) as
to *why* the association of the namespace:stats environment with d1()
causes it to "do the right thing".


This sounds like a difference in precedence. The expression

if (log) 1 else dnorm(x, mean, sd) / sd

is apparently being interpreted differently as

d1: (if (log) 1 else dnorm(x, mean, sd)) / sd
d2: if (log) 1 else (dnorm(x, mean, sd)) / sd)

It's unclear how environments could affect this, so it would be very
helpful to have a reproducible example.



Rolf said these were automatically produced functions.  Those don't 
always deparse properly, because manipulating expressions can produce 
things that can never be produced by the parser.  I'm not sure this 
happened in this case.  You'd need to examine the parse trees of d1 and 
d2 to see.


There's also a possibility that the srcref attached to them is lying, 
and we're not seeing the deparsed versions of the functions.  Printing 
removeSource(d1) and removeSource(d2) should reveal that.


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] Environmental oddity --- reproducible example.

2021-11-07 Thread Berwin A Turlach
G'day Rolf,

On Sun, 7 Nov 2021 19:33:40 +1300
Rolf Turner  wrote:

> library(Deriv)
> d1 <- Deriv(dnorm,"sd")
> source("d2.txt") # d2.txt is attached
> 
> d1(1,0,3,TRUE) # [1] -0.2962963
> d2(1,0,3,TRUE) # [1] -0.889

Fascinating:

R> pryr::call_tree(body(d1))
R> pryr::call_tree(body(d2))

clearly show that the two functions have a different idea to what
expression the final "/sd" is applied too (as an earlier poster
suggested), but I have no idea why.

Deriv() seems to return the correct function, but when it is displayed,
the deparser(?) somehow omits a crucial pair of braces.

Cheers,

Berwin

__
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] Environmental oddity.

2021-11-07 Thread Ivan Krylov
On Sun, 7 Nov 2021 09:02:36 +0530
Deepayan Sarkar  wrote:

> This sounds like a difference in precedence. The expression
> 
> if (log) 1 else dnorm(x, mean, sd) / sd
> 
> is apparently being interpreted differently as
> 
> d1: (if (log) 1 else dnorm(x, mean, sd)) / sd
> d2: if (log) 1 else (dnorm(x, mean, sd)) / sd)
> 
> It's unclear how environments could affect this, so it would be very
> helpful to have a reproducible example.

This seems to be caused by the deparser producing the same source text
for different expressions:

( x <- expression(`/`(`*`(a, if (b) c else d), e)) )
# expression(a * if (b) c else d/e)
( y <- expression(a * if (b) c else d/e) )
# expression(a * if (b) c else d/e)
all.equal(x, y)
# [1] TRUE

The expressions *seem* to be the same, but:

as.list(x[[1]])
# [[1]]
# `/`
# 
# [[2]]
# a * if (b) c else d
# 
# [[3]]
# e

as.list(y[[1]])
# [[1]]
# `*`
# 
# [[2]]
# a
# 
# [[3]]
# if (b) c else d/e

Perhaps it could be possible to make the deparser output extra
parentheses at the cost of slightly uglier output in cases when they
are not needed. all.equal.language uses deparse(), so it will behave
correctly when the deparse() output is fixed.

In the original example, as.list(body(d1)) and as.list(body(d2)) should
show different results, too.

-- 
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.