Re: [R] Avoiding Delete key function as 'Quit R' in Rterm when there are no characters in cursor line

2024-02-09 Thread Iago Giné Vázquez
Duncan, do you think it's worth to comment this in R-devel list?

Iago


De: CALUM POLWART 
Enviat el: divendres, 9 de febrer de 2024 18:28
Per a: Duncan Murdoch 
A/c: Iago Giné Vázquez ; r-help@r-project.org 

Tema: Re: [R] Avoiding Delete key function as 'Quit R' in Rterm when there are 
no characters in cursor line

I don't use term, but I've just tested it and this is reproducable.

Is it a bug? Not sure. If you hit c after getting the message it will cancel 
the q() request.


On Fri, 9 Feb 2024, 17:21 Duncan Murdoch, 
mailto:murdoch.dun...@gmail.com>> wrote:
That looks to me like a bug, but I don't use Windows any more, so I
won't offer to try to fix it for you.  In fact I don't think Rterm has
many users at all:  most Windows users probably use RStudio or one of
the other graphical front ends (Visual Studio, Emacs, Rgui, etc.)

So maybe you can track down the issue, or someone else will try.  Or
maybe you'll just have to avoid triggering the bug (if it really is one).

Duncan Murdoch

On 09/02/2024 10:03 a.m., Iago Giné Vázquez wrote:
> Yes, indeed, I am talking about Rterm in Windows.
>
> Iago
> 
> *De:* Duncan Murdoch 
> mailto:murdoch.dun...@gmail.com>>
> *Enviat el:* divendres, 9 de febrer de 2024 13:50
> *Per a:* Iago Giné Vázquez mailto:iago.g...@sjd.es>>
> *Tema:* Re: [R] Avoiding Delete key function as 'Quit R' in Rterm when
> there are no characters in cursor line
> On 09/02/2024 6:25 a.m., Iago Giné Vázquez wrote:
>> Hi all,
>>
>> I cite from README.Rterm
>>
>> ^D, DEL : Delete the character under the cursor.
>>
>> That is the general behaviour, but when there is no character (neither under 
>> the cursor nor at its left), pressing the Delete key suggests closing the R 
>> terminal. Is there any (configurable) way to avoid this behaviour?
>
> Are you talking about rterm in Windows, or which front end?
>
> 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.

[[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] Avoiding Delete key function as 'Quit R' in Rterm when there are no characters in cursor line

2024-02-09 Thread CALUM POLWART
I don't use term, but I've just tested it and this is reproducable.

Is it a bug? Not sure. If you hit c after getting the message it will
cancel the q() request.


On Fri, 9 Feb 2024, 17:21 Duncan Murdoch,  wrote:

> That looks to me like a bug, but I don't use Windows any more, so I
> won't offer to try to fix it for you.  In fact I don't think Rterm has
> many users at all:  most Windows users probably use RStudio or one of
> the other graphical front ends (Visual Studio, Emacs, Rgui, etc.)
>
> So maybe you can track down the issue, or someone else will try.  Or
> maybe you'll just have to avoid triggering the bug (if it really is one).
>
> Duncan Murdoch
>
> On 09/02/2024 10:03 a.m., Iago Giné Vázquez wrote:
> > Yes, indeed, I am talking about Rterm in Windows.
> >
> > Iago
> > 
> > *De:* Duncan Murdoch 
> > *Enviat el:* divendres, 9 de febrer de 2024 13:50
> > *Per a:* Iago Giné Vázquez 
> > *Tema:* Re: [R] Avoiding Delete key function as 'Quit R' in Rterm when
> > there are no characters in cursor line
> > On 09/02/2024 6:25 a.m., Iago Giné Vázquez wrote:
> >> Hi all,
> >>
> >> I cite from README.Rterm
> >>
> >> ^D, DEL : Delete the character under the cursor.
> >>
> >> That is the general behaviour, but when there is no character (neither
> under the cursor nor at its left), pressing the Delete key suggests closing
> the R terminal. Is there any (configurable) way to avoid this behaviour?
> >
> > Are you talking about rterm in Windows, or which front end?
> >
> > 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.
>

[[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] Avoiding Delete key function as 'Quit R' in Rterm when there are no characters in cursor line

2024-02-09 Thread Duncan Murdoch
That looks to me like a bug, but I don't use Windows any more, so I 
won't offer to try to fix it for you.  In fact I don't think Rterm has 
many users at all:  most Windows users probably use RStudio or one of 
the other graphical front ends (Visual Studio, Emacs, Rgui, etc.)


So maybe you can track down the issue, or someone else will try.  Or 
maybe you'll just have to avoid triggering the bug (if it really is one).


Duncan Murdoch

On 09/02/2024 10:03 a.m., Iago Giné Vázquez wrote:

Yes, indeed, I am talking about Rterm in Windows.

Iago

*De:* Duncan Murdoch 
*Enviat el:* divendres, 9 de febrer de 2024 13:50
*Per a:* Iago Giné Vázquez 
*Tema:* Re: [R] Avoiding Delete key function as 'Quit R' in Rterm when 
there are no characters in cursor line

On 09/02/2024 6:25 a.m., Iago Giné Vázquez wrote:

Hi all,

I cite from README.Rterm

^D, DEL : Delete the character under the cursor.

That is the general behaviour, but when there is no character (neither under 
the cursor nor at its left), pressing the Delete key suggests closing the R 
terminal. Is there any (configurable) way to avoid this behaviour?


Are you talking about rterm in Windows, or which front end?

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] Avoiding Delete key function as 'Quit R' in Rterm when there are no characters in cursor line

2024-02-09 Thread Iago Giné Vázquez
Yes, indeed, I am talking about Rterm in Windows.

Iago

De: Duncan Murdoch 
Enviat el: divendres, 9 de febrer de 2024 13:50
Per a: Iago Giné Vázquez 
Tema: Re: [R] Avoiding Delete key function as 'Quit R' in Rterm when there are 
no characters in cursor line

On 09/02/2024 6:25 a.m., Iago Giné Vázquez wrote:
> Hi all,
>
> I cite from README.Rterm
>
> ^D, DEL : Delete the character under the cursor.
>
> That is the general behaviour, but when there is no character (neither under 
> the cursor nor at its left), pressing the Delete key suggests closing the R 
> terminal. Is there any (configurable) way to avoid this behaviour?

Are you talking about rterm in Windows, or which front end?

Duncan Murdoch


[[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] Is simplify2array working for dimension > 2?

2024-02-09 Thread Jean-Claude Arbaut
Re your mention in your other mail (which didn't go to r-help) of this part
of the doc:

"The default value, TRUE, returns a vector or matrix if appropriate,
whereas if simplify = "array" the result may be an array of “rank”
(==length(dim(.))) **one higher than the result of FUN(X[[i]]).**"

It's not I understood this, but it makes some sense:

sapply(1:2, function(i) diag(3)) is a matrix, but
sapply(1:2, function(i) diag(3), simplify = "array") is a rank-3 array.

So this is the "appropriate case", and recursively simplifying nested list
to high rank arrays is not something that's supposed to be done.

And indeed, simplify2array(list(diag(2), diag(2))) does yield a rank-3
array as well. And it works for a list of rank-3 arrays, converted to
rank-4, etc.

So list of array is ok, list of list is not, except for rank 2. The
behavior for rank 2 led me to think it applied as well for higher rank, and
the doc for the 'higher' argument seemed to confirm this, but I was a bit
optimistic.

Thanks for your answer. I believe the doc may be improved a little bit, but
the intent looks clearer now.



Le jeu. 8 févr. 2024 à 10:32, Bert Gunter  a écrit :

> Jean-Claude:
>
> Well, here's my "explanation". Caveat emptor!
>
> Note that:
> "simplify2array() is the utility called from sapply() when simplify is
> not false"
>
> and
>
> > sapply(a, I, simplify = "array")
>  [,1]   [,2]
> [1,] list,2 list,2
> [2,] list,2 list,2
>
> So it seems that simplify2array() is not intended to operate in the
> way that you expected, i.e. that recursive simplification is done.
> And, indeed, if you check the code for the function, you will see that
> that is the case. Perhaps the key phrase in the docs is in the
> sapply() part that says:
>
> "sapply is a user-friendly version and wrapper of lapply by default
> returning a vector, matrix or, if simplify = "array", an array ***if
> appropriate***, by applying simplify2array(). "   In other words,
> recursive simplification is considered not "appropriate".
>
> FWIW I also find this somewhat confusing and think that explicitly
> saying that recursive simplification is not done might make it less
> so. But writing docs that  address all our possible misconceptions is
> pretty difficult (or impossible!), and maybe adding that explicit
> caveat would confuse others even more... :-(
>
> Cheers,
> Bert
>
>
>
>
>
>
>
>
>
> On Thu, Feb 8, 2024 at 12:12 AM Jean-Claude Arbaut 
> wrote:
> >
> > Reading the doc for ?simplify2array, I got the impression that with the
> > 'higher = T' argument the function returns an array of dimension greater
> > than 2 when it makes sense (the doc says "when appropriate", which is
> > rather vague). I would expect
> >
> > a <- list(
> >   list(list(1, 2), list(3, 4)),
> >   list(list(5, 6), list(7, 8))
> > )
> > simplify2array(a, higher = T)
> >
> > to return the same (possibly up to a dimension permutation) as
> > array(1:8, dim = c(2, 2, 2))
> >
> > However, in this case simplify2array returns a matrix (i.e. 2 dimensional
> > array), whose elements are lists.
> > It's the same as
> > structure(list(list(1, 2), list(3, 4), list(5, 6), list(7, 8)), dim =
> c(2,
> > 2))
> >
> > I get the same behavior with
> > a <- list(
> >   list(c(1, 2), c(3, 4)),
> >   list(c(5, 6), c(7, 8))
> > )
> > but then the matrix elements are numeric vectors instead of lists.
> >
> > Did I miss something to get the result I expected with this function? Or
> is
> > it a bug? Or maybe the function is not supposed to return a higher
> > dimensional array, and I didn't understand the documentation correctly?
> >
> > There is a workaround, one can do for instance
> > array(unlist(a), dim = c(2, 2, 2))
> > and there may be better options (checking dimensions?).
> >
> > In case it's important: running R 4.3.2 on Debian 12.4.
> >
> > Best regards,
> >
> > Jean-Claude Arbaut
> >
> > [[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] Avoiding Delete key function as 'Quit R' in Rterm when there are no characters in cursor line

2024-02-09 Thread Iago Giné Vázquez
Hi all,

I cite from README.Rterm

^D, DEL : Delete the character under the cursor.

That is the general behaviour, but when there is no character (neither under 
the cursor nor at its left), pressing the Delete key suggests closing the R 
terminal. Is there any (configurable) way to avoid this behaviour?

Thanks!

Best regards,
Iago

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