[R] subsetting lists....

2018-06-18 Thread akshay kulkarni
dear members,
I have list YH and index vector iuhV. I want to 
select iuhV[1] from YH[[1]], iuhv[2] from YH[[2]], iuhv[3] from 
YH[[3]]..iuhv[n] from YH[[n]]...

How to do this?
I searched SO and the internet but was bootless

Very many thanks for your time and effort.
Yours 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.


[R] Fw: subsetting lists....

2018-06-18 Thread akshay kulkarni
correctionI want the method without a for loop

From: akshay kulkarni 
Sent: Monday, June 18, 2018 4:25 PM
To: R help Mailing list
Subject: subsetting lists

dear members,
I have list YH and index vector iuhV. I want to 
select iuhV[1] from YH[[1]], iuhv[2] from YH[[2]], iuhv[3] from 
YH[[3]]..iuhv[n] from YH[[n]]...

How to do this?
I searched SO and the internet but was bootless

Very many thanks for your time and effort.
Yours 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.


[R] on execution time of a function...

2018-06-12 Thread akshay kulkarni
I ran  a function in R three days ago and the execution time was about 4 
minutes. I ran the same function yesterday and the execution time was more than 
6:50 minutes(I aborted the function after that time).

I read in the Internet that this is possible. I also came to know that software 
or hardware interrupts are the main reasons.

How do you know whether the delay was caused by interrupts? Which hardware or 
software triggered the interrupts? In general, how to know the exact cause of 
the delay in execution in R? Are there any packages for these analyses?

Very many thanks for your time and effort

yours 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] on execution time of a function...

2018-06-13 Thread akshay kulkarni
I do felt a little unsettled by your exhortions on the incongruity of posting 
this question on an OS-agnostic mailing list...I thought that there might be 
some issues on how R communicates with the OS...and also that some R packages 
might rectify the issue(in my experience, I have had a R package for every R 
issue that I had!)

Anyway, I ran the  same function again and it is executing within limits. Also, 
I would be using AWS EC2 servers to run my R functions(I am a day trader in 
india and input some 250 stocks to R functions daily), and I don't think that 
the issue would persist on Intel Xeon processors and dedicated VMs

Anyway,thanks for all your concerns tolerating my query on an OS-agnostic 
mailing list!

AKSHAY M KULKARNI

From: Loris Bennett 
Sent: Wednesday, June 13, 2018 1:37 PM
To: Jeff Newmiller
Cc: r-help@r-project.org; akshay kulkarni
Subject: Re: [R] on execution time of a function...

Hi Akshay,

In addition to all the things Jeff rightly points out, contention for IO
resources can be an issue.  So if another process was hogging the
bandwidth while your program was attempting to read or write to disk,
that could also have slowed things down.

HTH

Loris

Jeff Newmiller  writes:

> Wow, you can find almost any explanation on the Internets. That doesn't mean 
> you
> should believe all of them. R does not do anything likely to tweak
> interrupts... if that is your problem then you need to be on an
> operating-system/computer-model-specific forum rather than this OS-agnostic
> mailing list.
>
> It is far more likely that your overall memory usage conditions have changed
> since the last time you ran it... or that you didn't actually record all of 
> the
> things you did last time in your script. (Newbie R users often do things at 
> the
> console without putting them in their scripts.)
>
> I suggest that you run your script one statement at a time and see where your
> problem is. You might also want to make sure that other programs are not using
> up a lot of your memory (which could involve some OS-specific tools or just
> shutting down some other programs.)
>
> On June 12, 2018 7:36:40 PM HST, akshay kulkarni  
> wrote:
>>I ran  a function in R three days ago and the execution time was about
>>4 minutes. I ran the same function yesterday and the execution time was
>>more than 6:50 minutes(I aborted the function after that time).
>>
>>I read in the Internet that this is possible. I also came to know that
>>software or hardware interrupts are the main reasons.
>>
>>How do you know whether the delay was caused by interrupts? Which
>>hardware or software triggered the interrupts? In general, how to know
>>the exact cause of the delay in execution in R? Are there any packages
>>for these analyses?
>>
>>Very many thanks for your time and effort
>>
>>yours 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.
--
Dr. Loris Bennett (Mr.)
ZEDAT, Freie Universit�t Berlin Email loris.benn...@fu-berlin.de

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

2018-07-01 Thread akshay kulkarni
dear Members,
  Thanks for the reply..I do have another 
issue; I will be highly obliged if you answer it:
I tried "top" at the bash prompt, but it provides a way to measure CPU 
performance of the existing processes. I want to check the CPU usage of the 
execution of an R function. So I start R by this

$ R

and at the R prompt I type the function to be executed. But if I type "top" at 
the R prompt, it says object "top" not found.

So, should I change to bash prompt after running the R function? If yes, how do 
I do it? If not, how to use "top" inside the R prompt?

Again, I think this is an OS isuuebut I could'nt find any answer in the 
Internet. I am an independent researcher and I don't have personal access to 
experts...this mail list is the only vent I have...

Very many thanks for your time and effort...
Yours sincerely,
AKSHAY M KULKARNI


From: Jeff Newmiller 
Sent: Saturday, June 30, 2018 11:46 PM
To: r-help@r-project.org; akshay kulkarni; R help Mailing list
Subject: Re: [R] parallel processing in r...

Use "top" at the bash prompt.

Read about the "mc.cores" parameter to mclapply.

Make a simplified example version of your analysis and post your question in 
the context of that example [1][2][3]. You will learn about the issues you are 
dealing with in the process of trimming your problem, and will have code you 
can share that demonstrates the issue without exposing private information.

Running parallel does not necessarily improve performance because other factors 
like task switching overhead and Inter-process-communication (data sharing) can 
drag it down. Read about the real benefits and drawbacks of parallelism... 
there are many discussions out there out there... you might start with [4].


[1] 
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette)

[4] 
https://nceas.github.io/oss-lessons/parallel-computing-in-r/parallel-computing-in-r.html

On June 30, 2018 10:07:49 AM PDT, akshay kulkarni  wrote:
>dear members,
>I am using mclapply to parallelize my code. I am using Red Hat Linux in
>AWS.
>
>When I use mclapply, I see no speed increase. I doubt that the Linux OS
>is allowing fewer than the maximum number of cores to mclapply ( by
>default, mclapply takes all the available cores to it).
>
>How do you check if the number of workers is less than the output given
>by detectCores(), in Linux? Is there any R function for it?
>
>I do acknowledge that help on an OS is not suitable for this mailing
>list, but even Internet could'nt help me. Therefore this mail..
>
>very many thanks for your time  and effort...
>yours 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.


[R] parallel processing in r...

2018-06-30 Thread akshay kulkarni
dear members,
 I am using mclapply to parallelize my code. I am 
using Red Hat Linux in AWS.

When I use mclapply, I see no speed increase. I doubt that the Linux OS is 
allowing fewer than the maximum number of cores to mclapply ( by default, 
mclapply takes all the available cores to it).

How do you check if the number of workers is less than the output given by 
detectCores(), in Linux? Is there any R function for it?

I do acknowledge that help on an OS is not suitable for this mailing list, but 
even Internet could'nt help me. Therefore this mail..

very many thanks for your time  and effort...
yours 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.


[R] compiling functions....

2018-06-21 Thread akshay kulkarni
dear members,
I a Day Trader based in INDIA. I use R for my 
research. I have a function ygusa(snlq,snlcqn) which takes 208 stocks and 
returns 4 best stocks for the next day(snlq is the list of 208 stocks and 
snlcqn is their names). However, the execution time is around 2 hrs, making it 
hard for me.

I recently read in the internet that you can precompile the code in R to make 
it run faster. Also that you can enable JIT(just in time compilation) from your 
R session automatically. I came to know that R 3.4.x has JIT enabled in it by 
default. Is it true? Is it also true that even after enabling JIT in R 3.4.x, 
the first run of a function is not Byte compiled?

So when I start my R session, download the data, and run ygusa(snlq,snlcqn), it 
is not byte compiled and therefore it is very slow? Will including the 
following lines in ygusa solve my problem:
> require(compiler)
> enableJIT(3)

?

Also, instead of compiling the function ygusa every time I run it, can I 
compile it once and store it, and run that compiled file instead of 
ygusa(snlq,snlcqn)?

Can you point me to some online resources that can help on this issue?

very many thanks for your time and effort...
Yours 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.


[R] subsetting ls() as per class...

2018-07-27 Thread akshay kulkarni
dear memebers,
   I am using R in AWS linux instance for my 
research. I want to remove certain objects from the global environment  to 
reduce my EBS cost..for example, I want to remove all objects of class "xts", 
"zoo". Is there any way to automate this, instead of removing the objects one 
by one?

Basically, I want to subset  ls() according to class, and then remove that 
subset by using rm function.

I got to know about mget in SO, but that is not working in my case

Also, all the above objects end with ".NS".  I came to know that you can remove 
objects starting with a certain pattern; is there any way to remove objects 
ending in a certain pattern?

very many thanks for your time and effort...
yours 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] subsetting ls() as per class...

2018-07-28 Thread akshay kulkarni
dear peter,
 Its workingthanks a lot...

yours sincerely,
AKSHAY M KULKARNI

From: Peter Langfelder 
Sent: Saturday, July 28, 2018 11:41 AM
To: akshay...@hotmail.com
Cc: r-help
Subject: Re: [R] subsetting ls() as per class...

Looking at ?rm, my solution would be something like

rm(list = grep("\\.NS$", ls(), value = TRUE))

But test it since I have not tested it.

Peter


On Fri, Jul 27, 2018 at 10:58 PM akshay kulkarni  wrote:
>
> dear memebers,
>I am using R in AWS linux instance for my 
> research. I want to remove certain objects from the global environment  to 
> reduce my EBS cost..for example, I want to remove all objects of class "xts", 
> "zoo". Is there any way to automate this, instead of removing the objects one 
> by one?
>
> Basically, I want to subset  ls() according to class, and then remove that 
> subset by using rm function.
>
> I got to know about mget in SO, but that is not working in my case
>
> Also, all the above objects end with ".NS".  I came to know that you can 
> remove objects starting with a certain pattern; is there any way to remove 
> objects ending in a certain pattern?
>
> very many thanks for your time and effort...
> yours 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.

[[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] inconsistency in forecast package....

2018-08-02 Thread akshay kulkarni
dear members,
   I am using R to do my research for Day Trading in 
INDIA. I have a list of 206 stocks to work with.

I have extracted a parameter of a stock based on the OHLC data of the stock. It 
includes values both less than and greater than 1 ( It basically is a ratio). I 
am using forecast package to predict the value of the parameter for the next 
day.

However, the value of the parameter is greater than 1 for all stocks! Actually, 
according to statistics, half of the stocks should have value less than 1 and 
half greater than 1.

Is this because of  a one odd day or is there some techniques of properly 
handling the forecast package?

very many thanks for your time and effort...
yours 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.


[R] installing R in Amazon linux AMI

2018-08-07 Thread akshay kulkarni
dear members,
I am using R in AWS. I am currently using RHEL AMI 
in ec2 instance. I want to shift to Amazon LINUX AMI to lower costs.

How do you install R in Amazon lINUX AMI? I have searched the web, and , to my 
disappointment have not found any articles on how to install R in Amazon linux 
AMI, as is there for RED HAT AMI.

Any help?

Very many thanks for your time and effort...
yours 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.


[R] RHEl Vs UBUNTU for R

2018-09-02 Thread akshay kulkarni
dear members,
 I am using AWS LINUX ec2 instances for running my 
R code.

I am in  a conundrum whether to use RHEL or Ubuntu.

Does R run faster on Red Hat as compared to Ubuntu?

What other advantages does running R have on Red Hat over Ubuntu?

Very many thanks for your time and effort...
Yours 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] inconsistency in display of character vector....

2018-07-10 Thread akshay kulkarni
dear members,
 I've gone through debug(update.snlcqn)  
(update.snlcqn is the above function) and  I think the problem lies in 
read_excel returning a tibble...any suggestions on how to convert it to a 
regular data frame? Any other packages that read xls files as a regular data 
frame?

Very many thanks for your time and effort
Yours sincerely,
AKSHAY M KULKARNI


From: Eric Berger 
Sent: Monday, July 9, 2018 12:15 PM
To: PIKAL Petr
Cc: akshay kulkarni; R help Mailing list
Subject: Re: [R] inconsistency in display of character vector

>  If (identical(snlcqn, snlcqna)) snlcqn else snlcqna

??

Why not just always return snicqna ?


On Mon, Jul 9, 2018 at 9:43 AM, PIKAL Petr 
mailto:petr.pi...@precheza.cz>> wrote:
Hi

You definitely should not use HTML formated mail. This is plain text mailing 
list for reason.

If you experience space between "NSE/" and pasted second part, you should read 
paste help page which states

paste (..., sep = " ", collapse = NULL)

so it has space as separator.

You should use paste0 if you want to get rid of separating space or axplicitely 
state
paste (..., sep = "")

> lneq <- c()
> for (i in 1:10) lneq[i] <- letters[i]
> lneq
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j"
> snlcqna<-LETTERS[1:10]
> for (j in 1:10) snlcqna[j] <- paste("NSE/",lneq[j])
> snlcqna
 [1] "NSE/ a" "NSE/ b" "NSE/ c" "NSE/ d" "NSE/ e" "NSE/ f" "NSE/ g" "NSE/ h"
 [9] "NSE/ i" "NSE/ j"
> for (j in 1:10) snlcqna[j] <- paste0("NSE/",lneq[j])
> snlcqna
 [1] "NSE/a" "NSE/b" "NSE/c" "NSE/d" "NSE/e" "NSE/f" "NSE/g" "NSE/h" "NSE/i"
[10] "NSE/j"

Cheers
Petr

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/

> -Original Message-
> From: R-help 
> [mailto:r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org>] On 
> Behalf Of akshay
> kulkarni
> Sent: Sunday, July 8, 2018 2:38 PM
> To: R help Mailing list mailto:r-help@r-project.org>>
> Subject: [R] Fw: inconsistency in display of character vector
>
> dear members,
>  The mail is not showing the spaces between [192]
> "NSE/YESBANK" and  [193] "NSE/ZEEL" ...Actually there is a lot of empty spaces
[[elided Hotmail spam]]
>
> 
> From: R-help 
> mailto:r-help-boun...@r-project.org>> on behalf 
> of akshay kulkarni
> mailto:akshay...@hotmail.com>>
> Sent: Sunday, July 8, 2018 5:58 PM
> To: R help Mailing  list
> Subject: [R] inconsistency in display of character vector
>
> dear members,
> I have the following code to update the list of 
> stocks:
>
> function (snlcqn)
> {
>   lneq <- c()
>   URL <- "https://canmoney.in/Intraday%20scrip.xls;
>   file.string <- tempfile()
>
>   download.file(URL,file.string)
>
>   IDT <- read_excel(file.string)
>
>   leq <- IDT[,1]
>
>   for(i in 1:length(leq)){
>   lneq[i] <- substr(leq[i],1,(nchar(leq[i])-2))}
>
>   for(j in 1:length(lneq)){
>   snlcqna[j] <- paste("NSE/",lneq[j])}
>
>   if(identical(snlcqn,snlcqna) == "FALSE"){
>   return(snlcqna) }
>
>   else{
>   return(snlcqn)  }
>
> }
> snlcqn is the list of present stocks and snlcqna is the list of updated 
> stocks.
> The problem is the return object, instead of getting displayed in contiguous 
> list,
> is getting displayed with lots of spaces...( I am using R on a LINUX RHEL AWS
> i

[R] Fw: inconsistency in pbmclapply...

2018-10-16 Thread akshay kulkarni


dear members,
 however, "ts must have more than one observation" 
error is only found for the first entry of LYG1 ( LYG1[[20]], LYG1[[200]], 
LYG1[[1000]]..etc are all well defined!

From: R-help  on behalf of akshay kulkarni 

Sent: Tuesday, October 16, 2018 1:57 PM
To: R help Mailing  list
Subject: [R] inconsistency in pbmclapply...

dear members,
 I am using parallel processing with pbmclapply. 
below is the code. LYG1[[1]] got from pbmclapply is not the same as LYG1[[1]] 
got from direct application of auto.arima. what may be wrong?

  debug at #20: LYG1 <- pbmclapply(LYGH, FUN = auto.arima, 
mc.cores = detectCores())
Browse[2]>
  |=   |  68%, ETA 00:21
debug at #21: LYG2 <- pbmclapply(LYGH, FUN = ets, mc.cores = detectCores())
Browse[2]> LYG1[[1]]
[1] "Error in ts(x) : 'ts' object must have one or more observations\n"
attr(,"class")
[1] "try-error"
attr(,"condition")

Warning message:
In pbmclapply(LYGH, FUN = auto.arima, mc.cores = detectCores()) :
  scheduled cores encountered errors in user code
Browse[2]> LYGH[[1]]
 [1] 0.7 0.4 0.3 0.15000 0.25000 0.95000
 [7] 1.0 0.3 0.65000 0.2 0.6 0.1
[13] 0.001412873 1.55000 0.15000 0.3 0.45000 0.35000
[19] 0.15000 2.35000 0.25000 0.1 3.7 3.95000
[25] 3.05000 0.9 0.4 1.05000 1.1 1.95000
[31] 2.0 0.65000 0.7 0.25000 5.25000 0.8
[37] 0.001412873
Browse[2]> auto.arima(LYGH[[1]])
Series: LYGH[[1]]
ARIMA(0,1,0)

sigma^2 estimated as 2.303:  log likelihood=-66.1
AIC=134.2   AICc=134.31   BIC=135.78

very many thanks for your time and effort.
yours 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.

[[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] inconsistency in pbmclapply/mclapply....

2018-10-18 Thread akshay kulkarni
dear members,
  I am using pbmclapply in pbmcapply package, to do 
parallel processing in my R function. Below is the line that is malfunctioning:

> LYG1b <- pbmclapply(lygh171, FUN = auto.arima, mc.cores = detectCores())

auto.arima is a function from the "forecast" package. The length of lygh171 is 
2435.

NOW:

> LYG1b[[1]]
[1] "Error in ts(x) : 'ts' object must have one or more observations\n"
attr(,"class")
[1] "try-error"
attr(,"condition")


AND:

> auto.arima(lygh171[[1]])
Series: lygh171[[1]]
ARIMA(0,1,0)

sigma^2 estimated as 2.303:  log likelihood=-66.1
AIC=134.2   AICc=134.31   BIC=135.78

AND:

> LYG1ba <- pbmclapply(lygh171[1:9], FUN = auto.arima, mc.cores = detectCores())

> LYG1ba[[1]]
Series: X[[i]]
ARIMA(0,1,0)

sigma^2 estimated as 2.303:  log likelihood=-66.1
AIC=134.2   AICc=134.31   BIC=135.78

Why is LYG1b[[1]] not welldefined  but  LYG1ba[[1]] is eventhough the 
function(auto.arima) is the same in both cases? And why is the direct 
application of auto.arima on lygh171[[1]] successful, but not when auto.arima 
is iterated through pbmclapply on lygh171?
 here is the output of dput:
lygh171[1:9] <-  list(c(0.699, 0.399, 0.301,
0.149, 0.25, 0.949, 1, 0.301,
0.65, 0.199, 0.6, 0.0996, 0.00141287284144427,
1.55, 0.15, 0.301, 0.449, 0.351,
0.149, 2.35, 0.25, 0.101, 3.7, 3.95,
3.05, 0.899, 0.399, 1.05, 1.1, 1.95,
2, 0.649, 0.699, 0.25, 5.25, 0.801,
0.00141287284144427), c(0, 0.199, 1.3, 2, 1.9, 1.6
), c(0.699, 0.399, 0.301,
0.149, 0.25, 1, 0.301, 0.65, 0.199,
0.0996, 0.301, 0.15, 0.25, 0.15, 0.301,
0.449, 0.801, 0.25, 0.351,
0.149, 2.35, 0.25, 0.101, 3.7, 3.95,
3.05, 0.899, 0.399, 1.05, 1.1, 1.95,
2, 0.649, 0.699, 0.25, 5.25, 0.801,
0.699, 0.449, 0.801, 0.801
), c(0.0507, 0.25, 0.101, 1.25, 1, 0.65,
0.65, 0.9, 0.4, 0.0507, 0.0507, 0.451,
1.2, 0.5, 0.15, 0.35, 0.0507, 0.301,
1.1, 0.0996, 0.951, 0.25, 0.75, 0.199,
0.5, 0.5, 0.25, 2, 0.699, 2.75, 1.65, 0.149,
0.203, 2, 1.25, 4.3, 0.601, 0.75, 0.547,
0.5, 3.6, 4.1, 0.899, 0.101, 1, 0.25,
0.101, 0.399, 0.149, 1.7,
0.949, 0.152), c(0.0507,
0.25, 0.15, 0.0996, 0.5, 0.15, 0.601,
1, 0.149, 0.601, 3.05, 0.101,
0.199, 1.3), c(0.5, 0.5, 0.0996, 1.2,
3.75, 1.9), c(0.000770416024653313, 0.551, 1.2, 3
), 1, 0.25)

very many thanks for your time and effort
yours 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.


[R] large number of scrollable histograms....

2019-01-22 Thread akshay kulkarni
dear members,
I am a day trader based in INDIA. I use R for my 
research.

I have about 200 vectors whose histograms I need to inspect. I have to compare 
them simultaneously.

I know methods whereby you can plot multiple histograms on one screen. However, 
you can clearly view only 4 to 5  histograms in one screen.

Is there a way to construct a long list of all the 100 histograms that can be 
scrollable (like you scroll up or down the R console) both downwards and 
upwards? Any package to that effect?

I would be highly grateful, also, if you can offer any suggestions or "out of 
the box" ideas to simultaneously compare all the 100 histograms.

very many thanks for your help and support..
yours 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] Fw: inconsistency in nls output....

2019-03-06 Thread akshay kulkarni
dear JN,
Thanks for the reply. I will consider using the nlsr package. 
But for now I make did with reducing the exponent. It is working for me.

very many thanks for your time and effort
yours sincerely,
AKSHAY M KULKARNI


From: J C Nash 
Sent: Wednesday, March 6, 2019 10:40 PM
To: akshay kulkarni; R help Mailing list
Subject: Re: [R] Fw: inconsistency in nls output

nls() is a Model T Ford trying to drive on the Interstate. The code
is quite old and uses approximations that work well when the user
provides a reasonable problem, but in cases where there are mixed large
and small numbers like yours could get into trouble.

Duncan Murdoch and I prepared the nlsr package to address some
of the weaknesses (in particular we try to use analytic derivatives).

The output of nlsr also gives the singular values of the Jacobian, though
I suspect many R users will have to do some work to interpret those.

You haven't provided a reproducible example. That's almost always the
way to get definitive answers. Otherwise we're guessing as to the issue.

JN

On 2019-03-06 7:48 a.m., akshay kulkarni wrote:
> dear members,
> with reference to the attached message:
>
> I think I have found out the problem:
> YLf13 has the structure:
> YLf13 <- a*exp(-1000*LM1); LM1 is another vector.
>
> most of the YLf13 vector is getting populated with zeros, I think, because of 
> the very low value of exp(-1000*LM1). Is there any method in R wherein I can 
> work with these very low values?
>
> Or is the problem not related to the structure of YLf13?
>
> very many thanks for your time and effort...
> yours sincerely,
> AKSHAY M KULKARNI
>
>
> ________
> From: R-help  on behalf of akshay kulkarni 
> 
> Sent: Wednesday, March 6, 2019 6:02 PM
> To: R help Mailing  list
> Subject: [R] inconsistency in nls output
>
> dear members,
>  I have the following nls output:
>
>  Formula: YLf13 ~ (d + e * ((XL)^(1/3)) + f * log(LM3 + 18.81))
>
> Parameters:
> Estimate Std. Error t value Pr(>|t|)
> d  5.892e-09  8.644e-10   6.817 2.06e-11 ***
> e -6.585e-09  5.518e-10 -11.934  < 2e-16 ***
> f  1.850e-10  2.295e-10   0.806 0.42
> ---
> Signif. codes:  0 �***� 0.001 �**� 0.01 �*� 0.05 �.� 0.1 � � 1
>
> Residual standard error: 9.57e-10 on 677 degrees of freedom
>
> Number of iterations to convergence: 2
> Achieved convergence tolerance: 3.973e-08
>
> --
> Residual sum of squares: 6.2e-16
>
> --
> t-based confidence interval:
>2.5% 97.5%
> d  4.195378e-09  7.589714e-09
> e -7.668142e-09 -5.501342e-09
> f -2.655647e-10  6.354852e-10
>
> --
> Correlation matrix:
>d e f
> d  1.000 -6.202339e-01 -7.832539e-01
> e -0.6202339  1.00e+00 -2.127301e-05
> f -0.7832539 -2.127301e-05  1.00e+00
>
>
> if I let XL = 1.1070513 and LM3 = 0.3919 , and consider the coeffs as given 
> above, the right hand side of the above equation is negative.
> But YLf13 is always positive! How is this possible? Am I interpreting the 
> result of the nls output properly?  Should I interpret the coeffs 
> differently? I have done hours of thinking over the above problem but 
> couldn't find any results...
>
> I cannot provide the full values of YLf13, XL and LM3 due to IPR 
> issuesplease cooperate..however, if the only way to solve the problem 
> is to give these values, I would indeed give them.
>
> Also forgive me if there is a minor mistake in my calculations... or a 
> typo
>
> very many thanks for your time and effort
> yours 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.
>

[[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] problem with nlsLM function

2019-03-19 Thread akshay kulkarni
dear members,
I am getting the "singular gradient error" when I use nls 
for a function of two variables:
> formulaDH5
HM1 ~ (a + (b * ((HM2 + 0.3)^(1/2 + (A * sin(w * HM3 + a) +
C)

HM1 is the response variable, and HM2 and HM3 are predictors.

The problem is I get the same error even when I use nlsLM(in the minpack.lm 
package):

> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 0.43143, b = 2,A = 0.09,w 
> = 0.8,a = 0.01,C = 0.94))
Error in nlsModel(formula, mf, start, wts) :
  singular gradient matrix at initial parameter estimates
> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 1, b = 2,A = 0.09,w = 
> 0.8,a = 0.01,C = 0.94))
Error in nlsModel(formula, mf, start, wts) :
  singular gradient matrix at initial parameter estimates
> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 1, b = 2,A = 0.09,w = 
> 0.8,a = 0.01,C = 2))
Error in nlsModel(formula, mf, start, wts) :
  singular gradient matrix at initial parameter estimates

I came to know that nlsLM converges when nls throws a singular gradient error. 
What is happening above? Can the problem get  solved if I use nls.lm 
function(in the minpack.lm package) instead?

very many thanks for your time and effort
yours 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] Fw: problem with nlsLM function

2019-03-19 Thread akshay kulkarni
Dear duncan,
Sorry to bother you with such a silly mistake I 
didn,t notice it!
Sent: Tuesday, March 19, 2019 6:01 PM
To: akshay kulkarni; R help Mailing list
Subject: Re: [R] Fw: problem with nlsLM function

On 19/03/2019 8:26 a.m., akshay kulkarni wrote:
>
> dear members,
>  also,I can provide HM1,HM2 and HM3 if needed
>
> 
> From: R-help  on behalf of akshay kulkarni 
> 
> Sent: Tuesday, March 19, 2019 5:43 PM
> To: R help Mailing  list
> Subject: [R] problem with nlsLM function
>
> dear members,
>  I am getting the "singular gradient error" when I use 
> nls for a function of two variables:
>> formulaDH5
> HM1 ~ (a + (b * ((HM2 + 0.3)^(1/2 + (A * sin(w * HM3 + a) +
>  C)
>
> HM1 is the response variable, and HM2 and HM3 are predictors.
>
> The problem is I get the same error even when I use nlsLM(in the minpack.lm 
> package):
>
>> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 0.43143, b = 2,A = 
>> 0.09,w = 0.8,a = 0.01,C = 0.94))

You have "a" twice in your start list.  That's bound to cause trouble...

Duncan Murdoch


> Error in nlsModel(formula, mf, start, wts) :
>singular gradient matrix at initial parameter estimates
>> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 1, b = 2,A = 0.09,w = 
>> 0.8,a = 0.01,C = 0.94))
> Error in nlsModel(formula, mf, start, wts) :
>singular gradient matrix at initial parameter estimates
>> nonlin_modDH5 <- nlsLM(formulaDH5, start = list(a = 1, b = 2,A = 0.09,w = 
>> 0.8,a = 0.01,C = 2))
> Error in nlsModel(formula, mf, start, wts) :
>singular gradient matrix at initial parameter estimates
>
> I came to know that nlsLM converges when nls throws a singular gradient 
> error. What is happening above? Can the problem get  solved if I use nls.lm 
> function(in the minpack.lm package) instead?
>
> very many thanks for your time and effort
> yours 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.
>
>[[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] problem with nls....

2019-03-21 Thread akshay kulkarni
184791050  -0.076097183  -1.798061452   0.080099125   2.062484105  
-0.348501142  -2.106705631   0.007017747   2.305538391
[631]  -0.915838960  -0.220861746   0.077200047   0.610466280  -0.688401758  
-0.207153770   0.049139553  22.362186197  -5.441551857
[640]  -1.708605711   0.926299855   0.207035751  -0.106446657  -2.675294607  
-0.404511023  -0.788943233  -0.048807464  -0.227614326
[649]  -0.085333035   0.977385829 -16.826537503  -0.200423157  -0.051340705   
6.499090143  -0.304213082  -0.065082852   0.048070630
[658]   0.666539778  -0.064016381  -0.109602571   0.533325153   0.528565621  
-0.248317213  -3.473373955   1.272400022   1.711836935
[667]  -0.228344960  -0.252753461  -0.488373752  -0.401594723  -0.030427542  
-0.455079097   3.252051577   0.960391227  -0.256075733
[676]  -0.136915862   0.098237444   1.674612416   0.044609980  -0.248469202  
-0.298662830   1.173803660  -0.208363252   1.850645023
[685]   1.036270876  -0.152137097  -0.048105658  -1.277109207   0.059431246   
0.064698690  -0.246801765  -0.196775000   0.533961473
[694]   0.220699810  -0.312873635   0.014867680  -0.241851486   0.032156787  
-1.816522484  -0.167733410   4.158794025   2.099466739
[703]  -0.030488507   0.112566051   0.075675048   0.302820106  -0.469476310   
0.210115120   0.056139143  -0.030484607  -0.072570524
[712]  -0.033886465   0.091219120  -0.248023454  -0.08146  -0.203068185   
0.054095543  -0.015255905  -3.701371648  -0.623879061
[721]   0.853410776   6.103753013  -1.341198580   1.247921308   0.751060465   
0.781642884   0.379135477   1.145320110   0.313305428
[730]   0.112618403  -1.412256823  -0.103142715  -0.007113346   0.659901598  
-2.519498558  -0.365995410  -0.184937991   0.897416670
[739]  -0.518805259  -3.353209940   1.867572217   9.205127781  -0.187969046  
-0.778383177  -0.042669664   0.806807477  -0.090799820
[748]  -0.021826161   0.448223805  -0.164371146  -0.618774302  -0.244839681   
0.194235170   1.570125546   1.754972837   0.500679719
[757]   0.870366653   0.433784961  -1.002863246   2.101960944   0.697030522   
7.950881827  -0.061270167  -2.371332122  -0.142291873
[766]  -1.729969712  -1.941166110  -0.245036824  -0.106730528   5.057757700  
-1.038846526  -0.858866602   3.386084663   1.395573786
[775]  -0.291650577  -2.212035645   0.856991031  -1.532383568  -0.185747818  
-0.711396025   1.062315644   0.241829929  -1.838103065
[784] -12.577074634   1.735801542   0.484405184   0.013854970   0.416285923  
-1.975226723   0.938110382  -0.647308291  -0.706063547
[793]  -0.082810695  -0.054601369  -0.014973073   0.127614348  18.906618087   
0.502810107  -0.152371107  -0.036187828


very many thanks for your time and effort
Yours sincerely,
AKSHAY M KULKARNI


From: Ivan Krylov 
Sent: Thursday, March 21, 2019 9:06 PM
To: r-help@r-project.org
Cc: akshay kulkarni
Subject: Re: [R] problem with nls

One of the assumptions made by least squares method is that the
residuals are independent and normally distributed with same parameters
(or, in case of weighted regression, the standard deviation of the
residual is known for every point). If this is the case, the parameters
that minimize the sum of squared residuals are the maximum likelihood
estimation of the true parameter values.

The problem is, your data doesn't seem to adhere well to your formula.
Have you tried plotting your HF1 - ((m/HF6) + 1) against HF6 (i.e. the
residuals themselves)? With large residual values (outliers?), the loss
function (i.e. sum of squared residuals) is disturbed and doesn't
reflect the values you would expect to get otherwise. Try computing
sum((HF1 - ((m/HF6) + 1))^2) for different values of m and see if
changing m makes any difference.

Try looking up "robust regression" (e.g. minimize sum of absolute
residuals instead of squared residuals; a unique solution is not
guaranteed, but it's be less disturbed by outliers).

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



[R] securing R code....

2020-10-26 Thread akshay kulkarni
dear members,
 I am a stock trader. I am using R for my research.

I want to service my laptop, wherein resides all my R code, which, for obvious 
reasons, has to be secured. I am using Windows 7 Ultimate.

I cannot encrypt the R data by Bitdefender, as it encrypts the entire drive. I 
anyway need to give the key when the system, if at all, gets locked when 
servicing.

My cousin suggested backing up the data and deleting that data in the laptop 
when giving it for servicing. How do you back up the R data? What is the file 
name that contains all the workspace in windows 7? .RHistory only contains the 
previous commands. Can I delete only all the data/code without deleting the R 
GUI? The extreme option would be to delete the whole of installed R GUI, after 
backing up the workspace. Some other way to secure the data/code?

I've tried using Backup and sync by google, but that is very cumbersome.

Please help.

thanking you,
Yours sincerely,
AKSHAY M KULKARNI

[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]
  Virus-free. 
www.avast.com

[[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] showing the complexity of r code.....

2021-08-27 Thread akshay kulkarni
dear members,
I am a stock trader and a data science freelancer.  
I am weighing the advantages of taking a R course in coursera to show my 
proficiency in R in some freelancing sites. But I have already done extensive 
research on Stock trading and data science, using R. How do I show that I am 
proficient in R, given my workspace? For example, can I show the total size of 
my workspace and the size of the functions I have created? Any other ideas?

Yours 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] coercion to an object...

2021-08-29 Thread akshay kulkarni
dear Enrico,
   it works. Thanks a lot. I spent over an hour looking for 
this function in the web, but was bootless. Do you have any way to get 
functions where you are given what it has to do? The most common case is that 
you are given a list of functions, but they number to over 10. Any idea to 
find them without resorting to help from another R expert?

yours sincerely
AKSHAY M KULKARNI


From: Enrico Schumann 
Sent: Sunday, August 29, 2021 4:57 PM
To: akshay kulkarni 
Cc: R help Mailing list ; r-help-requ...@r-project.org 

Subject: Re: [R] coercion to an object...

On Sun, 29 Aug 2021, akshay kulkarni writes:

> Dear members,
>  I think the following question is rudimentary, 
> but I couldn't find an answer in the Internet.
>
> Suppose there is an object A, and ls() lists it as "A". How do you convert 
> this character object to the object A. i.e I want a function f such that 
> class(f("A")) = class(A) (of course, class("A") = "character") . f should 
> just coerce the character to the object represented by it.


Perhaps ?get is what you're looking for:

  A <- 42
  get("A")
  ## [1] 42


> Thank you,
> Yours sincerely,
> AKSHAY M KULKARNI
>

--
Enrico Schumann
Lucerne, Switzerland
http://enricoschumann.net

[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
  Virus-free. 
www.avast.com<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>

[[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] coercion to an object...

2021-08-29 Thread akshay kulkarni
dear Duncun,
   Thanks a lot...


From: Duncan Murdoch 
Sent: Sunday, August 29, 2021 5:49 PM
To: akshay kulkarni ; Enrico Schumann 

Cc: R help Mailing list ; r-help-requ...@r-project.org 

Subject: Re: [R] coercion to an object...

On 29/08/2021 7:52 a.m., akshay kulkarni wrote:
> dear Enrico,
> it works. Thanks a lot. I spent over an hour looking 
> for this function in the web, but was bootless. Do you have any way to get 
> functions where you are given what it has to do? The most common case is that 
> you are given a list of functions, but they number to over 10. Any idea 
> to find them without resorting to help from another R expert?

The sos package does a pretty good job, but your query needs to be
fairly narrow or the result list will be really long.  I don't think it
would have found get() in the top hits given the words in your original
question.  Some questions need intelligence to interpret, not just
pattern matching.

Other than asking on this list, there's stackoverflow.com to get humans
involved in the search.

Duncan Murdoch


>
> yours sincerely
> AKSHAY M KULKARNI
>
> 
> From: Enrico Schumann 
> Sent: Sunday, August 29, 2021 4:57 PM
> To: akshay kulkarni 
> Cc: R help Mailing list ; r-help-requ...@r-project.org 
> 
> Subject: Re: [R] coercion to an object...
>
> On Sun, 29 Aug 2021, akshay kulkarni writes:
>
>> Dear members,
>>   I think the following question is rudimentary, 
>> but I couldn't find an answer in the Internet.
>>
>> Suppose there is an object A, and ls() lists it as "A". How do you convert 
>> this character object to the object A. i.e I want a function f such that 
>> class(f("A")) = class(A) (of course, class("A") = "character") . f should 
>> just coerce the character to the object represented by it.
>
>
> Perhaps ?get is what you're looking for:
>
>A <- 42
>get("A")
>## [1] 42
>
>
>> Thank you,
>> Yours sincerely,
>> AKSHAY M KULKARNI
>>
>
> --
> Enrico Schumann
> Lucerne, Switzerland
> http://enricoschumann.net
>
> [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
>   Virus-free. 
> www.avast.com<https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail>
>
>[[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] coercion to an object...

2021-08-29 Thread akshay kulkarni
Dear members,
 I think the following question is rudimentary, but 
I couldn't find an answer in the Internet.

Suppose there is an object A, and ls() lists it as "A". How do you convert this 
character object to the object A. i.e I want a function f such that 
class(f("A")) = class(A) (of course, class("A") = "character") . f should just 
coerce the character to the object represented by it.

Thank you,
Yours 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] help with LDA topic modelling..

2021-12-20 Thread akshay kulkarni
Thanks a lot

From: Jim Lemon 
Sent: Monday, December 20, 2021 1:43 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] help with LDA topic modelling..

Hi Akshay,
It depends upon how the circles are calculated. If each circle
encloses all of the members of each group, yes. I doubt you would get
perfect separation in any real example, though. At the moment:
Hanukkah is finished,
Margashirsha Punima has just happened and
Christmas is coming up.
No matter how devout the adherents, I don't think you would find news
articles that only mentioned one of these festivals. Less facetious
groupings would suffer the same eclectic problem.

Jim

On Mon, Dec 20, 2021 at 6:29 PM akshay kulkarni  wrote:
>
> dear members,
>  I am using LDA for topic modelling of news articles 
> (topicmodels package). I am visualizing the accuracy with the LDAvis package.
>
> The visualization shows clusters as circles, probably intersecting. My 
> question is, if a find the optimal number of topics, k, and if the circles 
> representing the topics doesn't intersect, then I have achieved perfect 
> segregation. AM I right?
>
> Thanking You,
> Yours 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.

[[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 with LDA topic modelling..

2021-12-19 Thread akshay kulkarni
dear members,
 I am using LDA for topic modelling of news articles 
(topicmodels package). I am visualizing the accuracy with the LDAvis package.

The visualization shows clusters as circles, probably intersecting. My question 
is, if a find the optimal number of topics, k, and if the circles representing 
the topics doesn't intersect, then I have achieved perfect segregation. AM I 
right?

Thanking You,
Yours 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.


[R] problem with RSelenium....

2021-12-18 Thread akshay kulkarni
dear members,
 I am using RSelenium. I have downloaded the java 
binary standalone server. I am running it in my windows powershell with the 
following command:  java -jar selenium-server-standalone-4.0.0-alpha-2.jar
(note that the command doesn't get finished in the powershell ( the prompt 
doesn't return to C"\Users\Administrator\Downloads after running the command)).

Then I run the following in R console:
 > remDr <- remoteDriver(remoteServerAddr = "localhost", port = L, 
 > browserName = "chrome")

and then the following:
> remDr$open

It gives me the following error:

[1] "Connecting to remote server"

Selenium message:Unable to create new service: ChromeDriverService
Build info: version: '4.0.0-alpha-2', revision: 'f148142cf8', time: 
'2019-07-01T21:30:10'
System info: host: 'EC2AMAZ-1JRGETJ', ip: '172.31.9.48', os.name: 'Windows 
Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: driver.version: unknown

Error:   Summary: SessionNotCreatedException
 Detail: A new session could not be created.
 Further Details: run errorDetails method

Please note that I'm fine with using rsDriver. What's going on? (I'm using 
remoteDriver instaed of rsDriver because it should not give the "port already 
in use" error.

Thanking you,
Yours 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.


[R] doubt with boosting algorithms in caret in r

2021-12-28 Thread akshay kulkarni
dear members,
 I am using caret and caretEnsemble packages for my 
research involving machine learning.

This link https://topepo.github.io/caret/train-models-by-tag.html#boosting 
indicates the various boosting algorithms available in the caret package. 
However, I know that boosting algorithms need to have base learners specified. 
I have no issues with adaboost.m1 algorithm which takes as a base learner 
Decision Trees. But what about the other algorithms? How do you specify the 
base learners for the algorithms? The page in the link speaks loosely of 
"Ensembles" relating to the boosting algorithms, but it doesn't specify how to 
pass them as arguments for the boosting algorithms in caret. What's going on? 
For example, I need a boosting algorithm with SVM. How do you effect it with 
caret or caretEnsemble?

Thanking you,
Yours 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.


[R] problem with switching windows in RSelenium..

2021-12-22 Thread akshay kulkarni
dear Kim,
Hope you are doing well.

I am Akshay, from bengaluru, INDIA. I am stock trader and am using R for my 
research. More specifically, I am using RSelenium to scrape news articles. I am 
stuck in the problem related to RSelenium.

I am not able to switch windows in Rselenium 1.7.7 ( I am using chrome) . My 
situation is exactly as described in this link: 
https://github.com/ropensci/RSelenium/issues/143
I also referred to this link:   https://github.com/ropensci/RSelenium/issues/205
I have three questions:


  1.  Please refer to the second link. I ran the following command as suggested 
in that link:
  2.  > binman::list_versions("chromedriver")
$win32
[1] "96.0.4664.45" "97.0.4692.20" "97.0.4692.36"

  I am currently using the first option. Will i be lucky if I switch to 
either the second or the third option? Or to any other version? Also, I suppose 
the versions are for 32 bit($win32 above). Again, will I be lucky if I switch 
to 64bit versions? If yes, how do you switch to 64 bit versions? (I am using 
AWS EC2 windows instance which is 64 bit system)

2. Please refer to the first link. I have read in the comments that the 
myswitch function works in these cases. The solution was presented in 2017. 
Will myswitch still be valid in December 2021? If not, can you please give me a 
modified version?

3. My Rselenium session gets terminated after some period of 
inactivity. How can I change that?

Your help will be highly appreciated.

Thanking You,
Yours 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.


[R] visualizing CTM topic models in R...

2021-12-22 Thread akshay kulkarni
dear members,
 I am using topicmodels package in R to segregate some 
news articles related to stocks.

I know that I can visualize LDA models with LDAvis package. But I have not 
stumbled upon any package or a base function(in the internet) to visualize the 
CTM model. Any ideas therefor?

Thanking You,
Yours 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.


[R] help with parellel processing and RSelenium

2021-12-12 Thread akshay kulkarni
dear members,
 I am a stock trader based in INDIA using R for my 
research. I have two questions:


  1.  I want to send the same function with different arguments to different 
cores. This link in SO 
https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using
  2.  gives the following solution:

   library(parallel)

cl <- makeCluster(4)
clusterExport(cl, "foo")
cores <- seq_along(cl)
r <- clusterApply(cl[cores], cores, function(core) {
  if (core == 1) {
foo(5, 4, 1/2, 3, "a")
  } else if (core == 2) {
foo(5, 3, 1/3, 1, "b")
  } else if (core == 3) {
foo(5, 4, 1/4, 1, "c")
  } else if (core == 4) {
foo(5, 2, 1/5, 0, "d")
  }})

My question is: what is the structure of the output "r" in the above code? I 
think it is a list with r[[1]] = output of foo(5,4,1/2,3,"a"),r[[2]] = output 
of foo(5,1/3,1,"b")

and so on. AM I right?

  1.

I am using RSelenium to scrape a website. Javascript has a document.ready 
function which ensures that any JS code is run only after the whole document is

  *

loaded. Is there a similar function in RSelenium? Or will the execution of the 
next expression takes place only after the whole page is loaded (with the

  *

"navigate" method of RSelenium)?

Thanking you,

Yours 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] help with parellel processing and RSelenium

2021-12-14 Thread akshay kulkarni
Dear Rui,
Thanks a lot. I've not yet ran the function. I hoped that I 
make sure of it before. Therefore I can't print r. Thanks anyways!

Yours sincerely,
Akshay M Kulkarni

From: Rui Barradas 
Sent: Sunday, December 12, 2021 10:42 PM
To: akshay kulkarni ; R help Mailing list 

Subject: Re: [R] help with parellel processing and RSelenium

Hello,

Inline.

�s 16:43 de 12/12/21, akshay kulkarni escreveu:
> dear members,
>   I am a stock trader based in INDIA using R for my 
> research. I have two questions:
>
>
>1.  I want to send the same function with different arguments to different 
> cores. This link in SO 
> https://stackoverflow.com/questions/25045998/send-function-calls-with-different-arguments-to-different-processors-in-r-using
>2.  gives the following solution:
>
> library(parallel)
>
> cl <- makeCluster(4)
> clusterExport(cl, "foo")
> cores <- seq_along(cl)
> r <- clusterApply(cl[cores], cores, function(core) {
>if (core == 1) {
>  foo(5, 4, 1/2, 3, "a")
>} else if (core == 2) {
>  foo(5, 3, 1/3, 1, "b")
>} else if (core == 3) {
>  foo(5, 4, 1/4, 1, "c")
>} else if (core == 4) {
>  foo(5, 2, 1/5, 0, "d")
>}})
>
> My question is: what is the structure of the output "r" in the above code? I 
> think it is a list with r[[1]] = output of foo(5,4,1/2,3,"a"),r[[2]] = output 
> of foo(5,1/3,1,"b")
>
> and so on. AM I right?

Yes, you are right. Why don't you try and print r[[1]]?

Anyway, I would put the parameters in a list and pass them to the
function following the below lines.


library(parallel)

foo <- function(pars){
   x <- pars$x
   y <- pars$y
   z <- pars$z
   w <- pars$w
   alpha <- pars$alpha
   res <- (x + y)*z^w
   list(result = res, message = alpha)
}
params <- list(
   list(x=5, y=4, z=1/2, w=3, alpha="a"),
   list(x=5, y=3, z=1/3, w=1, alpha="b"),
   list(x=5, y=4, z=1/4, w=1, alpha="c"),
   list(x=5, y=2, z=1/5, w=0, alpha="d")
)

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

do.call(rbind.data.frame, r)


Hope this helps,

Rui Barradas


>
>1.
>
> I am using RSelenium to scrape a website. Javascript has a document.ready 
> function which ensures that any JS code is run only after the whole document 
> is
>
>*
>
> loaded. Is there a similar function in RSelenium? Or will the execution of 
> the next expression takes place only after the whole page is loaded (with the
>
>*
>
> "navigate" method of RSelenium)?
>
> Thanking you,
>
> Yours 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.
>

[[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] SDLC methodology for R and Data science......

2022-02-15 Thread akshay kulkarni
dear ERic,
 Thanks for your reply. As mentioned, I will post my issue in 
the R devel list.

Thanking you,
Yours sinecerly,
AKSHAY M KULKARNI

From: Eric Berger 
Sent: Tuesday, February 15, 2022 10:26 PM
To: Bert Gunter 
Cc: akshay kulkarni ; R help Mailing list 

Subject: Re: [R] SDLC methodology for R and Data science..

Bert Gunter writes:
>> 1. This dialogue should be taken offlist imo.

Akshay, I think you asked a great question and I was looking forward
to seeing the answers.
After reading Bert's comment I checked the posting guide for this list
and I see that a better fit for your question would be the r-devel
list.

https://stat.ethz.ch/mailman/listinfo/r-devel

Best,
Eric



On Tue, Feb 15, 2022 at 6:37 PM Bert Gunter  wrote:
>
> 1. This dialogue should be taken offlist imo.
>
> 2. And really, make some effort of your own before posting: An internet
> search on "Watts Humphrey Software Development" immediately brought up what
> appeared to be answers to at least some of your queries.
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Tue, Feb 15, 2022 at 8:27 AM akshay kulkarni 
> wrote:
>
> > Dear richard,
> >   I am very grateful for your informative reply.
> >
> > THe fact is, I am doing a project, which is not less complex,(if not more)
> > than those of Microsoft or Accenture or Google , but I am doing it all by
> > myself. Can you please let me the full title of the book by Watts Humphrey?

get
> > some tips on how to go about my project ( I've mostly taken into account
> > standard methods of the state of the art, I am looking for something
> > "whizzy" than aids development by one person).
> >
> > Thanks again,
> > Yours sinecerly,
> > AKSHAY M KULKARNI
> > 
> > From: Richard O'Keefe 
> > Sent: Monday, February 14, 2022 5:23 AM
> > To: akshay kulkarni 
> > Cc: R help Mailing list 
> > Subject: Re: [R] SDLC methodology for R and Data science..
> >
> > There are at least two ways to use R.
> > If you have devised a statistical/data science technique
> > and are writing a package to be used by other people,
> > that is normal software development that happens to be
> > using R and the R tool.  Lots of attention to documentation
> > and tests.  Test-Driven Development is one approach.
> >
> > Many R users aren't developing code for other people.
> > They are trying to make sense of some kind of data.
> > This is what used to be called "exploratory programming".
> > And heavyweight development processes aren't really
> > appropriate for this kind of work.  In traditional terms,
> > when you are doing exploratory programming, you spend
> > most of your time in the requirements phase.
> >
> > Perhaps the most important thing here is to keep a log
> > of what you are doing and record things that didn't work,
> > why they didn't work, and what you learned from it.
> > When something DOES give you some insight, you want to
> > be able to do it again.
> >
> > The tricky thing is scaling from exploration to development.
> > After playing around with one data set, you might want to
> > provide a script that other people can use to process
> > similar data sets the same way.
> > Use a light weight process, but make sure you have plenty
> > of tests, and adequate documentation.
> >
> > Watts Humphrey developed something he called the "Personal
> > Software Process" and wrote a book about it.  I don't like
> > his examples for several reasons, but the point about
> > watching what you do and measuring it so you can improve is
> > well made.
> >
> >
> >
> > On Mon, 14 Feb 2022 at 05:33, akshay kulkarni  > <mailto:akshay...@hotmail.com>> wrote:
> > dear members,
> >  I am Stock trader and using R for research.
> >
> > Until now I was coding very haphazardly, but recently I stumbled upon the
> > Software Development Life Cycle (SDLC), which introduced me to principled
> > software design. I am college dropout and don't have in depth knowledge in
> > Software Engineering principles. However, now, I want to go in a structured
> > manner.
> >
> > I googled for a SDLC method (like XP, AGILE and WATERFALL) that suits the
> > R programming language and specifically for data science, but was 

Re: [R] SDLC methodology for R and Data science......

2022-02-15 Thread akshay kulkarni
Dear richard,
  I am very grateful for your informative reply.

THe fact is, I am doing a project, which is not less complex,(if not more) than 
those of Microsoft or Accenture or Google , but I am doing it all by myself. 
Can you please let me the full title of the book by Watts Humphrey? Or any 
online resources for "personal software process"? Perhaps I can get some tips 
on how to go about my project ( I've mostly taken into account standard methods 
of the state of the art, I am looking for something "whizzy" than aids 
development by one person).

Thanks again,
Yours sinecerly,
AKSHAY M KULKARNI

From: Richard O'Keefe 
Sent: Monday, February 14, 2022 5:23 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] SDLC methodology for R and Data science..

There are at least two ways to use R.
If you have devised a statistical/data science technique
and are writing a package to be used by other people,
that is normal software development that happens to be
using R and the R tool.  Lots of attention to documentation
and tests.  Test-Driven Development is one approach.

Many R users aren't developing code for other people.
They are trying to make sense of some kind of data.
This is what used to be called "exploratory programming".
And heavyweight development processes aren't really
appropriate for this kind of work.  In traditional terms,
when you are doing exploratory programming, you spend
most of your time in the requirements phase.

Perhaps the most important thing here is to keep a log
of what you are doing and record things that didn't work,
why they didn't work, and what you learned from it.
When something DOES give you some insight, you want to
be able to do it again.

The tricky thing is scaling from exploration to development.
After playing around with one data set, you might want to
provide a script that other people can use to process
similar data sets the same way.
Use a light weight process, but make sure you have plenty
of tests, and adequate documentation.

Watts Humphrey developed something he called the "Personal
Software Process" and wrote a book about it.  I don't like
his examples for several reasons, but the point about
watching what you do and measuring it so you can improve is
well made.



On Mon, 14 Feb 2022 at 05:33, akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
dear members,
 I am Stock trader and using R for research.

Until now I was coding very haphazardly, but recently I stumbled upon the 
Software Development Life Cycle (SDLC), which introduced me to principled 
software design. I am college dropout and don't have in depth knowledge in 
Software Engineering principles. However, now, I want to go in a structured 
manner.

I googled for a SDLC method (like XP, AGILE and WATERFALL) that suits the R 
programming language and specifically for data science, but was bootless. Do 
you people have any idea on which software engineering methodology to use in R 
and data science, so that I can code efficiently and in a structured manner? 
The point to note, with regards to R, is that statistical ANALYSIS sometimes 
takes very little code as compared to other programming languages. Any SDLC 
method for these types of analysis, besides, rigorous scripting with R?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI


[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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] handling breaks in a for loop

2022-02-06 Thread akshay kulkarni
dear Tim,
I have not yet ran the function. I just wanted to be prepared. 
The data is the html document and the code is the scraping code, but the point 
is, the error might be from neither data nor code, but due to the 
inconsistencies in the web page. THis can happen however perfect I make my 
code. I think save () function in the body might save me, but any other faster 
method?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Ebert,Timothy Aaron 
Sent: Monday, February 7, 2022 12:33 AM
To: akshay kulkarni ; R help Mailing list 

Subject: RE: handling breaks in a for loop

Is the bug in the data or in the code?
Can you identify the cause? Can you get a subset of the data to find the bug 
using fewer resources?
If you can identify the root cause, then you can set an error trap.
If the error is a memory problem, they you either need to save, reallocate 
memory, or get more memory.

Tim

-Original Message-
From: R-help  On Behalf Of akshay kulkarni
Sent: Sunday, February 6, 2022 1:56 PM
To: R help Mailing list 
Subject: [R] handling breaks in a for loop

[External Email]

dear members,
 I have a very large for loop (basically a web scraping 
loop) with 500 iterations(over different stocks). I am concerned about the loop 
breaking midway.

My question is: is there any method to store the succesful iterations and 
continue with the iteration (ofcourse, after fixing the bug) where the 
exception occured? I can insert a save () function in the body of the loop and 
save the succesful iterations but this would slow down the execution speed. Any 
other method? I want to avoid trycatch as much as possible because an NA in the 
place of a succesful iteration would cost me much.

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=F0cPNGUlUW-Cd9RJzYladHn1oypv0cPLA-d9dEO42hExw8rxis6aw3FPV6DtBQU2=jmZ4HPdnRH6ive_u-90RBNQQtFrnMey9AZv8MRZGQbc=
PLEASE do read the posting guide 
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=F0cPNGUlUW-Cd9RJzYladHn1oypv0cPLA-d9dEO42hExw8rxis6aw3FPV6DtBQU2=Tpxb0boNRBRe0_7_FZteYKLLal9zfDXAXImIExuV35o=
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] unbalanced design in multifactor anova....

2022-01-22 Thread akshay kulkarni
dear members,
 Thanks Peter, Bert, Rolf and Terry. Regrets to reply 
this late.

iF you say that balancedness is not required for lm, I think there is some 
inconsistency. The coded vectors can still be correlated and unless lm handles 
it with some trick, aov and lm are essentially the same. I even came to know 
that aov calls lm internally! Moroevr, can you please give me  a reference that 
explains how exactly lm handles semipartial correlations (if at all it does). I 
am just curious.

Moroever, If I drop some elements to make my data balanced, will the results 
(from aov and lm) be reliable, i.e makes the correct inference about my sample?

THanking You,
AkshaY Kulkarni


From: peter dalgaard 
Sent: Tuesday, January 18, 2022 6:13 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] unbalanced design in multifactor anova

In brief, aov() requires balancedness (or at least you _really_ need to know 
what you are doing otherwise), lm() does not, but you need to be careful that 
results, like in any multiple regression, depends on test order. For models 
with random effects, things get tricky and you likely need to use the "lme4" 
package.

- Peter D.

> On 18 Jan 2022, at 08:14 , akshay kulkarni  wrote:
>
> dear members,
> I have a question on anova as implemented in R.
>
> If there is an unbalanced design in multifactor anova, will aov or lm work 
> properly? I was reading a book on excel where the author points that in an 
> unbalanced design, the factors, as coded vectors, are correlated. He says 
> that variance will be allocated properly only when the coded vectors are 
> uncorrelated. But he also justifies that the function TREND() in Excel 
> handles this automatically using semipartial correlations.
>
> What about aov or lm in R, which are used to implement anova? Should we do 
> some thing extra for them to work properly in an unbalanced design? Or will 
> the coding system used by R to represent the factors or levels internally 
> handles the correlation?
>
> THanking you,
> Yours 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.

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


[[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] lag.plot showing only lines....

2023-08-28 Thread akshay kulkarni
dear Eric,
Working...! thanks a lot!

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Eric Berger 
Sent: Monday, August 28, 2023 8:37 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] lag.plot showing only lines

Hi Akshay,
I have never used this function before but according to ?lag.plot you
simply need to pass the argument do.lines=FALSE.

HTH,
Eric


On Mon, Aug 28, 2023 at 5:45 PM akshay kulkarni  wrote:
>
> Dear members,
>  I am using the following code:
>
> lag.plot(ygrpch(OHLCData[[i]]),lags=4)
>
> But instead of dots, it is showing lines, which I don't know how to 
> interpret. How to make it plot dots? This is working properly:
>
> lag.plot(na_interpolation(OHLCData[[i]][,4]),lags=4)
>
> I am not attaching the graph here because it would not fit properly. If you 
> want to have a look at the graph, how do i send it?
>
> Thanking you,
> Yours 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.

[[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] lag.plot showing only lines....

2023-08-28 Thread akshay kulkarni
Dear members,
 I am using the following code:

lag.plot(ygrpch(OHLCData[[i]]),lags=4)

But instead of dots, it is showing lines, which I don't know how to interpret. 
How to make it plot dots? This is working properly:

lag.plot(na_interpolation(OHLCData[[i]][,4]),lags=4)

I am not attaching the graph here because it would not fit properly. If you 
want to have a look at the graph, how do i send it?

Thanking you,
Yours 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.


[R] biasadj = TRUE in auto.arima...

2023-08-28 Thread akshay kulkarni
dear members,
 I am considering whether to set biasadj = TRUE in 
auto.arima in forecast package. If TRUE, the mean is very nearly equal to the 
original data. So there is no point in doing the transformation at all...

If FALSE, the point forecast is the median which is different from the mean.

So if I have to get more accuracy and gain some thing by the BoxCox 
transformation I have to set the biasadj argument to FALSE.

Am i right?

PLease flag me if this question doesn't belong to R proper and doesn't fit to 
this list.

THanking you,
Yours 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] byte coding compiling.....

2022-07-07 Thread akshay kulkarni
Dear Uwe,
  I have attached the info from the parallel package 
description from my Rstudio IDE:

Package: parallel
Version: 4.1.2
Priority: base
Title: Support for Parallel computation in R
Author: R Core Team
Maintainer: R Core Team 
Contact: R-help mailing list 
Description: Support for parallel computation, including by forking
   (taken from package multicore), by sockets (taken from package snow)
   and random-number generation.
License: Part of R 4.1.2
Imports: tools, compiler
Suggests: methods
Enhances: snow, nws, Rmpi
NeedsCompilation: yes
Built: R 4.1.2; x86_64-w64-mingw32; 2021-11-01 18:38:05 UTC; windows

It says: NeedsCompilation: yes

How about it?

Yours sincerely,
AKSHAY M KULKARNI


From: Uwe Ligges 
Sent: Thursday, July 7, 2022 4:08 PM
To: akshay kulkarni ; Bert Gunter 

Cc: R help Mailing list 
Subject: Re: [R] byte coding compiling.



On 06.07.2022 19:54, akshay kulkarni wrote:
> Dear Bert,
>   Thanks for your reply...
>
> So
>> cmpfun(mclapply)

mclapply is already byte compiled as it is in a package.

You may want to
cmpfun(yourFunction)
the function that you use in the mclapply call.

Best,
Uwe Ligges


>
> should  do the job right?
>
> By the by, how can I give a reprex? Reprex of the code that I am giving to 
> mclapply (as FUN argument)?
>
> Yours sincerely,
> AKSHAY M KULKARNI
> 
> From: Bert Gunter 
> Sent: Wednesday, July 6, 2022 10:32 PM
> To: akshay kulkarni 
> Cc: R help Mailing list 
> Subject: Re: [R] byte coding compiling.
>
> Unlikely
>
> See here:
>   
> https://www.r-bloggers.com/2017/08/how-to-make-best-use-of-the-byte-compiler-in-r/
>
> Byte code compilation should be automatic in both cases, as I understand it. 
> Of course, I could be wrong due to special features of parallel  programming, 
> etc.
>
> A reprex might be helpful here.
>
> Cheers,
> Bert
>
>
> On Wed, Jul 6, 2022, 7:29 PM akshay kulkarni 
> mailto:akshay...@hotmail.com>> wrote:
> Dear members,
>I am using pbmclapply, the progress bar version of 
> mclapply, from the parallel package. The point is, pbmclapply is three times 
> faster than mclapply, and I think the most probable reason would be that 
> pbmclapply is byte code compiled (I can think of no other reason).
>
> I know the cmpfun function from compiler package. If I do:
>
>> cmpfun(mclapply)
>
> will the job be done? The point is mclapply may look for other functions in 
> the parallel package. So I have to compile the whole package right? How do 
> you do that? or in general, how do you byte code compile a whole package?
>
> Thanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
>  [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> 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] inconsistency in tryCatch...

2022-06-27 Thread akshay kulkarni
Dear Richard,
 Thanks for the informative reply
Yours sincerely,
AKSHAY M KULKARNI

From: Richard O'Keefe 
Sent: Sunday, June 26, 2022 7:26 AM
To: akshay kulkarni 
Cc: Jeff Newmiller ; r-help@r-project.org 

Subject: Re: [R] inconsistency in tryCatch...

I think the confusion is simple.
What you *really* wanted to do was
tryCatch(print("fred"), -- other stuff --)
because the first argument of tryCatch is an EXPRESSION.  You don't need to 
have 'function' in there anywhere at all.   Every function in R gets to decide 
for itself which, if any, of its arguments are evaluated, and when.  NONE of 
the arguments of tryCatch is evaluated until tryCatch decides it is time.  In 
most other programming languages, arguments are evaluated before the call, and 
if you want something delayed, you have to wrap it in an anonymous function.  
Not R.d

So tryCatch
 - first sets up condition handling
 - THEN evaluates its first argument

On Thu, 23 Jun 2022 at 07:42, akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
Dear Jeff,
   Thanks! I think it is an idiosyncrasy of tryCatch? The other 
arguments like "error" doesn't need to be assigned to a call right? Just the 
definition would be sufficient, i think?

Yours sincerely,
AKSHAY M KULKARNI

From: Jeff Newmiller mailto:jdnew...@dcn.davis.ca.us>>
Sent: Thursday, June 23, 2022 12:53 AM
To: r-help@r-project.org<mailto:r-help@r-project.org> 
mailto:r-help@r-project.org>>; akshay kulkarni 
mailto:akshay...@hotmail.com>>; R help Mailing list 
mailto:r-help@r-project.org>>
Subject: Re: [R] inconsistency in tryCatch...

You defined a function. You did not call the function. tryCatch returned the 
object you defined. So the interactive console printed the object returned.

Invoking the "function" function does not call the defined function for you. 
Try:

tryCatch((function() print("fred"))(), error = function(e) sum(1:3), finally = 
sum(1:3))

On June 22, 2022 12:00:38 PM PDT, akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
>Dear members,
>  I have the following code:
>
>> tryCatch(function() print("fred"),  error = function(e) sum(1:3), 
> finally = sum(1:3))
> function() print("fred")
>
>The expected output from the tryCatch call should be to print "fred" to the 
>console, and exit, but as seen above, it is outputting
>  function() print("fred")
>
>Can you people please shed some light on what is happening?
>
>thanking you,
>Yours sincerely,
>AKSHAY M KULKARNI
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
>UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>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<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.


[R] is.na with lists....

2022-07-02 Thread akshay kulkarni
Dear memebers,
I have list of stock data OHLCData for 500 stocks, 
15 of whom are NA's. The following is the code:

require(quantmod)
getOHLCData <- function(NSESym) {
  OHLCData1 <- list()
  for(i in 1:500){
OHLCData1[[i]] <- tryCatch(getSymbols(NSESym[i], auto.assign=FALSE),
  error = function (e) {print(i); return(NA)})

  }
  return(OHLCData1)
}

 OHLCData <- getOHLCData(NSESym)

however, when I check for is.na, I get the following:

length(OHLCData)
[1] 500
> length(is.na(OHLCData))
[1] 500

length(is.na(OHLCData)) should return 15. Whats going wrong? I assume is.na 
returns TRUE if there is an NA.

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


[R] printing with bothe print and cat...

2022-07-09 Thread akshay kulkarni
Dear members,
 I have the following code:

testprint <- function() {

  for(i in 1:5) {for(j in 1:5)
  {cat(j)}
print(i)}
}

And the output is:

> testprint()
12345[1] 1
12345[1] 2
12345[1] 3
12345[1] 4
12345[1] 5

Any idea on how to remove the [1] from the output, and give spaces in the cat 
output? The desired output is:

1 2 3 4 5  1
1 2 3 4 5  2
1 2 3 4 5  3
1 2 3 4 5  4
1 2 3 4 5  5
 Many thanks in advance.

THanking you,
Yours  sincreely,
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] printing with bothe print and cat...

2022-07-09 Thread akshay kulkarni
Dear David,
   Thanks ...

Yours sinecrely,
AKSHAY M KULKARNI

From: David Winsemius 
Sent: Saturday, July 9, 2022 10:30 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] printing with bothe print and cat...

If spaces needed. In first sequences then

paste( 1:5, collapse=“ “)

Sent from my iPhone

> On Jul 9, 2022, at 9:59 AM, David Winsemius  wrote:
>
> Skip the for loops:
>
> cat(paste( seq(1:5), ““, 1:5) )
>
> —
> David
>
> Sent from my iPhone
>
>> On Jul 9, 2022, at 9:47 AM, akshay kulkarni  wrote:
>>
>> Dear members,
>>I have the following code:
>>
>> testprint <- function() {
>>
>> for(i in 1:5) {for(j in 1:5)
>> {cat(j)}
>>   print(i)}
>> }
>>
>> And the output is:
>>
>>> testprint()
>> 12345[1] 1
>> 12345[1] 2
>> 12345[1] 3
>> 12345[1] 4
>> 12345[1] 5
>>
>> Any idea on how to remove the [1] from the output, and give spaces in the 
>> cat output? The desired output is:
>>
>> 1 2 3 4 5  1
>> 1 2 3 4 5  2
>> 1 2 3 4 5  3
>> 1 2 3 4 5  4
>> 1 2 3 4 5  5
>> Many thanks in advance.
>>
>> THanking you,
>> Yours  sincreely,
>> 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.


[[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] printing with bothe print and cat...

2022-07-09 Thread akshay kulkarni
Dear Tim,
   Many thanks...

Yours sincerely
AKSHAYM KULKARNI

From: Ebert,Timothy Aaron 
Sent: Saturday, July 9, 2022 11:03 PM
To: akshay kulkarni ; David Winsemius 

Cc: R help Mailing list 
Subject: RE: [R] printing with bothe print and cat...

Here is an alternative that makes a dataframe and then prints the dataframe.
n_rows <- 5
n_cols <- 5
p_mat<-matrix(0,nrow=n_rows,ncol=n_cols)
for(i in 1:n_rows) {
  for(j in 1:n_cols){
p_mat[i,j]<-(j)
  }
}
p_df <- data.frame(p_mat,1:n_rows)
print(p_df)


Tim

-Original Message-
From: R-help  On Behalf Of akshay kulkarni
Sent: Saturday, July 9, 2022 1:02 PM
To: David Winsemius 
Cc: R help Mailing list 
Subject: Re: [R] printing with bothe print and cat...

[External Email]

Dear David,
THe code given was a reprex, and unfortunately, I cannot 
skip the for loops: Its a very big  web scraping code. Any alternative?

Many thanks in advance...

Yours sincrely,
AKSHAY M KULKARNI


From: David Winsemius 
Sent: Saturday, July 9, 2022 10:28 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] printing with bothe print and cat...

Skip the for loops:

cat(paste( seq(1:5), ““, 1:5) )

—
David

Sent from my iPhone

> On Jul 9, 2022, at 9:47 AM, akshay kulkarni  wrote:
>
> Dear members,
> I have the following code:
>
> testprint <- function() {
>
>  for(i in 1:5) {for(j in 1:5)
>  {cat(j)}
>print(i)}
> }
>
> And the output is:
>
>> testprint()
> 12345[1] 1
> 12345[1] 2
> 12345[1] 3
> 12345[1] 4
> 12345[1] 5
>
> Any idea on how to remove the [1] from the output, and give spaces in the cat 
> output? The desired output is:
>
> 1 2 3 4 5  1
> 1 2 3 4 5  2
> 1 2 3 4 5  3
> 1 2 3 4 5  4
> 1 2 3 4 5  5
> Many thanks in advance.
>
> THanking you,
> Yours  sincreely,
> AKSHAY M KULKARNI
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mail
> man_listinfo_r-2Dhelp=DwIGaQ=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAs
> Rzsn7AkP-g=lceoyahibi7acrpoFW6uDxJ4j_QtB0NYjb7GNZu_e9WpZDZ4hdpYpgvtx
> sQZbqGe=m5EK_gr2QGFthC1Q_GqiGjSV05AZSmV-T1kQpq5KlUM=
> PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
> g_posting-2Dguide.html=DwIGaQ=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeA
> sRzsn7AkP-g=lceoyahibi7acrpoFW6uDxJ4j_QtB0NYjb7GNZu_e9WpZDZ4hdpYpgvt
> xsQZbqGe=EdP6JP8fQVHC-xOJfowZ7VlJOlqWwnJBjAi8sZR2Els=
> 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://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwIGaQ=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=lceoyahibi7acrpoFW6uDxJ4j_QtB0NYjb7GNZu_e9WpZDZ4hdpYpgvtxsQZbqGe=m5EK_gr2QGFthC1Q_GqiGjSV05AZSmV-T1kQpq5KlUM=
PLEASE do read the posting guide 
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwIGaQ=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=lceoyahibi7acrpoFW6uDxJ4j_QtB0NYjb7GNZu_e9WpZDZ4hdpYpgvtxsQZbqGe=EdP6JP8fQVHC-xOJfowZ7VlJOlqWwnJBjAi8sZR2Els=
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] printing with bothe print and cat...

2022-07-10 Thread akshay kulkarni
Dear Rui,
Many thanks...

Yours
Akshay M Kulkarni


From: Rui Barradas 
Sent: Sunday, July 10, 2022 12:39 AM
To: akshay kulkarni ; R help Mailing list 

Subject: Re: [R] printing with bothe print and cat...

Hello,

Like this?


testprint <- function() {
   for(i in 1:5) {
 for(j in 1:5) {
   cat(j, "")
 }
 cat("\t", i, "\n")
   }
}

testprint()
#> 1 2 3 4 5 1
#> 1 2 3 4 5 2
#> 1 2 3 4 5 3
#> 1 2 3 4 5 4
#> 1 2 3 4 5 5


Hope this helps,

Rui Barradas

�s 17:46 de 09/07/2022, akshay kulkarni escreveu:
> Dear members,
>   I have the following code:
>
> testprint <- function() {
>
>for(i in 1:5) {for(j in 1:5)
>{cat(j)}
>  print(i)}
> }
>
> And the output is:
>
>> testprint()
> 12345[1] 1
> 12345[1] 2
> 12345[1] 3
> 12345[1] 4
> 12345[1] 5
>
> Any idea on how to remove the [1] from the output, and give spaces in the cat 
> output? The desired output is:
>
> 1 2 3 4 5  1
> 1 2 3 4 5  2
> 1 2 3 4 5  3
> 1 2 3 4 5  4
> 1 2 3 4 5  5
>   Many thanks in advance.
>
> THanking you,
> Yours  sincreely,
> 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.

[[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] byte coding compiling.....

2022-07-06 Thread akshay kulkarni
Dear Bert,
 Thanks for your reply...

So
> cmpfun(mclapply)

should  do the job right?

By the by, how can I give a reprex? Reprex of the code that I am giving to 
mclapply (as FUN argument)?

Yours sincerely,
AKSHAY M KULKARNI

From: Bert Gunter 
Sent: Wednesday, July 6, 2022 10:32 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] byte coding compiling.

Unlikely

See here:
 
https://www.r-bloggers.com/2017/08/how-to-make-best-use-of-the-byte-compiler-in-r/

Byte code compilation should be automatic in both cases, as I understand it. Of 
course, I could be wrong due to special features of parallel  programming, etc.

A reprex might be helpful here.

Cheers,
Bert


On Wed, Jul 6, 2022, 7:29 PM akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
Dear members,
  I am using pbmclapply, the progress bar version of 
mclapply, from the parallel package. The point is, pbmclapply is three times 
faster than mclapply, and I think the most probable reason would be that 
pbmclapply is byte code compiled (I can think of no other reason).

I know the cmpfun function from compiler package. If I do:

> cmpfun(mclapply)

will the job be done? The point is mclapply may look for other functions in the 
parallel package. So I have to compile the whole package right? How do you do 
that? or in general, how do you byte code compile a whole package?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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] inconsistency in tryCatch...

2022-06-22 Thread akshay kulkarni
Dear Bert,
 THanks a lot! I don't know how I escaped such a simple 
reasoning...

Your sincerely,
AKSHAY M KULKARNI

From: Bert Gunter 
Sent: Thursday, June 23, 2022 12:51 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] inconsistency in tryCatch...

inline

On Wed, Jun 22, 2022 at 12:01 PM akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
Dear members,
  I have the following code:

> tryCatch(function() print("fred"),  error = function(e) sum(1:3), 
finally = sum(1:3))
 function() print("fred")

The expected output from the tryCatch call should be to print "fred" to the 
console,
NO! You have simple defined the function -- you have not called/executed it. 
This defines and calls it:

> tryCatch({function() print("fred")}(),  error = function(e) sum(1:3), finally 
> = sum(1:3))
[1] "fred"

Cheers,
Bert




and exit, but as seen above, it is outputting
  function() print("fred")

Can you people please shed some light on what is happening?

thanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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] inconsistency in tryCatch...

2022-06-22 Thread akshay kulkarni
Dear Jeff,
   Thanks! I think it is an idiosyncrasy of tryCatch? The other 
arguments like "error" doesn't need to be assigned to a call right? Just the 
definition would be sufficient, i think?

Yours sincerely,
AKSHAY M KULKARNI

From: Jeff Newmiller 
Sent: Thursday, June 23, 2022 12:53 AM
To: r-help@r-project.org ; akshay kulkarni 
; R help Mailing list 
Subject: Re: [R] inconsistency in tryCatch...

You defined a function. You did not call the function. tryCatch returned the 
object you defined. So the interactive console printed the object returned.

Invoking the "function" function does not call the defined function for you. 
Try:

tryCatch((function() print("fred"))(), error = function(e) sum(1:3), finally = 
sum(1:3))

On June 22, 2022 12:00:38 PM PDT, akshay kulkarni  wrote:
>Dear members,
>  I have the following code:
>
>> tryCatch(function() print("fred"),  error = function(e) sum(1:3), 
> finally = sum(1:3))
> function() print("fred")
>
>The expected output from the tryCatch call should be to print "fred" to the 
>console, and exit, but as seen above, it is outputting
>  function() print("fred")
>
>Can you people please shed some light on what is happening?
>
>thanking you,
>Yours 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.


[R] removing dates from xts object..

2022-07-25 Thread akshay kulkarni
Dear members,
 I have:


> head(testOHLC)
   HINDUNILVR.NS.Open HINDUNILVR.NS.High HINDUNILVR.NS.Low 
HINDUNILVR.NS.Close
2007-01-02 217.80 219.00215.45  
216.40
2007-01-03 217.00 217.65211.05  
212.00
2007-01-04 213.00 214.25209.65  
210.60
2007-01-05 211.40 214.25209.55  
213.35
2007-01-08 213.35 213.35207.10  
210.10
2007-01-09 210.10 214.20208.70  
209.85
   HINDUNILVR.NS.Volume HINDUNILVR.NS.Adjusted
2007-01-02  2626898   155.0396
2007-01-03  4603921   151.8872
2007-01-04  5486460   150.8841
2007-01-05  5706066   152.8545
2007-01-08  3760443   150.5260
2007-01-09  5474633   150.3468

AND:


> head(testOHLC["2007-01-09"])
   HINDUNILVR.NS.Open HINDUNILVR.NS.High HINDUNILVR.NS.Low 
HINDUNILVR.NS.Close
2007-01-09  210.1  214.2 208.7  
209.85
   HINDUNILVR.NS.Volume HINDUNILVR.NS.Adjusted
2007-01-09  5474633   150.3468

BUT:

> head(testOHLC[-"2007-01-09"])
 Error in -"2007-01-09" : invalid argument to unary operator

How do remove rows with certain dates in an xts object? This doesn't work:

x[-dates] (however, this does: x[dates])

Many thanks in advance..

Yours sincreley
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] removing dates from xts object..

2022-07-25 Thread akshay kulkarni
Dear joshua,
  THanks for the reply

If I have a list of dates, it should be like this right?

y <- x[!(index(x) %in% dates)]
 where dates is a character vector of dates.

Thanking you,
Yours sincrely,
AKSHAY M KULKARNI




From: Joshua Ulrich 
Sent: Tuesday, July 26, 2022 1:56 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] removing dates from xts object..

This is the most straightforward and general way I can think of quickly:

library(xts)
data(sample_matrix)
x <- as.xts(sample_matrix, dateFormat = "Date")
head(x)
##Open High  LowClose
## 2007-01-02 50.03978 50.11778 49.95041 50.11778
## 2007-01-03 50.23050 50.42188 50.23050 50.39767
## 2007-01-04 50.42096 50.42096 50.26414 50.33236
## 2007-01-05 50.37347 50.37347 50.22103 50.33459
## 2007-01-06 50.24433 50.24433 50.11121 50.18112
## 2007-01-07 50.13211 50.21561 49.99185 49.99185

y <- x[!(index(x) %in% as.Date(c("2007-01-04", "2007-01-05")))]
head(y)
##Open High  LowClose
## 2007-01-02 50.03978 50.11778 49.95041 50.11778
## 2007-01-03 50.23050 50.42188 50.23050 50.39767
## 2007-01-06 50.24433 50.24433 50.11121 50.18112
## 2007-01-07 50.13211 50.21561 49.99185 49.99185
## 2007-01-08 50.03555 50.10363 49.96971 49.98806
## 2007-01-09 49.99489 49.99489 49.80454 49.91333

Best,
Josh


On Mon, Jul 25, 2022 at 3:20 PM akshay kulkarni  wrote:
>
> Dear members,
>  I have:
>
>
> > head(testOHLC)
>HINDUNILVR.NS.Open HINDUNILVR.NS.High HINDUNILVR.NS.Low 
> HINDUNILVR.NS.Close
> 2007-01-02 217.80 219.00215.45
>   216.40
> 2007-01-03 217.00 217.65211.05
>   212.00
> 2007-01-04 213.00 214.25209.65
>   210.60
> 2007-01-05 211.40 214.25209.55
>   213.35
> 2007-01-08 213.35 213.35207.10
>   210.10
> 2007-01-09 210.10 214.20208.70
>   209.85
>HINDUNILVR.NS.Volume HINDUNILVR.NS.Adjusted
> 2007-01-02  2626898   155.0396
> 2007-01-03  4603921   151.8872
> 2007-01-04  5486460   150.8841
> 2007-01-05  5706066   152.8545
> 2007-01-08  3760443   150.5260
> 2007-01-09  5474633   150.3468
>
> AND:
>
>
> > head(testOHLC["2007-01-09"])
>HINDUNILVR.NS.Open HINDUNILVR.NS.High HINDUNILVR.NS.Low 
> HINDUNILVR.NS.Close
> 2007-01-09  210.1  214.2 208.7
>   209.85
>HINDUNILVR.NS.Volume HINDUNILVR.NS.Adjusted
> 2007-01-09  5474633   150.3468
>
> BUT:
>
> > head(testOHLC[-"2007-01-09"])
>  Error in -"2007-01-09" : invalid argument to unary operator
>
> How do remove rows with certain dates in an xts object? This doesn't work:
>
> x[-dates] (however, this does: x[dates])
>
> Many thanks in advance..
>
> Yours sincreley
> 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.



--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com<http://www.fosstrading.com>

[[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] removing dates from xts object..

2022-07-25 Thread akshay kulkarni
Dear Joshua,
 Thanks a lot...

Yours sincrely,
AKSHAY M KULKARNI

From: Joshua Ulrich 
Sent: Tuesday, July 26, 2022 2:20 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] removing dates from xts object..

On Mon, Jul 25, 2022 at 3:34 PM akshay kulkarni  wrote:
>
> Dear joshua,
>   THanks for the reply
>
> If I have a list of dates, it should be like this right?
>
> y <- x[!(index(x) %in% dates)]
>  where dates is a character vector of dates.
>

'dates' needs to be a vector of Date-classed values, not character

# character vector
dates_chr <- c("2007-01-04", "2007-01-05")
# Date vector -- use this below
dates_Date <- as.Date(dates_chr)

y <- x[!(index(x) %in% dates_Date)]

> Thanking you,
> Yours sincrely,
> AKSHAY M KULKARNI
>
> ____
> From: Joshua Ulrich 
> Sent: Tuesday, July 26, 2022 1:56 AM
> To: akshay kulkarni 
> Cc: R help Mailing list 
> Subject: Re: [R] removing dates from xts object..
>
> This is the most straightforward and general way I can think of quickly:
>
> library(xts)
> data(sample_matrix)
> x <- as.xts(sample_matrix, dateFormat = "Date")
> head(x)
> ##Open High  LowClose
> ## 2007-01-02 50.03978 50.11778 49.95041 50.11778
> ## 2007-01-03 50.23050 50.42188 50.23050 50.39767
> ## 2007-01-04 50.42096 50.42096 50.26414 50.33236
> ## 2007-01-05 50.37347 50.37347 50.22103 50.33459
> ## 2007-01-06 50.24433 50.24433 50.11121 50.18112
> ## 2007-01-07 50.13211 50.21561 49.99185 49.99185
>
> y <- x[!(index(x) %in% as.Date(c("2007-01-04", "2007-01-05")))]
> head(y)
> ##Open High  LowClose
> ## 2007-01-02 50.03978 50.11778 49.95041 50.11778
> ## 2007-01-03 50.23050 50.42188 50.23050 50.39767
> ## 2007-01-06 50.24433 50.24433 50.11121 50.18112
> ## 2007-01-07 50.13211 50.21561 49.99185 49.99185
> ## 2007-01-08 50.03555 50.10363 49.96971 49.98806
> ## 2007-01-09 49.99489 49.99489 49.80454 49.91333
>
> Best,
> Josh
>
>
> On Mon, Jul 25, 2022 at 3:20 PM akshay kulkarni  wrote:
> >
> > Dear members,
> >  I have:
> >
> >
> > > head(testOHLC)
> >HINDUNILVR.NS.Open HINDUNILVR.NS.High HINDUNILVR.NS.Low 
> > HINDUNILVR.NS.Close
> > 2007-01-02 217.80 219.00215.45  
> > 216.40
> > 2007-01-03 217.00 217.65211.05  
> > 212.00
> > 2007-01-04 213.00 214.25209.65  
> > 210.60
> > 2007-01-05 211.40 214.25209.55  
> > 213.35
> > 2007-01-08 213.35 213.35207.10  
> > 210.10
> > 2007-01-09 210.10 214.20208.70  
> > 209.85
> >HINDUNILVR.NS.Volume HINDUNILVR.NS.Adjusted
> > 2007-01-02  2626898   155.0396
> > 2007-01-03  4603921   151.8872
> > 2007-01-04  5486460   150.8841
> > 2007-01-05  5706066   152.8545
> > 2007-01-08  3760443   150.5260
> > 2007-01-09  5474633   150.3468
> >
> > AND:
> >
> >
> > > head(testOHLC["2007-01-09"])
> >HINDUNILVR.NS.Open HINDUNILVR.NS.High HINDUNILVR.NS.Low 
> > HINDUNILVR.NS.Close
> > 2007-01-09  210.1  214.2 208.7  
> > 209.85
> >HINDUNILVR.NS.Volume HINDUNILVR.NS.Adjusted
> > 2007-01-09  5474633   150.3468
> >
> > BUT:
> >
> > > head(testOHLC[-"2007-01-09"])
> >  Error in -"2007-01-09" : invalid argument to unary operator
> >
> > How do remove rows with certain dates in an xts object? This doesn't work:
> >
> > x[-dates] (however, this does: x[dates])
> >
> > Many thanks in advance..
> >
> > Yours sincreley
> > 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.
>
>
>
> --
> Joshua Ulrich  |  about.me/joshuaulrich
> FOSS Trading  |  www.fosstrading.com<http://www.fosstrading.com>



--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com<http://www.fosstrading.com>

[[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] running a scraping code in parallel...

2022-07-14 Thread akshay kulkarni
Dear members,

please feel free to ignore this mail if you feel that it is not about Base R.

  I have the following web scraping code ( i have 500 
stocks to iterate over):
getFirmsDates <- function() {
 rD <- RsDriver(browser="chrome")
 remDr <- rD$client

 { scrape for stock i }
 }

Will the following code work?

DATES <- mclapply(1:500, getFirmsDates, mc.cores = 48)

Basically, there must be 500 chrome instances and rD and remDr are same for all 
iterations. If not any suggestions on how to accomplish the task?

I am using RSelenium and rvest packages.

THanking you,
yours 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] aborting the execution of a function...

2022-07-14 Thread akshay kulkarni
Dear Avi,
 THanks a lot...

Yours sincerely,
AKSHAY M KULKARNI

From: R-help  on behalf of avi.e.gr...@gmail.com 

Sent: Thursday, July 14, 2022 1:39 AM
To: 'R help Mailing list' 
Subject: Re: [R] aborting the execution of a function...

Jeff & Akshay,

What you say is true if you just call a function and do not arrange to
handle various interrupts and errors.

Obviously if you find a way to gracefully handle an error then you can opt
to have your work so far saved. For what is meant to be a fatal error,
though, you are expected to GIVE UP or at least exit rapidly after doing
something graceful.

I am not clear what machine the user is using and their R setup. It may be
you can find something like a try() or suspendInterrupts method to catch and
handle control-C but may I offer a DIFFERENT solution?

You can identify your R process and send it some other milder signal that
can easily be caught or change your loop to slow it down a bit more.

For example, change your code so it opens a file and writes data to it in
some format like one result per line or a CSV format or whatever makes you
happy. Your loop adds new lines/items to the file and perhaps even closes
the file on interrupt or whatever works. Or it writes the results to the
console where you can copy/paste from if not too long.

And, consider having long-running code periodically check something in the
environment looking for a signal. Say every hundredth iteration it checks
for the existence of a file called "STOP_IT.stupid" and if it sees it,
removes it and exits gracefully while preserving your results somehow or
whatever you need. No interrupt needed, just create an empty file or other
logical marker.

Another variant is to use some form of threading or subprocess that does the
work somewhat in the background but can get commands from the foreground
process as needed including a request to stop. Again, no horrible signals
that kill the program.

And note on some systems, a process can be halted and resumed, if the
problem is that it has run a long time and is using too many resources at a
time they are needed.



-Original Message-
From: R-help  On Behalf Of Jeff Newmiller
Sent: Wednesday, July 13, 2022 3:49 PM
To: r-help@r-project.org; akshay kulkarni ; R help
Mailing list 
Subject: Re: [R] aborting the execution of a function...

This would be easy for you to test on a small example on your local
computer.

But the answer is "no". Nothing is assigned if the function does not return
normally... and Ctrl+C is anything but normal.

On July 13, 2022 12:19:58 PM PDT, akshay kulkarni 
wrote:
>Dear members,
> I am running a large scraping code in a very
powerful AWS ec2 instance:
>
>DATES <- getFirms Dates()
>
>It iterates over 500 stocks from a website. Despite the power of the
machine, the execution is very slow.
>
>If I abort the function (by ctrl + C), after, say 150th iteration, the
DATES object will still contain the scraped data untill the 150th iteration,
right? ( The rest of the 350 entries will be NA's, I suppose).
>
>Many thanks in advance.
>
>Yours 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-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] aborting the execution of a function...

2022-07-14 Thread akshay kulkarni
Dear Bill,
Many thanks ..

Yours sincrely,
AKSHAY M KULKARNI

From: Bill Dunlap 
Sent: Thursday, July 14, 2022 1:28 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] aborting the execution of a function...

You could write a function that returns an environment (or list if you prefer) 
containing the results collected before the interrupt by using 
tryCatch(interrupt=...).  E.g.,

doMany <- function(names) {
resultEnv <- new.env(parent=emptyenv())
tryCatch(
for(name in names) resultEnv[[name]] <- Sys.sleep(1), # replace 
Sys.sleep(1) by getStuffFromWeb(name)
interrupt = function(e) NULL)
resultEnv
}

Use it as

> system.time(e <- doMany(state.name<http://state.name>)) # hit Esc or ^C after 
> a few seconds
^C   user  system elapsed
  0.001   0.000   4.390
> names(e)
[1] "Alabama"  "Alaska"   "Arizona"  "Arkansas"
> eapply(e, identity)
$Alabama
NULL

$Alaska
NULL

$Arizona
NULL

$Arkansas
NULL

-Bill

On Wed, Jul 13, 2022 at 12:20 PM akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
Dear members,
 I am running a large scraping code in a very powerful 
AWS ec2 instance:

DATES <- getFirms Dates()

It iterates over 500 stocks from a website. Despite the power of the machine, 
the execution is very slow.

If I abort the function (by ctrl + C), after, say 150th iteration, the DATES 
object will still contain the scraped data untill the 150th iteration, right? ( 
The rest of the 350 entries will be NA's, I suppose).

Many thanks in advance.

Yours sincerely,
AKSHAY M KULKARNI



[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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] inconsistency in switch statements.....

2022-09-07 Thread akshay kulkarni
Dear Bert,
Thanks...I went through the doc pages but couldn't glean 
from that that for numeric options one has to backtick it. I is not given in 
the doc page...I actually had hundreds of different choices and so cannot 
depend on evaluation by position...Thanks again...I got to know that 2 is not a 
valid identifier but`2` is!

Yours sincerely,
AKSHAY M KULKARNI


From: Bert Gunter 
Sent: Thursday, September 8, 2022 12:39 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] inconsistency in switch statements.

Well, as it states on the Help page, which should always be the first
place to look for, ummm, help:

"If the value of EXPR is not a character string it is coerced to
integer. Note that this also happens for factors, with a warning, as
typically the character level is meant. If the integer is between 1
and nargs()-1 then the corresponding element of ... is evaluated and
the result returned: thus if the first argument is 3 then the fourth
argument is evaluated and returned."

So following up on Bill's comment, the arguments do not even need to
be names when Stst evaluates to) an integer:

> Stst <- 2
> switch(Stst, print("NO"), print("YES"))
[1] "YES"

Cheers,
Bert

On Wed, Sep 7, 2022 at 11:35 AM akshay kulkarni  wrote:
>
> Dear members,
>  The following is my code:
>
> > Stst <- 2
> > switch(Stst, 1 = print("NO"), 2 = print("YES"))
> Error: unexpected '=' in "switch(Stst, 1 ="
>
> Why isn't it printing "YES" on to the console?
>
> many thanks in advance.
>
> Thanking you,
> Yours 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.

[[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] inconsistency in switch statements.....

2022-09-07 Thread akshay kulkarni
Dear Andrew,
 Its working. Thanks a lot

Yours sincerely,
AKSHAY M KULKARNI


From: Andrew Simmons 
Sent: Thursday, September 8, 2022 12:08 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] inconsistency in switch statements.

1 and 2 are not valid identifiers in R, so you need to surround them with 
backticks to make them valid, the same as quoting a string:

switch(Stst, `1` = print("NO"), `2` = print("YES"))


On Wed., Sep. 7, 2022, 14:35 akshay kulkarni, 
mailto:akshay...@hotmail.com>> wrote:
Dear members,
 The following is my code:

> Stst <- 2
> switch(Stst, 1 = print("NO"), 2 = print("YES"))
Error: unexpected '=' in "switch(Stst, 1 ="

Why isn't it printing "YES" on to the console?

many thanks in advance.

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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] inadequacy in as.integer....

2022-09-11 Thread akshay kulkarni
Dear Tim,
  I am using the result of cumsum(), which has leading zeroes, 
(like 0 0 1 1 2 2), coerce it to a character vector, collapse it, and then 
coerce it back to an integer to compare it in a switch statement. But now I got 
it. I can just use the collapsed character value...THanks anyways...

Yours sincerely,
AKSHAY M KULKARNI


From: Ebert,Timothy Aaron 
Sent: Monday, September 12, 2022 12:30 AM
To: akshay kulkarni ; R help Mailing list 

Subject: RE: inadequacy in as.integer


Can you tell us why you want to do this? Is there something special about 09098 
versus 9098 or 009098? In any mathematical operation these are all the same 
number.



Tim



From: akshay kulkarni 
Sent: Sunday, September 11, 2022 2:58 PM
To: Ebert,Timothy Aaron ; R help Mailing list 

Subject: Re: inadequacy in as.integer



[External Email]

Dear Tim,

  So there is no way to coerce "09098" to 09098?



Yours sincerely,

AKSHAY M KULKARNI



From: Ebert,Timothy Aaron mailto:teb...@ufl.edu>>
Sent: Monday, September 12, 2022 12:07 AM
To: akshay kulkarni mailto:akshay...@hotmail.com>>; R 
help Mailing list mailto:r-help@r-project.org>>
Subject: RE: inadequacy in as.integer



Keep as character.

Tim

-Original Message-
From: R-help 
mailto:r-help-boun...@r-project.org>> On Behalf 
Of akshay kulkarni
Sent: Sunday, September 11, 2022 12:22 PM
To: R help Mailing list mailto:r-help@r-project.org>>
Subject: [R] inadequacy in as.integer

[External Email]

Dear members,
 I came across this queer thing during my analysis:
> as.integer("09098")


Any idea on how to retain the "0"?

Yours sincerely,
AKSHAY M KULKARNI

[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-helpdata=05%7C01%7Ctebert%40ufl.edu%7C70a6ae074d1e42c17e9108da9411d934%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637985101625267716%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=%2FV4NoU8j%2F9KIYX5ExaY93fwQf%2FPqx1kisbt87Mj9%2F7Q%3Dreserved=0<https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-help=05%7C01%7Ctebert%40ufl.edu%7C6a2c6801bcbf4bf0e6f708da94278655%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637985194721617829%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=IimcrUXv0HF%2F2FyD5S699dgqmGAZe5%2FKcRqHTiHDyvE%3D=0>
PLEASE do read the posting guide 
https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.htmldata=05%7C01%7Ctebert%40ufl.edu%7C70a6ae074d1e42c17e9108da9411d934%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637985101625267716%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=BA0o8oGcR%2FFBX9Vth5DuitlZnTGG7rNDmFga3ixZ9j4%3Dreserved=0<https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.r-project.org%2Fposting-guide.html=05%7C01%7Ctebert%40ufl.edu%7C6a2c6801bcbf4bf0e6f708da94278655%7C0d4da0f84a314d76ace60a62331e1b84%7C0%7C0%7C637985194721617829%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=HQmvbdpGZj4Mt64EwTre5pdzE9xHJ8mdWHN8c%2Fye3CY%3D=0>
and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

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


[R] difference between script and a function....

2022-12-24 Thread akshay kulkarni
Dear members,
I will be running scripts automatically in RHEL 
with crontab. I want to know the differences between running  a script and a 
function. in particular:


  1.  An execution environment will be created for the function. what about a 
script? Is the execution environment the global environment?
  2.  What happens if I use return() at the end of a script?
  3.  I came to know that when you use R CMD BATCH, a file will be created and 
the output will be saved to the file. How do I output what I want to output in 
a script? Should I use return()? Will ALL the intermediate objects be stored ?
  4.  When I run a script, it will have access to the objects in the global 
environment right? i.e I can use all the functions in the global environment, 
right?
  5.  Any links to resources for further information? How do i access the 
relevant documentation?

ANy help will be greatly appreciated...

thanking you,
yours 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] difference between script and a function....

2022-12-24 Thread akshay kulkarni
Dear Ivan,
   Thanks a lot.!

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Ivan Krylov 
Sent: Saturday, December 24, 2022 9:27 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] difference between script and a function

On Sat, 24 Dec 2022 15:47:14 +
akshay kulkarni  wrote:

> How do you debug if there is an error, particularly if I run the
> script from the BASH prompt?

Post-mortem debugging for non-interactive R scripts can be enabled by
setting options(error = quote(dump.frames("A_SUITABLE_FILE_NAME",
to.file = TRUE))) in your script. See ?dump.frames for more information.

When you're running command-line R interactively, the main tools at
your disposal are traceback() and browser() (see their respective help
pages). There are two main ways to use the browser: (1) by setting the
debugging flag on a function via debug(function) or debugonce(function)
-- you will land in the browser when the function is called -- and (2)
by setting options(error = recover), which will launch the browser at
the time of the crash, letting you walk the stack and inspect the
values of various variables.

For more information on pure-R debugging, see The R Inferno book:
<https://www.burns-stat.com/documents/books/the-r-inferno/>

--
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] difference between script and a function....

2022-12-24 Thread akshay kulkarni
dear Ivan,
  Thanks for the reply. One last question:


  1.  How do you debug if there is an error, particularly if I run the script 
from the BASH prompt? The closest I have come to debugging a script is when I 
source the script in Rstudio. There everything is intiutive...but from the 
Linux prompt?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Ivan Krylov 
Sent: Saturday, December 24, 2022 8:52 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] difference between script and a function

On Sat, 24 Dec 2022 14:54:52 +
akshay kulkarni  wrote:

> If there is  some error in the script, the error will be output to
> the stdout? Or to the file that it creates for saving the output of
> the script?

When using Rscript: to stderr, to be precise.

When using R CMD BATCH: to the Rout file.

> Will ALL the intermediate objects be stored ?

May I shamelessly plug my own package, depcache? Using its cache()
function, you can save intermediate objects into *.rds files in a
relatively transparent manner. By default, they are stored in a
subdirectory of the working directory. A downside is that I haven't
come up with a useful cache expiration strategy yet.

A more involved approach that will also let you access your
intermediates is provided by the "targets" package, not only on CRAN
but also peer-reviewed by rOpenSci.

--
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] difference between script and a function....

2022-12-24 Thread akshay kulkarni
Dear Simmons,
Thanks a lot. One more question:


  1.  If there is  some error in the script, the error will be output to the 
stdout? Or to the file that it creates for saving the output of the script?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Andrew Simmons 
Sent: Saturday, December 24, 2022 8:18 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] difference between script and a function

1. The execution environment for a script is the global environment. Each R 
script run from a shell will be given its own global environment. Each R 
session has exactly one global environment, but you can have several active R 
sessions.

2. Using return in a script instead of a function will throw an error

Error: no function to return from, jumping to top level

3. You can use print(), cat(), and writeLines() to write to the output. It does 
not save your R objects before it exits the script. You could use save() or 
save.image() to save your objects, or possibly saveRDS() if you are only 
looking to save one object. You could also use source() if you just want the 
objects from another script.

4. Will you have shared access to the objects in another R session? No, objects 
are not shared, unless you've got something weird setup with external pointers. 
Each session has it owns global environment.

5. Any of the doc pages for the functions I listed above would help, you can 
also do

?utils::Rscript

[[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] error in exists.....

2022-12-28 Thread akshay kulkarni
Dear Bert,
  Thanks for sharing your views...

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Bert Gunter 
Sent: Wednesday, December 28, 2022 12:28 AM
To: akshay kulkarni 
Cc: Sarah Goslee ; R help Mailing list 

Subject: Re: [R] error in exists.

There is no substitute for experience/knowledge; nor any universally
optimal strategy for debugging. But using the debugging tools that R
provides -- ?debug, ?traceback, ?recover (e.g. in the form of
options(error = utils::recover) ) -- should always be the first goto
(or maybe the second after carefully re-reading relevant Help docs).
However, the debugging tools would not have helped here afaics.

-- Bert

On Tue, Dec 27, 2022 at 10:22 AM akshay kulkarni  wrote:
>
> Dear Bert,
>Yeah, it's workingSometimes (only sometimes) I feel 
> that I am troubling this list with very simple questions the answer to which 
> I always happen to find myself a little after...any solutions for that (you 
> seem to be an omniscient person)!?
>
> Thanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
> 
> From: Bert Gunter 
> Sent: Tuesday, December 27, 2022 11:39 PM
> To: akshay kulkarni 
> Cc: Sarah Goslee ; R help Mailing list 
> 
> Subject: Re: [R] error in exists.
>
> You are confused about the list hierarchy. Perhaps this will explain:
> > i <- 1
> >  E <- new.env()
> >   E$L <- list()  ## L is an empty list in E
> >   i <- 1
> >E$L[[i]]$T1A1 <- Sys.time()
> Error in `*tmp*`[[i]] : subscript out of bounds
> ## L is empty, so L[[1]] does not exist; is not a list;
> ## cannot have a value assigned to a component
> ## The following works:
> ## Create an empty list as a sublist of L
> >  E$L[[1]] <- list()
> ## Now create and assign to a component of the empty list
> >  E$L[[i]]$T1A1 <- Sys.time()
> > E$L ## a list
> [[1]]  ## whose first component is a list
> [[1]]$T1A1 ## T1A1 named component of L[[1]]
> [1] "2022-12-27 10:00:10 PST"
>
> ergo, no conundra... (assuming I've understood you correctly)
>
> Cheers,
> Bert
>
> On Tue, Dec 27, 2022 at 9:57 AM akshay kulkarni  wrote:
> >
> > Dear Sarah,
> >  I had this also before the assignment of Sys.time():
> >
> > > E$L[[i]] <- i
> >
> > After assignment of Sys.time():
> >
> > > E$L
> > [[1]]
> > [[1]][[1]]
> > [1] 1
> >
> > [[1]]$T1A1
> > [1] "2022-12-27 22:40:02 IST"
> >
> > regrets for not sharing this ..Can you reproduce it now?
> >
> > Thanking you,
> > Yours sincerely,
> > AKSHAY M KULKARNI
> > 
> > From: Sarah Goslee 
> > Sent: Tuesday, December 27, 2022 11:20 PM
> > To: akshay kulkarni 
> > Cc: R help Mailing list 
> > Subject: Re: [R] error in exists.
> >
> > Hi,
> >
> > I can't create the desired object using the code you provided, but if
> > I create it in two steps so that E$L[[i]]$T1A1 does exist, exist()
> > returns TRUE.
> >
> > E <- new.env()
> > E$L <- list()
> > i <- 1
> > E$L[[i]]$T1A1 <- Sys.time()
> >
> > # returns: Error in `*tmp*`[[i]] : subscript out of bounds
> >
> > E$L[[i]] <- list()
> > E$L[[i]]$T1A1 <- Sys.time()
> >
> >
> > exists("T1A1", where = E$L[[i]])
> > # returns: [1] TRUE
> >
> >
> > > str(E$L)
> > List of 1
> >  $ :List of 1
> >   ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26"
> >
> > Sarah
> >
> > On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni  
> > wrote:
> > >
> > > Dear members,
> > >  I have the following code:
> > > >  E <- new.env()
> > > >  E$L <- list()
> > > >  i <- 1
> > > >   E$L[[i]]$T1A1 <- Sys.time()
> > > > exists("T1A1", where = E$L[[i]])
> > > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) :
> > >   attempt to use zero-length variable name
> > >
> > > I want the output of the exists() function to be TRUE. In any case:
> > >
> > > > E$L[[1]]$T1A1
> > > [1] "2022-12-27 22:40:02 IST"
> > >
> > > Please help me solve this conundrum
> > >
> > > Thanking you,
> > > Yours sincerely,
> > > AKSHAY M KULKARNI
> > >
> > >
> > > [[alternative HTML versi

Re: [R] return value of {....}

2023-01-10 Thread akshay kulkarni
Dear Avi,
 Thanks for your reply...your exhortations are indeed 
justified...! But one caveat: I was not complaining about anything...just was 
curious of the rationale of a particular designThanks again...

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: R-help  on behalf of avi.e.gr...@gmail.com 

Sent: Tuesday, January 10, 2023 4:39 AM
Cc: 'R help Mailing list' 
Subject: Re: [R] return value of {}

Akshay,

Your question seems a tad mysterious to me as you are complaining about
NOTHING.

R was designed to return single values. The last statement executed in a
function body, for example, is the value returned even when not at the end.

Scoping is another issue entirely. What is visible is another discussion.

So, yes, if you can see ALL the variables, you might see the last one BUT
there often is no variable at the end. There is an expression that evaluates
to a value with no NAME attached. You cannot reference that unless the block
in curly braces returns that value.

You can design your own language any way you want. The people who designed R
did it this way. Mind you, the most common use of curly braces is probably
in function bodies, or if/else blocks and loops, not quite what you are
looking at and complaining about. The design is what it is.

Others require things like an explicit return() statement. R chose not to.

And if the value is redundant for you, who cares?

Did you know that when running a program in the interpreter the last value
is stored in a variable like this:

> x <- 6
> .Last.value
[1] 6

Why would that duplicate be needed or useful?

Consider a partial calculation you want to reuse in another context:

> y = x*2 + 2*x -3
> z <- .Last.value/2
> z
[1] 10.5

Yes, you could have used "y" ...




-Original Message-----
From: R-help  On Behalf Of akshay kulkarni
Sent: Monday, January 9, 2023 12:06 PM
To: Valentin Petzel 
Cc: R help Mailing list 
Subject: Re: [R] return value of {}

Dear Valentin,
  But why should {} "return" a value? It could
just as well evaluate all the expressions and store the resulting objects in
whatever environment the interpreter chooses, and then it would be left to
the user to manipulate any object he chooses. Don't you think returning the
last, or any value, is redundant? We are living in the 21st century world,
and the R-core team might,I suppose, have a definite reason for"returning"
the last value. Any comments?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI


From: Valentin Petzel 
Sent: Monday, January 9, 2023 9:18 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] return value of {}

Hello Akshai,

I think you are confusing {...} with local({...}). This one will evaluate
the expression in a separate environment, returning the last expression.

{...} simply evaluates multiple expressions as one and returns the result of
the last line, but it still evaluates each expression.

Assignment returns the assigned value, so we can chain assignments like this

a <- 1 + (b <- 2)

conveniently.

So when is {...} useful? Well, anyplace where you want to execute complex
stuff in a function argument. E.g. you might do:

data %>% group_by(x) %>% summarise(y = {if(x[1] > 10) sum(y) else mean(y)})

Regards,
Valentin Petzel

09.01.2023 15:47:53 akshay kulkarni :

> Dear members,
>  I have the following code:
>
>> TB <- {x <- 3;y <- 5}
>> TB
> [1] 5
>
> It is consistent with the documentation: For {, the result of the last
expression evaluated. This has the visibility of the last evaluation.
>
> But both x AND y are created, but the "return value" is y. How can this be
advantageous for solving practical problems? Specifically, consider the
following code:
>
> F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}
>
> Both expr5 and expr7 are created, and are accessible by the code
> outside of the nested braces right? But the "return value" of the
> nested braces is expr7. So doesn't this mean that only expr7 should be
> accessible? Please help me entangle this (of course the return value
> of F is expr10, and all the other objects created by the preceding
> expressions are deleted. But expr5 is not, after the control passes
> outside of the nested braces!)
>
> Thanking you,
> Yours 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.

[[alter

Re: [R] return value of {....}

2023-01-10 Thread akshay kulkarni
Dear Avi,
 THanks a lot..much of the "rationale" is explained !

Thanking you,
Yours sincerely
AKSHAY M KULKARNI

From: avi.e.gr...@gmail.com 
Sent: Tuesday, January 10, 2023 10:23 PM
To: 'akshay kulkarni' 
Cc: 'R help Mailing list' 
Subject: RE: [R] return value of {}


Fair enough, Akshay. Wondering why a design was chosen is reasonable.



There are languages like python that allow unpacking multiple values and it is 
not uncommon to return multiple things from some constructs as in this:



>>> a,b,c = { 4, 5, 6 }

>>> a

4

>>> b

5

>>> c

6



But that is a bit of an illusion as the thing in curly braces is a very 
different creature called a set with three items.  Python does not need or use 
curly braces for the purposes used in R as indentation levels group things.



It is different in design. I do not know what other computer languages you have 
used, but R is NOT them and must be approached for what it is, and it is a 
fairly simple paradigm for the last item in a sequence to be the value of the 
sequence. You can return multiple things, if you wish, in other ways. Such as 
making a list:



vals <- list(1+2, sin(.7), cos(.7))



> vals[2:3]

[[1]]

[1] 0.6442177



[[2]]

[1] 0.7648422



You get the idea. R returns ONE thing and it ca have parts, named or not.





From: akshay kulkarni 
Sent: Tuesday, January 10, 2023 9:33 AM
To: avi.e.gr...@gmail.com
Cc: 'R help Mailing list' 
Subject: Re: [R] return value of {}



Dear Avi,

 Thanks for your reply...your exhortations are indeed 
justified...! But one caveat: I was not complaining about anything...just was 
curious of the rationale of a particular designThanks again...



Thanking you,

Yours sincerely,

AKSHAY M KULKARNI



From: R-help 
mailto:r-help-boun...@r-project.org>> on behalf 
of avi.e.gr...@gmail.com<mailto:avi.e.gr...@gmail.com> 
mailto:avi.e.gr...@gmail.com>>
Sent: Tuesday, January 10, 2023 4:39 AM
Cc: 'R help Mailing list' mailto:r-help@r-project.org>>
Subject: Re: [R] return value of {}



Akshay,

Your question seems a tad mysterious to me as you are complaining about
NOTHING.

R was designed to return single values. The last statement executed in a
function body, for example, is the value returned even when not at the end.

Scoping is another issue entirely. What is visible is another discussion.

So, yes, if you can see ALL the variables, you might see the last one BUT
there often is no variable at the end. There is an expression that evaluates
to a value with no NAME attached. You cannot reference that unless the block
in curly braces returns that value.

You can design your own language any way you want. The people who designed R
did it this way. Mind you, the most common use of curly braces is probably
in function bodies, or if/else blocks and loops, not quite what you are
looking at and complaining about. The design is what it is.

Others require things like an explicit return() statement. R chose not to.

And if the value is redundant for you, who cares?

Did you know that when running a program in the interpreter the last value
is stored in a variable like this:

> x <- 6
> .Last.value
[1] 6

Why would that duplicate be needed or useful?

Consider a partial calculation you want to reuse in another context:

> y = x*2 + 2*x -3
> z <- .Last.value/2
> z
[1] 10.5

Yes, you could have used "y" ...




-Original Message-
From: R-help 
mailto:r-help-boun...@r-project.org>> On Behalf 
Of akshay kulkarni
Sent: Monday, January 9, 2023 12:06 PM
To: Valentin Petzel mailto:valen...@petzel.at>>
Cc: R help Mailing list mailto:r-help@r-project.org>>
Subject: Re: [R] return value of {}

Dear Valentin,
  But why should {} "return" a value? It could
just as well evaluate all the expressions and store the resulting objects in
whatever environment the interpreter chooses, and then it would be left to
the user to manipulate any object he chooses. Don't you think returning the
last, or any value, is redundant? We are living in the 21st century world,
and the R-core team might,I suppose, have a definite reason for"returning"
the last value. Any comments?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI


From: Valentin Petzel mailto:valen...@petzel.at>>
Sent: Monday, January 9, 2023 9:18 PM
To: akshay kulkarni mailto:akshay...@hotmail.com>>
Cc: R help Mailing list mailto:r-help@r-project.org>>
Subject: Re: [R] return value of {}

Hello Akshai,

I think you are confusing {...} with local({...}). This one will evaluate
the expression in a separate environment, returning the last expression.

{...} simply evaluates multiple expressions as one and returns the result of
the last lin

[R] extracting a table from pdf file....

2023-01-08 Thread akshay kulkarni
dear members,
I am extracting a pdf table into a data frame from 
this URL:

https://www.canmoney.in/pdf/INTRADAYLEVERAGE-20220531-latest.pdf

I am using extract_table() from the tabulizer package (it is archived and have 
installed it from github)

IDTpdf <- 
extract_tables("https://www.canmoney.in/pdf/INTRADAYLEVERAGE-20220531-latest.pdf",output="data.frame;)

But IDTpdf consists of four different dfs, and I want to collapse them into 
one. The dput of IDTpdf:

list(structure(list(SCRIPS.AVAILABLE.FOR.INTRADAY.WITH.LEVERAGES.PROVIDED.ON.THEM
 = c("S.No.",
"times)", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21",
"22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32",
"33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43",
"44", "45", "46", "47", "48", "49", "50", "51", "52", "53"),
X = c("Scrip Name", "", "ALKEM LABORATORIES LTD.", "ATUL LTD",
"ABB INDIA LIMITED", "AARTI INDUSTRIES LTD", "ABBOTT INDIA LIMITED",
"ADITYA BIRLA CAPITAL LTD.", "ADITYA BIRLA FASHION & RT",
"ACC LIMITED", "ADANI ENTERPRISES LIMITED", "ADANI PORT & SEZ LTD",
"AMARA RAJA BATTERIES LTD.", "ASTRAL LIMITED", "AMBUJA CEMENTS LTD",
"ALEMBIC PHARMA LTD", "APOLLO HOSPITALS ENTER. L", "APOLLO TYRES LTD",
"ASHOK LEYLAND LTD", "ASIAN PAINTS LIMITED", "AU SMALL FINANCE BANK LTD",
"AUROBINDO PHARMA LTD", "AXIS BANK LIMITED", "BAJAJ AUTO LIMITED",
"BAJAJ FINSERV LTD.", "BAJAJ FINANCE LIMITED", "BALRAMPUR CHINI MILLS LTD",
"BANDHAN BANK LIMITED", "BANK OF BARODA", "BATA INDIA LTD",
"BHARAT ELECTRONICS LTD", "BERGER PAINTS (I) LTD", "BHARTI AIRTEL LIMITED",
"BHEL", "BIOCON LIMITED.", "BOSCH LIMITED", "BRITANNIA INDUSTRIES LTD",
"BIRLASOFT LIMITED", "ZYDUS LIFESCIENCES LTD", "CANARA BANK",
"CAN FIN HOMES LTD", "CHAMBAL FERTILIZERS LTD", "CHOLAMANDALAM IN & FIN CO",
"CIPLA LTD", "COAL INDIA LTD", "COFORGE LIMITED", "COLGATE PALMOLIVE LTD.",
"CONTAINER CORP OF IND LTD", "COROMANDEL INTERNTL. LTD",
"CROMPT GREA CON ELEC LTD", "CITY UNION BANK LTD", "CUMMINS INDIA LTD",
"DABUR INDIA LTD", "DEEPAK NITRITE LTD", "DELTA CORP LIMITED"
), X.1 = c("Symbol Series", "", "ALKEM", "ATUL", "ABB", "AARTIIND",
"ABBOTINDIA", "ABCAPITAL", "ABFRL", "ACC", "ADANIENT", "ADANIPORTS",
"AMARAJABAT", "ASTRAL", "AMBUJACEM", "APLLTD", "APOLLOHOSP",
"APOLLOTYRE", "ASHOKLEY", "ASIANPAINT", "AUBANK", "AUROPHARMA",
"AXISBANK", "BAJAJ-AUTO", "BAJAJFINSV", "BAJFINANCE", "BALRAMCHIN",
"BANDHANBNK", "BANKBARODA", "BATAINDIA", "BEL", "BERGEPAINT",
"BHARTIARTL", "BHEL", "BIOCON", "BOSCHLTD", "BRITANNIA",
"BSOFT", "ZYDUSLIFE", "CANBK", "CANFINHOME", "CHAMBLFERT",
"CHOLAFIN", "CIPLA", "COALINDIA", "COFORGE", "COLPAL", "CONCOR",
"COROMANDEL", "CROMPTON", "CUB", "CUMMINSIND", "DABUR", "DEEPAKNTR",
"DELTACORP"), X.2 = c("Leverage (in", "", "4.5", "4.5", "4.5",
"4.5", "4.5", "4.5", "4.5", "4.5", "4", "4.5", "4.5", "4.5",
"4.5", "4.5", "4.5", "4.5", "4.5", "4.5", "4.5", "4.5", "4.5",
"4.5", "4.5", "4.5", "4", "4", "4.5", "4.5", "4.5", "4.5",
"4.5", "4", "4.5", "4.5", "4.5", "4", "4.5", "4", "4.5",
"4", "4", "4.5", "4.5", "4", "4.5", "4.5", "4.5", "4.5",
"4.5", "4.5", "4.5", "4.5", "4")), class = "data.frame", row.names = c(NA,
-55L)), structure(list(X54 = 55:110, DIVI.S.LABORATORIES.LTD = c("DIXON TECHNO 
(INDIA) LTD",
"DLF LIMITED", "DR. REDDY S LABORATORIES", "ESCORTS INDIA LTD",
"EXIDE INDUSTRIES LTD", "FEDERAL BANK LTD", "FIRSTSOURCE SOLU. LTD.",
"GAIL (INDIA) LTD", "GLENMARK PHARMACEUTICALS", "GMR INFRASTRUCTURE LTD.",
"GUJ NAR VAL FER & CHEM L", "DALMIA BHARAT LIMITED", "GODREJ CONSUMER PRODUCTS",
"GRANULES INDIA LIMITED", "GRASIM INDUSTRIES LTD", "GUJARAT STATE PETRO LTD",
"GUJARAT GAS LIMITED", "HINDUSTAN AERONAUTICS LTD", "HAVELLS INDIA LIMITED",
"HCL TECHNOLOGIES LTD", "HDFC LTD", "HDFC AMC LIMITED", "HDFC BANK LTD",
"HDFC LIFE INS CO LTD", "HERO MOTOCORP LIMITED", "HINDALCO INDUSTRIES LTD",
"HINDUSTAN COPPER LTD", "HONEYWELL AUTOMATION IND", "ICICI BANK LTD.",
"ICICI LOMBARD GIC LIMITED", "ICICI PRU LIFE INS CO LTD", "IDFC LIMITED",
"IDFC FIRST BANK LIMITED", "INDIAN ENERGY EXC LTD", "INDRAPRASTHA GAS LTD",
"THE INDIAN HOTELS CO. LTD", "THE INDIA CEMENTS LIMITED", "INDIAMART INTERMESH 
LTD",
"INTERGLOBE AVIATION LTD", "INDUSIND BANK LIMITED", "INDUS TOWERS LIMITED",
"INFOSYS LIMITED", "INTELLECT DESIGN ARENA", "INDIAN OIL CORP LTD",
"IPCA LABORATORIES LTD", "INDIAN RAIL TOUR CORP LTD", "ITC LTD",
"JINDAL STEEL & POWER LTD", "JSW STEEL LIMITED", "JUBILANT FOODWORKS LTD",
"KOTAK MAHINDRA BANK LTD", "L FINANCE HOLDINGS LTD", "DR. LAL PATH LABS LTD.",
"LAURUS LABS LIMITED", "LIC HOUSING FINANCE LTD", "LARSEN & TOUBRO LTD."
), DIVISLAB = c("DIXON", "DLF", "DRREDDY", "ESCORTS", "EXIDEIND",
"FEDERALBNK", "FSL", "GAIL", "GLENMARK", "GMRINFRA", "GNFC",
"DALBHARAT", "GODREJCP", "GRANULES", "GRASIM", "GSPL", "GUJGASLTD",
"HAL", 

Re: [R] extracting a table from pdf file....

2023-01-08 Thread akshay kulkarni
Dear jeff,
  Thanks a lot

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Jeff Newmiller 
Sent: Sunday, January 8, 2023 3:59 PM
To: r-help@r-project.org ; akshay kulkarni 
; R help Mailing list 
Subject: Re: [R] extracting a table from pdf file

Here is a start for two of them... PDF files are actually programs written in 
the Postscript language... there are a lot of ways to write a program to put 
marks on a page, so this mess is actually not as bad a result as you might have 
encountered.

str(IDTpdf)

DF <- IDTpdf[[1]][ -(1:2), ]
names( DF ) <- c( "SNo", "Scrip", "Symbol", "Leverage" )
DF$SNo <- as.integer( DF$SNo )
DF$Leverage <- as.numeric( DF$Leverage )
IDTpdf[[ 1 ]] <- DF

DF <- IDTpdf[[2]]
names( DF ) <- c( "SNo", "Scrip", "Symbol", "Leverage" )
DF <- rbind(
  data.frame(
SNo = 54
  , Symbol = "DIVISLAB"
  , Scrip = "DIVIS LABORATORIES LTD"
  , Leverage = 4.5
  )
, DF
)
IDTpdf[[ 2 ]] <- DF

do.call( rbind, IDTpdf[ 1:2 ] )

On January 8, 2023 12:59:58 AM PST, akshay kulkarni  
wrote:
>dear members,
>I am extracting a pdf table into a data frame from 
> this URL:
>
>https://www.canmoney.in/pdf/INTRADAYLEVERAGE-20220531-latest.pdf
>
>I am using extract_table() from the tabulizer package (it is archived and have 
>installed it from github)
>
>IDTpdf <- 
>extract_tables("https://www.canmoney.in/pdf/INTRADAYLEVERAGE-20220531-latest.pdf",output="data.frame;)
>
>But IDTpdf consists of four different dfs, and I want to collapse them into 
>one. The dput of IDTpdf:
>
>list(structure(list(SCRIPS.AVAILABLE.FOR.INTRADAY.WITH.LEVERAGES.PROVIDED.ON.THEM
> = c("S.No.",
>"times)", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
>"11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21",
>"22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32",
>"33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43",
>"44", "45", "46", "47", "48", "49", "50", "51", "52", "53"),
>X = c("Scrip Name", "", "ALKEM LABORATORIES LTD.", "ATUL LTD",
>"ABB INDIA LIMITED", "AARTI INDUSTRIES LTD", "ABBOTT INDIA LIMITED",
>"ADITYA BIRLA CAPITAL LTD.", "ADITYA BIRLA FASHION & RT",
>"ACC LIMITED", "ADANI ENTERPRISES LIMITED", "ADANI PORT & SEZ LTD",
>"AMARA RAJA BATTERIES LTD.", "ASTRAL LIMITED", "AMBUJA CEMENTS LTD",
>"ALEMBIC PHARMA LTD", "APOLLO HOSPITALS ENTER. L", "APOLLO TYRES LTD",
>"ASHOK LEYLAND LTD", "ASIAN PAINTS LIMITED", "AU SMALL FINANCE BANK LTD",
>"AUROBINDO PHARMA LTD", "AXIS BANK LIMITED", "BAJAJ AUTO LIMITED",
>"BAJAJ FINSERV LTD.", "BAJAJ FINANCE LIMITED", "BALRAMPUR CHINI MILLS LTD",
>"BANDHAN BANK LIMITED", "BANK OF BARODA", "BATA INDIA LTD",
>"BHARAT ELECTRONICS LTD", "BERGER PAINTS (I) LTD", "BHARTI AIRTEL LIMITED",
>"BHEL", "BIOCON LIMITED.", "BOSCH LIMITED", "BRITANNIA INDUSTRIES LTD",
>"BIRLASOFT LIMITED", "ZYDUS LIFESCIENCES LTD", "CANARA BANK",
>"CAN FIN HOMES LTD", "CHAMBAL FERTILIZERS LTD", "CHOLAMANDALAM IN & FIN 
> CO",
>"CIPLA LTD", "COAL INDIA LTD", "COFORGE LIMITED", "COLGATE PALMOLIVE LTD.",
>"CONTAINER CORP OF IND LTD", "COROMANDEL INTERNTL. LTD",
>"CROMPT GREA CON ELEC LTD", "CITY UNION BANK LTD", "CUMMINS INDIA LTD",
>"DABUR INDIA LTD", "DEEPAK NITRITE LTD", "DELTA CORP LIMITED"
>), X.1 = c("Symbol Series", "", "ALKEM", "ATUL", "ABB", "AARTIIND",
>"ABBOTINDIA", "ABCAPITAL", "ABFRL", "ACC", "ADANIENT", "ADANIPORTS",
&

[R] return value of {....}

2023-01-09 Thread akshay kulkarni
Dear members,
 I have the following code:

> TB <- {x <- 3;y <- 5}
> TB
[1] 5

It is consistent with the documentation: For {, the result of the last 
expression evaluated. This has the visibility of the last evaluation.

But both x AND y are created, but the "return value" is y. How can this be 
advantageous for solving practical problems? Specifically, consider the 
following code:

F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}

Both expr5 and expr7 are created, and are accessible by the code outside of the 
nested braces right? But the "return value" of the nested braces is expr7. So 
doesn't this mean that only expr7 should be accessible? Please help me entangle 
this (of course the return value of F is expr10, and all the other objects 
created by the preceding expressions are deleted. But expr5 is not, after the 
control passes outside of the nested braces!)

Thanking you,
Yours 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] return value of {....}

2023-01-09 Thread akshay kulkarni
Dear Andrew,
  Nice point.

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Andrew Simmons 
Sent: Monday, January 9, 2023 10:52 PM
To: akshay kulkarni 
Cc: Valentin Petzel ; R help Mailing list 

Subject: Re: [R] return value of {}

Returning the last value of { is the basis of functions not needing a return 
statement. Before R invokes a function (specifically a closure), it creates a 
new context. When R evaluates a call to return, it looks for a context to 
return from and finds the context of function, ending the context and the 
evaluation of the function body early. However, if you don't use return, R just 
returns the value from evaluating the function body, and if your function body 
starts with {, it will return the last expression from the function body, as 
desired.

On Mon, Jan 9, 2023, 12:15 akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
Dear Valentin,
  But why should {} "return" a value? It could just 
as well evaluate all the expressions and store the resulting objects in 
whatever environment the interpreter chooses, and then it would be left to the 
user to manipulate any object he chooses. Don't you think returning the last, 
or any value, is redundant? We are living in the 21st century world, and the 
R-core team might,I suppose, have a definite reason for"returning" the last 
value. Any comments?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI


From: Valentin Petzel mailto:valen...@petzel.at>>
Sent: Monday, January 9, 2023 9:18 PM
To: akshay kulkarni mailto:akshay...@hotmail.com>>
Cc: R help Mailing list mailto:r-help@r-project.org>>
Subject: Re: [R] return value of {}

Hello Akshai,

I think you are confusing {...} with local({...}). This one will evaluate the 
expression in a separate environment, returning the last expression.

{...} simply evaluates multiple expressions as one and returns the result of 
the last line, but it still evaluates each expression.

Assignment returns the assigned value, so we can chain assignments like this

a <- 1 + (b <- 2)

conveniently.

So when is {...} useful? Well, anyplace where you want to execute complex stuff 
in a function argument. E.g. you might do:

data %>% group_by(x) %>% summarise(y = {if(x[1] > 10) sum(y) else mean(y)})

Regards,
Valentin Petzel

09.01.2023 15:47:53 akshay kulkarni 
mailto:akshay...@hotmail.com>>:

> Dear members,
>  I have the following code:
>
>> TB <- {x <- 3;y <- 5}
>> TB
> [1] 5
>
> It is consistent with the documentation: For {, the result of the last 
> expression evaluated. This has the visibility of the last evaluation.
>
> But both x AND y are created, but the "return value" is y. How can this be 
> advantageous for solving practical problems? Specifically, consider the 
> following code:
>
> F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}
>
> Both expr5 and expr7 are created, and are accessible by the code outside of 
> the nested braces right? But the "return value" of the nested braces is 
> expr7. So doesn't this mean that only expr7 should be accessible? Please help 
> me entangle this (of course the return value of F is expr10, and all the 
> other objects created by the preceding expressions are deleted. But expr5 is 
> not, after the control passes outside of the nested braces!)
>
> Thanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
> UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> 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<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] return value of {....}

2023-01-09 Thread akshay kulkarni
dear Rui,
 Thanks a lot

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Rui Barradas 
Sent: Monday, January 9, 2023 9:48 PM
To: akshay kulkarni ; R help Mailing list 

Subject: Re: [R] return value of {}

�s 14:47 de 09/01/2023, akshay kulkarni escreveu:
> Dear members,
>   I have the following code:
>
>> TB <- {x <- 3;y <- 5}
>> TB
> [1] 5
>
> It is consistent with the documentation: For {, the result of the last 
> expression evaluated. This has the visibility of the last evaluation.
>
> But both x AND y are created, but the "return value" is y. How can this be 
> advantageous for solving practical problems? Specifically, consider the 
> following code:
>
> F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}
>
> Both expr5 and expr7 are created, and are accessible by the code outside of 
> the nested braces right? But the "return value" of the nested braces is 
> expr7. So doesn't this mean that only expr7 should be accessible? Please help 
> me entangle this (of course the return value of F is expr10, and all the 
> other objects created by the preceding expressions are deleted. But expr5 is 
> not, after the control passes outside of the nested braces!)
>
> Thanking you,
> Yours 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.

Hello,

Everything happens as you have described it, expr5 is accessible outside
{}. Whether it is advantageous to solve pratical problems is another
thing. The way f() is called creates variable `input` and this can be
seen in many places of the R sources. Personally, I find it harder to
read and prefer to break that one-liner into two instructions.

The code below shows a seldom pratical feature, if ever, put to work.


f <- function(X) {
   x <- X; y <- x*2
   u <- {
 z <- y # expr5 creates a variable by assigning it a value
 z*pi   # expr7's value is assigned to u
   }
   v <- u + z   # expr5's value is accessible
   10 * v
}

# the call also creates input
f(input <- 1)
#> [1] 82.83185
.Last.value / 10
#> [1] 0.1
.Last.value - input*2
#> [1] -1
.Last.value / pi
#> [1] 0.3183099
.Last.value / 2
#> [1] 0.5
.Last.value == input
#> [1] TRUE


Hoep this helps,

Rui Barradas


[[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] return value of {....}

2023-01-09 Thread akshay kulkarni
Dear Valentin,
  But why should {} "return" a value? It could just 
as well evaluate all the expressions and store the resulting objects in 
whatever environment the interpreter chooses, and then it would be left to the 
user to manipulate any object he chooses. Don't you think returning the last, 
or any value, is redundant? We are living in the 21st century world, and the 
R-core team might,I suppose, have a definite reason for"returning" the last 
value. Any comments?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI


From: Valentin Petzel 
Sent: Monday, January 9, 2023 9:18 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] return value of {}

Hello Akshai,

I think you are confusing {...} with local({...}). This one will evaluate the 
expression in a separate environment, returning the last expression.

{...} simply evaluates multiple expressions as one and returns the result of 
the last line, but it still evaluates each expression.

Assignment returns the assigned value, so we can chain assignments like this

a <- 1 + (b <- 2)

conveniently.

So when is {...} useful? Well, anyplace where you want to execute complex stuff 
in a function argument. E.g. you might do:

data %>% group_by(x) %>% summarise(y = {if(x[1] > 10) sum(y) else mean(y)})

Regards,
Valentin Petzel

09.01.2023 15:47:53 akshay kulkarni :

> Dear members,
>  I have the following code:
>
>> TB <- {x <- 3;y <- 5}
>> TB
> [1] 5
>
> It is consistent with the documentation: For {, the result of the last 
> expression evaluated. This has the visibility of the last evaluation.
>
> But both x AND y are created, but the "return value" is y. How can this be 
> advantageous for solving practical problems? Specifically, consider the 
> following code:
>
> F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}
>
> Both expr5 and expr7 are created, and are accessible by the code outside of 
> the nested braces right? But the "return value" of the nested braces is 
> expr7. So doesn't this mean that only expr7 should be accessible? Please help 
> me entangle this (of course the return value of F is expr10, and all the 
> other objects created by the preceding expressions are deleted. But expr5 is 
> not, after the control passes outside of the nested braces!)
>
> Thanking you,
> Yours 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.

[[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] return value of {....}

2023-01-09 Thread akshay kulkarni
dear Bert,
   Thanks a lot...

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Bert Gunter 
Sent: Monday, January 9, 2023 9:59 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] return value of {}

Unless you do something special within a function, only the value(s) returned 
are available to the caller. That is the essence of functional-type programming 
languages.

You need to read up on (function) environments in R . You can search on this. 
?function and its links also contain useful information, but it may too terse 
to be explicable to you. There are of course many available references on the 
internet.

I believe your mental model for how R works is flawed, and you have some 
homework to do to correct it. I may be wrong, naturally, but you can judge by 
looking at some tutorials.

-- Bert

On Mon, Jan 9, 2023 at 6:47 AM akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
Dear members,
 I have the following code:

> TB <- {x <- 3;y <- 5}
> TB
[1] 5

It is consistent with the documentation: For {, the result of the last 
expression evaluated. This has the visibility of the last evaluation.

But both x AND y are created, but the "return value" is y. How can this be 
advantageous for solving practical problems? Specifically, consider the 
following code:

F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}

Both expr5 and expr7 are created, and are accessible by the code outside of the 
nested braces right? But the "return value" of the nested braces is expr7. So 
doesn't this mean that only expr7 should be accessible? Please help me entangle 
this (of course the return value of F is expr10, and all the other objects 
created by the preceding expressions are deleted. But expr5 is not, after the 
control passes outside of the nested braces!)

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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] on parallel package.....

2023-01-08 Thread akshay kulkarni
dear members,
I want to parallelize a scraping code. Is 
mclapply() and clusterApplyLB() similar in functionality? I read the 
documentation and noted that there is copious information on clusyterApplyLB(), 
but not much on mclapply (it just says that on Unix alikes mclapply "uses 
parallel oprations"). I have a AWS EC2 Linux instance. Can I substitute 
mclapply() for clusterApplyLB()? Where can I get more information on mclapply()?

any help will be greatly appreciated
Thanking you,
Yours 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.


[R] free_port returning only one port...

2023-01-08 Thread akshay kulkarni
Dear members,
I am using free_port from the netstat package, but 
it is returning only one value:

> library(netstat)
> free_port()
[1] 14415

This is occurring in both Linux and Windows. Previously it used to output 
thousands of ports. What has gone wrong?

thanking you,
Yours 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] free_port returning only one port...

2023-01-08 Thread akshay kulkarni
dear Dan,
   Yes, i just read the documentation...Previously i was using 
it with RSelenium package and never got to know that the argument random 
defaulted to FALSE. I was just using it blindly...only now I got to know that 
you must set random = TRUE to get different values across invocations...
Thanks anyways...

Thanking you,
Yours sincerely
AKSHAY M KULKARNI


From: Daniel Nordlund 
Sent: Monday, January 9, 2023 1:35 AM
To: akshay kulkarni ; R help Mailing list 

Subject: Re: [R] free_port returning only one port...

On 1/8/2023 11:35 AM, akshay kulkarni wrote:
> Dear members,
>  I am using free_port from the netstat package, 
> but it is returning only one value:
>
>> library(netstat)
>> free_port()
> [1] 14415
>

 thousands of ports. What has gone wrong?
>
> thanking you,
> Yours 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.

I haven't used that function before, and I don't know what you
previously experienced, but if you set the parameter random=TRUE you
will get a different port on each invocation

free_port(random=TRUE)


Hope this is helpful,

Dan

--
Daniel Nordlund
Port Townsend, WA  USA


--
This email has been checked for viruses by Avast antivirus software.
www.avast.com<http://www.avast.com>

[[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] return value of {....}

2023-01-11 Thread akshay kulkarni
Dear Richard,
Thanks for your reply. As replied to Avi, i was not 
complaining, just inquiring: was just curious to know the rationale for the 
design of {...}, thas all...!

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Richard O'Keefe 
Sent: Wednesday, January 11, 2023 8:31 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] return value of {}

I am more than a little puzzled by your question.
In the construct {expr1; expr2; expr3} all of the
expressions expr1, expr2, and expr3 are evaluated,
in that order.  That's what curly braces are FOR.
When you want some expressions evaluated in a
specific order, that's why and when you use curly
braces.  If that's not what you want, don't use them.
Complaining about it is like complaining that + adds.


On Tue, 10 Jan 2023 at 03:47, akshay kulkarni 
mailto:akshay...@hotmail.com>> wrote:
Dear members,
 I have the following code:

> TB <- {x <- 3;y <- 5}
> TB
[1] 5

It is consistent with the documentation: For {, the result of the last 
expression evaluated. This has the visibility of the last evaluation.

But both x AND y are created, but the "return value" is y. How can this be 
advantageous for solving practical problems? Specifically, consider the 
following code:

F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}

Both expr5 and expr7 are created, and are accessible by the code outside of the 
nested braces right? But the "return value" of the nested braces is expr7. So 
doesn't this mean that only expr7 should be accessible? Please help me entangle 
this (of course the return value of F is expr10, and all the other objects 
created by the preceding expressions are deleted. But expr5 is not, after the 
control passes outside of the nested braces!)

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

[[alternative HTML version deleted]]

__
R-help@r-project.org<mailto:R-help@r-project.org> mailing list -- To 
UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
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] error in exists.....

2022-12-27 Thread akshay kulkarni
Dear members,
 I have the following code:
>  E <- new.env()
>  E$L <- list()
>  i <- 1
>   E$L[[i]]$T1A1 <- Sys.time()
> exists("T1A1", where = E$L[[i]])
Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) :
  attempt to use zero-length variable name

I want the output of the exists() function to be TRUE. In any case:

> E$L[[1]]$T1A1
[1] "2022-12-27 22:40:02 IST"

Please help me solve this conundrum

Thanking you,
Yours 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] error in exists.....

2022-12-27 Thread akshay kulkarni
Dear Sarah,
 I had this also before the assignment of Sys.time():

> E$L[[i]] <- i

After assignment of Sys.time():

> E$L
[[1]]
[[1]][[1]]
[1] 1

[[1]]$T1A1
[1] "2022-12-27 22:40:02 IST"

regrets for not sharing this ..Can you reproduce it now?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Sarah Goslee 
Sent: Tuesday, December 27, 2022 11:20 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] error in exists.

Hi,

I can't create the desired object using the code you provided, but if
I create it in two steps so that E$L[[i]]$T1A1 does exist, exist()
returns TRUE.

E <- new.env()
E$L <- list()
i <- 1
E$L[[i]]$T1A1 <- Sys.time()

# returns: Error in `*tmp*`[[i]] : subscript out of bounds

E$L[[i]] <- list()
E$L[[i]]$T1A1 <- Sys.time()


exists("T1A1", where = E$L[[i]])
# returns: [1] TRUE


> str(E$L)
List of 1
 $ :List of 1
  ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26"

Sarah

On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni  wrote:
>
> Dear members,
>  I have the following code:
> >  E <- new.env()
> >  E$L <- list()
> >  i <- 1
> >   E$L[[i]]$T1A1 <- Sys.time()
> > exists("T1A1", where = E$L[[i]])
> Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) :
>   attempt to use zero-length variable name
>
> I want the output of the exists() function to be TRUE. In any case:
>
> > E$L[[1]]$T1A1
> [1] "2022-12-27 22:40:02 IST"
>
> Please help me solve this conundrum
>
> Thanking you,
> Yours 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.



--
Sarah Goslee (she/her)
http://www.numberwright.com

[[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] error in exists.....

2022-12-27 Thread akshay kulkarni
Dear Bert,
   Yeah, it's workingSometimes (only sometimes) I feel that 
I am troubling this list with very simple questions the answer to which I 
always happen to find myself a little after...any solutions for that (you seem 
to be an omniscient person)!?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Bert Gunter 
Sent: Tuesday, December 27, 2022 11:39 PM
To: akshay kulkarni 
Cc: Sarah Goslee ; R help Mailing list 

Subject: Re: [R] error in exists.

You are confused about the list hierarchy. Perhaps this will explain:
> i <- 1
>  E <- new.env()
>   E$L <- list()  ## L is an empty list in E
>   i <- 1
>E$L[[i]]$T1A1 <- Sys.time()
Error in `*tmp*`[[i]] : subscript out of bounds
## L is empty, so L[[1]] does not exist; is not a list;
## cannot have a value assigned to a component
## The following works:
## Create an empty list as a sublist of L
>  E$L[[1]] <- list()
## Now create and assign to a component of the empty list
>  E$L[[i]]$T1A1 <- Sys.time()
> E$L ## a list
[[1]]  ## whose first component is a list
[[1]]$T1A1 ## T1A1 named component of L[[1]]
[1] "2022-12-27 10:00:10 PST"

ergo, no conundra... (assuming I've understood you correctly)

Cheers,
Bert

On Tue, Dec 27, 2022 at 9:57 AM akshay kulkarni  wrote:
>
> Dear Sarah,
>  I had this also before the assignment of Sys.time():
>
> > E$L[[i]] <- i
>
> After assignment of Sys.time():
>
> > E$L
> [[1]]
> [[1]][[1]]
> [1] 1
>
> [[1]]$T1A1
> [1] "2022-12-27 22:40:02 IST"
>
> regrets for not sharing this ..Can you reproduce it now?
>
> Thanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
> 
> From: Sarah Goslee 
> Sent: Tuesday, December 27, 2022 11:20 PM
> To: akshay kulkarni 
> Cc: R help Mailing list 
> Subject: Re: [R] error in exists.
>
> Hi,
>
> I can't create the desired object using the code you provided, but if
> I create it in two steps so that E$L[[i]]$T1A1 does exist, exist()
> returns TRUE.
>
> E <- new.env()
> E$L <- list()
> i <- 1
> E$L[[i]]$T1A1 <- Sys.time()
>
> # returns: Error in `*tmp*`[[i]] : subscript out of bounds
>
> E$L[[i]] <- list()
> E$L[[i]]$T1A1 <- Sys.time()
>
>
> exists("T1A1", where = E$L[[i]])
> # returns: [1] TRUE
>
>
> > str(E$L)
> List of 1
>  $ :List of 1
>   ..$ T1A1: POSIXct[1:1], format: "2022-12-27 12:47:26"
>
> Sarah
>
> On Tue, Dec 27, 2022 at 12:36 PM akshay kulkarni  
> wrote:
> >
> > Dear members,
> >  I have the following code:
> > >  E <- new.env()
> > >  E$L <- list()
> > >  i <- 1
> > >   E$L[[i]]$T1A1 <- Sys.time()
> > > exists("T1A1", where = E$L[[i]])
> > Error in list2env(list(1, T1A1 = 1672161002.38743), NULL, ) :
> >   attempt to use zero-length variable name
> >
> > I want the output of the exists() function to be TRUE. In any case:
> >
> > > E$L[[1]]$T1A1
> > [1] "2022-12-27 22:40:02 IST"
> >
> > Please help me solve this conundrum
> >
> > Thanking you,
> > Yours 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.
>
>
>
> --
> Sarah Goslee (she/her)
> http://www.numberwright.com
>
> [[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] setting timezone variable permanently...

2022-12-07 Thread akshay kulkarni
Dear Marc,
 Thanks for the reply. However, the use of usethis package 
is very handy here: 
https://stackoverflow.com/questions/49738564/r-set-environment-variable-permanently.
 How do you compare your solution with that of using usethis package? Which is 
more effective?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI


From: Marc Girondot 
Sent: Wednesday, December 7, 2022 10:39 PM
To: r-help@r-project.org ; akshay...@hotmail.com 

Subject: Re: [R] setting timezone variable permanently...

You can create a file .Rprofile in your home directory with this command.

Each time you will open R, it will run this command.

https://support.posit.co/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf

Marc

Le 07/12/2022 � 17:47, akshay kulkarni a �crit :
> Dear members,
>   I am setting the Time zone environment variable 
> by this code:
>
>> Sys.setenv(TZ = "Asia/Kolkata")
> But I have to run it every time I open a new R session. How do I set it 
> permanently?
>
> Thanking you,
> Yours 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.

[[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] setting timezone variable permanently...

2022-12-07 Thread akshay kulkarni
Dear members,
 I am setting the Time zone environment variable by 
this code:

> Sys.setenv(TZ = "Asia/Kolkata")

But I have to run it every time I open a new R session. How do I set it 
permanently?

Thanking you,
Yours 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] setting timezone variable permanently...

2022-12-07 Thread akshay kulkarni
dear Jeff,
 THanks for your reply. Would you not recommend this  solution 
too : 
https://stackoverflow.com/questions/49738564/r-set-environment-variable-permanently
 ?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI


From: Jeff Newmiller 
Sent: Wednesday, December 7, 2022 10:44 PM
To: r-help@r-project.org ; akshay kulkarni 
; R help Mailing list 
Subject: Re: [R] setting timezone variable permanently...

Technically this is a question regarding your operating system, since 
environment variables are propagated by the OS creation of processes and 
different OSes include different mechanisms for configuring them.

However, for practical purposes in R you can just put that statement into your 
.Rprofile file.

I would not recommend it though... rather you should include this statement in 
every script that depends on this assumption. Otherwise your script will have a 
hidden configuration dependency. In fact the timezone you set should be linked 
with the data files you are using... if you work with time data from different 
places then you should set it appropriately for that data at the point in your 
script where you do the import.

On December 7, 2022 8:47:20 AM PST, akshay kulkarni  
wrote:
>Dear members,
> I am setting the Time zone environment variable 
> by this code:
>
>> Sys.setenv(TZ = "Asia/Kolkata")
>
>But I have to run it every time I open a new R session. How do I set it 
>permanently?
>
>Thanking you,
>Yours 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] setting timezone variable permanently...

2022-12-07 Thread akshay kulkarni
Dear Jeff,
thanks a lot

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Jeff Newmiller 
Sent: Wednesday, December 7, 2022 11:03 PM
To: akshay kulkarni ; r-help@r-project.org 

Subject: Re: [R] setting timezone variable permanently...

As I said, the tz is linked to your data, not where you OR your compute server 
are, so setting TZ in your R code or specifying it as the tz argument when you 
convert it are the best options.

If you choose to use your OS to set it that is up to you... but your code 
should not depend on that setting either way.

On December 7, 2022 9:19:40 AM PST, akshay kulkarni  
wrote:
>dear Jeff,
> THanks for your reply. Would you not recommend this  solution 
> too : 
> https://stackoverflow.com/questions/49738564/r-set-environment-variable-permanently
>  ?
>
>THanking you,
>Yours sincerely,
>AKSHAY M KULKARNI
>
>
>From: Jeff Newmiller 
>Sent: Wednesday, December 7, 2022 10:44 PM
>To: r-help@r-project.org ; akshay kulkarni 
>; R help Mailing list 
>Subject: Re: [R] setting timezone variable permanently...
>
>Technically this is a question regarding your operating system, since 
>environment variables are propagated by the OS creation of processes and 
>different OSes include different mechanisms for configuring them.
>
>However, for practical purposes in R you can just put that statement into your 
>.Rprofile file.
>
>I would not recommend it though... rather you should include this statement in 
>every script that depends on this assumption. Otherwise your script will have 
>a hidden configuration dependency. In fact the timezone you set should be 
>linked with the data files you are using... if you work with time data from 
>different places then you should set it appropriately for that data at the 
>point in your script where you do the import.
>
>On December 7, 2022 8:47:20 AM PST, akshay kulkarni  
>wrote:
>>Dear members,
>> I am setting the Time zone environment variable 
>> by this code:
>>
>>> Sys.setenv(TZ = "Asia/Kolkata")
>>
>>But I have to run it every time I open a new R session. How do I set it 
>>permanently?
>>
>>Thanking you,
>>Yours 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.

--
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] remembering the state of an action in R....

2022-12-11 Thread akshay kulkarni
Dear Rui,
 Thanks for your replyyour reply covers the first part of 
my question. What about the second part? i.e remembering the state when the 
price q breaches Q? Will some thing like this work:

f <- function(envir) {expr1; expr2; expr3; envir$j <- envir$j + 1L}

e <- new.env()
e$j <- 1L
# do you need counter for something else?
# if not delete these two lines
counter <- list()
counter[[e$j]] <- 1L
# this seems to be all you need, not counter
if ((q >= Q)  && e$j == 1L) {f(e); C1 <- "the price Q has been breached!"}

if(C1 != "the price Q has been breached!") { do something }

ANy other method?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI




From: Rui Barradas 
Sent: Sunday, December 11, 2022 10:58 PM
To: akshay kulkarni ; R help Mailing list 

Subject: Re: [R] remembering the state of an action in R

�s 17:11 de 11/12/2022, akshay kulkarni escreveu:
> Dear members,
>  I am a stock trader and using R for my research. 
> I am monitoring stock prices in real time. I have the following code:
>
>> if (sock price q, breaches a certain value Q) { expr1; expr2; expr3}
>
> THe point is, expr1,expr2,expr3 should execute only once, i.e when q breaches 
> Q. I thought of something like this:
>
>> if( q >= Q ) { expr1; expr2; expr3;}
>
> But expressions keep repeating as long as q >= Q, NOT when q breaches Q for 
> the first time. I did some research on myself and came up with this:
>
>> f <- function() {expr1; expr2; expr3; j <<- j + 1}
>> j <- 1; counter[[j]] <- 1;
>> if ((q >= Q)  && length(counter) == 1) {f}
>
> I just want your help to know whether it is logically right or not. ARe not 
> there any other possibility other than using the superassignment operator?
>
> Also, any way how to remember when the real time price q, breaches a value Q, 
> for the first time ( the price may come back to Q again afterwards) ?
>
> THanking you,
> Yours 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.
Hello,

Use environments. You will assign to a variable living in a special
place, protected from the rest of the code, that you can access any time
you want.
Something like the following.



f <- function(envir) {expr1; expr2; expr3; envir$j <- envir$j + 1L}

e <- new.env()
e$j <- 1L
# do you need counter for something else?
# if not delete these two lines
counter <- list()
counter[[e$j]] <- 1L
# this seems to be all you need, not counter
if ((q >= Q)  && e$j == 1L) {f(e)}



Hope this helps,

Rui Barradas


[[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] remembering the state of an action in R....

2022-12-11 Thread akshay kulkarni
Dear Rui,
 Thanks a lot..

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Rui Barradas 
Sent: Sunday, December 11, 2022 11:27 PM
To: akshay kulkarni ; R help Mailing list 

Subject: Re: [R] remembering the state of an action in R

�s 17:46 de 11/12/2022, akshay kulkarni escreveu:
> Dear Rui,
>   Thanks for your replyyour reply covers the first part 
> of my question. What about the second part? i.e remembering the state when 
> the price q breaches Q? Will some thing like this work:
>
> f <- function(envir) {expr1; expr2; expr3; envir$j <- envir$j + 1L}
>
> e <- new.env()
> e$j <- 1L
> # do you need counter for something else?
> # if not delete these two lines
> counter <- list()
> counter[[e$j]] <- 1L
> # this seems to be all you need, not counter
> if ((q >= Q)  && e$j == 1L) {f(e); C1 <- "the price Q has been breached!"}
>
> if(C1 != "the price Q has been breached!") { do something }
>
> ANy other method?
>
> Thanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
>
>
> 
> From: Rui Barradas 
> Sent: Sunday, December 11, 2022 10:58 PM
> To: akshay kulkarni ; R help Mailing list 
> 
> Subject: Re: [R] remembering the state of an action in R
>
> �s 17:11 de 11/12/2022, akshay kulkarni escreveu:
>> Dear members,
>>   I am a stock trader and using R for my 
>> research. I am monitoring stock prices in real time. I have the following 
>> code:
>>
>>> if (sock price q, breaches a certain value Q) { expr1; expr2; expr3}
>>
>> THe point is, expr1,expr2,expr3 should execute only once, i.e when q 
>> breaches Q. I thought of something like this:
>>
>>> if( q >= Q ) { expr1; expr2; expr3;}
>>
>> But expressions keep repeating as long as q >= Q, NOT when q breaches Q for 
>> the first time. I did some research on myself and came up with this:
>>
>>> f <- function() {expr1; expr2; expr3; j <<- j + 1}
>>> j <- 1; counter[[j]] <- 1;
>>> if ((q >= Q)  && length(counter) == 1) {f}
>>
>> I just want your help to know whether it is logically right or not. ARe not 
>> there any other possibility other than using the superassignment operator?
>>
>> Also, any way how to remember when the real time price q, breaches a value 
>> Q, for the first time ( the price may come back to Q again afterwards) ?
>>
>> THanking you,
>> Yours 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.
> Hello,
>
> Use environments. You will assign to a variable living in a special
> place, protected from the rest of the code, that you can access any time
> you want.
> Something like the following.
>
>
>
> f <- function(envir) {expr1; expr2; expr3; envir$j <- envir$j + 1L}
>
> e <- new.env()
> e$j <- 1L
> # do you need counter for something else?
> # if not delete these two lines
> counter <- list()
> counter[[e$j]] <- 1L
> # this seems to be all you need, not counter
> if ((q >= Q)  && e$j == 1L) {f(e)}
>
>
>
> Hope this helps,
>
> Rui Barradas
>
>
Hello,

Envirnments are still the solution for this. You can hold another
variable in the environment passed to f.


f <- function(real_time_price, Q_breach = Q, envir) {
   envir$counter <- envir$counter + 1L
   envir$breached <- "the price Q has been breached"
   x <- pi
   x
}

q <- 10
Q <- 5
e <- new.env()
e$counter <- 0L
# this seems to be all you need, not counter
if ((q >= Q)  && e$counter == 0L) {
   print(f(q, Q, envir = e))
}

if(e$breached != "the price Q has been breached!") {
   message("do something...")
}


Hope this helps,

Rui Barradas


[[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] remembering the state of an action in R....

2022-12-11 Thread akshay kulkarni
Dear members,
I am a stock trader and using R for my research. I 
am monitoring stock prices in real time. I have the following code:

> if (sock price q, breaches a certain value Q) { expr1; expr2; expr3}

THe point is, expr1,expr2,expr3 should execute only once, i.e when q breaches 
Q. I thought of something like this:

> if( q >= Q ) { expr1; expr2; expr3;}

But expressions keep repeating as long as q >= Q, NOT when q breaches Q for the 
first time. I did some research on myself and came up with this:

> f <- function() {expr1; expr2; expr3; j <<- j + 1}
> j <- 1; counter[[j]] <- 1;
> if ((q >= Q)  && length(counter) == 1) {f}

I just want your help to know whether it is logically right or not. ARe not 
there any other possibility other than using the superassignment operator?

Also, any way how to remember when the real time price q, breaches a value Q, 
for the first time ( the price may come back to Q again afterwards) ?

THanking you,
Yours 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] netstat in R in linux...

2022-12-06 Thread akshay kulkarni
Dear Henrik,
The error is:

> library(netstat)
> free_port()
sh: netstat: command not found
Error in system("netstat -n -a", intern = TRUE) :
  error in running command

Thanking you,
Yours sincerely
AKSHAY M KULKARNI

From: Henrik Bengtsson 
Sent: Tuesday, December 6, 2022 11:53 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] netstat in R in linux...

What's the error?!?

/Henrik

On Tue, Dec 6, 2022 at 10:19 AM akshay kulkarni  wrote:
>
> dear members,
>
> I am using free_port() in netstat package in R. It is working in windows but 
> not in linux. It is throwing an error in linux. ANy help please?
>
> THanking you,
> Yours 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.

[[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] netstat in R in linux...

2022-12-06 Thread akshay kulkarni
Dear Henrik,
   OK thanks a lot..

thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Henrik Bengtsson 
Sent: Wednesday, December 7, 2022 12:44 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] netstat in R in linux...

> By the by, what advantages does port4me have as compared to netstat?

As I said in my previous email, it doesn't require external tools, so
it's more likely to work out of the box for more people. But that
wasn't the main reason for this package. For the full motivation
behind port4me, see the vignette
<https://cran.r-project.org/web/packages/port4me/vignettes/port4me-overview.html>.

/Henrik

On Tue, Dec 6, 2022 at 11:00 AM akshay kulkarni  wrote:
>
> Dear Henrik
>   It is workingthanks a lot! I had actually 
> previously tried this:  sudo yum install netstat rather than sudo yum install 
> net-tools
>
> By the by, what advantages does port4me have as compared to netstat?
>
> THanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
> 
> From: Henrik Bengtsson 
> Sent: Wednesday, December 7, 2022 12:19 AM
> To: akshay kulkarni 
> Cc: R help Mailing list 
> Subject: Re: [R] netstat in R in linux...
>
> Okay,
>
> that means that the Linux machine where you run this on does not have
> the 'netstat' software installed.  That is something that needs to be
> installed outside of R.  For example, if it's Ubuntu, I think 'sudo
> apt info net-tools' will do.
>
> (Disclaimer: I'm the author)
> A cross-platform alternative to netstat::free_port(), is
> port4me::port4me(), which is also available from CRAN
> (https://cran.r-project.org/package=port4me). It requires no external
> tools, but R (>= 4.0.0).
>
> /Henrik
>
> On Tue, Dec 6, 2022 at 10:41 AM akshay kulkarni  wrote:
> >
> > Dear Henrik,
> > The error is:
> >
> > > library(netstat)
> > > free_port()
> > sh: netstat: command not found
> > Error in system("netstat -n -a", intern = TRUE) :
> >   error in running command
> >
> > Thanking you,
> > Yours sincerely
> > AKSHAY M KULKARNI
> > 
> > From: Henrik Bengtsson 
> > Sent: Tuesday, December 6, 2022 11:53 PM
> > To: akshay kulkarni 
> > Cc: R help Mailing list 
> > Subject: Re: [R] netstat in R in linux...
> >
> > What's the error?!?
> >
> > /Henrik
> >
> > On Tue, Dec 6, 2022 at 10:19 AM akshay kulkarni  
> > wrote:
> > >
> > > dear members,
> > >
> > > I am using free_port() in netstat package in R. It is working in windows 
> > > but not in linux. It is throwing an error in linux. ANy help please?
> > >
> > > THanking you,
> > > Yours 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.

[[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] netstat in R in linux...

2022-12-06 Thread akshay kulkarni
dear members,

I am using free_port() in netstat package in R. It is working in windows but 
not in linux. It is throwing an error in linux. ANy help please?

THanking you,
Yours 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] netstat in R in linux...

2022-12-06 Thread akshay kulkarni
Dear Henrik
  It is workingthanks a lot! I had actually previously 
tried this:  sudo yum install netstat rather than sudo yum install net-tools

By the by, what advantages does port4me have as compared to netstat?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI


From: Henrik Bengtsson 
Sent: Wednesday, December 7, 2022 12:19 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] netstat in R in linux...

Okay,

that means that the Linux machine where you run this on does not have
the 'netstat' software installed.  That is something that needs to be
installed outside of R.  For example, if it's Ubuntu, I think 'sudo
apt info net-tools' will do.

(Disclaimer: I'm the author)
A cross-platform alternative to netstat::free_port(), is
port4me::port4me(), which is also available from CRAN
(https://cran.r-project.org/package=port4me). It requires no external
tools, but R (>= 4.0.0).

/Henrik

On Tue, Dec 6, 2022 at 10:41 AM akshay kulkarni  wrote:
>
> Dear Henrik,
> The error is:
>
> > library(netstat)
> > free_port()
> sh: netstat: command not found
> Error in system("netstat -n -a", intern = TRUE) :
>   error in running command
>
> Thanking you,
> Yours sincerely
> AKSHAY M KULKARNI
> 
> From: Henrik Bengtsson 
> Sent: Tuesday, December 6, 2022 11:53 PM
> To: akshay kulkarni 
> Cc: R help Mailing list 
> Subject: Re: [R] netstat in R in linux...
>
> What's the error?!?
>
> /Henrik
>
> On Tue, Dec 6, 2022 at 10:19 AM akshay kulkarni  wrote:
> >
> > dear members,
> >
> > I am using free_port() in netstat package in R. It is working in windows 
> > but not in linux. It is throwing an error in linux. ANy help please?
> >
> > THanking you,
> > Yours 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.

[[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] return value of {....}

2023-01-15 Thread akshay kulkarni
Dear Bill,
 Thanks for your reply.

thanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Bill Dunlap 
Sent: Friday, January 13, 2023 10:48 PM
To: Valentin Petzel 
Cc: akshay kulkarni ; R help Mailing list 

Subject: Re: [R] return value of {}

R's
   { expr1; expr2; expr3}
acts much like C's
   ( expr1, expr2, expr3)

E.g.,

$ cat a.c
#include 

int main(int argc, char* argv[])
{
double y = 10 ;
double x = (printf("Starting... "), y = y + 100, y * 20);
printf("Done: x=%g, y=%g\n", x, y);
return 0;
}
$ gcc -Wall a.c
$ ./a.out
Starting... Done: x=2200, y=110

I don't like that syntax (e.g., commas between expressions instead of the usual 
semicolons after expressions).  Perhaps John Chambers et all didn't either.

-Bill

On Fri, Jan 13, 2023 at 2:28 AM Valentin Petzel 
mailto:valen...@petzel.at>> wrote:
Hello Akshay,

R is quite inspired by LISP, where this is a common thing. It is not in fact 
that {...} returned something, rather any expression evalulates to some value, 
and for a compound statement that is the last evaluated expression.

{...} might be seen as similar to LISPs (begin ...).

Now this is a very different thing compared to {...} in something like C, even 
if it looks or behaves similarly. But in R {...} is in fact an expression and 
thus has evaluate to some value. This also comes with some nice benefits.

You do not need to use {...} for anything that is a single statement. But you 
can in each possible place use {...} to turn multiple statements into one.

Now think about a statement like this

f <- function(n) {
x <- runif(n)
x**2
}

Then we can do

y <- f(10)

Now, you suggested way would look like this:

f <- function(n) {
x <- runif(n)
y <- x**2
}

And we'd need to do something like:

f(10)
y <- somehow_get_last_env_of_f$y

So having a compound statement evaluate to a value clearly has a benefit.

Best Regards,
Valentin

09.01.2023 18:05:58 akshay kulkarni 
mailto:akshay...@hotmail.com>>:

> Dear Valentin,
>   But why should {} "return" a value? It could 
> just as well evaluate all the expressions and store the resulting objects in 
> whatever environment the interpreter chooses, and then it would be left to 
> the user to manipulate any object he chooses. Don't you think returning the 
> last, or any value, is redundant? We are living in the 21st century world, 
> and the R-core team might,I suppose, have a definite reason for"returning" 
> the last value. Any comments?
>
> Thanking you,
> Yours sincerely,
> AKSHAY M KULKARNI
>
> --------
> *From:* Valentin Petzel mailto:valen...@petzel.at>>
> *Sent:* Monday, January 9, 2023 9:18 PM
> *To:* akshay kulkarni mailto:akshay...@hotmail.com>>
> *Cc:* R help Mailing list mailto:r-help@r-project.org>>
> *Subject:* Re: [R] return value of {}
>
> Hello Akshai,
>
> I think you are confusing {...} with local({...}). This one will evaluate the 
> expression in a separate environment, returning the last expression.
>
> {...} simply evaluates multiple expressions as one and returns the result of 
> the last line, but it still evaluates each expression.
>
> Assignment returns the assigned value, so we can chain assignments like this
>
> a <- 1 + (b <- 2)
>
> conveniently.
>
> So when is {...} useful? Well, anyplace where you want to execute complex 
> stuff in a function argument. E.g. you might do:
>
> data %>% group_by(x) %>% summarise(y = {if(x[1] > 10) sum(y) else mean(y)})
>
> Regards,
> Valentin Petzel
>
> 09.01.2023 15:47:53 akshay kulkarni 
> mailto:akshay...@hotmail.com>>:
>
>> Dear members,
>>  I have the following code:
>>
>>> TB <- {x <- 3;y <- 5}
>>> TB
>> [1] 5
>>
>> It is consistent with the documentation: For {, the result of the last 
>> expression evaluated. This has the visibility of the last evaluation.
>>
>> But both x AND y are created, but the "return value" is y. How can this be 
>> advantageous for solving practical problems? Specifically, consider the 
>> following code:
>>
>> F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}
>>
>> Both expr5 and expr7 are created, and are accessible by the code outside of 
>> the nested braces right? But the "return value" of the nested braces is 
>> expr7. So doesn't this mean that only expr7 should be accessible? Please 
>> help me entangle this (of course the return value of F is expr10, and all 
>> the other objects created by the preceding expressions are deleted. But 
>> expr5 is not, after the 

Re: [R] return value of {....}

2023-01-15 Thread akshay kulkarni
Dear valentin,
  Thanks for a comprehensive background

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Valentin Petzel 
Sent: Friday, January 13, 2023 4:48 AM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] return value of {}

Hello Akshay,

R is quite inspired by LISP, where this is a common thing. It is not in fact 
that {...} returned something, rather any expression evalulates to some value, 
and for a compound statement that is the last evaluated expression.

{...} might be seen as similar to LISPs (begin ...).

Now this is a very different thing compared to {...} in something like C, even 
if it looks or behaves similarly. But in R {...} is in fact an expression and 
thus has evaluate to some value. This also comes with some nice benefits.

You do not need to use {...} for anything that is a single statement. But you 
can in each possible place use {...} to turn multiple statements into one.

Now think about a statement like this

f <- function(n) {
x <- runif(n)
x**2
}

Then we can do

y <- f(10)

Now, you suggested way would look like this:

f <- function(n) {
x <- runif(n)
y <- x**2
}

And we'd need to do something like:

f(10)
y <- somehow_get_last_env_of_f$y

So having a compound statement evaluate to a value clearly has a benefit.

Best Regards,
Valentin


09.01.2023 18:05:58 akshay kulkarni :

Dear Valentin,
  But why should {} "return" a value? It could just 
as well evaluate all the expressions and store the resulting objects in 
whatever environment the interpreter chooses, and then it would be left to the 
user to manipulate any object he chooses. Don't you think returning the last, 
or any value, is redundant? We are living in the 21st century world, and the 
R-core team might,I suppose, have a definite reason for"returning" the last 
value. Any comments?

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI


From: Valentin Petzel 
Sent: Monday, January 9, 2023 9:18 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] return value of {}

Hello Akshai,

I think you are confusing {...} with local({...}). This one will evaluate the 
expression in a separate environment, returning the last expression.

{...} simply evaluates multiple expressions as one and returns the result of 
the last line, but it still evaluates each expression.

Assignment returns the assigned value, so we can chain assignments like this

a <- 1 + (b <- 2)

conveniently.

So when is {...} useful? Well, anyplace where you want to execute complex stuff 
in a function argument. E.g. you might do:

data %>% group_by(x) %>% summarise(y = {if(x[1] > 10) sum(y) else mean(y)})

Regards,
Valentin Petzel

09.01.2023 15:47:53 akshay kulkarni :

> Dear members,
>  I have the following code:
>
>> TB <- {x <- 3;y <- 5}
>> TB
> [1] 5
>
> It is consistent with the documentation: For {, the result of the last 
> expression evaluated. This has the visibility of the last evaluation.
>
> But both x AND y are created, but the "return value" is y. How can this be 
> advantageous for solving practical problems? Specifically, consider the 
> following code:
>
> F <- function(X) {  expr; expr2; { expr5; expr7}; expr8;expr10}
>
> Both expr5 and expr7 are created, and are accessible by the code outside of 
> the nested braces right? But the "return value" of the nested braces is 
> expr7. So doesn't this mean that only expr7 should be accessible? Please help 
> me entangle this (of course the return value of F is expr10, and all the 
> other objects created by the preceding expressions are deleted. But expr5 is 
> not, after the control passes outside of the nested braces!)
>
> Thanking you,
> Yours 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.

[[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] return value of {....}

2023-01-15 Thread akshay kulkarni
Dear leonard,
 I think Avi's repsonse was best...it's just a 
design...as he said, there are other possibilities in other programming 
languages which augments this design...thanks anyways for your reply...

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Leonard Mada 
Sent: Friday, January 13, 2023 1:44 AM
To: Akshay Kulkarni 
Cc: R-help Mailing List 
Subject: Re: [R] return value of {}

Dear Akshay,

The best response was given by Andrew. "{...}" is not a closure.

This is unusual for someone used to C-type languages. But I will try to
explain some of the rationale.

In the case that "{...}" was a closure, then external variables would
need to be explicitly declared before the closure (in order to reuse
those values):
intermediate = c()
{
 intermediate = ...;
 result = someFUN(intermediate);
}

1.) Interactive Sessions
This is cumbersome in interactive sessions. For example: you often
compute the mean or the variance as intermediary results, and will need
them later on as well. They could have been computed outside the
"closure", but writing code in interactive sessions may not always be
straightforward.

2.) Missing arguments
f = function(x, y) {
 if(missing(y)) {
 # assuming x = matrix
 y = x[,2]; x = x[,1];
 }
}
It would be much more cumbersome to define/use a temporary tempY.

I hope this gives a better perspective why this is indeed a useful
feature - even if it is counterintuitive.

Sincerely,

Leonard



[[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] return value of {....}

2023-01-15 Thread akshay kulkarni
dear Heinz,
 Thanks for your replyreason is as old as the Sun..!

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: R-help  on behalf of Heinz Tuechler 

Sent: Friday, January 13, 2023 4:30 PM
To: r-help@r-project.org 
Subject: Re: [R] return value of {}

> 09.01.2023 18:05:58 akshay kulkarni :
>
> We are living in the 21st century world, and the R-core team might,I suppose, 
> have a definite reason ...
>

Maybe compatibility reasons with S and R-versions from the 20st century?
But maybe, you would have expected some reason even then.

best regards,

Heinz

__
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] function doesn't exists but still runs.....

2023-01-19 Thread akshay kulkarni
dear members,
I am using the RSelenium package which uses the 
function selenium() from the wdman package. The selenium function contains the 
function java_check at line 12. If I try to run it, it throws an error:

>   javapath <- java_check()
Error in java_check() : could not find function "java_check"

Also:

> exists("java_check")
[1] FALSE

But when I run selenium(), it works fine

How do you explain this conundrum? You can refer to this link: 
https://github.com/ropensci/wdman/issues/15

Specifically what concept of R explains this weird behaviour?

Thanking you,
Yours 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] [EXTERNAL] Re: function doesn't exists but still runs..... (akshay kulkarni)

2023-01-23 Thread akshay kulkarni
Dear Jorgen,
   thanks a lot

Thanking you,
Yours sincerely
Akshay M Kulkarni

From: Jorgen Harmse 
Sent: Monday, January 23, 2023 9:31 PM
To: r-help@r-project.org ; akshay kulkarni 

Subject: Re: [R] [EXTERNAL] Re: function doesn't exists but still runs. 
(akshay kulkarni)


Hi Akshay,



I usually use debug (a function provided by R). When you are stepping through a 
function your environment is the one in which function code is being executed, 
so you can easily see everything that is visible to the function. If you single 
step into a function that the first function calls then you also see everything 
that is available to that function. Moreover, you don't see anything that is 
not visible to the function you are debugging, so you can really determine what 
any piece of code would do if called inside the function.



Note 1: Code in R is always executed in an environment. I show in the example 
below that in the empty environment (the ultimate ancestor of all other 
environments) R can't even add. Usually the current environment (e.g. 
.GlobalEnv at the command line or a fresh environment created by a function 
call) has the right contents and the right parent to do what you expect, but in 
some special cases you need to understand how environments work. Even evalq & 
with are functions (unavailable for example in the empty environment), and the 
environment argument has to be evaluated in the current environment before the 
main expression can be evaluated in the environment that you want.



> E[1]

[[1]]





> evalq(2+2, E[[1L]])

Error in 2 + 2 : could not find function "+"

> evalq(2L+2L, E[[1L]])

Error in 2L + 2L : could not find function "+"



Note 2: Besides automatically showing what a function sees, using debug 
(instead of hand-executing lines of code from the function) gives you the 
correct call stack. Suppose that you run some code at the debug command line to 
make a sub-sub-…-function do what you want, and you create in that environment 
what you hope is the correct return value. You can then use parent.frame() to 
put that value into the environment of the caller and run the caller's 
remaining code in the correct environment to see what happens. If there are no 
other problems then you can work your way up to top level and confirm that your 
patch has the right effect before you even modify the actual code of the 
offending function. (Saving all environments in .GlobalEnv forces R to keep 
them even if you quit the debugger. Combining eval & parse is sometimes more 
convenient than using evalq.)



Regards,

Jorgen.

--

Message: 2
Date: Sun, 22 Jan 2023 14:25:59 +
From: akshay kulkarni 
To: Jorgen Harmse , "r-help@r-project.org"
, "williamwdun...@gmail.com"

Subject: Re: [R] [EXTERNAL] Re: function doesn't exists but still
runs. (akshay kulkarni)
Message-ID:



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

Dear Jorgen,
regrets to reply this late
I got into this issue because it threw an error, and it took more than 4 days 
to fix this. I  learnt a lot, and one things I learnt  is to debug the 
function, even when that is a public package functioninstead of googling 
the error message...Any ideas on how to do this more efficiently?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI
____
From: Jorgen Harmse 
Sent: Friday, January 20, 2023 11:35 PM
To: akshay kulkarni ; r-help@r-project.org 
; williamwdun...@gmail.com 
Subject: Re: [EXTERNAL] Re: function doesn't exists but still runs. (akshay 
kulkarni)


Hi Akshay,



Lexical scoping and environments are closely tied. (I think Bill even cited the 
documentation.) I guess it's arcane in the sense that scoping usually does what 
you expect, but the way that works is related to what we discussed.



What led you to discover the issue? Were you debugging the public package 
function because it didn't do what you expected, or were you just curious how 
it worked?



Regards,

Jorgen.





From: akshay kulkarni 
Date: Friday, January 20, 2023 at 11:19
To: Jorgen Harmse , r-help@r-project.org 
, williamwdun...@gmail.com 
Subject: [EXTERNAL] Re: function doesn't exists but still runs. (akshay 
kulkarni)

Dear Jorgen,

 thanks for the reply.so according to you one can 
pegion hole the problem as concerning R's lexical scoping rules,am I right? Or 
some arcane concept regarding environments?



THanking you,

Yours sincerely,

AKSHAY M KULKARNI



From: Jorgen Harmse 
Sent: Friday, January 20, 2023 9:34 PM
To: r-help@r-project.org ; akshay...@hotmail.com 
; williamwdun...@gmail.com 
Subject: Re: function doesn't exists but still runs. (akshay kulkarni)



It may help to expand a bit on Bill Dunlap's answer. I think 

Re: [R] [EXTERNAL] Re: function doesn't exists but still runs..... (akshay kulkarni)

2023-01-22 Thread akshay kulkarni
Dear Jorgen,
regrets to reply this late
I got into this issue because it threw an error, and it took more than 4 days 
to fix this. I  learnt a lot, and one things I learnt  is to debug the 
function, even when that is a public package functioninstead of googling 
the error message...Any ideas on how to do this more efficiently?

THanking you,
Yours sincerely,
AKSHAY M KULKARNI

From: Jorgen Harmse 
Sent: Friday, January 20, 2023 11:35 PM
To: akshay kulkarni ; r-help@r-project.org 
; williamwdun...@gmail.com 
Subject: Re: [EXTERNAL] Re: function doesn't exists but still runs. (akshay 
kulkarni)


Hi Akshay,



Lexical scoping and environments are closely tied. (I think Bill even cited the 
documentation.) I guess it's arcane in the sense that scoping usually does what 
you expect, but the way that works is related to what we discussed.



What led you to discover the issue? Were you debugging the public package 
function because it didn't do what you expected, or were you just curious how 
it worked?



Regards,

Jorgen.





From: akshay kulkarni 
Date: Friday, January 20, 2023 at 11:19
To: Jorgen Harmse , r-help@r-project.org 
, williamwdun...@gmail.com 
Subject: [EXTERNAL] Re: function doesn't exists but still runs. (akshay 
kulkarni)

Dear Jorgen,

 thanks for the reply.so according to you one can 
pegion hole the problem as concerning R's lexical scoping rules,am I right? Or 
some arcane concept regarding environments?



THanking you,

Yours sincerely,

AKSHAY M KULKARNI



From: Jorgen Harmse 
Sent: Friday, January 20, 2023 9:34 PM
To: r-help@r-project.org ; akshay...@hotmail.com 
; williamwdun...@gmail.com 
Subject: Re: function doesn't exists but still runs. (akshay kulkarni)



It may help to expand a bit on Bill Dunlap's answer. I think that library does 
something like this:



Create a new environment for all the package objects. This environment will not 
be directly visible from .GlobalEnv, and ancestor environments may not be 
directly visible either. It may contain functions & other objects that are not 
exported, and it may use objects in ancestor environments that .GlobalEnv 
doesn't see directly. On the other hand, functions in the package will still 
see external functions in the way the package author intended instead of seeing 
functions with the same name that are visible to .GlobalEnv.



Run the source code in the private environment (using source(local=private 
environment, )?). Most package source code just defines functions, but the 
source code could build other objects that the package needs for some reason, 
or it could use delayedAssign to build the objects lazily. By default, the 
environment of any function defined by the source code is the private 
environment, so the function has access to private objects and to anything in 
ancestor environments.



Create a second new environment whose parent is parent.env(.GlobalEnv). For 
every export, assign the corresponding object from the private environment into 
the corresponding name in the public environment. Note that the environment of 
any function is still the private environment in which it was created. (I think 
that a function is mostly determined by its environment, its formals, and its 
body. A function call creates a new environment whose parent is the environment 
of the function. Thus whoever wrote the function can control the search for 
anything that isn�t passed in or created by the function itself.)



Reset parent.env(.GlobalEnv) to be the public environment. This makes all the 
exported objects (usually functions) available at the command line and allows 
the user to see everything that was available before (usually by name only, but 
by scope-resolved name if necessary). As noted by Bill Dunlap and in more 
detail above, package functions can use functions & other objects that are not 
directly visible to the user. As he also showed, you can (usually) pierce the 
privacy as long at least one function is exported. 
environment(package_function) is the private environment, so you can use it to 
see all the private objects and everything in the ancestor environments. You 
can repeat the trick to see private environments of packages you didn't 
directly pull in. I think you can even unlock bindings and do ghastly things to 
the package's private environment.



Regards,

Jorgen Harmse.

--

Message: 17
Date: Thu, 19 Jan 2023 16:02:31 -0800
From: Bill Dunlap 
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] function doesn't exists but still runs.
Message-ID:

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

Look into R's scoping rules.  E.g.,
https://bookdown.org/rdpeng/rprogdatascience/scoping-rules-of-r.html.

* When a function looks up a name, it looks it up in the environment in
which the function was de

Re: [R] function doesn't exists but still runs..... (akshay kulkarni)

2023-01-22 Thread akshay kulkarni
Dear Jeff,
  I am indeed guilty of a highly inadvertent diction...I have 
to welcome your exhortations

Coming back to the point, I have read Avanced R by HAdley. But its all 
theory...and the present issue that I ran into is, possibly, a practical 
application of ALL that. For example, I never knew, and don't think that it is 
ever mentioned in Avanced R, that, as Bill advised, to use the function with() 
to get the source code of java_check()...(caveat: if it is mentioned in 
Advanced R, please let me know the chapter and page number so that I can have a 
look...). And to get on the path to solve these practical problems, my first 
choice is R Help Mailing list! Therefore, a hearty thanks for your pointed 
answer and more importantly, your exhortations!

Thanking you,
Yours sincerely
AKSHAY M KULKARNI


From: Jeff Newmiller 
Sent: Friday, January 20, 2023 11:29 PM
To: r-help@r-project.org ; akshay kulkarni 
; Jorgen Harmse ; r-help@r-project.org 
; williamwdun...@gmail.com 
Subject: Re: [R] function doesn't exists but still runs. (akshay kulkarni)

This is not a "problem" ... it is a "feature". Packages often use functions 
from other packages, but that does NOT mean that you as a user can 
automatically use those functions  also.

If Package A uses Package B to implement something, but Package B becomes 
unavailable, the maintainer of Package A would like to fill in the gap. If 
Package A "Depends" on Package B then users of package A automatically get 
access to Package B and they get used to treating Package A like it contains 
all of the functions in Package B directly.

Therefore it is common to have Package A "Import" Package B so that the Package 
A maintainer won't have to re-implement all of Package B to avoid breaking code 
for users of Package A. They can fix things under the hood for their own 
Package A functions using other code.

If a user wants to depend on Package B, it is up to them to use the library 
function to do so explicitly... and when Package B goes away, they are 
responsible for dealing with that mess themselves.

You asked "how", and got answers... but you didn't bother to follow up on those 
answers by reading things like "Writing R Extensions" or Hadley Wickham's "R 
Packages" or "Advanced R". Don't turn that laziness into a value judgement 
about "problems" with R.

On January 20, 2023 9:18:54 AM PST, akshay kulkarni  
wrote:
>Dear Jorgen,
> thanks for the reply.so according to you one can 
> pegion hole the problem as concerning R's lexical scoping rules,am I right? 
> Or some arcane concept regarding environments?
>
>THanking you,
>Yours sincerely,
>AKSHAY M KULKARNI
>
>From: Jorgen Harmse 
>Sent: Friday, January 20, 2023 9:34 PM
>To: r-help@r-project.org ; akshay...@hotmail.com 
>; williamwdun...@gmail.com 
>Subject: Re: function doesn't exists but still runs. (akshay kulkarni)
>
>
>It may help to expand a bit on Bill Dunlap's answer. I think that library does 
>something like this:
>
>
>
>Create a new environment for all the package objects. This environment will 
>not be directly visible from .GlobalEnv, and ancestor environments may not be 
>directly visible either. It may contain functions & other objects that are not 
>exported, and it may use objects in ancestor environments that .GlobalEnv 
>doesn't see directly. On the other hand, functions in the package will still 
>see external functions in the way the package author intended instead of 
>seeing functions with the same name that are visible to .GlobalEnv.
>
>
>
>Run the source code in the private environment (using source(local=private 
>environment, )?). Most package source code just defines functions, but the 
>source code could build other objects that the package needs for some reason, 
>or it could use delayedAssign to build the objects lazily. By default, the 
>environment of any function defined by the source code is the private 
>environment, so the function has access to private objects and to anything in 
>ancestor environments.
>
>
>
>Create a second new environment whose parent is parent.env(.GlobalEnv). For 
>every export, assign the corresponding object from the private environment 
>into the corresponding name in the public environment. Note that the 
>environment of any function is still the private environment in which it was 
>created. (I think that a function is mostly determined by its environment, its 
>formals, and its body. A function call creates a new environment whose parent 
>is the environment of the function. Thus whoever wrote the function can 
>control the search for anything that isn�t passed in or created by th

Re: [R] function doesn't exists but still runs.....

2023-01-20 Thread akshay kulkarni
Dear Greg,
  THanks for a very well pointed answer.

THanking you,
yours sincerely
AKSHAY M KULKARNI

From: Greg Snow <538...@gmail.com>
Sent: Friday, January 20, 2023 10:28 PM
To: akshay kulkarni 
Cc: R help Mailing list 
Subject: Re: [R] function doesn't exists but still runs.

A little simpler answer than the others.

Look at package Namespaces.  When a package is created, the NAMESPACE
file defines which functions in the package are exported (i.e.
available for you to use), the other functions are "private" to the
package meaning that other functions in the package can call those
functions, but they are not meant to be called directly by the user.

So in your case, the `selenium` function was exported, but
`java_check` was not exported.  The function does exist, but R's
regular search rules do not find it when you try to call it directly
(but because it shares the Namespace with selenium, it is found when
called there).

It is possible to call non-exported functions (use something like
RSelenium:::java_check()), but non-exported functions are not usually
documented and subject to change without any warning.  You are using
the functionality in a way different from how the author intended, so
there are no guarantees that it will do what you think it should.

On Thu, Jan 19, 2023 at 3:28 PM akshay kulkarni  wrote:
>
> dear members,
> I am using the RSelenium package which uses the 
> function selenium() from the wdman package. The selenium function contains 
> the function java_check at line 12. If I try to run it, it throws an error:
>
> >   javapath <- java_check()
> Error in java_check() : could not find function "java_check"
>
> Also:
>
> > exists("java_check")
> [1] FALSE
>
> But when I run selenium(), it works fine
>
> How do you explain this conundrum? You can refer to this link: 
> https://github.com/ropensci/wdman/issues/15
>
> Specifically what concept of R explains this weird behaviour?
>
> Thanking you,
> Yours 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.



--
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

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


  1   2   >