Re: [R] Is there some way to customize colours for the View output?

2024-05-13 Thread Iago Giné Vázquez
Hi all,

I've just could test your suggestions on using dataedit... entries now, and 
indeed they work... partially. See, please, the next screenshot:
https://ibb.co/Dkn2pVs


dataedituser modifies the red borders
dataedittext the yellow text
dataeditfg... I do not know, specified to green the output of View(mtcars) does 
not change from that of the screenshot
dataeditbg is the (almost) black background, but in the column and row 
names.

I tried the modifying the different colours through the GUI preferences, and 
the background colour for column and row names did not change. May this be a 
bug?


Thank you for your help.

Best regards,

Iago

De: Rolf Turner 
Enviat el: dimarts, 7 de maig de 2024 23:58
Per a: Duncan Murdoch 
A/c: Iago Gin� V�zquez ; r-help@r-project.org 
; Achim Zeileis 
Tema: Re: [R] Is there some way to customize colours for the View output?


On Tue, 7 May 2024 06:34:50 -0400
Duncan Murdoch  wrote:

> On 07/05/2024 6:31 a.m., Iago Gin� V�zquez wrote:
> > Thanks Duncan.
> >
> > I am currently on Windows. Is there any solution for it?
>
> Switch to Linux or MacOS?


Fortune nomination!

cheers,

Rolf Turner

--
Honorary Research Fellow
Department of Statistics
University of Auckland
Stats. Dep't. (secretaries) phone:
 +64-9-373-7599 ext. 89622
Home phone: +64-9-480-4619


[[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 there some way to customize colours for the View output?

2024-05-07 Thread Iago Giné Vázquez
Thanks Duncan.

I am currently on Windows. Is there any solution for it?

Best regards,
Iago



De: Duncan Murdoch 
Enviat el: dimarts, 7 de maig de 2024 12:24
Per a: Iago Gin� V�zquez ; r-help@r-project.org 

Tema: Re: [R] Is there some way to customize colours for the View output?

If you are using X11, then the paragraph on X resources is relevant.
Create a file named .Xresources in your home directory, and put a line like

R_dataentry.background: green

in it.  On my Mac, this has to be in place before Xquartz is started.
There is probably a similar restriction on other platforms.

Colour names (used for foreground and background) can be words or hex
colors like #ff .  I don't know the format for "geometry", but I'd
guess it's like the -geometry argument to X11 apps, e.g. 1000x1000+0+0.

If you are on Windows, none of this is relevant.

Duncan Murdoch

On 07/05/2024 5:51 a.m., Iago Gin� V�zquez wrote:
> Hi all,
>
> As the email subject tells, I write to ask if there is the chance to 
> customize the colours (and in particular the background) of the `View` output 
> window.
>
>
> In the View help, it is told that:
>
>  On Windows, the initial size of the data viewer window is taken from the 
> default dimensions of a pager (see Rconsole), but adjusted downwards to show 
> a whole number of rows and columns.
>
> So if it works for the sizes, it could work for the colours. But after 
> modifying
>
> ## Colours for console and pager(s)
> # (see rw/etc/rgb.txt for the known colours).
> background = gray9
> normaltext = yellow
> usertext = YellowGreen
> highlight = golderod
>
> I did not have success.
>
> On the other hand, in the data.entry it is told that
>
>  The data entry window responds to X resources of class R_dataentry. 
> Resources foreground, background and geometry are utilized.
>
> But I do not know if this is related and how to modify those resources.
>
> Can someone help me?
>
> If this is not possible, is there any chance of making a feature request of 
> this to R-devel? (I mean, I could write to R-devel list, but do you think 
> there would be any interest in developing this?)
>
> 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.


[[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] Is there some way to customize colours for the View output?

2024-05-07 Thread Iago Giné Vázquez
Hi all,

As the email subject tells, I write to ask if there is the chance to customize 
the colours (and in particular the background) of the `View` output window.


In the View help, it is told that:

On Windows, the initial size of the data viewer window is taken from the 
default dimensions of a pager (see Rconsole), but adjusted downwards to show a 
whole number of rows and columns.

So if it works for the sizes, it could work for the colours. But after modifying

## Colours for console and pager(s)
# (see rw/etc/rgb.txt for the known colours).
background = gray9
normaltext = yellow
usertext = YellowGreen
highlight = golderod

I did not have success.

On the other hand, in the data.entry it is told that

The data entry window responds to X resources of class R_dataentry. 
Resources foreground, background and geometry are utilized.

But I do not know if this is related and how to modify those resources.

Can someone help me?

If this is not possible, is there any chance of making a feature request of 
this to R-devel? (I mean, I could write to R-devel list, but do you think there 
would be any interest in developing this?)

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.


Re: [R] Debugging functions defined (locally) inside another functions

2024-04-12 Thread Iago Giné Vázquez
Thanks a lot both Duncan and Ivan,

I will keep that example in mind, Duncan, great!

Best  regards,
Iago


De: Duncan Murdoch 
Enviat el: divendres, 12 d�abril de 2024 15:36
Per a: Iago Gin� V�zquez ; r-help@r-project.org 

Tema: Re: [R] Debugging functions defined (locally) inside another functions

On 12/04/2024 8:15 a.m., Iago Gin� V�zquez wrote:
> Hi all, I am trying to debug an error of a function g defined and used inside 
> another function f of a package.
> So I have
>
> f <- function(whatever){
> ...
> g <- function(whatever2){
>   ...
> }
> ...
> }
>
> If I wanted to debug some thing directly inside f I would do debug(f). But 
> this does not go inside g code. On the other hand, debug(g) does not work as 
> g is not a defined function in the namespace of the package.
>
> Is there some way to debug errors inside g?

The easiest case is if you have access to the source code.  Just put a
browser() statement at the start of g, i.e. change it to

  g <- function(whatever2){
browser()
...
  }

and it will break very similarly to what happens if you have set debug(g).

Another possibility if you have the source but don't want to edit it is
to use trace.  Suppose that the definition of g is in source.R at lines
100 to 120.  Then you can run

   setBreakpoint("source.R#101")

to set a breakpoint via trace() just before line 101 runs.  trace() has
lots of options; it can just print things, or call browser(), etc.  They
are available in setBreakpoint().

If you are executing code from a package and you don't have the source
handy it's a bit tedious, but you can still do the search that
setBreakpoint() does to find the source.  For example, let's set a
breakpoint just before the print statement in g in this example:

  f <- function() {
g <- function() {
  print("this is g")
}
print("this is f")
g()
  }

You need to find the location of that line in f.  Look at as.list(body(f)):

 > as.list(body(f))
[[1]]
`{`

[[2]]
g <- function() {
 print("this is g")
}

[[3]]
print("this is f")

[[4]]
g()

So we need to look within entry 2:

 > as.list(body(f)[[2]])
[[1]]
`<-`

[[2]]
g

[[3]]
function() {
 print("this is g")
}

Continue drilling down:

 > as.list(body(f)[[c(2,3)]])
[[1]]
`function`

[[2]]
NULL

[[3]]
{
 print("this is g")
}

[[4]]
function() {
  print("this is g")
}

 > as.list(body(f)[[c(2,3, 3)]])
[[1]]
`{`

[[2]]
print("this is g")

So now we know the print statement is at location c(2,3,3,2).  Set a
browser call there:

 > trace(f, at=list(c(2,3,3,2)), tracer = quote(browser()))
[1] "f"
 > body(f)
{
 g <- function() {
 {
 .doTrace(browser(), "step 2,3,3,2")
 print("this is g")
 }
 }
 print("this is f")
 g()
}

Note that the "at" argument needs to be a list to drill down; if you
just said at=c(2,3,3,2) it would set breakpoints at step 2 and 3.

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] Debugging functions defined (locally) inside another functions

2024-04-12 Thread Iago Giné Vázquez
Thank you Ivan, your example solves my issue this time through

debug(environment(Adder$add)$add)


Just for the future, you say

Moreover, `g` doesn't exist at all until f() is evaluated and reaches
this point. If `f` was a function, it would be possible to trace() it,
inserting a call to debug(g) after it's created.

How should I call trace() if f was a function?


Best regards,
Iago


De: Ivan Krylov 
Enviat el: divendres, 12 d��abril de 2024 14:38
Per a: Iago Gin�� V��zquez 
A/c: r-help@r-project.org 
Tema: Re: [R] Debugging functions defined (locally) inside another functions

�� Fri, 12 Apr 2024 12:15:07 +
Iago Gin�� V��zquez  ��ڧ�֧�:

> f <- function(whatever){
>...
>g <- function(whatever2){
>  ...
>}
>...
> }
>
> If I wanted to debug some thing directly inside f I would do
> debug(f). But this does not go inside g code. On the other hand,
> debug(g) does not work as g is not a defined function in the
> namespace of the package.

Moreover, `g` doesn't exist at all until f() is evaluated and reaches
this point. If `f` was a function, it would be possible to trace() it,
inserting a call to debug(g) after it's created.

> f <- ggplot2::ggproto(...)
>
> So debug(f) produces
> Error in debug(f) : argument must be a function

Can you show more information about the call that produces `f`? Where
does `g` come into play? Following ?ggplot2::ggproto, I can trigger the
browser if I reach into the environment of the publicly available
method:

Adder <- ggproto(...) # from the example
debug(environment(Adder$add)$add)
Adder$add(1234)
# debugging in: add(..., self = self)
# debug �ߧ� #3: {
# self$x <- self$x + n
# self$x
# }

--
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] Debugging functions defined (locally) inside another functions

2024-04-12 Thread Iago Giné Vázquez
To be precise, in the case I am looking this time f is not a function, but

f <- ggplot2::ggproto(...)

So debug(f) produces
Error in debug(f) : argument must be a function

Iago

De: R-help  de part de Iago Gin� V�zquez 

Enviat el: divendres, 12 d�abril de 2024 14:15
Per a: r-help@r-project.org 
Tema: [R] Debugging functions defined (locally) inside another functions

Hi all, I am trying to debug an error of a function g defined and used inside 
another function f of a package.
So I have

f <- function(whatever){
   ...
   g <- function(whatever2){
 ...
   }
   ...
}

If I wanted to debug some thing directly inside f I would do debug(f). But this 
does not go inside g code. On the other hand, debug(g) does not work as g is 
not a defined function in the namespace of the package.

Is there some way to debug errors inside g?

Thank you in advance.

All the best,
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.

[[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] Debugging functions defined (locally) inside another functions

2024-04-12 Thread Iago Giné Vázquez
Hi all, I am trying to debug an error of a function g defined and used inside 
another function f of a package.
So I have

f <- function(whatever){
   ...
   g <- function(whatever2){
 ...
   }
   ...
}

If I wanted to debug some thing directly inside f I would do debug(f). But this 
does not go inside g code. On the other hand, debug(g) does not work as g is 
not a defined function in the namespace of the package.

Is there some way to debug errors inside g?

Thank you in advance.

All the best,
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.


[ESS] Where does ESS saves ESSR environment information

2024-03-20 Thread Iago Giné Vázquez via ESS-help
Hi all,

I have included a line such as the following in my .emacs file:
(add-hook 'ess-r-post-run-hook (lambda () (ess-load-file "~/startR.r")))

I have restarted Emacs, tried to start R and get an error due to that R did not 
find the file.  I realized that I put ~ thinking in home path for Emacs, not 
home path for R, so I updated the path address to the correct one in my .emacs 
file:
(add-hook 'ess-r-post-run-hook (lambda () (ess-load-file 
"C:/Users/.../startR.r")))

Again, restarted Emacs, tried starting R..., but I got the same error, which 
through a traceback I get

 base::as.environment("ESSR")$.ess.source("~/startR.r", visibly = FALSE,
   output = TRUE)

So, at some point the address "~/startR.r" was saved, but I cannot find it. How 
may I remove it and update the ESS configuration?

Thank you for your help.

Best regards,
Iago

[[alternative HTML version deleted]]

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Iago Giné Vázquez
Hi Iris,

Thank you. Further, very nice solution.

Best,

Iago

On 01/03/2024 12:49, Iris Simmons wrote:
> Hi Iago,
>
>
> This is not a bug. It is expected. Patterns may not overlap. However, there
> is a way to get the result you want using perl:
>
> ```R
> gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
> ```
>
> The specific change I made is called a positive lookahead, you can read
> more about it here:
>
> https://www.regular-expressions.info/lookaround.html
>
> It's a way to check for a piece of text without consuming it in the match.
>
> Also, since you don't care about character case, it might be more legible
> to add ignore.case = TRUE and remove the upper case characters:
>
> ```R
> gsub("([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE, ignore.case =
> TRUE)
>
> ## or
>
> gsub("(?i)([aeiou])(?=[aeiou])", "\\1_", "aerioue", perl = TRUE)
> ```
>
> I hope this helps!
>
>
> On Fri, Mar 1, 2024, 06:37 Iago Giné Vázquez  wrote:
>
>> Hi all,
>>
>> I tested next command:
>>
>> gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")
>>
>> with the following output:
>>
>> [1] "a_eri_ou_e"
>>
>> So, there are two consecutive vowels where an underscore is not added.
>>
>> May it be a bug? Is it expected (bug or not)? Is there any chance to get
>> what I want (an underscore between each pair of consecutive vowels)?
>>
>>
>> Thank you!
>>
>> 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.
>>
[[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] gsub issue with consecutive pattern finds

2024-03-01 Thread Iago Giné Vázquez
Hi all,

I tested next command:

gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")

with the following output:

[1] "a_eri_ou_e"

So, there are two consecutive vowels where an underscore is not added.

May it be a bug? Is it expected (bug or not)? Is there any chance to get 
what I want (an underscore between each pair of consecutive vowels)?


Thank you!

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.


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

2024-02-12 Thread Iago Giné Vázquez
Thanks to both, Duncan and Thomas.

Best,
Iago


De: Tomas Kalibera 
Enviat el: dilluns, 12 de febrer de 2024 11:18
Per a: Iago Giné Vázquez ; CALUM POLWART 
; Duncan Murdoch 
A/c: 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

On 2/9/24 21:39, Iago Giné Vázquez wrote:
> Duncan, do you think it's worth to comment this in R-devel list?

Duncan filed a bug report via R bugzilla (thanks).

There is no way to disable this functionality and it has existed for
very long time, I tested that at least in R 3.0. Optionally ending the
session was I believe intentional with Ctrl+D, when the input is empty,
and it is also how Unix terminals work. But ending the session with DEL
was probably an implementation compromise and I've changed that in
R-devel. Thanks for the report.

More implementation details in the bugzilla report:
https://bugs.r-project.org/show_bug.cgi?id=18666

Best
Tomas

> 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<mailto: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] 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<mailto: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 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.


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


[R] Why Rprofile.site is not built with manual installation of R devel in linux?

2023-11-09 Thread Iago Giné Vázquez
Hi all,

I downloaded R-devel as explicited in 
https://developer.r-project.org/SVNtips.html
Then, I tried to install it through instructions in 
https://cran.r-project.org/doc/manuals/r-devel/R-admin.html#Installation
(taking into account also 
https://stat.ethz.ch/pipermail/r-devel/2016-May/072777.html)
So:
export REPOS=https://svn.r-project.org/R
export RTOP=~ #adjust as necessary
cd $RTOP
svn co $REPOS/trunk r-devel/R
cd r-devel/R
tools/rsync-recommended
mkdir ../build-R
 cd ../build-R
 ../R/configure --prefix=/where/you/want/R/to/go
 make
 make check
make install
make install-tests
cd tests
## followed by one of
../bin/R CMD make check
../bin/R CMD make check-devel

And here I get the following error
checking package 'base'
Error in file(filename, "r", encoding = encoding) :
  cannot open the connection
Calls: source -> file
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file '.../etc/Rprofile.site': No such file or directory
Execution halted

where the dots ... specify the path to the build-R folder where R-devel was 
built. And I check the etc folder and indeed there is no the Rprofile.site
-rw-r--r-- 1 iago iago  209 Nov  9 08:27 javaconf
-rw-r--r-- 1 iago iago  770 Nov  9 08:35 ldpaths
-rw-r--r-- 1 iago iago 6672 Nov  9 08:35 Makeconf
-rw-r--r-- 1 iago iago 3336 Nov  9 08:27 Makefile
-rw-r--r-- 1 iago iago 1853 Nov  9 08:27 Renviron
-rw-r--r-- 1 iago iago 1173 Nov  9 08:32 repositories

I note that make install installed R in the path I specified in  ../R/configure 
--prefix=/where/you/want/R/to/go
however
1. make install-tests installed the tests folder in build-R .
2.  In the installed R in /where/you/want/R/to/go, there is no even etc 
folder, there are only the folders bin, lib and share.

Am I  skipping some step? I am on Debain 12.

Thank you!


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.


Re: [R] aggregate formula - differing results

2023-09-04 Thread Iago Giné Vázquez
It seems that the issue are the missings. If in  #1 you use the dataset 
na.omit(my_data) instead of my_data, you get the same output that in #2 and in 
#4, where all observations with missing data are removed since you are 
including all the variables.


The second dataset has no issue since it has no missing data.

Iago

De: R-help  de part de Ivan Calandra 

Enviat el: dilluns, 4 de setembre de 2023 11:44
Per a: R-help 
Tema: [R] aggregate formula - differing results

Dear useRs,

I have just stumbled across a behavior in aggregate() that I cannot
explain. Any help would be appreciated!

Sample data:
my_data <- structure(list(ID = c("FLINT-1", "FLINT-10", "FLINT-100",
"FLINT-101", "FLINT-102", "HORN-10", "HORN-100", "HORN-102", "HORN-103",
"HORN-104"), EdgeLength = c(130.75, 168.77, 142.79, 130.1, 140.41,
121.37, 70.52, 122.3, 71.01, 104.5), SurfaceArea = c(1736.87, 1571.83,
1656.46, 1247.18, 1177.47, 1169.26, 444.61, 1791.48, 461.15, 1127.2),
Length = c(44.384, 29.831, 43.869, 48.011, 54.109, 41.742, 23.854,
32.075, 21.337, 35.459), Width = c(45.982, 67.303, 52.679, 26.42,
25.149, 33.427, 20.683, 62.783, 26.417, 35.297), PLATWIDTH = c(38.84,
NA, 15.33, 30.37, 11.44, 14.88, 13.86, NA, NA, 26.71), PLATTHICK =
c(8.67, NA, 7.99, 11.69, 3.3, 16.52, 4.58, NA, NA, 9.35), EPA = c(78,
NA, 78, 54, 72, 49, 56, NA, NA, 56), THICKNESS = c(10.97, NA, 9.36, 6.4,
5.89, 11.05, 4.9, NA, NA, 10.08), WEIGHT = c(34.3, NA, 25.5, 18.6, 14.9,
29.5, 4.5, NA, NA, 23), RAWMAT = c("FLINT", "FLINT", "FLINT", "FLINT",
"FLINT", "HORNFELS", "HORNFELS", "HORNFELS", "HORNFELS", "HORNFELS")),
row.names = c(1L, 2L, 3L, 4L, 5L, 111L, 112L, 113L, 114L, 115L), class =
"data.frame")

1) Simple aggregation with 2 variables:
aggregate(cbind(Length, Width) ~ RAWMAT, data = my_data, FUN = mean,
na.rm = TRUE)

2) Using the dot notation - different results:
aggregate(. ~ RAWMAT, data = my_data[-1], FUN = mean, na.rm = TRUE)

3) Using dplyr, I get the same results as #1:
group_by(my_data, RAWMAT) %>%
   summarise(across(c("Length", "Width"), ~ mean(.x, na.rm = TRUE)))

4) It gets weirder: using all columns in #1 give the same results as in
#2 but different from #1 and #3
aggregate(cbind(EdgeLength, SurfaceArea, Length, Width, PLATWIDTH,
PLATTHICK, EPA, THICKNESS, WEIGHT) ~ RAWMAT, data = my_data, FUN = mean,
na.rm = TRUE)

So it seems it is not only due to the notation (cbind() vs. dot). Is it
a bug? A peculiar thing in my dataset? I tend to think this could be due
to some variables (or their names) as all notations seem to agree when I
remove some variables (although I haven't found out which variable(s) is
(are) at fault), e.g.:

my_data2 <- structure(list(ID = c("FLINT-1", "FLINT-10", "FLINT-100",
"FLINT-101", "FLINT-102", "HORN-10", "HORN-100", "HORN-102", "HORN-103",
"HORN-104"), EdgeLength = c(130.75, 168.77, 142.79, 130.1, 140.41,
121.37, 70.52, 122.3, 71.01, 104.5), SurfaceArea = c(1736.87, 1571.83,
1656.46, 1247.18, 1177.47, 1169.26, 444.61, 1791.48, 461.15, 1127.2),
Length = c(44.384, 29.831, 43.869, 48.011, 54.109, 41.742, 23.854,
32.075, 21.337, 35.459), Width = c(45.982, 67.303, 52.679, 26.42,
25.149, 33.427, 20.683, 62.783, 26.417, 35.297), RAWMAT = c("FLINT",
"FLINT", "FLINT", "FLINT", "FLINT", "HORNFELS", "HORNFELS", "HORNFELS",
"HORNFELS", "HORNFELS")), row.names = c(1L, 2L, 3L, 4L, 5L, 111L, 112L,
113L, 114L, 115L), class = "data.frame")

aggregate(cbind(EdgeLength, SurfaceArea, Length, Width) ~ RAWMAT, data =
my_data2, FUN = mean, na.rm = TRUE)

aggregate(. ~ RAWMAT, data = my_data2[-1], FUN = mean, na.rm = TRUE)

group_by(my_data2, RAWMAT) %>%
   summarise(across(where(is.numeric), ~ mean(.x, na.rm = TRUE)))


Thank you in advance for any hint.
Best wishes,
Ivan




*LEIBNIZ-ZENTRUM*
*F�R ARCH�OLOGIE*

*Dr. Ivan CALANDRA*
**Head of IMPALA (IMaging Platform At LeizA)

*MONREPOS* Archaeological Research Centre, Schloss Monrepos
56567 Neuwied, Germany

T: +49 2631 9772 243
T: +49 6131 8885 543
ivan.calan...@leiza.de

leiza.de 

ORCID 
ResearchGate


LEIZA is a foundation under public law of the State of
Rhineland-Palatinate and the City of Mainz. Its headquarters are in
Mainz. Supervision is carried out by the Ministry of Science and Health
of the State of Rhineland-Palatinate. LEIZA is a research museum of the
Leibniz Association.
__
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 

Re: [R] Help/documentation on Rgui

2023-07-03 Thread Iago Giné Vázquez
Thank you Petr, great!

Best,
Iago


De: PIKAL Petr
Enviat: Dilluns, 3-juliol 3e000 2023 9:42
Per a: Iago Gin� V�zquez; r-help@r-project.org
Assumpte: RE: Help/documentation on Rgui

Hi

I am not sure about opening Rgui in terminal but for customising Rgui
appearance you can modify Rconsole and Rprofile or Rprofile.site which you
should find in etc folder of your R installation.

https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rconsole.html
https://rdrr.io/r/utils/Rconsole.html
and "Initialization at Start of an R Session" in R help
?Rprofile

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Iago Gin�
> V�zquez
> Sent: Monday, July 3, 2023 8:36 AM
> To: r-help@r-project.org
> Subject: [R] Help/documentation on Rgui
>
> Hi all,
>
> Where can I find a detailed document(ation) on the use of Rgui.exe. The
most
> detailed I found is https://cran.r-project.org/doc/manuals/r-release/R-
> ints.html#GUI-consoles, where there is almost nothing.
>
> Actually I want to know how to open Rgui.exe (let's say, from a terminal
> [mainly in Windows], even better, through the ViM plugin NVim-R) with a
set
> of specific preferences, like a dark background or specific text colour
and size,
> which I see I can modify once it is open.
>
> Thank you for your help.
>
> 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.

[[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/documentation on Rgui

2023-07-03 Thread Iago Giné Vázquez
Hi all,

Where can I find a detailed document(ation) on the use of Rgui.exe. The most 
detailed I found is 
https://cran.r-project.org/doc/manuals/r-release/R-ints.html#GUI-consoles, 
where there is almost nothing.

Actually I want to know how to open Rgui.exe (let's say, from a terminal 
[mainly in Windows], even better, through the ViM plugin NVim-R) with a set of 
specific preferences, like a dark background or specific text colour and size, 
which I see I can modify once it is open.

Thank you for your help.

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.


Re: [R] Matrix scalar operation that saves memory?

2023-04-12 Thread Iago Giné Vázquez
You may take a look at the bigmemory package or other which deal with large 
memory data in 
https://cran.r-project.org/web/views/HighPerformanceComputing.html#large-memory-and-out-of-memory-data
Some extra explanation is in https://stackoverflow.com/a/11127229/997979

Iago


De: R-help  de part de Eric Berger 

Enviat el: dimecres, 12 d’abril de 2023 8:38
Per a: Bert Gunter 
A/c: R-help 
Tema: Re: [R] Matrix scalar operation that saves memory?

One possibility might be to use Rcpp.
An R matrix is stored in contiguous memory, which can be considered as a
vector.
Define a C++ function which operates on a vector in place, as in the
following:

library(Rcpp)
cppFunction(
  'void subtractConst(NumericVector x, double c) {
  for ( int i = 0; i < x.size(); ++i)
x[i] = x[i] - c;
}')

Try this function out on a matrix. Here we define a 5x2 matrix

m <- matrix(150.5 + 1:10, nrow=5)
print(m)

  [,1]  [,2]
[1,] 151.5 156.5
[2,] 152.5 157.5
[3,] 153.5 158.5
[4,] 154.5 159.5
[5,] 155.5 160.5

Now call the C++ function

subtractConst(m,100.0)
print(m)

[,1] [,2]
[1,] 51.5 56.5
[2,] 52.5 57.5
[3,] 53.5 58.5
[4,] 54.5 59.5
[5,] 55.5 60.5

HTH,
Eric


On Wed, Apr 12, 2023 at 7:34 AM Bert Gunter  wrote:

> I doubt that R's basic matrix capabilities can handle this, but have a look
> at the Matrix package, especially if your matrix is some special form.
>
> Bert
>
> On Tue, Apr 11, 2023, 19:21 Shunran Zhang <
> szh...@ngs.gen-info.osaka-u.ac.jp>
> wrote:
>
> > Hi all,
> >
> > I am currently working with a quite large matrix that takes 300G of
> > memory. My computer only has 512G of memory. I would need to do a few
> > arithmetic on it with a scalar value. My current code looks like this:
> >
> > mat <- 100 - mat
> >
> > However such code quickly uses up all of the remaining memory and got
> > the R script killed by OOM killer.
> >
> > Are there any more memory-efficient way of doing such operation?
> >
> > Thanks,
> >
> > S. Zhang
> >
> > [[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.

[[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] Importing data with value labels into R

2022-11-14 Thread IAGO GINÉ VÁZQUEZ
Hello Maryam,

The haven function for reading Stata files is read_dta (not read.dta!!!). May 
this be your issue?

Iago


De: R-help  de part de Maryam Iraniparast 

Enviat el: dilluns, 14 de novembre de 2022 19:07
Per a: r-help@r-project.org 
Tema: [R] Importing data with value labels into R

Hello!

I want to read SPSS data into R and I want to carry the value labels with my 
dataset.
Based on my research, only Stata file can transfer the value labels to R (It is 
easy to save SPSS data with Stata format).
The last time I did that successfully, I was using R4.2.1 and the following 
code. But it does not work anymore.


install.packages("tidyverse")

install.packages("haven")
library(tidyverse)

library(haven)

df=file.choose() *Note: Select the STATA file from the folder where it is saved.

dataset=read.dta(df)

I appreciate any thoughts or suggestion.

Thanks,
Mary

[[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] Rare behaviour for nlme::reStruct example and question about ?lmeObject

2022-11-14 Thread IAGO GINÉ VÁZQUEZ
Dear developers,

When I run the example code in the help of reStruct, I get


> library(nlme)
> rs1 <- reStruct(list(Dog = ~day, Side = ~1), data = Pixel)
> rs1
Uninitialized random effects structure
> str(rs1)
List of 2
 $ Side:Error in pdMatrix.pdSymm(x) :
  cannot extract matrix from an uninitialized object


Is it expected?

In addition to that I would like to ask if shouldn't be `terms` documented in 
`?lmeObject`.


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


[R] Is it possible to set a default working directory for all R consoles?

2022-06-17 Thread IAGO GINÉ VÁZQUEZ
Hi all,

Is there some way to set a default working directory each time R.exe is opened? 
I ask this because Always that I open R 4.2.o in Windows 10 I get the next 
warning messages

Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="\\172.19.2.44\profiles\profiles\me\Documents": Access is denied
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="\\172.19.2.44\profiles\profiles\me\Documents": Access is denied
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="\\172.19.2.44\profiles\profiles\me\Documents": Access is denied
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="\\172.19.2.44\profiles\profiles\me\Documents": Access is denied

Even from cmd.exe in a  C: location

C:\Users\me>R
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :   


path[1]="\\172.19.2.44\profiles\profiles\me\Documents": Access is denied
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
 path[1]="\\172.19.2.44\profiles\profiles\me\Documents": Access is denied
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
 path[1]="\\172.19.2.44\profiles\profiles\me\Documents": Access is denied
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
 path[1]="\\172.19.2.44\profiles\profiles\me\Documents": Access is denied

Reading 
https://cran.r-project.org/bin/windows/base/rw-FAQ.html#What-are-HOME-and-working-directories_003f,
 first I cannot apply the suggested solution (I cannot see such "shortcut�s 
properties"), and second, I am not interested just in Rgui, or even RStudio, 
but other terminals running R (like VSCode-radian or SublimeText-Terminus)

Thanks in advance.

Best wishes,

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.