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

2022-07-02 Thread Avi Gross via R-help
People often use sum() to count how many boolean values are true, not length).

Sent from the all new AOL app for Android 
 
  On Sat, Jul 2, 2022 at 2:14 PM, Andrew Simmons wrote:   
It's supposed to match the length. Perhaps you meant to use which(is.na())?

On Sat, Jul 2, 2022, 14:04 akshay kulkarni  wrote:

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

    [[alternative HTML version deleted]]

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

[[alternative HTML version deleted]]

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


[R] is.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.


Re: [R] A humble request

2022-07-02 Thread Spencer Graves




On 7/2/22 12:30 PM, David Winsemius wrote:




On Jul 2, 2022, at 9:32 AM, Muhammad Zubair Chishti  
wrote:

Dear Respected Sir,
Thank you for the quick response. However, the link your shared provides
the old version of wmtsa that is not working in R 4.2.0.
Can you please tell me any other solution for this issue?


Your response suggests that you do not understand how one installs a source 
package for R. You probably need to educate yourself about how to compile 
packages from source. Since the process is different for Linux, MacOS, and 
Windows, you would need to pay attention to the specific requirements of your 
unnamed OS.



BUT you do not need to compile the entire package to use a function in 
it:  You only need to source that particular function ... and any others 
it calls that you don't already have ;-)  That simplifies the task 
greatly.  With luck, Muhammad Zubair Chishti can source only the desired 
functions, and they will run and do what is desired with no further 
effort.  If not, Muhammad can be guided by the error message(s):  If 
they complain that a certain function is not available, Muhammad can 
find it and source it.  If the problem is more subtle, Muhammad can use 
"debug", as I earlier suggested.  Spencer Graves




You might find as I did that the wmtsa package has some dependencies that are 
also archived, namely pkg:splus2R (provided generously by Insightful for many 
years but apparently no longer) and pkg:ifultools. They both have 
incompatibilities that prevent compilation from source with my Mac setup. I did 
find a mirror that has a binary version of splus2R that did install and load.

install.packages("splus2R", repo="https://mirrors.vcea.wsu.edu/r-cran/;, 
type="binary", dependencies=TRUE)

So maybe part of your PhD training should be learning how to compile packages 
and address changes in the compilers being used as R evolves. That is beyond my 
capabilities for offering assistance. Alternately you might find a forum or a 
consultant with similar interests to yours. Again, I can offer no assistance 
because I have never used pkg:wmtsa and don't know what it provided when it was 
compatible with the CRAN universe.



__
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] A humble request

2022-07-02 Thread Ebert,Timothy Aaron
Would package versions help? It would allow you to install a specific version 
of wmtsa into R 4.2.
Tim

-Original Message-
From: R-help  On Behalf Of Muhammad Zubair Chishti
Sent: Saturday, July 2, 2022 12:39 PM
To: Spencer Graves ; r-help@r-project.org
Subject: Re: [R] A humble request

[External Email]

Dear Respected Professor,
You are right. However, a student like me who doesn't know much R requires 
specific helping packages to install. Therefore, I requested here to experts to 
give the solution for my issue.

I hope that I will get the solution from this platform.

Regards
Muhammad Zubair Chishti

On Sat, 2 Jul 2022, 21:34 Spencer Graves, < 
spencer.gra...@effectivedefense.org> wrote:

> If I understand correctly the rules for "archived" packages, anyone is 
> free to download them, compile them locally -- AND resubmit any such 
> package with themselves as the maintainer:  They were archived, 
> because they would no longer pass CRAN checks, and the designated 
> maintainer failed to respond to the notice of problems with newer versions of 
> R.
> If anything I've said here is wrong or poorly nuanced, I trust someone 
> knowledgeable will correct me.  Spencer Graves
>
>
> On 7/2/22 11:24 AM, Rainer Hurling wrote:
> > Hi Muhammad,
> >
> > Am 02.07.22 um 18:11 schrieb Muhammad Zubair Chishti:
> >> Dear Experts,
> >> I cannot find a package "wmtsa" for my R version "R 4.2.0". Kindly 
> >> help me to find it or share the link with me.
> >> Although I tried the old version of "wmtsa" but failed.
> >> Thank you for your precious time.
> >>
> >> Regards
> >> Muhammad Zubair Chishti
> >>
> >> [[alternative HTML version deleted]]
> >
> > AFAIK there is no package wmtsa anymore. It has been archived on
> > 2020-06-09 [1], the latest version was wmtsa_2.0-3.tar.gz from
> 2017-12-06.
> >
> > [1] 
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__cran.r-2Dprojec
> > t.org_src_contrib_Archive_wmtsa_=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg
> > =9PEhQh2kVeAsRzsn7AkP-g=dWy_4gLGVAfQXtlFKz60hApURH4b1S-aO2lzWIDMTy
> > ABcOJ1gS2DXUhqww0npRxq=dgdXo5a7Pf0lxEB5T1DNMCBEJICza3NUIVXlGNYnwA4
> > =
> >
> > HTH,
> > Rainer
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_ma
> > ilman_listinfo_r-2Dhelp=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2k
> > VeAsRzsn7AkP-g=dWy_4gLGVAfQXtlFKz60hApURH4b1S-aO2lzWIDMTyABcOJ1gS2
> > DXUhqww0npRxq=CuJJJWS5D5eyTOWy9Wfp3klxqALm4jzyFByUpvlj178=
> > 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=9PEhQh2
> > kVeAsRzsn7AkP-g=dWy_4gLGVAfQXtlFKz60hApURH4b1S-aO2lzWIDMTyABcOJ1gS
> > 2DXUhqww0npRxq=Q6r9x0BVDfQ_WvryQqz7NpwFr5qSH1VrW792A0VAfgY=
> > and provide commented, minimal, self-contained, reproducible code.
>
> __
> 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=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAs
> Rzsn7AkP-g=dWy_4gLGVAfQXtlFKz60hApURH4b1S-aO2lzWIDMTyABcOJ1gS2DXUhqw
> w0npRxq=CuJJJWS5D5eyTOWy9Wfp3klxqALm4jzyFByUpvlj178=
> PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.or
> g_posting-2Dguide.html=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeA
> sRzsn7AkP-g=dWy_4gLGVAfQXtlFKz60hApURH4b1S-aO2lzWIDMTyABcOJ1gS2DXUhq
> ww0npRxq=Q6r9x0BVDfQ_WvryQqz7NpwFr5qSH1VrW792A0VAfgY=
> 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=DwICAg=sJ6xIWYx-zLMB3EPkvcnVg=9PEhQh2kVeAsRzsn7AkP-g=dWy_4gLGVAfQXtlFKz60hApURH4b1S-aO2lzWIDMTyABcOJ1gS2DXUhqww0npRxq=CuJJJWS5D5eyTOWy9Wfp3klxqALm4jzyFByUpvlj178=
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=dWy_4gLGVAfQXtlFKz60hApURH4b1S-aO2lzWIDMTyABcOJ1gS2DXUhqww0npRxq=Q6r9x0BVDfQ_WvryQqz7NpwFr5qSH1VrW792A0VAfgY=
and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] A humble request

2022-07-02 Thread Spencer Graves

  Are you familiar with the "debug" function?


	  You can download the package, source the function you want to use. 
If it doesn't run or doesn't seem to give a sensible answer, debug(fun) 
followed by fun(arg1, arg2, arg3) will start the function then stop and 
invite you to walk through the function line by line.  You can look at 
what it does, and change it as you like.  Doing so should help you learn 
R while also making it easier for you to figure out how to make the 
function do what you want.



  Hope this helps.
  Spencer Graves


On 7/2/22 11:39 AM, Muhammad Zubair Chishti wrote:

Dear Respected Professor,
You are right. However, a student like me who doesn't know much R 
requires specific helping packages to install. Therefore, I requested 
here to experts to give the solution for my issue.


I hope that I will get the solution from this platform.

Regards
Muhammad Zubair Chishti

On Sat, 2 Jul 2022, 21:34 Spencer Graves, 
> wrote:


If I understand correctly the rules for "archived" packages, anyone is
free to download them, compile them locally -- AND resubmit any such
package with themselves as the maintainer:  They were archived, because
they would no longer pass CRAN checks, and the designated maintainer
failed to respond to the notice of problems with newer versions of R.
If anything I've said here is wrong or poorly nuanced, I trust someone
knowledgeable will correct me.  Spencer Graves


On 7/2/22 11:24 AM, Rainer Hurling wrote:
 > Hi Muhammad,
 >
 > Am 02.07.22 um 18:11 schrieb Muhammad Zubair Chishti:
 >> Dear Experts,
 >> I cannot find a package "wmtsa" for my R version "R 4.2.0". Kindly
 >> help me
 >> to find it or share the link with me.
 >> Although I tried the old version of "wmtsa" but failed.
 >> Thank you for your precious time.
 >>
 >> Regards
 >> Muhammad Zubair Chishti
 >>
 >> [[alternative HTML version deleted]]
 >
 > AFAIK there is no package wmtsa anymore. It has been archived on
 > 2020-06-09 [1], the latest version was wmtsa_2.0-3.tar.gz from
2017-12-06.
 >
 > [1] https://cran.r-project.org/src/contrib/Archive/wmtsa/

 >
 > HTH,
 > Rainer
 >
 > __
 > 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.



__
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] A humble request

2022-07-02 Thread Rainer Hurling

Hi Muhammad,

Am 02.07.22 um 18:11 schrieb Muhammad Zubair Chishti:

Dear Experts,
I cannot find a package "wmtsa" for my R version "R 4.2.0". Kindly help me
to find it or share the link with me.
Although I tried the old version of "wmtsa" but failed.
Thank you for your precious time.

Regards
Muhammad Zubair Chishti

[[alternative HTML version deleted]]


AFAIK there is no package wmtsa anymore. It has been archived on 
2020-06-09 [1], the latest version was wmtsa_2.0-3.tar.gz from 2017-12-06.


[1] https://cran.r-project.org/src/contrib/Archive/wmtsa/

HTH,
Rainer

__
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] A humble request

2022-07-02 Thread Muhammad Zubair Chishti
Dear Experts,
I cannot find a package "wmtsa" for my R version "R 4.2.0". Kindly help me
to find it or share the link with me.
Although I tried the old version of "wmtsa" but failed.
Thank you for your precious time.

Regards
Muhammad Zubair Chishti

[[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 a vector using an index with all missing values

2022-07-02 Thread Peter Langfelder
Ah, thanks, that makes sense.

Peter

On Fri, Jul 1, 2022 at 10:01 PM Bill Dunlap  wrote:
>
> This has to do with the mode of the subscript - logical subscripts are 
> repeated to the length of x and integer/numeric ones are not.  NA is logical, 
> NA_integer_ is integer, so we get
>
> > x <- 1:10
> > x[ rep(NA_integer_, 3) ]
> [1] NA NA NA
> > x[ rep(NA, 3) ]
>  [1] NA NA NA NA NA NA NA NA NA NA
>
> -Bill
>
>
> On Fri, Jul 1, 2022 at 8:31 PM Peter Langfelder  
> wrote:
>>
>> Hi all,
>>
>> I stumbled on subsetting behavior that seems counterintuitive and
>> perhaps is a bug. Here's a simple example:
>>
>> > x = 1:10
>> > x[ rep(NA, 3)]
>>  [1] NA NA NA NA NA NA NA NA NA NA
>>
>> I would have expected 3 NAs (the length of the index), not 10 (all
>> values in x). Looked at the documentation for the subsetting operator
>> `[` but found nothing indicating that if the index contains all
>> missing data, the result is the entire vector.
>>
>> I can work around the issue for a general 'index' using a somewhat
>> clunky but straightforward construct along the lines of
>>
>> > index = rep(NA, 3)
>> > x[c(1, index)][-1]
>> [1] NA NA NA
>>
>> but I'm wondering if the behaviour above is intended.
>>
>> Thanks,
>>
>> Peter
>>
>> __
>> 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.