Re: [R] on parallel processing...

2022-11-04 Thread akshay kulkarni
dear Jeff,
 Yeah, you are right.just went through the documentation 
and found out that clusterApplyLB() from parallel package does the job... 
Thanks again

THanking you,
Yours sincerely
AKSHAY M KULKARNI

From: Jeff Newmiller 
Sent: Saturday, November 5, 2022 1:24 AM
To: r-help@r-project.org ; akshay kulkarni 
; R help Mailing list 
Subject: Re: [R] on parallel processing...

You don't specify processors. Just invoke the worker functions with the 
relevant packages and they will be allocated according to how you defined the 
cluster object... typically automatically. Processors are usually specified (to 
the cluster object) according to IP address. Cores within the processors are 
allocated according to how many processes are created.

Maybe you should read some documentation (vignettes), and/or look into 
R-sig-hpc (https://stat.ethz.ch/mailman/listinfo/r-sig-hpc). This is probably 
not the best place to pursue this.

On November 4, 2022 12:35:11 PM PDT, akshay kulkarni  
wrote:
>Dear members,
>  I want to send the same function with different 
> arguments to different processors. This solution was provided in Stack 
> Overflow 
> https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using
>[https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-i...@2.png?v=73d79a89bded]
>Send function calls with different arguments to different processors in R 
>using parallel package - Stack 
>Overflow
>Teams. Q&A for work. Connect and share knowledge within a single location that 
>is structured and easy to search. Learn more about Teams
>stackoverflow.com
>I have a 48 core processor. My question is, how do i loop through the cores 
>without explicitly mentioning the core numbers?
>Will this work?
>
>
>
>library(parallel)
>cl <- makeCluster(4)
>clusterExport(cl, "foo")
>cores <- seq_along(cl)
>r <- clusterApply(cl[cores], cores, function(core) {
>
>  for(i in 1:48) {
>
>  if (core ==i) {
>
>foo( x[i] )
>
>}
>}
>})
>
>Many thanks in advance..
>
>Thanking you,
>Your sincerely,
>AKSHAY M KULKARNI
>
>   [[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.

[[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] on parallel processing...

2022-11-04 Thread Jeff Newmiller
You don't specify processors. Just invoke the worker functions with the 
relevant packages and they will be allocated according to how you defined the 
cluster object... typically automatically. Processors are usually specified (to 
the cluster object) according to IP address. Cores within the processors are 
allocated according to how many processes are created.

Maybe you should read some documentation (vignettes), and/or look into 
R-sig-hpc (https://stat.ethz.ch/mailman/listinfo/r-sig-hpc). This is probably 
not the best place to pursue this.

On November 4, 2022 12:35:11 PM PDT, akshay kulkarni  
wrote:
>Dear members,
>  I want to send the same function with different 
> arguments to different processors. This solution was provided in Stack 
> Overflow 
> https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using
>[https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-i...@2.png?v=73d79a89bded]
>Send function calls with different arguments to different processors in R 
>using parallel package - Stack 
>Overflow
>Teams. Q&A for work. Connect and share knowledge within a single location that 
>is structured and easy to search. Learn more about Teams
>stackoverflow.com
>I have a 48 core processor. My question is, how do i loop through the cores 
>without explicitly mentioning the core numbers?
>Will this work?
>
>
>
>library(parallel)
>cl <- makeCluster(4)
>clusterExport(cl, "foo")
>cores <- seq_along(cl)
>r <- clusterApply(cl[cores], cores, function(core) {
>
>  for(i in 1:48) {
>
>  if (core ==i) {
>
>foo( x[i] )
>
>}
>}
>})
>
>Many thanks in advance..
>
>Thanking you,
>Your sincerely,
>AKSHAY M KULKARNI
>
>   [[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.


[R] on parallel processing...

2022-11-04 Thread akshay kulkarni
Dear members,
  I want to send the same function with different 
arguments to different processors. This solution was provided in Stack Overflow 
https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using
[https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-i...@2.png?v=73d79a89bded]
Send function calls with different arguments to different processors in R using 
parallel package - Stack 
Overflow
Teams. Q&A for work. Connect and share knowledge within a single location that 
is structured and easy to search. Learn more about Teams
stackoverflow.com
I have a 48 core processor. My question is, how do i loop through the cores 
without explicitly mentioning the core numbers?
Will this work?



library(parallel)
cl <- makeCluster(4)
clusterExport(cl, "foo")
cores <- seq_along(cl)
r <- clusterApply(cl[cores], cores, function(core) {

  for(i in 1:48) {

  if (core ==i) {

foo( x[i] )

}
}
})

Many thanks in advance..

Thanking you,
Your sincerely,
AKSHAY M KULKARNI

[[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] data frame returned from sapply but vector expected

2022-11-04 Thread PIKAL Petr
Hallo Ivan

Thanks, yes it seems to be working. I thought also removing NULL by

mylist2[sapply(mylist2, is.null)] <- NULL

but your approach is probably better (in any case simpler)

Thanks again.

Petr

> -Original Message-
> From: Ivan Krylov 
> Sent: Friday, November 4, 2022 1:37 PM
> To: PIKAL Petr 
> Cc: R-help Mailing List 
> Subject: Re: [R] data frame returned from sapply but vector expected
> 
> On Fri, 4 Nov 2022 15:30:27 +0300
> Ivan Krylov  wrote:
> 
> > sapply(mylist2, `[[`, 'b')
> 
> Wait, that would simplify the return value into a matrix when there are no
> NULLs. But lapply(mylist2, `[[`, 'b') should work in both cases, which in
my
> opinion goes to show the dangers of using simplifying functions in
to-be-library
> code.
> 
> Sorry for the double-post!
> 
> --
> 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] data frame returned from sapply but vector expected

2022-11-04 Thread Ivan Krylov
On Fri, 4 Nov 2022 15:30:27 +0300
Ivan Krylov  wrote:

> sapply(mylist2, `[[`, 'b')

Wait, that would simplify the return value into a matrix when there are
no NULLs. But lapply(mylist2, `[[`, 'b') should work in both cases,
which in my opinion goes to show the dangers of using simplifying
functions in to-be-library code.

Sorry for the double-post!

-- 
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] data frame returned from sapply but vector expected

2022-11-04 Thread Ivan Krylov
On Fri, 4 Nov 2022 12:19:09 +
PIKAL Petr  wrote:

> > str(sapply(mylist2, "[", "b"))  
> 
> List of 3
> 
> $ : NULL
> 
> $ :'data.frame':   5 obs. of  1 variable:
> 
>   ..$ b: num [1:5] 0.01733 0.46055 0.19421 0.11609 0.00789
> 
> $ :'data.frame':   5 obs. of  1 variable:
> 
>   ..$ b: num [1:5] 0.593 0.478 0.299 0.185 0.847

Is sapply(mylist2, `[[`, 'b') closer to what you'd like to see, i.e. a
list of vectors or NULLs?

-- 
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] data frame returned from sapply but vector expected

2022-11-04 Thread PIKAL Petr
Hallo all

 

I found a strange problem for coding if part of list is NULL. 

In this case, sapply result is ***list of data frames*** but if there is no
NULL leaf, the result is ***list of vectors***. 

I tried simplify option but it did not help me neither I found anything in
help page. 

 

The code is part of bigger project where I fill list by reading in data and
if it fails, the leaf is set to NULL. Then the the boxplot is created simply
by

boxplot(sapply(mylist2, "[", "b")) and the user is asked to select if values
should be rbinded or not.

 

Is it possible to perform some *apply without getting data frame as result
in case NULL leaf?

 

Here is an example (without boxplot)

 

df1 <- data.frame(a=rnorm(5), b=runif(5), c=rlnorm(5))

df2 <- data.frame(a=rnorm(5), b=runif(5), c=rlnorm(5))

mylist1 <- list(df1,df2, df3)

mylist2 <- list(NULL,df2, df3)

> str(sapply(mylist1, "[", "b"))

List of 3

$ b: num [1:5] 0.387 0.69 0.876 0.836 0.819

$ b: num [1:5] 0.01733 0.46055 0.19421 0.11609 0.00789

$ b: num [1:5] 0.593 0.478 0.299 0.185 0.847

> str(sapply(mylist2, "[", "b"))

List of 3

$ : NULL

$ :'data.frame':   5 obs. of  1 variable:

  ..$ b: num [1:5] 0.01733 0.46055 0.19421 0.11609 0.00789

$ :'data.frame':   5 obs. of  1 variable:

  ..$ b: num [1:5] 0.593 0.478 0.299 0.185 0.847

 

S pozdravem | Best Regards

RNDr. Petr PIKAL
Vedoucí Výzkumu a vývoje | Research Manager

PRECHEZA a.s.
nábř. Dr. Edvarda Beneše 1170/24 | 750 02 Přerov | Czech Republic
Tel: +420 581 252 256 | GSM: +420 724 008 364
  petr.pi...@precheza.cz |
 www.precheza.cz

Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
partnerů PRECHEZA a.s. jsou zveřejněny na:

https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about
processing and protection of business partner's personal data are available
on website:

https://www.precheza.cz/en/personal-data-protection-principles/

Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné
a podléhají tomuto právně závaznému prohlášení o vyloučení odpovědnosti:
 https://www.precheza.cz/01-dovetek/ |
This email and any documents attached to it may be confidential and are
subject to the legally binding disclaimer:

https://www.precheza.cz/en/01-disclaimer/

 

__
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] Associate a .R file with the RGui

2022-11-04 Thread PIKAL Petr
Hi 

another option is to use SendTo folder. This was easy to find in older
Windows versions. Now the easiest way is:

Press the Windows Key + R to trigger the Run window. At the Open field in
the window, type shell:SendTo and then click OK

And SendTo folder should open.

You can then add link to any application here so add RGui link

After that, rightclick on file .RData file and menu with option SendTo opens
with RGui one of the options.

I learned it before ages and it is quite usefull not only in this case.

Here is link to another explanation.

https://www.pcmag.com/how-to/how-to-customize-the-send-to-menu-in-windows

Cheers
Petr

> -Original Message-
> From: R-help  On Behalf Of Andrew Simmons
> Sent: Friday, November 4, 2022 10:09 AM
> To: Amarjit Chandhial 
> Cc: R-help Mailing List 
> Subject: Re: [R] Associate a .R file with the RGui
> 
> In an R session, run this:
> 
> writeLines(normalizePath(R.home("bin")))
> 
> Right click your .R file > Open with > Choose another app > Check the box
> "Always use this app to open .R files" > Look for another app on this PC
Paste
> the directory found above, then select "Rgui.exe"
> 
> On Fri, Nov 4, 2022, 04:49 Amarjit Chandhial via R-help < r-help@r-
> project.org> wrote:
> 
> >
> > Hi,
> >
> >
> > My OS is Windows 11 Pro 64-Bit, I have R 4.2.2 and RStudio installed.
> >
> > If I double-click on a .R file in File Explorer the OS gives me the
> > option of opening the .R in RStudio, or Look for an app in the
> > Microsoft Store, or More Apps. Similarly with a right-click.
> >
> > I would like to associate a .R file with the RGui, not RStudio, thus
> > when I double-click on a .R file in File Explorer the .R file opens in
> > the R Editor in RGui.
> >
> > On my PC R 4.2.2 is located in "C:/Program Files/R/R-4.2.2/etc"
> >
> > Please can someone provide step-by-step instructions on how to
> > associate?
> >
> >
> > thanks,
> > Amarjit
> >
> > [[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@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] Associate a .R file with the RGui

2022-11-04 Thread Andrew Simmons
In an R session, run this:

writeLines(normalizePath(R.home("bin")))

Right click your .R file > Open with > Choose another app > Check the box
"Always use this app to open .R files" > Look for another app on this PC
Paste the directory found above, then select "Rgui.exe"

On Fri, Nov 4, 2022, 04:49 Amarjit Chandhial via R-help <
r-help@r-project.org> wrote:

>
> Hi,
>
>
> My OS is Windows 11 Pro 64-Bit, I have R 4.2.2 and RStudio installed.
>
> If I double-click on a .R file in File Explorer the OS gives me the
> option of opening the .R in RStudio, or Look for an app in the Microsoft
> Store, or More Apps. Similarly with a right-click.
>
> I would like to associate a .R file with the RGui, not RStudio, thus
> when I double-click on a .R file in File Explorer the .R file opens in
> the R Editor in RGui.
>
> On my PC R 4.2.2 is located in "C:/Program Files/R/R-4.2.2/etc"
>
> Please can someone provide step-by-step instructions on how to
> associate?
>
>
> thanks,
> Amarjit
>
> [[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] Associate a .R file with the RGui

2022-11-04 Thread Amarjit Chandhial via R-help


Hi,


My OS is Windows 11 Pro 64-Bit, I have R 4.2.2 and RStudio installed.

If I double-click on a .R file in File Explorer the OS gives me the 
option of opening the .R in RStudio, or Look for an app in the Microsoft 
Store, or More Apps. Similarly with a right-click.

I would like to associate a .R file with the RGui, not RStudio, thus 
when I double-click on a .R file in File Explorer the .R file opens in 
the R Editor in RGui.

On my PC R 4.2.2 is located in "C:/Program Files/R/R-4.2.2/etc"

Please can someone provide step-by-step instructions on how to 
associate?


thanks,
Amarjit

[[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] R-package imputeTS / warning messages

2022-11-04 Thread Ivan Krylov
Dear Paulo Barata,

On Wed, 26 Oct 2022 11:27:54 -0300
Paulo Barata  wrote:

> In stats::StructTS(data, ...) :
>possible convergence problem: 'optim' gave code = 52 and message
> ‘ERROR: ABNORMAL_TERMINATION_IN_LNSRCH’
> 
> The function StructTS is called by the function na_kalman of the 
> imputeTS package.

Since you're not getting replies here, it might help to contact
maintainer('imputeTS').

I think that ABNORMAL_TERMINATION_IN_LNSRCH happens when the line
search part of the L-BFGS-B algorithm determines that the directional
derivative of the function being optimised along the direction of the
previous step turns out to be positive, meaning that the step direction
was bad in the first place. There may be many reasons for this to
happen.

It might also help to look at the optimisation process by passing the
optim.control = list(trace = 3) argument (available levels are 1 to 6,
with 6 being very verbose).

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