[R] refresh.console() function?

2024-03-13 Thread Christofer Bogaso
Hi,

I run a lengthy for loop and I want to display loop status for each
step in my loop.

I previously heard of a R function namely refresh.console() which
would print the status within the loop as it progresses.

However I see this

> help.search("refresh.console")

No vignettes or demos or help files found with alias or concept or

title matching ‘refresh.console’ using regular expression matching.

Could you please help me find the correct function name?

__
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] Generating mouse click and hold using R

2024-03-13 Thread Christofer Bogaso
Hi,

I wonder if R can provide any functionality where I need simulate
mouse click in windows machine at certain coordinate on screen and
hold the click for certain seconds e.g. for 5 seconds

Really appreciate if I can have someone suggestion how above can be
simulated with R

Thanks and regards,

__
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] Code editor for writing R code

2023-11-29 Thread Christofer Bogaso
Hi Sergei,

Where can I find TeX Comments extension in VS Code?

On Wed, Nov 29, 2023 at 9:34 PM Sergei Ko  wrote:
>
> TeX Comments extension in VS Code
>
>
>
>
> Sent from my phone
>
>
>  Original message 
> From: Christofer Bogaso 
> Date: Wed, 29 Nov 2023, 15:57
> To: r-help 
> Subject: [R] Code editor for writing R code
>
> Hi,
>
> Currently I use VS-Code to write codes in R. While it is very good, it
> does not allow me to write Latex expressions in comments, which I am
> willing to have to write corresponding mathematical expressions as
> comments in my code files.
>
> Does there exist any Code editor for R, that allows me to write Latex
> in comments?
>
> Any information will be appreciated.
>
> Thanks,
>
> __
> 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] Code editor for writing R code

2023-11-29 Thread Christofer Bogaso
Hi,

Currently I use VS-Code to write codes in R. While it is very good, it
does not allow me to write Latex expressions in comments, which I am
willing to have to write corresponding mathematical expressions as
comments in my code files.

Does there exist any Code editor for R, that allows me to write Latex
in comments?

Any information will be appreciated.

Thanks,

__
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] if-else that returns vector

2023-10-13 Thread Christofer Bogaso
This is very interesting. Thanks for sharing.

On Fri, Oct 13, 2023 at 10:25 AM Richard O'Keefe  wrote:
>
> ?ifelse
> 'ifelse' returns a value with the same shape as 'test' which is
>  filled with elements selected from either 'yes' or 'no' depending
>  on whether the element of 'test' is 'TRUE' or 'FALSE'.
>
> This is actually rather startling, because elsewhere in the
> S (R) language, operands are normally replicated to the length
> of the longer.  Thus
> c(1,2,3)*10 + c(5,6)
> first (notionally) replicates 10 to c(10,10,10)
> and then c(5,6) to c(5,6,5), yielding c(15,26,35).
> And this *does* happen, sort of.
> > ifelse(c(F,T,F), c(1,2,3), c(5,6))
> => 5 2 5.
> But it *doesn't* apply to the test.
>
> There's another surprise.  Years ago I expected that
> all three arguments would be evaluated, then length
> adjusted, and then processing would be done.
> But the 2nd argument is evaluated (in full) if and only
> if some element of the test is true,
> and the 3rd argument is evaluated (in full) if and oly
> if some element of the test is false.
> ifelse(c(NA,NA), stop("true"), stop("false"))
> => c(NA,NA).
>
> At any rate, what you want is if ()  else 
>
>
>
> On Fri, 13 Oct 2023 at 09:22, Christofer Bogaso  
> wrote:
>>
>> Hi,
>>
>> Following expression returns only the first element
>>
>> ifelse(T, c(1,2,3), c(5,6))
>>
>> However I am looking for some one-liner expression like above which
>> will return the entire vector.
>>
>> Is there any way to achieve this?
>>
>> __
>> 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] if-else that returns vector

2023-10-12 Thread Christofer Bogaso
Hi,

Following expression returns only the first element

ifelse(T, c(1,2,3), c(5,6))

However I am looking for some one-liner expression like above which
will return the entire vector.

Is there any way to achieve this?

__
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] Finding combination of states

2023-09-04 Thread Christofer Bogaso
Let say I have 3 time points.as T0, T1, and T2.(number of such time
points can be arbitrary) In each time point, an object can be any of 5
states, A, B, C, D, E (number of such states can be arbitrary)

I need to find all possible ways, how that object starting with state
B (say) at time T0, can be on state E (example) in time T2

For example one possibility is BAE etc.

Is there any function available with R, that can give me a vector of
such possibilities for arbitrary number of states, time, and for a
given initial and final (desired) states?

ANy pointer will be very appreciated.

Thanks for your time.

__
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] Could not read time series data using read.zoo()

2023-08-03 Thread Christofer Bogaso
Hi,

I just provided a snapshot of my CSV file. Attaching the full file
here (not sure if R-help would accept the attachment).

Thanks and regards,

On Thu, Aug 3, 2023 at 8:35 PM Jeff Newmiller  wrote:
>
> no commas?
>
> On August 3, 2023 7:53:07 AM PDT, Christofer Bogaso 
>  wrote:
> >Hi,
> >
> >I have a CSV which contains data like below (only first few rows),
> >
> >Date Adj Close lret
> >02-01-1997 737.01
> >03-01-1997 748.03 1.48416235
> >06-01-1997 747.65 -0.050813009
> >07-01-1997 753.23 0.743567202
> >08-01-1997 748.41 -0.64196699
> >09-01-1997 754.85 0.856809786
> >10-01-1997 759.5 0.614126802
> >
> >However when I try to read this data using below code I get error,
> >
> >read.zoo("1.csv", sep = ',', format = '%d-%m-%Y')
> >
> >Error reads as,
> >
> >index has 4500 bad entries at data rows: 1 2 3 4 5 6 7 8 9.
> >
> >Could you please help to understand why I am getting this error?
> >
> >> sessionInfo()
> >
> >R version 4.2.2 (2022-10-31)
> >
> >Platform: x86_64-apple-darwin17.0 (64-bit)
> >
> >Running under: macOS Big Sur ... 10.16
> >
> >
> >Matrix products: default
> >
> >BLAS:   
> >/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
> >
> >LAPACK: 
> >/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
> >
> >
> >locale:
> >
> >[1] C/UTF-8/C/C/C/C
> >
> >
> >attached base packages:
> >
> >[1] stats graphics  grDevices utils datasets  methods   base
> >
> >
> >other attached packages:
> >
> >[1] zoo_1.8-12
> >
> >
> >loaded via a namespace (and not attached):
> >
> >[1] compiler_4.2.2  tools_4.2.2 grid_4.2.2  lattice_0.20-45
> >
> >__
> >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.


[R] Could not read time series data using read.zoo()

2023-08-03 Thread Christofer Bogaso
Hi,

I have a CSV which contains data like below (only first few rows),

Date Adj Close lret
02-01-1997 737.01
03-01-1997 748.03 1.48416235
06-01-1997 747.65 -0.050813009
07-01-1997 753.23 0.743567202
08-01-1997 748.41 -0.64196699
09-01-1997 754.85 0.856809786
10-01-1997 759.5 0.614126802

However when I try to read this data using below code I get error,

read.zoo("1.csv", sep = ',', format = '%d-%m-%Y')

Error reads as,

index has 4500 bad entries at data rows: 1 2 3 4 5 6 7 8 9.

Could you please help to understand why I am getting this error?

> sessionInfo()

R version 4.2.2 (2022-10-31)

Platform: x86_64-apple-darwin17.0 (64-bit)

Running under: macOS Big Sur ... 10.16


Matrix products: default

BLAS:   
/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib

LAPACK: 
/Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib


locale:

[1] C/UTF-8/C/C/C/C


attached base packages:

[1] stats graphics  grDevices utils datasets  methods   base


other attached packages:

[1] zoo_1.8-12


loaded via a namespace (and not attached):

[1] compiler_4.2.2  tools_4.2.2 grid_4.2.2  lattice_0.20-45

__
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] Adding comment in C++ code for debugging purpose

2022-12-17 Thread Christofer Bogaso
Hi,

Below is the position of Rcout and underlying C++ function

#ifdef _OPENMP
#include 
#endif
// [[Rcpp::depends(RcppProgress)]]
#include 
#include "cpploss.h"
#include 
#include 
#include 

using namespace Rcpp;

// [[Rcpp::export]]
SEXP  GCPM_cpploss(SEXP default_distr_a,SEXP link_function_a, SEXP
S_a,SEXP Sigma_a, SEXP W_a, SEXP PD_a, SEXP PL_a, SEXP calc_rc_a, SEXP
loss_thr_a, SEXP max_entries_a){
  Rcpp::Rcout << "Some Value" << std::endl << 1.23 << std::endl;
  NumericMatrix S(S_a), W(W_a),Sigma(Sigma_a);
  NumericVector PD(PD_a),
PL(PL_a),max_entries(max_entries_a),default_distr(default_distr_a),link_function(link_function_a),calc_rc(calc_rc_a),loss_thr(loss_thr_a);
  List ret;

etc

This still does not print in the console.

Not sure if I am missing something.

Thanks and regards,

On Sat, Dec 17, 2022 at 6:57 PM Rui Barradas  wrote:
>
> Às 11:05 de 17/12/2022, Christofer Bogaso escreveu:
> > Hi Rui,
> >
> > Unfortunately, the code Rcpp::Rcout << "-->>>>>.My values" <<
> > "\n"; still not printing the value.
> >
> > Regarding your second suggestion, R_Print("My values\n"); - where
> > should I put this statement?
> >
> > On Sat, Dec 17, 2022 at 11:39 AM Rui Barradas  wrote:
> >>
> >> Às 23:32 de 16/12/2022, Christofer Bogaso escreveu:
> >>> Hi,
> >>>
> >>> I am using an R package where there are some C++ code.
> >>>
> >>> To check some intermediate values generated by that C++ code, I added
> >>> a line like
> >>>
> >>> std::cout << "My values";
> >>>
> >>> Now with this modification, I next build a modified package (source) using
> >>>
> >>> R CMD build
> >>>
> >>> Next I install this modified package using install.packages() function
> >>>
> >>> However during the run-time of the C++ code with above modification, I
> >>> dont get any print with "My values"
> >>>
> >>> Can you please help to understand why am not getting that printed?
> >>>
> >>> __
> >>> 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,
> >>
> >> If the package uses Rcpp try instead
> >>
> >>
> >> Rcpp::Rcout << "My values" << "\n";   // or std::endl
> >>
> >>
> >> More generally, there is also
> >>
> >>
> >> R_Print("My values\n");
> >>
> >>
> >>
> >> Hope this helps,
> >>
> >> Rui Barradas
> >>
> >>
> >>
> >>
>
> Hello,
>
> Put R_Print where your cout is and instead of it.
>
> As for Rcpp::Rcout, instead of "\n" try ending the line with std::endl
> to immediately flush the buffer.
>
> Hope this helps,
>
> Rui Barradas
>
>

__
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] Adding comment in C++ code for debugging purpose

2022-12-17 Thread Christofer Bogaso
Hi Rui,

Unfortunately, the code Rcpp::Rcout << "-->>>>>.My values" <<
"\n"; still not printing the value.

Regarding your second suggestion, R_Print("My values\n"); - where
should I put this statement?

On Sat, Dec 17, 2022 at 11:39 AM Rui Barradas  wrote:
>
> Às 23:32 de 16/12/2022, Christofer Bogaso escreveu:
> > Hi,
> >
> > I am using an R package where there are some C++ code.
> >
> > To check some intermediate values generated by that C++ code, I added
> > a line like
> >
> > std::cout << "My values";
> >
> > Now with this modification, I next build a modified package (source) using
> >
> > R CMD build
> >
> > Next I install this modified package using install.packages() function
> >
> > However during the run-time of the C++ code with above modification, I
> > dont get any print with "My values"
> >
> > Can you please help to understand why am not getting that printed?
> >
> > __
> > 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,
>
> If the package uses Rcpp try instead
>
>
> Rcpp::Rcout << "My values" << "\n";   // or std::endl
>
>
> More generally, there is also
>
>
> R_Print("My values\n");
>
>
>
> Hope this helps,
>
> Rui Barradas
>
>
>
>

__
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] Adding comment in C++ code for debugging purpose

2022-12-17 Thread Christofer Bogaso
Hi Ivan,

This is a very nice point. I will check this out.

Thanks and regards,

On Sat, Dec 17, 2022 at 1:53 PM Ivan Krylov  wrote:
>
> On Sat, 17 Dec 2022 05:02:33 +0530
> Christofer Bogaso  wrote:
>
> > I am using an R package where there are some C++ code.
> >
> > To check some intermediate values generated by that C++ code, I added
> > a line like
> >
> > std::cout << "My values";
>
> A more efficient way of debugging C++ code running under R could be
> with the use of a C++ debugger. For example,
>
> 0) Make sure you have GDB (or a different debugger, e.g. lldb on a Mac)
> installed. You probably do, since you already have a working C++
> toolchain.
>
> 1) Run R using the command line: R -g gdb. The debugger will start and
> wait for your commands. Type: run. This will start R.
>
> 2) Type library(YOUR_PACKAGE_NAME) to load the package. You don't have
> to do it in this order (GDB can remember to set a breakpoint on a
> function that's not yet loaded in the address space), but this way you
> can be sure about the name of the function.
>
> 3) Press Ctrl-C, sending an interrupt to the application. GDB handles
> the interrupt and presents you with its prompt again. Type:
> break YOUR_FUNCTION_NAME. If the function name is right, GDB will tell
> you that a breakpoint is set. If not, it will ask you whether to
> postpone setting a breakpoint until the function shows up. Since the
> shared library should have been loaded by this time, the correct answer
> would be probably "no".
>
> 4) Type: continue. The debugger will give the control back to R. You
> can press Enter once and see R print the prompt symbol (">") again. Run
> your code that uses the package.
>
> 5) Eventually, you'll hit the breakpoint and find yourself in the
> debugger again. Like in the R browser, you can use "n" to step line by
> line, "s" to step inside function calls, and "c" to continue execution
> uninterrupted. You can also use "bt" and "frame NUMBER" to inspect the
> call stack and "print EXPRESSION" to see the values of various objects.
>
> A longer guide to GDB can be found at <https://beej.us/guide/bggdb/>.
> Telling GDB where the package source code is [*] will ease the process
> even further, as would obtaining debugging symbols and the source code
> for R itself.
>
> --
> Best regards,
> Ivan
>
> [*]
> https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html
> https://alex.dzyoba.com/blog/gdb-source-path/

__
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] Adding comment in C++ code for debugging purpose

2022-12-16 Thread Christofer Bogaso
Hi,

I am using an R package where there are some C++ code.

To check some intermediate values generated by that C++ code, I added
a line like

std::cout << "My values";

Now with this modification, I next build a modified package (source) using

R CMD build

Next I install this modified package using install.packages() function

However during the run-time of the C++ code with above modification, I
dont get any print with "My values"

Can you please help to understand why am not getting that printed?

__
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] How to access source code

2022-12-08 Thread Christofer Bogaso
Hi,

I am trying to access the source code from package GCPM, where I am
interested to look into the source code of one function called LGD. So
I did below

> LGD

standardGeneric for "LGD" defined from package "GCPM"


function (this)

standardGeneric("LGD")





Methods may be defined for arguments: this

Use  showMethods(LGD)  for currently available ones.

> showMethods(LGD)

Function: LGD (package GCPM)

this="GCPM"

However I still could not find the source code using above approach.

It would be very helpful if you can help to find the complete source
code of this function.

__
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] Fixing the size of R's Graphic Device

2022-08-25 Thread Christofer Bogaso
I really dont know what could be the right value. So I am trying to
get the right value based on trial and error.

All I want is that the graphic windows' height should occupy the
height of my screen and width should be ~70% of width of my scream

I am using Mac desktop (21.5 inch 2017 model) but running Windows.

On Fri, Aug 26, 2022 at 1:02 AM Jeff Newmiller  wrote:
>
> Please read ?windows. There is a limit to the default size, which I am 
> guessing is related to the default window stacking behavior.
>
> Also, units of width and height are in inches ... do you really have a 300 
> inch display?
>
> On August 25, 2022 12:05:00 PM PDT, Christofer Bogaso 
>  wrote:
> >Thanks.
> >
> >But this is woking upto some number
> >
> >For example
> >
> >options(device=function()windows(width=303,height=354,xpos=-5,ypos=9))
> >graphics.off()
> >plot(1:10)
> >
> >and
> >
> >options(device=function()windows(width=303,height=394,xpos=-5,ypos=9))
> >graphics.off()
> >plot(1:10)
> >
> >do not change the height of device
> >
> >On Fri, Aug 26, 2022 at 12:14 AM Bill Dunlap  
> >wrote:
> >>
> >> In one of your R startup files you can set options("device") to a function 
> >> that dev.new() will call when a new plot window is requested.  E.g.,
> >>
> >> options(device=function()windows(width=3,height=4.5,xpos=-200,ypos=100))
> >> graphics.off()
> >> plot(1:10)
> >>
> >>
> >> -Bill
> >>
> >>
> >> On Thu, Aug 25, 2022 at 11:11 AM Christofer Bogaso 
> >>  wrote:
> >>>
> >>> Hi,
> >>>
> >>> I am wondering if there is any way to fix the size (i.e. height and
> >>> width) of R's graphic device permanently. Every time I open R, and
> >>> create my first plot, the default size of the graphic device is fairly
> >>> small, and I need to adjust it manually to make it of comfortable
> >>> size.
> >>>
> >>> Any help is really appreciated.
> >>>
> >>> Thanks for your time.
> >>>
> >>> __
> >>> 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.
>
> --
> 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.


Re: [R] Fixing the size of R's Graphic Device

2022-08-25 Thread Christofer Bogaso
Thanks.

But this is woking upto some number

For example

options(device=function()windows(width=303,height=354,xpos=-5,ypos=9))
graphics.off()
plot(1:10)

and

options(device=function()windows(width=303,height=394,xpos=-5,ypos=9))
graphics.off()
plot(1:10)

do not change the height of device

On Fri, Aug 26, 2022 at 12:14 AM Bill Dunlap  wrote:
>
> In one of your R startup files you can set options("device") to a function 
> that dev.new() will call when a new plot window is requested.  E.g.,
>
> options(device=function()windows(width=3,height=4.5,xpos=-200,ypos=100))
> graphics.off()
> plot(1:10)
>
>
> -Bill
>
>
> On Thu, Aug 25, 2022 at 11:11 AM Christofer Bogaso 
>  wrote:
>>
>> Hi,
>>
>> I am wondering if there is any way to fix the size (i.e. height and
>> width) of R's graphic device permanently. Every time I open R, and
>> create my first plot, the default size of the graphic device is fairly
>> small, and I need to adjust it manually to make it of comfortable
>> size.
>>
>> Any help is really appreciated.
>>
>> Thanks for your time.
>>
>> __
>> 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] Fixing the size of R's Graphic Device

2022-08-25 Thread Christofer Bogaso
Hi,

I am using a large screen monitor, the default size comes with fairly
small maybe smaller than a quarter.

Is there any to get exact measure of the default size?

I am using R in WIndows 11 OS

On Thu, Aug 25, 2022 at 11:54 PM Jeff Newmiller
 wrote:
>
> What is your default graphics device? That is, what OS are you using?
>
> On August 25, 2022 11:10:45 AM PDT, Christofer Bogaso 
>  wrote:
> >Hi,
> >
> >I am wondering if there is any way to fix the size (i.e. height and
> >width) of R's graphic device permanently. Every time I open R, and
> >create my first plot, the default size of the graphic device is fairly
> >small, and I need to adjust it manually to make it of comfortable
> >size.
> >
> >Any help is really appreciated.
> >
> >Thanks for your time.
> >
> >__
> >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] Fixing the size of R's Graphic Device

2022-08-25 Thread Christofer Bogaso
Hi,

I am wondering if there is any way to fix the size (i.e. height and
width) of R's graphic device permanently. Every time I open R, and
create my first plot, the default size of the graphic device is fairly
small, and I need to adjust it manually to make it of comfortable
size.

Any help is really appreciated.

Thanks for your time.

__
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] Cumulative probability from binomial distribution

2022-06-30 Thread Christofer Bogaso
Hi,

I have the below output.

> pbinom(0.10, 1, 0.40)

[1] 0.6

I am curious what it means to serve a fraction as the first argument
in pbinom()?

Thanks for your time

__
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] Connection to Oracle DB failing from R

2020-08-31 Thread Christofer Bogaso
Hi,

The Java version below. Let me know if any other information is
required. Thanks,

java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)


On Mon, Aug 31, 2020 at 8:21 PM William Dunlap  wrote:
>
> Which version of java do you have installed?  Oracle's web site says
> ojdbc5.jar is for Java 1.5 and ojdbc6.jar is for more recent versions.
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Mon, Aug 31, 2020 at 3:56 AM Christofer Bogaso
>  wrote:
> >
> > Hi,
> >
> > I am trying to establish a connection to a Oracle DB from R and used below
> > code which is failing every time I try -
> >
> > > library(RJDBC)
> > Loading required package: DBI
> > > jdbcDriver =JDBC("oracle.jdbc.OracleDriver",classPath="ojdbc5.jar")
> >
> >  *** caught segfault ***
> > address 0x854961, cause 'memory not mapped'
> >
> > Traceback:
> >  1: .jinit(classPath)
> >  2: JDBC("oracle.jdbc.OracleDriver", classPath = "ojdbc5.jar")
> >
> > Possible actions:
> > 1: abort (with core dump, if enabled)
> > 2: normal R exit
> > 3: exit R without saving workspace
> > 4: exit R saving workspace
> > Selection:
> >
> >
> > Below is my session info -
> >
> > > sessionInfo()
> > R version 4.0.2 (2020-06-22)
> > Platform: x86_64-apple-darwin17.0 (64-bit)
> > Running under: macOS Catalina 10.15.6
> >
> > Matrix products: default
> > BLAS:
> >  /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
> > LAPACK:
> > /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
> >
> > locale:
> > [1] C/UTF-8/C/C/C/C
> >
> > attached base packages:
> > [1] stats graphics  grDevices utils datasets  methods   base
> >
> > other attached packages:
> > [1] RJDBC_0.2-8  DBI_1.1.0rJava_0.9-13
> >
> > loaded via a namespace (and not attached):
> > [1] compiler_4.0.2
> >
> > I downloaded the JAR file from
> > https://www.oracle.com/database/technologies/jdbcdriver-ucp-downloads.html
> >
> > Can you please help me to understand why it is failing?
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.

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


[R] Connection to Oracle DB failing from R

2020-08-31 Thread Christofer Bogaso
Hi,

I am trying to establish a connection to a Oracle DB from R and used below
code which is failing every time I try -

> library(RJDBC)
Loading required package: DBI
> jdbcDriver =JDBC("oracle.jdbc.OracleDriver",classPath="ojdbc5.jar")

 *** caught segfault ***
address 0x854961, cause 'memory not mapped'

Traceback:
 1: .jinit(classPath)
 2: JDBC("oracle.jdbc.OracleDriver", classPath = "ojdbc5.jar")

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:


Below is my session info -

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6

Matrix products: default
BLAS:
 /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK:
/Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] C/UTF-8/C/C/C/C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] RJDBC_0.2-8  DBI_1.1.0rJava_0.9-13

loaded via a namespace (and not attached):
[1] compiler_4.0.2

I downloaded the JAR file from
https://www.oracle.com/database/technologies/jdbcdriver-ucp-downloads.html

Can you please help me to understand why it is failing?

[[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] Bayesian estimation with MCMC

2020-05-23 Thread Christofer Bogaso
Hi,

In python there is a package called pymc3 for Bayesian parameter
estimation with MCMC.

I am curious if there is any equivalent package available for R.

Any pointer will be highly appreciated.

__
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] Notational derivative in R

2020-05-14 Thread Christofer Bogaso
Hi,

I was wondering if R can perform notational derivative something like
Mathematica does as explained in
https://reference.wolfram.com/language/howto/TakeADerivative.html

Any pointer will be highly appreciated.

Thanks,

__
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] Fitting Richards' curve

2020-05-13 Thread Christofer Bogaso
Hi,

Is there any R package to fit Richards' curve in the form of
https://en.wikipedia.org/wiki/Generalised_logistic_function

I found there is one package grofit, but currently defunct.

Any pointer appreciated.

__
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] save() unable to find object

2019-10-31 Thread Christofer Bogaso
Thanks Duncan. It worked.

On Thu, Oct 31, 2019 at 3:02 PM Duncan Murdoch  wrote:
>
> On 31/10/2019 5:17 a.m., Christofer Bogaso wrote:
> > As I said the name 'AAA31' is itself a variable. So I cant hard-code
> > it within the save() function
>
> Use the list= argument to save().
>
> Duncan Murdoch
>
> >
> > On Thu, Oct 31, 2019 at 2:45 PM Jim Lemon  wrote:
> >>
> >> Hi Christofer,
> >> This is a guess, but have you tried:
> >>
> >> save(AAA31,file="Save.RData")
> >>
> >> Jim
> >>
> >> On Thu, Oct 31, 2019 at 8:10 PM Christofer Bogaso
> >>  wrote:
> >>>
> >>> Hi,
> >>>
> >>> I wanted to save a few R objects in RData file for some future use.
> >>> The names of such R objects are actually dynamic so I used below code
> >>> to save them -
> >>>
> >>> Date = Sys.Date()
> >>> assign(paste('AAA', format(Date, "%d"), sep = ""), 5)
> >>> save('Date', paste('AAA', format(Date, "%d"), sep = ""), file = 
> >>> 'Save.RData')
> >>>
> >>> With this, I am getting below error -
> >>>
> >>> Error in save("Date", paste("AAA", format(Date, "%d"), sep = ""), file
> >>> = "Save.RData") :
> >>>object ‘paste("AAA", format(Date, "%d"), sep = "")’ not found
> >>>
> >>> But I have the object in the workplace -
> >>>
> >>>> AAA31
> >>> [1] 5
> >>>
> >>> I will really appreciate if someone can point towards the right direction.
> >>>
> >>> Thanks,
> >>>
> >>> __
> >>> 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] save() unable to find object

2019-10-31 Thread Christofer Bogaso
As I said the name 'AAA31' is itself a variable. So I cant hard-code
it within the save() function

On Thu, Oct 31, 2019 at 2:45 PM Jim Lemon  wrote:
>
> Hi Christofer,
> This is a guess, but have you tried:
>
> save(AAA31,file="Save.RData")
>
> Jim
>
> On Thu, Oct 31, 2019 at 8:10 PM Christofer Bogaso
>  wrote:
> >
> > Hi,
> >
> > I wanted to save a few R objects in RData file for some future use.
> > The names of such R objects are actually dynamic so I used below code
> > to save them -
> >
> > Date = Sys.Date()
> > assign(paste('AAA', format(Date, "%d"), sep = ""), 5)
> > save('Date', paste('AAA', format(Date, "%d"), sep = ""), file = 
> > 'Save.RData')
> >
> > With this, I am getting below error -
> >
> > Error in save("Date", paste("AAA", format(Date, "%d"), sep = ""), file
> > = "Save.RData") :
> >   object ‘paste("AAA", format(Date, "%d"), sep = "")’ not found
> >
> > But I have the object in the workplace -
> >
> > > AAA31
> > [1] 5
> >
> > I will really appreciate if someone can point towards the right direction.
> >
> > Thanks,
> >
> > __
> > 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] save() unable to find object

2019-10-31 Thread Christofer Bogaso
Hi,

I wanted to save a few R objects in RData file for some future use.
The names of such R objects are actually dynamic so I used below code
to save them -

Date = Sys.Date()
assign(paste('AAA', format(Date, "%d"), sep = ""), 5)
save('Date', paste('AAA', format(Date, "%d"), sep = ""), file = 'Save.RData')

With this, I am getting below error -

Error in save("Date", paste("AAA", format(Date, "%d"), sep = ""), file
= "Save.RData") :
  object ‘paste("AAA", format(Date, "%d"), sep = "")’ not found

But I have the object in the workplace -

> AAA31
[1] 5

I will really appreciate if someone can point towards the right direction.

Thanks,

__
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] How to use breaks argument in hist() function correctly?

2019-09-18 Thread Christofer Bogaso
Hi,

I have a numerical vector as below

x = c(92958.2014593977, -379826.025677203, 881937.411562002, 25761.5278163719,
-11837.158273897, 48450.8089746788, -415505.62910869, -168462.98512054,
328504.255373387, -298966.051027528, 237133.794811816, -49610.1148173768,
-92459.1170329526, -261611.557495123, -314388.27876, -432257.362693919,
-1031328.04402229, 79654.3696754137, 107072.114744956, -43384.1420067487,
410881.767122128, 1107540.47690119, -187319.627164858, -363126.966946238,
264885.548330589, -127020.002396109, 150315.10537545, 609502.016523236,
218679.801620448, 901573.599806465, 8289.59210428538, -860908.637977889,
39680.5921457494, -70270.7462533897, 1135442.61429015, 133964.991179536,
1603815.51357657, 2509929.42959337, 193680.587201446, -167020.153065672,
-55258.5415736386, -121185.161514792, -1003115.2769274, 1345368.12703686,
91665.388397883, 137350.320344812, 29866.332965572, 558999.444304371,
523687.79187, -867194.523170726, -271190.308507375, -423629.796389981,
96407.0505512169, 193397.770743584, -1231855.39144784, 324272.89909045,
-1586859.60653751, 252986.272621096, -1008329.14877038, -24090.2255466315,
159815.745712707, 969037.929787668, -586905.922684562, 573133.370665267,
-285493.361916026, -368392.707593945, -199242.654709143, 151002.480443041,
-678758.615800119, 467477.65504, -267683.37512503, -1541813.6353232,
-6723.49019530666, 373.233886695949, 59116.2440402955, -1369030.26511923,
1527024.1822942, 63951.299612343, -535128.407281035, 304507.377244809,
141771.552178838, 98963.774668207, 10810.9015935012, 1022008.90830883,
276804.330003406, -304607.247552493, -15767.6578367545, -204454.923166458,
722866.275157944, 137685.886832198, 590201.29119819, 904805.824902981,
-47417.8588758472, 55097.1936075327, 144426.170076371, 1020559.38779514,
-7019.11334737329, 488224.043025845, -28272.5766026849, -295384.449673914,
-93475.8799719289, -367939.725072447, -1244135.36327203, -863835.124327735,
-1399240.55792133, 241146.794430078, -96612.1109580967, -9159.41140641969,
-240291.731366074, -7482.02181888149, 71427.8225121907, -228401.89341468,
948738.649629141, -327368.940001115, -53374.866091836, 126448.573738739,
344962.4459403, 270571.141270723, 746988.197131718, -253220.465177424,
-362652.833437272, -4385.56796251462, -114398.64639441, 454240.63525686,
-1239567.92855698, -389939.987378005, -364083.196493484, 24693.1882238397,
4635.22406457209, 57992.688805147, -67934.5184434773, 123034.937557127,
483909.751375248, -167441.867070132, -382537.019103907, 267584.10264059,
-188944.743935369, -47062.5409102427, -860201.712919788, -203096.090898701,
44317.9727734545, 375924.206160012, 67000.7086638517, 137607.783105903,
-306430.502044082, -669552.84790218, -72629.0354820569, 251145.827045551,
-230557.16727732, -112594.52630222, 74052.4425890159, -105774.458850881,
-241185.430318678, -296663.488112722, 156807.699193046, -520102.742784345,
-56451.5201730288, -23171.0259034268, -107945.719878344, -158480.929620835,
-769507.414580615, -83077.050717928, 477248.698330914, 27706.3803488034,
70485.7144565997, 302213.341425514, -322119.331851626, -476228.406727923,
-99453.524756431, -673693.791106482, 38765.0473434452, 63302.3087165867,
116619.019966859, -167803.424492692, 82982.1864557734, -262627.809345438,
643538.235642472, -90724.2065826313, -435531.286293254, -371820.753318447,
-224713.223837607, -538987.838068522, -195841.454277966, 13924.6120356087,
-415252.7309228, 209424.879456433, 485624.048364534, 74317.8482029741,
19994.939065553, -460452.302259829, -141374.457424938, -77310.8968822459,
56112.3979095014, -150891.122921784, -679395.088755517, -523803.739201696,
-69888.2239139985, -4463.34352237508, -63616.8025699607, 906704.585396864,
1096575.89875834, -382869.397851591, -624324.630106468, -468837.009485095,
-49963.2943695135, 17038.2753380311, 756286.614911188, -995536.510249994,
308899.601761641, -375123.707808525, -113921.428586057, -61573.6957341075,
55239.3511454715, -46731.8391379398, 697843.754042485, 265162.29364751,
1133747.94683337, -355974.319924194, 30699.0482856455, -19680.791041683,
-624454.313911307, 94983.7375389124, 744849.080038272, 172732.610815633,
-120546.157860821, 62579.2205127864, -621204.554941904, 293869.359181081,
-108505.317455271, 646163.583792489, -502636.630380265, 502413.155645464,
-49238.362688755, 108812.985894042, -139113.621347874, 1120034.73283877,
-296008.55142246, -845627.626734492, 116082.364002893, 85096.4224949463,
-84149.6401610159, 611729.398657364, -783642.839894851, -9788.4825023263,
-58734.3009729933, -110950.384570162, -53258.3833170316, -20519.0858192393,
456910.655858686, 48830.1071552214, -358333.95721609, 80046.3518406906,
-224193.119044228, 45897.0722281932, -4895.48804178487, 735710.318540904,
183571.602770915, -103173.288434665, 554285.106452708, 536724.819749035,
-38962.2828892764, 26730.2338615816, -267784.282389664, 659763.691652086,
331635.73797362, -305496.497141735, 337703.432388682, 26793.2725583163,
-214055.61511956, 

Re: [R] A question on regular expression

2019-09-13 Thread Christofer Bogaso
A quick question.

Could you please explain the -- [^}]* -- part in finding the pattern?

On Fri, Sep 13, 2019 at 12:19 AM Bert Gunter  wrote:
>
>
> You can't use the same regex for str_extract_all as I used for sub (or gsub, 
> which is what is required here)! If you do this sort of thing a lot, you 
> *must* learn more about regex's.
>
> Anyway, this will do what you want I think:
>
> z <- paste("ab{cd$ }ed", "ab{cad$ }ed", collapse = " ")  ## just for 
> readability
>
> > str_extract_all(z,"\\{[^}]*\\}")
> [[1]]
> [1] "{cd$ }"  "{cad$ }"
>
> Cheers,
> Bert
>
> On Thu, Sep 12, 2019 at 10:12 AM Christofer Bogaso 
>  wrote:
>>
>> Thanks Bert,
>>
>> This works, but if in my text there are more than one patterns then
>> fails to generate desired result.
>>
>> library(stringr)
>> str_extract_all(paste("ab{cd$ }ed", "ab{cad$ }ed", collapse = " "),
>> ".*(\\{.*\\}).*")
>>
>> This generates below -
>>
>> [[1]]
>>
>> [1] "ab{cd$ }ed ab{cad$ }ed"
>>
>> I was expecting I would get a vector of length 2 with desired pattern.
>>
>> Where did I make any mistake?
>>
>> Thanks,
>>
>> On Thu, Sep 12, 2019 at 10:29 PM Bert Gunter  wrote:
>> >
>> > > sub(".*(\\{.*\\}).*", "\\1","ab{cd$ }ed")
>> > [1] "{cd$ }"
>> >
>> > Use ".+" instead of ".*" within the {} if you don't want to return empty 
>> > {}'s.
>> >
>> > You might wish to use the stringr package for string matching and 
>> > manipulation, as it provides a more user friendly and consistent interface 
>> > to these tasks.
>> >
>> >
>> > 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 Thu, Sep 12, 2019 at 9:31 AM Christofer Bogaso 
>> >  wrote:
>> >>
>> >> Hi,
>> >>
>> >> I am wondering on what is the correct way to select a pattern which goes 
>> >> as -
>> >>
>> >> {"(any character with any length)"}
>> >>
>> >> The expressions " {" " and " "} " both are included in the pattern.
>> >>
>> >> For example, the lookup of the above pattern in the text "
>> >> {"asaf455%"}57573blabla " will result in {"asaf455%"}
>> >>
>> >> Any help will be highly appreciated.
>> >>
>> >> Thanks,
>> >>
>> >> __
>> >> 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 question on regular expression

2019-09-12 Thread Christofer Bogaso
Awesome, thanks!

On Fri, Sep 13, 2019 at 12:19 AM Bert Gunter  wrote:
>
>
> You can't use the same regex for str_extract_all as I used for sub (or gsub, 
> which is what is required here)! If you do this sort of thing a lot, you 
> *must* learn more about regex's.
>
> Anyway, this will do what you want I think:
>
> z <- paste("ab{cd$ }ed", "ab{cad$ }ed", collapse = " ")  ## just for 
> readability
>
> > str_extract_all(z,"\\{[^}]*\\}")
> [[1]]
> [1] "{cd$ }"  "{cad$ }"
>
> Cheers,
> Bert
>
> On Thu, Sep 12, 2019 at 10:12 AM Christofer Bogaso 
>  wrote:
>>
>> Thanks Bert,
>>
>> This works, but if in my text there are more than one patterns then
>> fails to generate desired result.
>>
>> library(stringr)
>> str_extract_all(paste("ab{cd$ }ed", "ab{cad$ }ed", collapse = " "),
>> ".*(\\{.*\\}).*")
>>
>> This generates below -
>>
>> [[1]]
>>
>> [1] "ab{cd$ }ed ab{cad$ }ed"
>>
>> I was expecting I would get a vector of length 2 with desired pattern.
>>
>> Where did I make any mistake?
>>
>> Thanks,
>>
>> On Thu, Sep 12, 2019 at 10:29 PM Bert Gunter  wrote:
>> >
>> > > sub(".*(\\{.*\\}).*", "\\1","ab{cd$ }ed")
>> > [1] "{cd$ }"
>> >
>> > Use ".+" instead of ".*" within the {} if you don't want to return empty 
>> > {}'s.
>> >
>> > You might wish to use the stringr package for string matching and 
>> > manipulation, as it provides a more user friendly and consistent interface 
>> > to these tasks.
>> >
>> >
>> > 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 Thu, Sep 12, 2019 at 9:31 AM Christofer Bogaso 
>> >  wrote:
>> >>
>> >> Hi,
>> >>
>> >> I am wondering on what is the correct way to select a pattern which goes 
>> >> as -
>> >>
>> >> {"(any character with any length)"}
>> >>
>> >> The expressions " {" " and " "} " both are included in the pattern.
>> >>
>> >> For example, the lookup of the above pattern in the text "
>> >> {"asaf455%"}57573blabla " will result in {"asaf455%"}
>> >>
>> >> Any help will be highly appreciated.
>> >>
>> >> Thanks,
>> >>
>> >> __
>> >> 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 question on regular expression

2019-09-12 Thread Christofer Bogaso
Thanks Bert,

This works, but if in my text there are more than one patterns then
fails to generate desired result.

library(stringr)
str_extract_all(paste("ab{cd$ }ed", "ab{cad$ }ed", collapse = " "),
".*(\\{.*\\}).*")

This generates below -

[[1]]

[1] "ab{cd$ }ed ab{cad$ }ed"

I was expecting I would get a vector of length 2 with desired pattern.

Where did I make any mistake?

Thanks,

On Thu, Sep 12, 2019 at 10:29 PM Bert Gunter  wrote:
>
> > sub(".*(\\{.*\\}).*", "\\1","ab{cd$ }ed")
> [1] "{cd$ }"
>
> Use ".+" instead of ".*" within the {} if you don't want to return empty {}'s.
>
> You might wish to use the stringr package for string matching and 
> manipulation, as it provides a more user friendly and consistent interface to 
> these tasks.
>
>
> 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 Thu, Sep 12, 2019 at 9:31 AM Christofer Bogaso 
>  wrote:
>>
>> Hi,
>>
>> I am wondering on what is the correct way to select a pattern which goes as -
>>
>> {"(any character with any length)"}
>>
>> The expressions " {" " and " "} " both are included in the pattern.
>>
>> For example, the lookup of the above pattern in the text "
>> {"asaf455%"}57573blabla " will result in {"asaf455%"}
>>
>> Any help will be highly appreciated.
>>
>> Thanks,
>>
>> __
>> 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] A question on regular expression

2019-09-12 Thread Christofer Bogaso
Hi,

I am wondering on what is the correct way to select a pattern which goes as -

{"(any character with any length)"}

The expressions " {" " and " "} " both are included in the pattern.

For example, the lookup of the above pattern in the text "
{"asaf455%"}57573blabla " will result in {"asaf455%"}

Any help will be highly appreciated.

Thanks,

__
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] Partition a vector into select groups with fixed length

2019-08-18 Thread Christofer Bogaso
Hi,

Let say I have a vector as below

Vec = LETTERS

Now I want to break this vector into groups of the same length of 5.

So,
1st group consists - "A" "B" "C" "D" "E"
2nd group - "F" "G" "H" "I" "J"

and so on..
last group will consist only the leftover elements

I have a very large initial vector, so looking for some efficient way
to achieve the same. Any pointer will be highly appreciated.

Thanks for your time.

__
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] Extract row as NA with no matching name

2019-08-08 Thread Christofer Bogaso
Hi,

Let say I have below matrix

mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol = 3, byrow = TRUE,
   dimnames = list(c("row1", "row2"),
   c("C.1", "C.2", "C.3")))


Now I can extract a raw by rowname as

> mdat['row1', ]

C.1 C.2 C.3

  1   2   3


However I am also looking for was to extract values as NA when a
rowname is supplied which is not existing rownames

I should get

> mdat['new_raw', ]

C.1 C.2 C.3

  NA   NA   NA


Current it throws error as default functionality. Is there any way to
force R to provide values as NA instead of showing any errore?

[[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] A question on generating Error message upon Timeout

2019-05-09 Thread Christofer Bogaso
Hi,

I have created a function called myFn() which should be acting as below:

1. If function takes too long, then it will timeout and a specific message
will be displayed
2. This function may generate error on its own, so if it evaluates before
that specific time and fails then another specific message will be displayed
3. Within that specific time, if that function successfully run then the
result will be displayed.

To implement above strategy my function is as follows:


*library(R.utils)*
*myFn = function(n) {*
* n_Try = try({*
* if (n == 1) {Sys.sleep(10); Res = -123}*
* if (n == 2) stop()*
* if (n > 2) Res = 1:5 *
* }, silent = TRUE)*
* if (class(n_Try) == 'try-error') {*
* return("ERROR : Good Error.")*
* } else {*
* return(Res)*
* }*
* }*

Below is for case #1

*aa = *
*tryCatch({*
*  res <- withTimeout({*
*myFn(1)*
*  }, timeout = 2, onTimeout = 'error')*
*}, error = function(ex) {*
*  ("Timeout Error")*
*}); aa*

I was expecting to get the expression for *aa* as *"Timeout Error"*,
however I am getting *"ERROR : Good Error."*. This is not going with my plan

Also, I dont think this function getting timeout just after 2 sec, appears
like it is evaluating for longer time

However for *myFn(2)*, I am getting right message as "*"ERROR : Good
Error."*"

*aa = *
*tryCatch({*
*  res <- withTimeout({*
*myFn(2)*
*  }, timeout = 2, onTimeout = 'error')*
*}, error = function(ex) {*
*  ("Timeout Error")*
*}); aa*

So clearly my strategy is failing for *myFn(1)*. Any pointer where I was
wrong?

[[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] Snapshot of a shiny app

2019-04-16 Thread Christofer Bogaso
Hi,

I have a Shiny app with address like http://xx.xx.xx.xx:1080/remotepp/

When I try to get a PDF snapshot of this app using webshot() function from
webshot package, I see a blank PDF file saved.

I also tried with appshot() function as below, however getting error:

appshot(" http://xx.xx.xx.xx/remotepp  ", "a.pdf", port = 1080)
Error in process_initialize(self, private, command, args, stdout, stderr,
:
  Command not found

Any pointer on how to take snapshot properly would be highly appreciated.

[[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] Complete month name from as.yearmon()

2019-04-13 Thread Christofer Bogaso
Hi,

I am wondering if there is any way to get the full name from as.yearmon()
function. Please consider below example:

library(quantmod)
as.yearmon(Sys.Date())

This gives: [1] "Apr 2019".

How can I extract the full name ie. 'April 2019'

Appreciate your pointer. Thanks,

[[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] Memory usage

2019-02-18 Thread Christofer Bogaso
Hi,

I have below lines of code to understand how R manages memory.

> library(pryr)

*Warning message:*

*package ‘pryr’ was built under R version 3.4.3 *

> mem_change(x <- 1:1e6)

4.01 MB

> mem_change(y <- x)

976 B

> mem_change(x[100] < NA)

976 B

> mem_change(rm(x))

864 B

> mem_change(rm(y))

-4 MB

>

I do understand why there is only 976 B positive change in the 3rd line.
This is because now y and x both points to the same block of memory that
holds 1:1e6.

But I dont understand below

> mem_change(rm(x))

864 B
Why memory consumption increased here while deleting an object, although by
a small amount?

Any detailed explanation will be appreciated. Thanks,

[[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] TIme Zone error

2019-01-26 Thread Christofer Bogaso
Hi,

I want to set a specific Timezone for my R environment, with below syntax:

> Sys.getenv("Asia/Calcutta")

[1] ""

>
But it sets to some blank timezone.

I checked with OlsonNames(), to see available zones for R, where I found
"Asia/Calcutta" available.

I idea why R failed to set timezone properly?

Thanks for your time.

[[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] Webshot failed to take snapshot in Ubuntu machine

2019-01-06 Thread Christofer Bogaso
Thanks Martin,

I reinstalled PhantomJS and now it works fine. Regards,

On Thu, Dec 20, 2018 at 5:30 PM Martin Maechler 
wrote:

> >>>>> Marc Girondot via R-help
> >>>>> on Tue, 18 Dec 2018 13:53:34 +0100 writes:
>
> > Hi Christofer, I just try on MacOSX and ubuntu and it
> > works on both:
>
> > For ubuntu:
> >> Sys.info()
> >sysname
> >   "Linux"
> >   release
> >   "4.15.0-42-generic"
> >   version "#45-Ubuntu
> > SMP Thu Nov 15 19:32:57 UTC 2018"
> >  nodename
> >"lepidochelys"
> >   machine
> >  "x86_64"
>
> > Not sure what to do...
> > Marc
>
> Hmm, if I try it (on my Linux desktop), I get
>
>   > library(webshot)
>   > url <- "
> https://www.bseindia.com/stock-share-price/asian-paints-ltd/asianpaint/500820/
> "
>   > webshot(url, 'bb.pdf')
>   PhantomJS not found. You can install it with
> webshot::install_phantomjs(). If it is installed, please make sure the
> phantomjs executable can be found via the PATH variable.
>   NULL
>
> So, it is clear this relies on extra javascript based software
> being available on your computer, *and* having that correctly in
> your PATH.
>
> On my linux system, I then did
>webshot::install_phantomjs()
> and that downloaded things and installed a 67 Megabyte
> executable in my PATH ... which then subsequently worked.
>
> On that Linux system it did *not* work, try
>
>   system("which phantomjs")
>
> and you should see that it gets a version of 'phantomjs' on your
> computer, i.e., the one that  webshot() will then try to use and
> somehow fails.
>
> I'd recommend you run   webshot::install_phantomjs()
> which then should install a "better" version of the 'phantomjs'
> executable that then *should* work ..
>
> Let us know if this helped (or why not).
>
> Best,
> Martin Maechler
> ETH Zurich
>
> > Le 18/12/2018 à 13:37, Christofer Bogaso a écrit :
> >> Hi,
> >>
> >> I was using webshot package to take snapshot of a webpage
> >> as below:
> >>
> >> library(webshot) webshot('
> >>
> https://www.bseindia.com/stock-share-price/asian-paints-ltd/asianpaint/500820/
> ',
> >> 'bb.pdf')
> >>
> >> However what I see is a Blank PDF file is saved.
> >>
> >> However if I use the same code in my windows machine it
> >> is able to produce correct snapshot.
> >>
> >> Below is my system information
> >>> Sys.info()
> >> sysname "Linux" release "4.4.0-139-generic" version
> >> "#165-Ubuntu SMP Wed Oct 24 10:58:50 UTC 2018" nodename
> >> "ubuntu-s-2vcpu-4gb-blr1-01" machine "x86_64" login
> >> "root" user "root" effective_user "root"
> >>
> >> Any idea what went wrong would be highly helpful.
> >>
> >> Thanks,
> >>
> >> [[alternative HTML version deleted]]
> >>
> >> __
> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and
> >> more, see https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html and provide
> >> commented, minimal, self-contained, reproducible code.
>
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and
> > more, see https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html and provide
> > commented, minimal, self-contained, reproducible code.
>

[[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] Failed to install RQuantLib in Ubuntu machine

2019-01-02 Thread Christofer Bogaso
Hi,

I was trying to install RQuantLib in my Ubuntu machine which failed with
below information :

*> install.packages('RQuantLib', INSTALL_opts = c('--no-lock'))*

*Installing package into ‘/usr/local/lib/R/site-library’*

*(as ‘lib’ is unspecified)*

*trying URL 'https://cloud.r-project.org/src/contrib/RQuantLib_0.4.7.tar.gz
'*

*Content type 'application/x-gzip' length 189726 bytes (185 KB)*

*==*

*downloaded 185 KB*


** installing *source* package ‘RQuantLib’ ...*

*** package ‘RQuantLib’ successfully unpacked and MD5 sums checked*

*checking whether the C++ compiler works... yes*

*checking for C++ compiler default output file name... a.out*

*checking for suffix of executables... *

*checking whether we are cross compiling... no*

*checking for suffix of object files... o*

*checking whether we are using the GNU C++ compiler... yes*

*checking whether g++ accepts -g... yes*

*checking how to run the C++ preprocessor... g++ -E*

*checking whether we are using the GNU C++ compiler... (cached) yes*

*checking whether g++ accepts -g... (cached) yes*

*checking for R... yes*

*checking for quantlib-config... yes*

*checking for Boost development files... yes*

*checking for minimal Boost version... yes*

*configure: creating ./config.status*

*config.status: creating src/Makevars*

*Completed configuration and ready to build.*

*** libs*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g  -I/usr/local/include -fpermissive -I../inst/include
-I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
RcppExports.cpp -o RcppExports.o*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g  -I/usr/local/include -fpermissive -I../inst/include
-I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
affine.cpp -o affine.o*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g  -I/usr/local/include -fpermissive -I../inst/include
-I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
asian.cpp -o asian.o*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g  -I/usr/local/include -fpermissive -I../inst/include
-I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
barrier_binary.cpp -o barrier_binary.o*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g  -I/usr/local/include -fpermissive -I../inst/include
-I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
bermudan.cpp -o bermudan.o*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g  -I/usr/local/include -fpermissive -I../inst/include
-I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
bonds.cpp -o bonds.o*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g  -I/usr/local/include -fpermissive -I../inst/include
-I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
calendars.cpp -o calendars.o*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong -Wformat -Werror=format-security -Wdate-time
-D_FORTIFY_SOURCE=2 -g  -I/usr/local/include -fpermissive -I../inst/include
-I. -DBOOST_NO_AUTO_PTR -fopenmp -fpic  -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c
curves.cpp -o curves.o*

*g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG
-I"/usr/local/lib/R/site-library/Rcpp/include"   -g -O2
-fstack-protector-strong 

Re: [R] Webshot failed to take snapshot in Ubuntu machine

2018-12-18 Thread Christofer Bogaso
Is there any alternative to webshot?

On Tue, Dec 18, 2018 at 6:23 PM Marc Girondot  wrote:

> Hi Christofer,
> I just try on MacOSX and ubuntu and it works on both:
>
> For ubuntu:
>  > Sys.info()
>sysname
>"Linux"
>release
>"4.15.0-42-generic"
>version
> "#45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018"
>   nodename
> "lepidochelys"
>machine
>       "x86_64"
>
> Not sure what to do...
>
> Marc
>
> Le 18/12/2018 à 13:37, Christofer Bogaso a écrit :
> > Hi,
> >
> > I was using webshot package to take snapshot of a webpage as below:
> >
> > library(webshot)
> > webshot('
> >
> https://www.bseindia.com/stock-share-price/asian-paints-ltd/asianpaint/500820/
> ',
> > 'bb.pdf')
> >
> > However what I see is a Blank PDF file is saved.
> >
> > However if I use the same code in my windows machine it is able to
> produce
> > correct snapshot.
> >
> > Below is my system information
> >> Sys.info()
> > sysname
> > "Linux"
> > release
> > "4.4.0-139-generic"
> > version
> > "#165-Ubuntu SMP Wed Oct 24 10:58:50 UTC 2018"
> >nodename
> >"ubuntu-s-2vcpu-4gb-blr1-01"
> > machine
> >"x86_64"
> >   login
> >  "root"
> >user
> >  "root"
> >  effective_user
> >  "root"
> >
> > Any idea what went wrong would be highly helpful.
> >
> > Thanks,
> >
> >   [[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] Webshot failed to take snapshot in Ubuntu machine

2018-12-18 Thread Christofer Bogaso
Also the Session information.

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8   LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] pdftools_2.0  webshot_0.5.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.19 ps_1.1.0 crayon_1.3.4 assertthat_0.2.0
 [5] R6_2.3.0 jsonlite_1.5 magrittr_1.5 pillar_1.3.0
 [9] rlang_0.2.2  debugme_1.1.0callr_3.0.0  tools_3.4.4
[13] compiler_3.4.4   processx_3.2.0   base64enc_0.1-3  tibble_1.4.2

On Tue, Dec 18, 2018 at 6:07 PM Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:

> Hi,
>
> I was using webshot package to take snapshot of a webpage as below:
>
> library(webshot)
> webshot('
> https://www.bseindia.com/stock-share-price/asian-paints-ltd/asianpaint/500820/',
> 'bb.pdf')
>
> However what I see is a Blank PDF file is saved.
>
> However if I use the same code in my windows machine it is able to produce
> correct snapshot.
>
> Below is my system information
> > Sys.info()
>sysname
>"Linux"
>release
>"4.4.0-139-generic"
>version
> "#165-Ubuntu SMP Wed Oct 24 10:58:50 UTC 2018"
>   nodename
>   "ubuntu-s-2vcpu-4gb-blr1-01"
>machine
>   "x86_64"
>  login
> "root"
>   user
> "root"
> effective_user
> "root"
>
> Any idea what went wrong would be highly helpful.
>
> Thanks,
>

[[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] Webshot failed to take snapshot in Ubuntu machine

2018-12-18 Thread Christofer Bogaso
Hi,

I was using webshot package to take snapshot of a webpage as below:

library(webshot)
webshot('
https://www.bseindia.com/stock-share-price/asian-paints-ltd/asianpaint/500820/',
'bb.pdf')

However what I see is a Blank PDF file is saved.

However if I use the same code in my windows machine it is able to produce
correct snapshot.

Below is my system information
> Sys.info()
   sysname
   "Linux"
   release
   "4.4.0-139-generic"
   version
"#165-Ubuntu SMP Wed Oct 24 10:58:50 UTC 2018"
  nodename
  "ubuntu-s-2vcpu-4gb-blr1-01"
   machine
  "x86_64"
 login
"root"
  user
"root"
effective_user
"root"

Any idea what went wrong would be highly helpful.

Thanks,

[[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] Width of a text

2018-12-12 Thread Christofer Bogaso
Hi,

In HTML there is a way to measure the width of a Text before printing it on
screen as in https://www.w3schools.com/tags/canvas_measuretext.asp

In R we have nchar() function which just measures the number of letters in
a Text, but I wonder if we can measure the width of text as well.

I have a shiny app where I need to print a text in an Area onto the screen
which has a specific width, so some the texts are not showing within that
area (overflowing), where some are though all of them have the equal number
of letters.

Thanks for any input.

[[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] POSIXct format

2018-12-04 Thread Christofer Bogaso
Hi,

I am trying to format my Character strings to POSIXct as below :

> as.POSIXct('2018-11-2700:00:00', format = "%Y-%m-%d%H:%M:%S", tz = 'UTC')
[1] "2018-11-27 UTC"
> as.POSIXct('2018-11-2701:00:00', format = "%Y-%m-%d%H:%M:%S", tz = 'UTC')
[1] "2018-11-27 01:00:00 UTC"

For the first case, I wanted to see "2018-11-27 00:00:00 UTC", but the
Hour/Min/Sec part was missing in R output. Is it possible to get consistent
formatting in both cases?

Thanks for your help. Regards

[[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] Drawing a random number

2018-11-29 Thread Christofer Bogaso
Hi,

I would like to draw an Integer from a range of [10, 1000] inclusive,
however that random integer should be outside of a pre-defined vector of
integers.

Let say I draw an integer as below

as.integer(runif(1, 10, 1000))

and my pre-defined vector is

Vec = c(563, 453, 897, 567)

The policy is my drawn random integer should never be equal to any item
from Vec

Ofcourse I can use ifelse() to achieve the same, however I was wondering if
there is any direct way to get the same.

Thanks,

[[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] How to remove backslash

2018-09-21 Thread Christofer Bogaso
Hi,

I have below string where I am trying to remove Backslash from. I tried
with gsub() function, however failed to remove that:

> str = ' gsub("\\", "", str)
Error in gsub("\\", "", str) :
  invalid regular expression '\', reason 'Trailing backslash'


Any pointer to the right approach?

Thanks for your time

[[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] Obtaining exact pattern in list.files()

2018-09-12 Thread Christofer Bogaso
Hi,

In the list.files() function, there is an argument 'pattern' to locate the
desired files. However I failed to see if I can manage to fetch those files
that having an exact match.

For example, if there are 2 files that contain the expression 'File' and
'Second_File', then I should get the 1st one. However R is returning both
the files.

Any pointer on how to achieve that would be helpful. Thanks,

[[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] Cant schedule R job using taskscheduleR

2018-08-24 Thread Christofer Bogaso
Hi,

I am trying to schedule an R job using taskscheduler_create() function
available in package taskscheduleR.

Below is my code:

> library(taskscheduleR)
Warning message:
package ‘taskscheduleR’ was built under R version 3.5.1
> taskscheduler_create(taskname = "ABC", rscript = paste("C:\\ABC.R"),
startdate = format(Sys.Date() + 1, "%d/%m/%Y"), schedule = "WEEKLY",
starttime = "16:30", days = c("MON", "TUE", "WED", "THU", "FRI")[1])
[1] "ERROR: Incorrect Start Date."
attr(,"status")
[1] 16389
Warning message:
In system(cmd, intern = TRUE) :
  running command 'schtasks /Create /TN "ABC" /TR "cmd /c
C:/PROGRA~1/R/R-35~1.0/bin/Rscript.exe \"C:\ABC.R\"  >> \"C:\ABC.log\"
2>&1" /SC WEEKLY /ST 16:30 /SD "25/08/2018" /D MON ' had status 16389


However it fails with stating Incorrect Start Date.

Any help to understand what went wrong?

I am using R in Windows. Below is Session Information :

> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252LC_MONETARY=English_United States.1252 LC_NUMERIC=C
 LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] taskscheduleR_1.1

loaded via a namespace (and not attached):
[1] compiler_3.5.0tools_3.5.0   data.table_1.11.4

[[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] [FORGED] Adding % sign to ticks in persp()

2018-08-05 Thread Christofer Bogaso
Awesome, thanks!

On Mon, Aug 6, 2018 at 2:54 AM Paul Murrell 
wrote:

> Hi
>
> Not in the persp() function itself, but the following code converts the
> persp() output to 'grid' output then modifies the labels to add
> percentage signs ...
>
> x <- seq(-10, 10, length= 30)
> y <- x
> f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
> z <- outer(x, y, f)
> z[is.na(z)] <- 1
> op <- par(bg = "white")
> persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue",
>ticktype = "detailed")
>
> library(gridGraphics)
> grid.echo()
> labelGrobs <- grid.grep("z-axis-labels", grep=TRUE, global=TRUE)
> addPercent <- function(x) {
>  lab <- grid.get(x)
>  grid.edit(x, label=paste0(lab$label, "%"), redraw=FALSE)
> }
> lapply(labelGrobs, addPercent)
> grid.refresh()
>
> ... is that what you meant?  The positioning of the labels relative to
> the tick marks is imperfect and could perhaps be improved by also
> editing the 'cex' for the labels, but hopefully this gets close enough
> to be useful.
>
> Paul
>
> On 06/08/18 01:04, Christofer Bogaso wrote:
> > Hi,
> >
> > Is there any way to add styles to the tick marks in persp() function?
> >
> > For eample I want to add '%' suffix to the z-axis tick marks.in below
> plot :
> >
> > x <- seq(-10, 10, length= 30)
> > y <- x
> > f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
> > z <- outer(x, y, f)
> > z[is.na(z)] <- 1
> > op <- par(bg = "white")
> > persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue",
> > ticktype = "detailed")
> >
> >   [[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 Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> p...@stat.auckland.ac.nz
> http://www.stat.auckland.ac.nz/~paul/
>

[[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] Adding % sign to ticks in persp()

2018-08-05 Thread Christofer Bogaso
Hi,

Is there any way to add styles to the tick marks in persp() function?

For eample I want to add '%' suffix to the z-axis tick marks.in below plot :

x <- seq(-10, 10, length= 30)
y <- x
f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r }
z <- outer(x, y, f)
z[is.na(z)] <- 1
op <- par(bg = "white")
persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue",
ticktype = "detailed")

[[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] dbGetQuery() returns wrong value

2018-07-30 Thread Christofer Bogaso
The data type is defined as bigint

On Mon, Jul 30, 2018 at 4:45 PM Eric Berger  wrote:

> The ID matches in the first 16 characters.
> How is your table  declared?
>
>
> On Mon, Jul 30, 2018 at 2:00 PM, Christofer Bogaso <
> bogaso.christo...@gmail.com> wrote:
>
>> Session Information for above error:
>>
>> > sessionInfo()
>> R version 3.5.0 (2018-04-23)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>> Running under: Windows 10 x64 (build 16299)
>>
>> Matrix products: default
>>
>> locale:
>> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
>> States.1252LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>>  LC_TIME=English_United States.1252
>>
>> attached base packages:
>> [1] stats graphics  grDevices utils datasets  methods   base
>>
>> other attached packages:
>> [1] csvread_1.2   bit64_0.9-7   bit_1.1-14RJDBC_0.2-7.1 rJava_0.9-10
>> DBI_1.0.0
>>
>> loaded via a namespace (and not attached):
>> [1] compiler_3.5.0 tools_3.5.0
>>
>> On Mon, Jul 30, 2018 at 2:27 PM Christofer Bogaso <
>> bogaso.christo...@gmail.com> wrote:
>>
>> > Hi,
>> >
>> > I used following SQL query to fetch information from DB
>> >
>> > > dbGetQuery(Conn, "select ID from  where date = '2018-07-18' and
>> ID =
>> > '72075186224672770' limit 10")
>> >  ID
>> > 1 72075186224672768
>> >
>> > As you see, it is returning a different result from what actual query
>> > string contains.
>> >
>> > However when I used the same query in some other SQL client, I get the
>> > expected result as:
>> >
>> > 72075186224672770
>> >
>> > Any idea on what went wrong in R supplied query would be highly
>> > appreciated.
>> >
>> >
>>
>> [[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] dbGetQuery() returns wrong value

2018-07-30 Thread Christofer Bogaso
Session Information for above error:

> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
States.1252LC_MONETARY=English_United States.1252 LC_NUMERIC=C
 LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
[1] csvread_1.2   bit64_0.9-7   bit_1.1-14RJDBC_0.2-7.1 rJava_0.9-10
DBI_1.0.0

loaded via a namespace (and not attached):
[1] compiler_3.5.0 tools_3.5.0

On Mon, Jul 30, 2018 at 2:27 PM Christofer Bogaso <
bogaso.christo...@gmail.com> wrote:

> Hi,
>
> I used following SQL query to fetch information from DB
>
> > dbGetQuery(Conn, "select ID from  where date = '2018-07-18' and ID =
> '72075186224672770' limit 10")
>  ID
> 1 72075186224672768
>
> As you see, it is returning a different result from what actual query
> string contains.
>
> However when I used the same query in some other SQL client, I get the
> expected result as:
>
> 72075186224672770
>
> Any idea on what went wrong in R supplied query would be highly
> appreciated.
>
>

[[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] dbGetQuery() returns wrong value

2018-07-30 Thread Christofer Bogaso
Hi,

I used following SQL query to fetch information from DB

> dbGetQuery(Conn, "select ID from  where date = '2018-07-18' and ID =
'72075186224672770' limit 10")
 ID
1 72075186224672768

As you see, it is returning a different result from what actual query
string contains.

However when I used the same query in some other SQL client, I get the
expected result as:

72075186224672770

Any idea on what went wrong in R supplied query would be highly appreciated.

[[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] Saving objects in RData file in different name

2018-07-28 Thread Christofer Bogaso
Hi,

Let say I have 2 objects as below

x1 = 1:3
x2 = 5:4

Now I want to save both x1 and x2 in some RData file, however x1 will be
saved with a different name e.g. y

I tried below

save(y = x1, x2, file = "file.RData")

However still they are saved in their original names i.e. x1 and x2, not y
and y2.

Is there any possibility that I can achieve above without explicitly
copying y = x1 before y is passed to save()

Thanks for any feedback.

[[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] Stop a loop if it takes long time

2018-07-24 Thread Christofer Bogaso
Hi,

Let say I am implementing a loop using for() / apply()-family etc.

Now, the calculation-time within a particular loop is not fixed, means,
some loop takes a long time to finish calculation, and next loop perhaps
very quick to finish.

I am exploring if there is any way, to check if the calculation within a
particular loop takes longer time than a pre-fixed threshold and if it does
then kill that loop and proceed to the next.

Is it possible to implement such without adding much overhead with existing
calculation?

Thanks for your feedback

[[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] Zoo changing time-zone when I merge 2 zoo time series

2018-07-09 Thread Christofer Bogaso
My default is set as GMT.

On Mon, Jul 9, 2018 at 4:01 PM David Wolfskill  wrote:

> On Mon, Jul 09, 2018 at 03:52:02PM +0530, Christofer Bogaso wrote:
> > Hi,
> >
> > Below is my code :
> >
> > library(zoo)
> > Dat1 = structure(c(17890, 17770.01, 17600, 17593, 17630.01), index =
> > structure(c(1512664740,
> > 1512664800, 1512664860, 1512664920, 1512664980), class = c("POSIXct",
> > "POSIXt"), tzone = "America/Los_Angeles"), class = "zoo")
> > Dat2 = structure(c(15804.28, 15720.61, 15770, 15750, 15770), index =
> > structure(c(1512664740,
> > 1512664800, 1512664860, 1512664920, 1512664980), class = c("POSIXct",
> > "POSIXt"), tzone = "America/Los_Angeles"), class = "zoo")
> >
> > merge(Dat1, Dat2)
> >
> > Dat1 Dat2
> > 2017-12-07 22:09:00 17890.00 15804.28
> > 2017-12-07 22:10:00 17770.01 15720.61
> > 2017-12-07 22:11:00 17600.00 15770.00
> > 2017-12-07 22:12:00 17593.00 15750.00
> > 2017-12-07 22:13:00 17630.01 15770.00
> >
> >
> > So, after merging the TZ of the original series got changed.
> >
> > Appreciate if someone points what went wrong
> > 
>
> Well... when I do the above, I see:
>
> > Dat1
> 2017-12-07 08:39:00 2017-12-07 08:40:00 2017-12-07 08:41:00 2017-12-07
> 08:42:00
>17890.0017770.0117600.00
> 17593.00
> 2017-12-07 08:43:00
>17630.01
> > Dat2
> 2017-12-07 08:39:00 2017-12-07 08:40:00 2017-12-07 08:41:00 2017-12-07
> 08:42:00
>15804.2815720.6115770.00
> 15750.00
> 2017-12-07 08:43:00
>15770.00
> > merge(Dat1, Dat2)
>
> Dat1 Dat2
> 2017-12-07 08:39:00 17890.00 15804.28
> 2017-12-07 08:40:00 17770.01 15720.61
> 2017-12-07 08:41:00 17600.00 15770.00
> 2017-12-07 08:42:00 17593.00 15750.00
> 2017-12-07 08:43:00 17630.01 15770.00
> >
>
> That said, one aspect that may be relevant:
> > Sys.timezone()
> [1] "America/Los_Angeles"
>
> What's yours?
>
>
> Peace,
> david
> --
> David H. Wolfskill  r...@catwhisker.org
> "Fly, Trump Baby!" -- only the biggest, YUGEST insults for Donald J. Trump!
>
> See http://www.catwhisker.org/~david/publickey.gpg for my public key.
>

[[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] Zoo changing time-zone when I merge 2 zoo time series

2018-07-09 Thread Christofer Bogaso
Hi,

Below is my code :

library(zoo)
Dat1 = structure(c(17890, 17770.01, 17600, 17593, 17630.01), index =
structure(c(1512664740,
1512664800, 1512664860, 1512664920, 1512664980), class = c("POSIXct",
"POSIXt"), tzone = "America/Los_Angeles"), class = "zoo")
Dat2 = structure(c(15804.28, 15720.61, 15770, 15750, 15770), index =
structure(c(1512664740,
1512664800, 1512664860, 1512664920, 1512664980), class = c("POSIXct",
"POSIXt"), tzone = "America/Los_Angeles"), class = "zoo")

merge(Dat1, Dat2)

Dat1 Dat2
2017-12-07 22:09:00 17890.00 15804.28
2017-12-07 22:10:00 17770.01 15720.61
2017-12-07 22:11:00 17600.00 15770.00
2017-12-07 22:12:00 17593.00 15750.00
2017-12-07 22:13:00 17630.01 15770.00


So, after merging the TZ of the original series got changed.

Appreciate if someone points what went wrong

[[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] R couldnt recognize US Pasific timezome

2018-07-09 Thread Christofer Bogaso
Hi,

I wanted to convert Epoch time to readable time with US Pacific Time Zone
using 'anytime' package, as below:

> library(anytime)
> anytime(1417411980, tz = 'PST')
[1] "2014-12-01 05:33:00 GMT"
Warning message:
In as.POSIXlt.POSIXct(x, tz) : unknown timezone 'PST'


However it appears that R couldn't recognize the PST as the short form of
Pacific time zone.

Any help to correctly change Epoch time to corresponding pacific time would
be helpful.

Thanks,

[[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 Christofer Bogaso
Hi,

On ' how to use "top" inside the R prompt? '
you can use system('top') command.

Thanks,

On Sun, Jul 1, 2018 at 9:53 PM Benoit Vaillant 
wrote:

> Hello,
>
> On Sun, Jul 01, 2018 at 11:31:29AM +, akshay kulkarni wrote:
> > 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.
>
> Try to open two bash prompts, in one use R and in the other use top to
> monitor what is going on.
>
> > 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.
>
> top is a shell command, no issue with R not knowing about this.
>
> > 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?
>
> Basically, you can't.
>
> > 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...
>
> ... (many more dots) Do you think we are experts on your system?
>
> Please do your home work and get back to us once it's done. ;-)
>
> Cheers,
>
> --
> Benoît
> __
> 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] A question on Statistics

2018-07-01 Thread Christofer Bogaso
I derive posting guide from https://www.r-project.org/posting-guide.html

I am imagining a distribution where mean is zero but there are few large
observations in the positive side which are not very frequent.

On Sun, Jul 1, 2018 at 8:29 PM Bert Gunter  wrote:

> From the posting guide:
>
> "*R-help* is intended to be comprehensible to people who want to use R to
> solve problems but who are not necessarily interested in or knowledgeable
> about programming."
>
> This says to me that R-help is for general questions about R programming,
> not statistics, though I grant you that the intersection is nonempty.
> Nevertheless, purely statistical issues should be posted elsewhere, and
> your query appears to be such.
>
> However, I'll just note: what does "centered at 0" mean for an asymmetric
> distribution? I think you may need to reconsider Jeff's advice.
>
>
> Cheers,
> Bert
>
>
>
> 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 Sun, Jul 1, 2018 at 5:53 AM, Christofer Bogaso <
> bogaso.christo...@gmail.com> wrote:
>
>> Hi,
>>
>> I could post in StackExchange for sure, however I dont think R-help
>> posting
>> guide discourage asking a question about Statistics, atleast formally.
>>
>> I could further clarify if my question is not elaborate enough. And many
>> apologies if it is very trivial - however still I am looking for 2nd
>> opinion on my question.
>>
>> Answer to Jeff's pointer - yes my distribution is assumed to be centered
>> at
>> 0.
>>
>> Thanks,
>>
>> On Sun, Jul 1, 2018 at 8:04 AM Hasan Diwan  wrote:
>>
>> > Christofer,
>> > On Sat, 30 Jun 2018 at 12:54, Jeff Newmiller 
>> > wrote:
>> > >
>> > > You should use Stack Exchange for questions about statistics.
>> >
>> > Specifically, https://stats.stackexchange.com/ -- H
>> > --
>> > OpenPGP:
>> > https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
>> > If you wish to request my time, please do so using
>> > bit.ly/hd1AppointmentRequest.
>> > Si vous voudrais faire connnaisance, allez a
>> bit.ly/hd1AppointmentRequest.
>> >
>> > Sent from my mobile device
>> > Envoye de mon portable
>> >
>> > __
>> > 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] A question on Statistics

2018-07-01 Thread Christofer Bogaso
Hi,

I could post in StackExchange for sure, however I dont think R-help posting
guide discourage asking a question about Statistics, atleast formally.

I could further clarify if my question is not elaborate enough. And many
apologies if it is very trivial - however still I am looking for 2nd
opinion on my question.

Answer to Jeff's pointer - yes my distribution is assumed to be centered at
0.

Thanks,

On Sun, Jul 1, 2018 at 8:04 AM Hasan Diwan  wrote:

> Christofer,
> On Sat, 30 Jun 2018 at 12:54, Jeff Newmiller 
> wrote:
> >
> > You should use Stack Exchange for questions about statistics.
>
> Specifically, https://stats.stackexchange.com/ -- H
> --
> OpenPGP:
> https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
> If you wish to request my time, please do so using
> bit.ly/hd1AppointmentRequest.
> Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest.
>
> Sent from my mobile device
> Envoye de mon portable
>
> __
> 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] A question on Statistics

2018-06-30 Thread Christofer Bogaso
Hi,

I have a quick question on Statistical distribution as follows, hoping
Statisticians here would give me very insightful feedback.

Say, I have a large sample from a highly asymmetric distribution ranging
from -Inf to +Inf. Now I wish to calculate sample X1 and X2 within which
middle 70% probability would reside.

One approach
x = my sample
calculatte quantile(x, prob = 15%) & quantile(x, prob = 85%)

another approach
calculate quantile(abs[x], prob = 85%)
In this case X1 and X2 would be +/- of above result.

My question is in all scenarios, are above two approach equivalent? If not
which is the better approach to find such range.

Thanks,

[[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] Correctly executing system code using R in Ubuntu server

2018-06-25 Thread Christofer Bogaso
It worked. Thanks,

On Tue, Jun 26, 2018 at 2:46 AM William Dunlap  wrote:

> Each call to system() starts and finishes a new shell so your approach
> will not work.
> Does the following do what you need?
>
> > system('Xvfb :10 -ac &')
> > Sys.setenv(DISPLAY=":10")
> > x11()
> Warning message:
> In x11() : cairo-based types may only work correctly on TrueColor visuals
>
>
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Mon, Jun 25, 2018 at 2:04 PM, Christofer Bogaso <
> bogaso.christo...@gmail.com> wrote:
>
>> Hi,
>>
>> I am curious on how to correctly run System code with R under Ubuntu. I
>> tried to execute below 2 lines of code using system() functions in Ubuntu
>> server, however could not achieve the desired result.
>>
>> system('Xvfb :10 -ac &')
>> system('export DISPLAY=:10')
>>
>> System parameters:
>> > Sys.info()
>>sysname
>>"Linux"
>>release
>>"4.4.0-128-generic"
>>version
>> "#154-Ubuntu SMP Fri May 25 14:15:18 UTC 2018"
>>   nodename
>>   "ubuntu-s-2vcpu-4gb-blr1-01"
>>machine
>>   "x86_64"
>>  login
>> "root"
>>   user
>> "root"
>> effective_user
>> "root"
>>
>> Background:
>> I use RSelenium package to perform various testing using web-browser. I
>> have installed firefox to do the same, however to make RSelenium work, it
>> requires display parameter as guided in below link:
>>
>> https://medium.com/@griggheo/running-selenium-webdriver-tests-using-firefox-headless-mode-on-ubuntu-d32500bb6af2
>> I want to set those parameters through R, each time I start R in Ubuntu
>> server.
>>
>> Appreciate for any pointer.
>>
>> Thanks,
>>
>> [[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] Correctly executing system code using R in Ubuntu server

2018-06-25 Thread Christofer Bogaso
Hi,

I am curious on how to correctly run System code with R under Ubuntu. I
tried to execute below 2 lines of code using system() functions in Ubuntu
server, however could not achieve the desired result.

system('Xvfb :10 -ac &')
system('export DISPLAY=:10')

System parameters:
> Sys.info()
   sysname
   "Linux"
   release
   "4.4.0-128-generic"
   version
"#154-Ubuntu SMP Fri May 25 14:15:18 UTC 2018"
  nodename
  "ubuntu-s-2vcpu-4gb-blr1-01"
   machine
  "x86_64"
 login
"root"
  user
"root"
effective_user
"root"

Background:
I use RSelenium package to perform various testing using web-browser. I
have installed firefox to do the same, however to make RSelenium work, it
requires display parameter as guided in below link:
https://medium.com/@griggheo/running-selenium-webdriver-tests-using-firefox-headless-mode-on-ubuntu-d32500bb6af2
I want to set those parameters through R, each time I start R in Ubuntu
server.

Appreciate for any pointer.

Thanks,

[[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] Efficient manipulation with list object

2018-06-10 Thread Christofer Bogaso
Using do.call() reduces my calculation time significantly.

On Sun, Jun 10, 2018 at 10:45 PM ruipbarradas  wrote:

> Hello,
>
> Instead of Reduce try do.call.
>
> do.call ('rbind', list)
>
> But with such a long list it will still take time.
>
> Hope this helps,
>
> Rui Barradas
>
>
>
> Enviado a partir do meu smartphone Samsung Galaxy.
> ---- Mensagem original 
> De: Christofer Bogaso 
> Data: 10/06/2018 16:33 (GMT+00:00)
> Para: r-help 
> Assunto: [R] Efficient manipulation with list object
>
> Hi,
>
> I have a list of length 10,000, and each element of that list is a matrix
> with 3 columns and 2,000 rows.
>
> Now when I tried to make a Matrix object with that list using
> Reduce('rbind', list), my code is taking a considerable amount of time.
>
> Is there any way to implement same above task in more efficient way?
>
> Thanks,
>
> [[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] Efficient manipulation with list object

2018-06-10 Thread Christofer Bogaso
Hi,

I have a list of length 10,000, and each element of that list is a matrix
with 3 columns and 2,000 rows.

Now when I tried to make a Matrix object with that list using
Reduce('rbind', list), my code is taking a considerable amount of time.

Is there any way to implement same above task in more efficient way?

Thanks,

[[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] Time and date conversion

2018-06-04 Thread Christofer Bogaso
Hi,

I have an automatic data feed and I obtained a Date vector in the following
format:

> Date
[1] "03 Jun 2018 10:01 am CT""01 Jun 2018 22:04:25 pm CT"

I now like to convert it to UTC time-zone

Is there any easy way to convert them so, particularly since 1st element
doesnt have any Second element whereas the 2nd element has.

Thanks for any pointer.

[[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] Unable to take correct Web-snapshot

2018-06-01 Thread Christofer Bogaso
Thanks for that information.

However how can I use R to directly get data from that API?

On Fri, Jun 1, 2018 at 8:36 PM Martin Møller Skarbiniks Pedersen <
traxpla...@gmail.com> wrote:

> On 1 June 2018 at 15:08, Christofer Bogaso 
> wrote:
> > Hi again,
> >
> > I use the *webshot* package to take snapshot from Webpage. However, when
> I
> > try to take snapshot from* https://www.coinbase.com/
> > <https://www.coinbase.com/>*, this fails to take the full snapshot of
> that
> > page.
>
> Yes, that is a general problem with many webshot programs and libraries.
>
> The coinbase page ( and many others ) uses a lot of javascript to generate
> their
> pages and the webshot programs must understand javascript in all
> details which is hard.
>
> If you are looking for the coinbase prices you can use their api to
> get json instead:
>
> https://api.coinbase.com/v2/prices/spot?currency=USD
>
> Regards
> Martin
>
> __
> 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] Unable to take correct Web-snapshot

2018-06-01 Thread Christofer Bogaso
Hi again,

I use the *webshot* package to take snapshot from Webpage. However, when I
try to take snapshot from* https://www.coinbase.com/
*, this fails to take the full snapshot of that
page.

I tried following :

> library(webshot)
> webshot("https://www.coinbase.com/;, 'aa.pdf')

However in the pdf page, I done see the quotes which are available on the
main page in the 4 boxes.

Any help how to resolve this would be highly appreciated.

Thanks,

[[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] Wired result when I convert from Character to Numeric

2018-05-23 Thread Christofer Bogaso
Hi,

Below is my simple result in R

> x = "1282553.821000"
> as.numeric(x)
[1] 1282554

Any idea where all numbers in the decimal places (ie 8, 2, 1) are gone?

Thanks,

__
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] Split a data.frame

2018-05-19 Thread Christofer Bogaso
Hi,

I am struggling to split a data.frame as will below scheme :

DF = data.frame(name = c('a', 'v', 'c'), val = 0); DF

split_str = c('a', 'c')

Now, for each element in split_str, R should find which row of DF contains
that element, and return DF with all rows starting from next row of the
corresponding element and ending with the preceding value of the next
element.

So in my case, I should see 2 data.frames

1st data-frame with name = 'v' (i.e. 2nd row of DF)

2nd data.frame with number_of_rows as 0 (as there is no row left after 'c')

Similarly if split_str = c('v'') then, my 2 data.frames will be

1st data.frame with name = 'a'
2nd data.frame with name = 'c'

Any idea how to efficiently implement above scheme would be highly
appreciated. I tried with split() function, however, it is not giving the
right answer.

Thanks,

__
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] Quandl data download error

2018-05-14 Thread Christofer Bogaso
Hi,

I use Quandl package to download data from Quandl https://www.quandl.com

Today when I tried to download data from there, I received below error :

> Quandl('LME/PR_CO')
Error in curl::curl_fetch_memory(url, handle = handle) :
   gnutls_handshake() failed: An unexpected TLS packet was received.

I am using Quandl_2.8.0 in below platform

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Any idea why I am getting above error suddenly?

Thanks for your help

__
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] Rolling window difference for zoo time series

2018-04-24 Thread Christofer Bogaso
Hi,

I have a 'zoo' time series as below :

Zoo_TS = zoo(5:1, as.Date(Sys.time())+0:4)

Now I want to calculate First order difference of order 1, rolling
window basis i.e.

(Zoo_TS[2] - Zoo_TS[1] ) / Zoo_TS[1]
(Zoo_TS[3] - Zoo_TS[2] ) / Zoo_TS[2]
.

Is there any direct function available to achieve this?

Thanks,

__
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] Empirical density estimation

2018-03-11 Thread Christofer Bogaso
But for my reporting purpose, I need to generate a bell curve like
plot based on empirical PDF, that also contains original points.

Any idea would be helpful. Thanks,

On Mon, Mar 12, 2018 at 3:49 AM, Bert Gunter <bgunter.4...@gmail.com> wrote:
> You need to re-read ?density and perhaps think again -- or do some study --
> about how a (kernel) density estimate works. The points at which the
> estimate is calculated are *not* the values given, nor should they be!
>
> Cheers,
> Bert
>
>
>
> 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 Sun, Mar 11, 2018 at 11:45 AM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>>
>> Hi,
>>
>> Let say I have below vector of data-points :
>>
>> Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,
>>
>> -0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,
>>
>> -0.199891067538126, -0.192920353982301, -0.192307692307692,
>> -0.186046511627907,
>>
>> -0.184418145956608, -0.181818181818182, -0.181818181818182,
>> -0.181266261925412,
>>
>> -0.181003118503119, -0.179064587973274, -0.178217821782178,
>> -0.17809021675454,
>>
>> -0.177685950413223, -0.177570093457944, -0.176470588235294,
>> -0.176470588235294,
>>
>> -0.174825741611282, -0.168021680216802, -0.167,
>> -0.167,
>>
>> -0.166380789022298, -0.164209115281501, -0.164011246485473,
>> -0.162689804772234,
>>
>> -0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,
>>
>> -0.154172560113154, -0.15311004784689, -0.151515151515152,
>> -0.151462994836489,
>>
>> -0.151098901098901, -0.150537634408602, -0.150442477876106,
>> -0.150406504065041,
>>
>> -0.149904214559387, -0.149882903981265, -0.149797570850202,
>> -0.148496240601504,
>>
>> -0.148325358851675, -0.147540983606557, -0.147239263803681,
>> -0.146989966555184,
>>
>> -0.14622641509434, -0.146095717884131, -0.145994832041344,
>> -0.14572864321608,
>>
>> -0.145161290322581, -0.144292237442922, -0.144144144144144,
>> -0.144021739130435,
>>
>> -0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,
>>
>> -0.139344262295082, -0.13884007029877, -0.138356164383562,
>> -0.137626262626263,
>>
>> -0.137142857142857, -0.136690647482014, -0.136577708006279,
>> -0.136363636363636,
>>
>> -0.136094674556213, -0.135879774577332, -0.135586319218241,
>> -0.135135135135135,
>>
>> -0.132780082987552, -0.132209405501331, -0.132023755139333,
>> -0.131233595800525,
>>
>> -0.130434782608696, -0.130434782608696, -0.130268199233717,
>> -0.128813559322034,
>>
>> -0.1284046692607, -0.128205128205128, -0.128182616330114,
>> -0.127937336814621,
>>
>> -0.126283367556468, -0.125853658536585, -0.125448028673835,
>> -0.125425564840607,
>>
>> -0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,
>>
>> -0.124031007751938, -0.123572170301142, -0.123188405797102,
>> -0.122905027932961,
>>
>> -0.1216667, -0.121573685907772, -0.120658135283364,
>> -0.120540019286403,
>>
>> -0.119858156028369, -0.11965811965812, -0.11965811965812,
>> -0.119565217391304,
>>
>> -0.118942731277533, -0.117820324005891, -0.116257947320618,
>> -0.115789473684211,
>>
>> -0.115683584819387, -0.115384615384615, -0.115281501340483,
>> -0.114492753623188,
>>
>> -0.114357262103506, -0.114285714285714, -0.114035087719298,
>> -0.113181972212809,
>>
>> -0.112790697674419, -0.112781954887218, -0.112195121951219,
>> -0.112191473448018,
>>
>> -0.111, -0.111, -0.110813226094727,
>> -0.110384300899428,
>>
>> -0.110147441457069, -0.110137672090113, -0.109913793103448,
>> -0.109792284866469,
>>
>> -0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,
>>
>> -0.107776617954071, -0.10752688172043, -0.107317073170732,
>> -0.106674272675414,
>>
>> -0.106382978723404, -0.106100795755968, -0.106060606060606,
>> -0.10595160235448,
>>
>> -0.105742474070326, -0.105263157894737, -0.104454685099846,
>> -0.104283054003724,
>>
>> -0.103916449086162, -0.103723404255319, -0.103448275862069,
>> -0.102737680438029,
>>
>> -0.10267471958585, -0.101696871753434, -0.100893997445721,
>> -0.10

[R] Empirical density estimation

2018-03-11 Thread Christofer Bogaso
Hi,

Let say I have below vector of data-points :

Dat = c(-0.444, -0.25, -0.237449799196787, -0.227467046669042,

-0.227454464682363, -0.22, -0.214876033057851, -0.211781206171108,

-0.199891067538126, -0.192920353982301, -0.192307692307692, -0.186046511627907,

-0.184418145956608, -0.181818181818182, -0.181818181818182, -0.181266261925412,

-0.181003118503119, -0.179064587973274, -0.178217821782178, -0.17809021675454,

-0.177685950413223, -0.177570093457944, -0.176470588235294, -0.176470588235294,

-0.174825741611282, -0.168021680216802, -0.167, -0.167,

-0.166380789022298, -0.164209115281501, -0.164011246485473, -0.162689804772234,

-0.162361623616236, -0.160161507402423, -0.16, -0.155038759689922,

-0.154172560113154, -0.15311004784689, -0.151515151515152, -0.151462994836489,

-0.151098901098901, -0.150537634408602, -0.150442477876106, -0.150406504065041,

-0.149904214559387, -0.149882903981265, -0.149797570850202, -0.148496240601504,

-0.148325358851675, -0.147540983606557, -0.147239263803681, -0.146989966555184,

-0.14622641509434, -0.146095717884131, -0.145994832041344, -0.14572864321608,

-0.145161290322581, -0.144292237442922, -0.144144144144144, -0.144021739130435,

-0.14375, -0.142212189616253, -0.141122913505311, -0.140324963072378,

-0.139344262295082, -0.13884007029877, -0.138356164383562, -0.137626262626263,

-0.137142857142857, -0.136690647482014, -0.136577708006279, -0.136363636363636,

-0.136094674556213, -0.135879774577332, -0.135586319218241, -0.135135135135135,

-0.132780082987552, -0.132209405501331, -0.132023755139333, -0.131233595800525,

-0.130434782608696, -0.130434782608696, -0.130268199233717, -0.128813559322034,

-0.1284046692607, -0.128205128205128, -0.128182616330114, -0.127937336814621,

-0.126283367556468, -0.125853658536585, -0.125448028673835, -0.125425564840607,

-0.125311203319502, -0.125, -0.124401913875598, -0.124248496993988,

-0.124031007751938, -0.123572170301142, -0.123188405797102, -0.122905027932961,

-0.1216667, -0.121573685907772, -0.120658135283364, -0.120540019286403,

-0.119858156028369, -0.11965811965812, -0.11965811965812, -0.119565217391304,

-0.118942731277533, -0.117820324005891, -0.116257947320618, -0.115789473684211,

-0.115683584819387, -0.115384615384615, -0.115281501340483, -0.114492753623188,

-0.114357262103506, -0.114285714285714, -0.114035087719298, -0.113181972212809,

-0.112790697674419, -0.112781954887218, -0.112195121951219, -0.112191473448018,

-0.111, -0.111, -0.110813226094727, -0.110384300899428,

-0.110147441457069, -0.110137672090113, -0.109913793103448, -0.109792284866469,

-0.109375, -0.10919540229885, -0.109112709832134, -0.10844250363901,

-0.107776617954071, -0.10752688172043, -0.107317073170732, -0.106674272675414,

-0.106382978723404, -0.106100795755968, -0.106060606060606, -0.10595160235448,

-0.105742474070326, -0.105263157894737, -0.104454685099846, -0.104283054003724,

-0.103916449086162, -0.103723404255319, -0.103448275862069, -0.102737680438029,

-0.10267471958585, -0.101696871753434, -0.100893997445721, -0.10041265474553,

-0.100042983021706, -0.1, -0.0995111731843576, -0.099502487562189,

-0.0994117647058824, -0.0991561181434598, -0.0989492119089317,

-0.0988372093023255, -0.0983908045977012, -0.0983050847457627,

-0.0977198697068404, -0.0974702380952382, -0.0973819695475956,

-0.097345132743363, -0.0971472629144179, -0.0971438645980254,

-0.0961538461538461, -0.096062667491239, -0.0957347238935687,

-0.0956521739130435, -0.0954773869346733, -0.0954115076474873,

-0.0952380952380952, -0.0951115834218915, -0.0950642007303569,

-0.0949423247559894, -0.0947368421052631, -0.0946291560102303,

-0.0945220193340494, -0.0944309927360775, -0.0943016759776536,

-0.0942720763723149, -0.0941770647653002, -0.0940298507462686,

-0.094017094017094, -0.0935672514619884, -0.0934579439252337,

-0.0930232558139535, -0.0929772502472798, -0.0929054054054054,

-0.0928778745255637, -0.0927700348432055, -0.0925266903914591,

-0.0922502666192677, -0.0918094218415418, -0.0915254237288135,

-0.0914774596906876, -0.0914662894860915, -0.0914285714285715,

-0.0912322274881517, -0.090909090909091, -0.0909090909090909,

-0.09079754601227, -0.0907071455016661, -0.0906593406593406,

-0.0903614457831325, -0.0903323548906352, -0.09, -0.0897243107769424,

-0.0896358543417368, -0.0895522388059702, -0.0895052902487847,

-0.0891719745222929, -0.0888, -0.0887227819304518,

-0.0887096774193548, -0.0886956521739131, -0.0884703196347032,

-0.0884450784593437, -0.0884413309982488, -0.0883577310155536,

-0.0883054892601431, -0.0882917466410749, -0.0881628999776236,

-0.0881193929739248, -0.0880681818181819, -0.0878186968838525,

-0.087719298245614, -0.0876010781671159, -0.0873634945397815,

-0.0872641509433961, -0.0871512228728901, -0.0871032050299035,

-0.0868133772309825, -0.0865384615384615, -0.0858895705521473,

-0.085742525327403, -0.0855766209280403, -0.0854700854700855,


Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
Thanks Eric, this is working.

On Sun, Mar 4, 2018 at 11:28 PM, Eric Berger <ericjber...@gmail.com> wrote:
> The reason that it works for Apply_MC=TRUE is that in that case you call
> mclapply(X,FUN,...) and
> the mclapply() function strips off the mc.cores argument from the "..." list
> before calling FUN, so FUN is being called with zero arguments, exactly as
> it is declared.
>
> A quick workaround is to change the line
>
> Lapply_me(as.list(1:4), function(xx) {
>
> to
>
> Lapply_me(as.list(1:4), function(xx,dummyList) {
>
> HTH,
> Eric
>
>
> On Sun, Mar 4, 2018 at 7:21 PM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>>
>> Below is my full implementation (tried to make it simple as for
>> demonstration)
>>
>> Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
>> if (Apply_MC) {
>> return(mclapply(X, FUN, ...))
>> } else {
>> if (any(names(list(...)) == 'mc.cores')) {
>> myList = list(...)[!names(list(...)) %in% 'mc.cores']
>> }
>> return(lapply(X, FUN, myList))
>> }
>> }
>>
>>
>> Lapply_me(as.list(1:4), function(xx) {
>> if (xx == 1) return('a')
>> if (xx == 2) return('b')
>> if (xx == 3) return('c')
>> if (xx == 4) return('d')
>> }, Apply_MC = FALSE, mc.cores = 2)
>>
>> Error message :
>>
>> Error in FUN(X[[i]], ...) : unused argument (list())
>>
>> Kindly note that, with Apply_MC = TRUE, it is working perfectly.
>>
>> On Sun, Mar 4, 2018 at 10:45 PM, Eric Berger <ericjber...@gmail.com>
>> wrote:
>> > That's fine. The issue is how you called Lapply_me(). What did you pass
>> > as
>> > the argument to FUN?
>> > And if you did not pass anything that how is FUN declared?
>> > You have not shown that in your email.
>> >
>> >
>> >
>> >
>> > On Sun, Mar 4, 2018 at 7:11 PM, Christofer Bogaso
>> > <bogaso.christo...@gmail.com> wrote:
>> >>
>> >> My modified function looks below :
>> >>
>> >> Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
>> >> if (Apply_MC) {
>> >> return(mclapply(X, FUN, ...))
>> >> } else {
>> >> if (any(names(list(...)) == 'mc.cores')) {
>> >> myList = list(...)[!names(list(...)) %in% 'mc.cores']
>> >> }
>> >> return(lapply(X, FUN, myList))
>> >> }
>> >> }
>> >>
>> >> Here, I am not passing ... anymore rather passing myList
>> >>
>> >> On Sun, Mar 4, 2018 at 10:37 PM, Eric Berger <ericjber...@gmail.com>
>> >> wrote:
>> >> > Hi Christofer,
>> >> > Before you made the change that I suggested, your program was
>> >> > stopping
>> >> > at
>> >> > the statement: list(...) = list(..) .etc
>> >> > This means that it never tried to execute the statement:
>> >> > return(lapply(X,FUN,...))
>> >> > Now that you have made the change, it gets past the first statement
>> >> > and
>> >> > tries to execute the statement: return(lapply(X,FUN,...)).
>> >> > That attempt is generating the error message because whatever you are
>> >> > passing in as the FUN argument is not expecting extra arguments.
>> >> >
>> >> > HTH,
>> >> > Eric
>> >> >
>> >> >
>> >> > On Sun, Mar 4, 2018 at 6:52 PM, Christofer Bogaso
>> >> > <bogaso.christo...@gmail.com> wrote:
>> >> >>
>> >> >> @Eric - with this approach I am getting below error :
>> >> >>
>> >> >> Error in FUN(X[[i]], ...) : unused argument (list())
>> >> >>
>> >> >> On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger <ericjber...@gmail.com>
>> >> >> wrote:
>> >> >> > Hi Christofer,
>> >> >> > You cannot assign to list(...). You can do the following
>> >> >> >
>> >> >> > myList <- list(...)[!names(list(...)) %in% 'mc.cores']
>> >> >> >
>> >> >> > HTH,
>> >> >> > Eric
>> >> >> >
>> >> >> > On Sun, Mar 4, 2018 at 6:38 PM, Christofer Bogaso
>> >> >> > <bogaso.christo...@gmail.com> wrote:
>> >> >> >>
>> >> >> >> Hi,
>> >> >> >>
>> >&g

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
Below is my full implementation (tried to make it simple as for demonstration)

Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
myList = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, myList))
}
}


Lapply_me(as.list(1:4), function(xx) {
if (xx == 1) return('a')
if (xx == 2) return('b')
if (xx == 3) return('c')
if (xx == 4) return('d')
}, Apply_MC = FALSE, mc.cores = 2)

Error message :

Error in FUN(X[[i]], ...) : unused argument (list())

Kindly note that, with Apply_MC = TRUE, it is working perfectly.

On Sun, Mar 4, 2018 at 10:45 PM, Eric Berger <ericjber...@gmail.com> wrote:
> That's fine. The issue is how you called Lapply_me(). What did you pass as
> the argument to FUN?
> And if you did not pass anything that how is FUN declared?
> You have not shown that in your email.
>
>
>
>
> On Sun, Mar 4, 2018 at 7:11 PM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>>
>> My modified function looks below :
>>
>> Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
>> if (Apply_MC) {
>> return(mclapply(X, FUN, ...))
>> } else {
>> if (any(names(list(...)) == 'mc.cores')) {
>> myList = list(...)[!names(list(...)) %in% 'mc.cores']
>> }
>> return(lapply(X, FUN, myList))
>> }
>> }
>>
>> Here, I am not passing ... anymore rather passing myList
>>
>> On Sun, Mar 4, 2018 at 10:37 PM, Eric Berger <ericjber...@gmail.com>
>> wrote:
>> > Hi Christofer,
>> > Before you made the change that I suggested, your program was stopping
>> > at
>> > the statement: list(...) = list(..) .etc
>> > This means that it never tried to execute the statement:
>> > return(lapply(X,FUN,...))
>> > Now that you have made the change, it gets past the first statement and
>> > tries to execute the statement: return(lapply(X,FUN,...)).
>> > That attempt is generating the error message because whatever you are
>> > passing in as the FUN argument is not expecting extra arguments.
>> >
>> > HTH,
>> > Eric
>> >
>> >
>> > On Sun, Mar 4, 2018 at 6:52 PM, Christofer Bogaso
>> > <bogaso.christo...@gmail.com> wrote:
>> >>
>> >> @Eric - with this approach I am getting below error :
>> >>
>> >> Error in FUN(X[[i]], ...) : unused argument (list())
>> >>
>> >> On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger <ericjber...@gmail.com>
>> >> wrote:
>> >> > Hi Christofer,
>> >> > You cannot assign to list(...). You can do the following
>> >> >
>> >> > myList <- list(...)[!names(list(...)) %in% 'mc.cores']
>> >> >
>> >> > HTH,
>> >> > Eric
>> >> >
>> >> > On Sun, Mar 4, 2018 at 6:38 PM, Christofer Bogaso
>> >> > <bogaso.christo...@gmail.com> wrote:
>> >> >>
>> >> >> Hi,
>> >> >>
>> >> >> As an example, I want to create below kind of custom Function which
>> >> >> either be mclapply pr lapply
>> >> >>
>> >> >> Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) {
>> >> >> if (Apply_MC) {
>> >> >> return(mclapply(X, FUN, ...))
>> >> >> } else {
>> >> >> if (any(names(list(...)) == 'mc.cores')) {
>> >> >> list(...) = list(...)[!names(list(...)) %in% 'mc.cores']
>> >> >> }
>> >> >> return(lapply(X, FUN, ...))
>> >> >> }
>> >> >> }
>> >> >>
>> >> >> However when Apply_MC = FALSE it generates below error saying :
>> >> >>
>> >> >>   '...' used in an incorrect context
>> >> >>
>> >> >>
>> >> >> Appreciate if you can help me with the correct approach. Thanks,
>> >> >>
>> >> >>
>> >> >> On Sun, Mar 4, 2018 at 9:34 PM, Duncan Murdoch
>> >> >> <murdoch.dun...@gmail.com>
>> >> >> wrote:
>> >> >> > On 04/03/2018 10:39 AM, Christofer Bogaso wrote:
>> >> >> >>
>> >> >> >> Hi again,
>> >> >> >>
>> >> >> >> I am looking for some way to alternately use 2 related functions,
>> >> >> >> based on some ifelse() condition.
>> &g

Re: [R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
My modified function looks below :

Lapply_me = function(X = X, FUN = FUN, Apply_MC = FALSE, ...) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
myList = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, myList))
}
}

Here, I am not passing ... anymore rather passing myList

On Sun, Mar 4, 2018 at 10:37 PM, Eric Berger <ericjber...@gmail.com> wrote:
> Hi Christofer,
> Before you made the change that I suggested, your program was stopping at
> the statement: list(...) = list(..) .etc
> This means that it never tried to execute the statement:
> return(lapply(X,FUN,...))
> Now that you have made the change, it gets past the first statement and
> tries to execute the statement: return(lapply(X,FUN,...)).
> That attempt is generating the error message because whatever you are
> passing in as the FUN argument is not expecting extra arguments.
>
> HTH,
> Eric
>
>
> On Sun, Mar 4, 2018 at 6:52 PM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>>
>> @Eric - with this approach I am getting below error :
>>
>> Error in FUN(X[[i]], ...) : unused argument (list())
>>
>> On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger <ericjber...@gmail.com>
>> wrote:
>> > Hi Christofer,
>> > You cannot assign to list(...). You can do the following
>> >
>> > myList <- list(...)[!names(list(...)) %in% 'mc.cores']
>> >
>> > HTH,
>> > Eric
>> >
>> > On Sun, Mar 4, 2018 at 6:38 PM, Christofer Bogaso
>> > <bogaso.christo...@gmail.com> wrote:
>> >>
>> >> Hi,
>> >>
>> >> As an example, I want to create below kind of custom Function which
>> >> either be mclapply pr lapply
>> >>
>> >> Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) {
>> >> if (Apply_MC) {
>> >> return(mclapply(X, FUN, ...))
>> >> } else {
>> >> if (any(names(list(...)) == 'mc.cores')) {
>> >> list(...) = list(...)[!names(list(...)) %in% 'mc.cores']
>> >> }
>> >> return(lapply(X, FUN, ...))
>> >> }
>> >> }
>> >>
>> >> However when Apply_MC = FALSE it generates below error saying :
>> >>
>> >>   '...' used in an incorrect context
>> >>
>> >>
>> >> Appreciate if you can help me with the correct approach. Thanks,
>> >>
>> >>
>> >> On Sun, Mar 4, 2018 at 9:34 PM, Duncan Murdoch
>> >> <murdoch.dun...@gmail.com>
>> >> wrote:
>> >> > On 04/03/2018 10:39 AM, Christofer Bogaso wrote:
>> >> >>
>> >> >> Hi again,
>> >> >>
>> >> >> I am looking for some way to alternately use 2 related functions,
>> >> >> based on some ifelse() condition.
>> >> >>
>> >> >> For example, I have 2 functions mclapply() and lapply()
>> >> >>
>> >> >> However, mclapply() function has one extra parameter 'mc.cores'
>> >> >> which
>> >> >> lapply doesnt not have.
>> >> >>
>> >> >> I know when mc.cores = 1, these 2 functions are essentially same,
>> >> >> however I am looking for more general way to control them within
>> >> >> ifelse() constion
>> >> >>
>> >> >> Can someone please help me how can I use them within ifelse()
>> >> >> condition.
>> >> >
>> >> >
>> >> > Don't.  ifelse() usually evaluates *both* the true and false values,
>> >> > and
>> >> > then selects entries from each.  Just use an if statement.
>> >> >
>> >> > Duncan Murdoch
>> >>
>> >> __
>> >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> >> https://stat.ethz.ch/mailman/listinfo/r-help
>> >> PLEASE do read the posting guide
>> >> http://www.R-project.org/posting-guide.html
>> >> and provide commented, minimal, self-contained, reproducible code.
>> >
>> >
>
>

__
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] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
@Eric - with this approach I am getting below error :

Error in FUN(X[[i]], ...) : unused argument (list())

On Sun, Mar 4, 2018 at 10:18 PM, Eric Berger <ericjber...@gmail.com> wrote:
> Hi Christofer,
> You cannot assign to list(...). You can do the following
>
> myList <- list(...)[!names(list(...)) %in% 'mc.cores']
>
> HTH,
> Eric
>
> On Sun, Mar 4, 2018 at 6:38 PM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>>
>> Hi,
>>
>> As an example, I want to create below kind of custom Function which
>> either be mclapply pr lapply
>>
>> Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) {
>> if (Apply_MC) {
>> return(mclapply(X, FUN, ...))
>> } else {
>> if (any(names(list(...)) == 'mc.cores')) {
>> list(...) = list(...)[!names(list(...)) %in% 'mc.cores']
>> }
>> return(lapply(X, FUN, ...))
>> }
>> }
>>
>> However when Apply_MC = FALSE it generates below error saying :
>>
>>   '...' used in an incorrect context
>>
>>
>> Appreciate if you can help me with the correct approach. Thanks,
>>
>>
>> On Sun, Mar 4, 2018 at 9:34 PM, Duncan Murdoch <murdoch.dun...@gmail.com>
>> wrote:
>> > On 04/03/2018 10:39 AM, Christofer Bogaso wrote:
>> >>
>> >> Hi again,
>> >>
>> >> I am looking for some way to alternately use 2 related functions,
>> >> based on some ifelse() condition.
>> >>
>> >> For example, I have 2 functions mclapply() and lapply()
>> >>
>> >> However, mclapply() function has one extra parameter 'mc.cores' which
>> >> lapply doesnt not have.
>> >>
>> >> I know when mc.cores = 1, these 2 functions are essentially same,
>> >> however I am looking for more general way to control them within
>> >> ifelse() constion
>> >>
>> >> Can someone please help me how can I use them within ifelse()
>> >> condition.
>> >
>> >
>> > Don't.  ifelse() usually evaluates *both* the true and false values, and
>> > then selects entries from each.  Just use an if statement.
>> >
>> > Duncan Murdoch
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>

__
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] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
Hi,

As an example, I want to create below kind of custom Function which
either be mclapply pr lapply

Lapply_me = function(X = X, FUN = FUN, ..., Apply_MC = FALSE) {
if (Apply_MC) {
return(mclapply(X, FUN, ...))
} else {
if (any(names(list(...)) == 'mc.cores')) {
list(...) = list(...)[!names(list(...)) %in% 'mc.cores']
}
return(lapply(X, FUN, ...))
}
}

However when Apply_MC = FALSE it generates below error saying :

  '...' used in an incorrect context


Appreciate if you can help me with the correct approach. Thanks,


On Sun, Mar 4, 2018 at 9:34 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote:
> On 04/03/2018 10:39 AM, Christofer Bogaso wrote:
>>
>> Hi again,
>>
>> I am looking for some way to alternately use 2 related functions,
>> based on some ifelse() condition.
>>
>> For example, I have 2 functions mclapply() and lapply()
>>
>> However, mclapply() function has one extra parameter 'mc.cores' which
>> lapply doesnt not have.
>>
>> I know when mc.cores = 1, these 2 functions are essentially same,
>> however I am looking for more general way to control them within
>> ifelse() constion
>>
>> Can someone please help me how can I use them within ifelse() condition.
>
>
> Don't.  ifelse() usually evaluates *both* the true and false values, and
> then selects entries from each.  Just use an if statement.
>
> Duncan Murdoch

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


[R] Change Function based on ifelse() condtion

2018-03-04 Thread Christofer Bogaso
Hi again,

I am looking for some way to alternately use 2 related functions,
based on some ifelse() condition.

For example, I have 2 functions mclapply() and lapply()

However, mclapply() function has one extra parameter 'mc.cores' which
lapply doesnt not have.

I know when mc.cores = 1, these 2 functions are essentially same,
however I am looking for more general way to control them within
ifelse() constion

Can someone please help me how can I use them within ifelse() condition.

Thanks for your pointer

__
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] How to programmatically save a web-page using R (mimicking Command+S)

2018-01-13 Thread Christofer Bogaso
Hi Henrik,

Thanks for your pointer. Saving via PDF is working for me, however, in
many cases, it is unusually taking a long time.

In many cases I am facing Error too as below. This is particularly
occurring if I trigger Multicore calculation option

webshot.js returned failure value: 1

Just wondering if there is any other direct ways to achieve the same.

Thanks,

On Sat, Jan 6, 2018 at 7:14 PM, Henrik Bengtsson
<henrik.bengts...@gmail.com> wrote:
> The 'webshot' package (on CRAN) can do this.
>
> Henrik
>
> On Jan 6, 2018 05:27, "Christofer Bogaso" <bogaso.christo...@gmail.com>
> wrote:
>>
>> Hi,
>>
>> I would appreciate if someone can give me a pointer on how to save a
>> webpage programmatically using R.
>>
>> For example, let say I have this webpage open in my browser:
>>
>> http://www.bseindia.com/stock-share-price/dabur-india-ltd/dabur/500096/
>>
>> When manually I save this page, I just press Command+S (using Mac) and
>> then this page get saved in hard-disk
>>
>> Now I want R to mimic this same job that I do using Command-S
>>
>> So far I have tried with readLines() however the output content is
>> different than what I could achieve using Command+S
>>
>> Any help will be highly appreciated.
>>
>> Thanks for your time.
>>
>> __
>> 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] How to programmatically save a web-page using R (mimicking Command+S)

2018-01-06 Thread Christofer Bogaso
Hi,

I would appreciate if someone can give me a pointer on how to save a
webpage programmatically using R.

For example, let say I have this webpage open in my browser:

http://www.bseindia.com/stock-share-price/dabur-india-ltd/dabur/500096/

When manually I save this page, I just press Command+S (using Mac) and
then this page get saved in hard-disk

Now I want R to mimic this same job that I do using Command-S

So far I have tried with readLines() however the output content is
different than what I could achieve using Command+S

Any help will be highly appreciated.

Thanks for your time.

__
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 Regular expression

2018-01-03 Thread Christofer Bogaso
Hi,

I was working on following expression :

"\":\"03-JAN-2018 16:00:00\""


This is basically a combination of Date and Time mixed with some Noise.

I want to extract only Date and Time part i.e. "03-JAN-2018 16:00:00

I tried following :

gsub("![0-9][0-9]-[a-zA-Z][a-zA-Z][a-zA-Z]-[0-9][0-9][0-9][0-9]
[0-9][0-9]:[0-9][0-9]:[0-9][0-9]", "", "\":\"03-JAN-2018 16:00:00\"",
ignore.case = TRUE)

Obviously, with above code, I am removing that portion of my string
which I actually I wanted!

How can I reverse above code, so that I will be removing that portion
of my string which I actually I ***NOT*** wanted?

Thanks for your time.

Happy New Year!

__
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] load() failed to load .Rdata file in AWS-Ububtu

2017-10-09 Thread Christofer Bogaso
Hi Eric, thanks for your further pointer.

I have put a line with load() function just as an illustration of a
bigger project of mine, which appears failing due to load() function
issue.

If I comment out that line my shiny app is working correctly locally
and globally.

otherwise, locally my shiny app is working but not with AWS.

On Mon, Oct 9, 2017 at 12:37 PM, Eric Berger <ericjber...@gmail.com> wrote:
> Hi Christofer,
> The shiny code you have written does not depend on loading the Dat.RData
> file.
> I commented out that line and ran your shiny app on my machine and it works
> fine.
> What happens if you comment out  (or remove) the line
>  load("/home/ubuntu/Dat.RData)
> Does your shiny app still fail? If so, then your problem is quite basic with
> your  AWS setup.
> Try to work through a simple tutorial/documentation example that shows how
> to get shiny running on AWS and see if following the steps helps you
> discover the problem.
>
> Good luck,
> Eric
>
>
>
>
> On Sun, Oct 8, 2017 at 8:05 PM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>>
>> Thanks Eric for your pointer. However I just altered the argument of
>> load() function a little bit to get that loaded. Below is the line
>> what I tried.
>>
>> ubuntu@ip-172-31-23-148:~$ R
>>
>>
>> R version 3.4.2 (2017-09-28) -- "Short Summer"
>>
>> Copyright (C) 2017 The R Foundation for Statistical Computing
>>
>> Platform: x86_64-pc-linux-gnu (64-bit)
>>
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>>
>> You are welcome to redistribute it under certain conditions.
>>
>> Type 'license()' or 'licence()' for distribution details.
>>
>>
>>   Natural language support but running in an English locale
>>
>>
>> R is a collaborative project with many contributors.
>>
>> Type 'contributors()' for more information and
>>
>> 'citation()' on how to cite R or R packages in publications.
>>
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>>
>> 'help.start()' for an HTML browser interface to help.
>>
>> Type 'q()' to quit R.
>>
>>
>> During startup - Warning message:
>>
>> Setting LC_CTYPE failed, using "C"
>>
>> > load("/home/ubuntu/Dat.RData")
>>
>> >
>>
>> However it still failing when I try that within my shiny app in AWS.
>>
>> Below are my ui.R and server.R files respectively.
>>
>> library(shiny)
>>
>> # Define UI for miles per gallon application
>> fluidPage(
>>   fluidRow(
>> column(12,
>>   tableOutput('table')
>> )
>>   )
>> )
>>
>> server.R :
>>
>> library(shiny)
>>
>> load("/home/ubuntu/Dat.RData")
>>
>> shinyServer(function(input, output) {
>> output$table = renderTable(head(data.frame(1:20, 1:20), 20))
>> })
>>
>> with above setup when I deploy my shiny app I get below error :
>>
>> 18.221.184.94:3838 says
>> The application unexpectedly exited
>> Diagnostic information has been dumped to the JavaScript error console.
>>
>> appreciate any help to get rid of this error.
>>
>> Thanks for your time.
>>
>> On Sun, Oct 8, 2017 at 12:39 AM, Eric Berger <ericjber...@gmail.com>
>> wrote:
>> > Hi Christofer,
>> > The directory /srv/shiny-server would normally be owned by the root
>> > user.
>> > Your options would seem to be to either (1) bring up the R session as
>> > root
>> > (dangerous)
>> > or (2) try copying the file to your local directory and read it from
>> > there
>> > (if allowed).
>> > e.g. from the Unix shell:
>> >> cd ~   (i.e. cd to your home directory)
>> >> cp /srv/shiny-server/Dat.Rdata .   (Note the '.' at the end. This may
>> >> not
>> >> work - if not then you can try the following
>> >> sudo cp /srv/shiny-server/Dat.Rdata . (if you have sudo privileges -
>> >> only
>> >> do this if the former command did not work)
>> >> chmod 777 Dat.Rdata  (a bit of overkill - again preface by sudo if it
>> >> does
>> >> not work without it)
>> >
>> > Then in your R session you can do the load from the file in this
>> > location.
>> > R>  load("~/Dat.Rdata")
>> >
>> > HTH,
>> > Eric
>> >
>> >
>> > On Sat, Oct 7, 2017 at 8:54 PM, 

Re: [R] load() failed to load .Rdata file in AWS-Ububtu

2017-10-08 Thread Christofer Bogaso
Thanks Eric for your pointer. However I just altered the argument of
load() function a little bit to get that loaded. Below is the line
what I tried.

ubuntu@ip-172-31-23-148:~$ R


R version 3.4.2 (2017-09-28) -- "Short Summer"

Copyright (C) 2017 The R Foundation for Statistical Computing

Platform: x86_64-pc-linux-gnu (64-bit)


R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.


  Natural language support but running in an English locale


R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.


Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.


During startup - Warning message:

Setting LC_CTYPE failed, using "C"

> load("/home/ubuntu/Dat.RData")

>

However it still failing when I try that within my shiny app in AWS.

Below are my ui.R and server.R files respectively.

library(shiny)

# Define UI for miles per gallon application
fluidPage(
  fluidRow(
column(12,
  tableOutput('table')
)
  )
)

server.R :

library(shiny)

load("/home/ubuntu/Dat.RData")

shinyServer(function(input, output) {
output$table = renderTable(head(data.frame(1:20, 1:20), 20))
})

with above setup when I deploy my shiny app I get below error :

18.221.184.94:3838 says
The application unexpectedly exited
Diagnostic information has been dumped to the JavaScript error console.

appreciate any help to get rid of this error.

Thanks for your time.

On Sun, Oct 8, 2017 at 12:39 AM, Eric Berger <ericjber...@gmail.com> wrote:
> Hi Christofer,
> The directory /srv/shiny-server would normally be owned by the root user.
> Your options would seem to be to either (1) bring up the R session as root
> (dangerous)
> or (2) try copying the file to your local directory and read it from there
> (if allowed).
> e.g. from the Unix shell:
>> cd ~   (i.e. cd to your home directory)
>> cp /srv/shiny-server/Dat.Rdata .   (Note the '.' at the end. This may not
>> work - if not then you can try the following
>> sudo cp /srv/shiny-server/Dat.Rdata . (if you have sudo privileges - only
>> do this if the former command did not work)
>> chmod 777 Dat.Rdata  (a bit of overkill - again preface by sudo if it does
>> not work without it)
>
> Then in your R session you can do the load from the file in this location.
> R>  load("~/Dat.Rdata")
>
> HTH,
> Eric
>
>
> On Sat, Oct 7, 2017 at 8:54 PM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>>
>> Hi again,
>>
>> I hope this is the right place to post my question on running R within
>> Ubuntu, however if not, any pointer on right distribution list will be
>> helpful.
>>
>> I am currently using R in Ubuntu which is hosted in Amazon - AWS.
>>
>> I have a .Rdata file in AWS which I am trying to load in R. Used
>> following code, however, fails to load showing some permission issue.
>> However that same .Rdata file is getting loaded perfectly when I try
>> in my regular iOS.
>>
>> Below is my code and corresponding result :
>>
>> ubuntu@ip-172-31-23-148:~$ R
>>
>>
>> R version 3.4.2 (2017-09-28) -- "Short Summer"
>>
>> Copyright (C) 2017 The R Foundation for Statistical Computing
>>
>> Platform: x86_64-pc-linux-gnu (64-bit)
>>
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>>
>> You are welcome to redistribute it under certain conditions.
>>
>> Type 'license()' or 'licence()' for distribution details.
>>
>>
>>   Natural language support but running in an English locale
>>
>>
>> R is a collaborative project with many contributors.
>>
>> Type 'contributors()' for more information and
>>
>> 'citation()' on how to cite R or R packages in publications.
>>
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>>
>> 'help.start()' for an HTML browser interface to help.
>>
>> Type 'q()' to quit R.
>>
>>
>> During startup - Warning message:
>>
>> Setting LC_CTYPE failed, using "C"
>>
>> > file.exists('/srv/shiny-server/Dat.Rdata')
>>
>> [1] TRUE
>>
>> > load('/srv/shiny-server/Dat.Rdata')
>>
>> Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
>>
>> In addition: Warning message:
>>
>> In readChar(con, 5L, useBytes = TRUE) :
>&

[R] load() failed to load .Rdata file in AWS-Ububtu

2017-10-07 Thread Christofer Bogaso
Hi again,

I hope this is the right place to post my question on running R within
Ubuntu, however if not, any pointer on right distribution list will be
helpful.

I am currently using R in Ubuntu which is hosted in Amazon - AWS.

I have a .Rdata file in AWS which I am trying to load in R. Used
following code, however, fails to load showing some permission issue.
However that same .Rdata file is getting loaded perfectly when I try
in my regular iOS.

Below is my code and corresponding result :

ubuntu@ip-172-31-23-148:~$ R


R version 3.4.2 (2017-09-28) -- "Short Summer"

Copyright (C) 2017 The R Foundation for Statistical Computing

Platform: x86_64-pc-linux-gnu (64-bit)


R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.


  Natural language support but running in an English locale


R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.


Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.


During startup - Warning message:

Setting LC_CTYPE failed, using "C"

> file.exists('/srv/shiny-server/Dat.Rdata')

[1] TRUE

> load('/srv/shiny-server/Dat.Rdata')

Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection

In addition: Warning message:

In readChar(con, 5L, useBytes = TRUE) :

  cannot open compressed file '/srv/shiny-server/Dat.Rdata', probable
reason 'Permission denied'

> readRDS('/srv/shiny-server/Dat.Rdata')

Error in gzfile(file, "rb") : cannot open the connection

In addition: Warning message:

In gzfile(file, "rb") :

  cannot open compressed file '/srv/shiny-server/Dat.Rdata', probable
reason 'Permission denied'


Can someone help me to understand where it went wrong with Ubuntu? I
also tried with changing the extension from .Rdata to .RData, however
observing the same error.

Any pointer will be highly appreciated.

Thanks for your time.

__
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] Getting all possible combinations

2017-08-23 Thread Christofer Bogaso
Hi again,

I am exploring if R can help me to get all possible combinations of
members in a group.

Let say I have a group with 5 members : A, B, C, D, E

Now I want to generate all possible unique combinations with all
possible lengths from that group e.g.

1st combination : A
2nd combination : B
.
5th combination : E
6th combination : A, B
7th combination : B, C

last combination: A, B, C, D, E

Ideally, I have a fairly large group so am looking for some
programmatic way to generate all possible combinations.

Any help will be highly appreciated.

Thanks for your time.

__
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] Zoo rolling window with increasing window size

2017-08-10 Thread Christofer Bogaso
Thanks Joshua, your solution is perfect.

On Fri, Aug 11, 2017 at 12:11 AM, Joshua Ulrich <josh.m.ulr...@gmail.com> wrote:
> Replace "sum" with your custom function's name.  I don't see any
> reason why that wouldn't work, and the problem with my solution is not
> clear in your response.
>
> r <- rollapplyr(x, seq_along(x), yourCustomFunctionGoesHere)
>
> On Thu, Aug 10, 2017 at 1:39 PM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>> Hi Joshua, thanks for your prompt reply. However as I said, sum()
>> function I used here just for demonstrating the problem, I have other
>> custom function to implement, not necessarily sum()
>>
>> I am looking for a generic solution for above problem.
>>
>> Any better idea? Thanks,
>>
>> On Fri, Aug 11, 2017 at 12:04 AM, Joshua Ulrich <josh.m.ulr...@gmail.com> 
>> wrote:
>>> Use a `width` of integer index locations.  And you likely want =
>>> "right" (or rollapplyr(), as I used).
>>>
>>> R> set.seed(21)
>>> R> x <- rnorm(10)
>>> R> rs <- rollapplyr(x, seq_along(x), sum)
>>> R> cs <- cumsum(x)
>>> R> identical(rs, cs)
>>> [1] TRUE
>>>
>>>
>>> On Thu, Aug 10, 2017 at 1:28 PM, Christofer Bogaso
>>> <bogaso.christo...@gmail.com> wrote:
>>>> Hi again,
>>>>
>>>> I am wondering there is any function for 'zoo' time series, where I
>>>> can apply a user defined function rolling window basis, wherein window
>>>> size is ever increasing i.e. not fixed. For example, let say I have
>>>> below user defined function and a zoo time series :
>>>>
>>>>> library(zoo)
>>>>
>>>>> UDF = function(x) sum(x)
>>>>
>>>>> TS = zoo(rnorm(10), seq(as.Date('2017-01-01'), as.Date('2017-01-10'), by 
>>>>> = '1 day'))
>>>>
>>>>>
>>>>
>>>> Now I want to apply UDF (this can be any custom function, however here
>>>> I put it just quick example) rolling window basis like :
>>>>
>>>> 1st data point = 1st data point of TS
>>>> 2nd data point = sum of 1st and 2nd data points of TS
>>>> 3rd data point = sum of 1st 2nd and 3rd data points of TS
>>>>
>>>> so on
>>>>
>>>> I am aware of the rollapply() function from zoo, however, appears like
>>>> it is only for fixed window size.
>>>>
>>>> Appreciate any pointer how to achieve above strategy of implementing
>>>> rolling calculation based on increased window size.
>>>>
>>>> Thanks for your time.
>>>>
>>>> __
>>>> 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
>>> R/Finance 2017 | www.rinfinance.com
>
>
>
> --
> Joshua Ulrich  |  about.me/joshuaulrich
> FOSS Trading  |  www.fosstrading.com
> R/Finance 2017 | www.rinfinance.com

__
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] Zoo rolling window with increasing window size

2017-08-10 Thread Christofer Bogaso
Hi Joshua, thanks for your prompt reply. However as I said, sum()
function I used here just for demonstrating the problem, I have other
custom function to implement, not necessarily sum()

I am looking for a generic solution for above problem.

Any better idea? Thanks,

On Fri, Aug 11, 2017 at 12:04 AM, Joshua Ulrich <josh.m.ulr...@gmail.com> wrote:
> Use a `width` of integer index locations.  And you likely want =
> "right" (or rollapplyr(), as I used).
>
> R> set.seed(21)
> R> x <- rnorm(10)
> R> rs <- rollapplyr(x, seq_along(x), sum)
> R> cs <- cumsum(x)
> R> identical(rs, cs)
> [1] TRUE
>
>
> On Thu, Aug 10, 2017 at 1:28 PM, Christofer Bogaso
> <bogaso.christo...@gmail.com> wrote:
>> Hi again,
>>
>> I am wondering there is any function for 'zoo' time series, where I
>> can apply a user defined function rolling window basis, wherein window
>> size is ever increasing i.e. not fixed. For example, let say I have
>> below user defined function and a zoo time series :
>>
>>> library(zoo)
>>
>>> UDF = function(x) sum(x)
>>
>>> TS = zoo(rnorm(10), seq(as.Date('2017-01-01'), as.Date('2017-01-10'), by = 
>>> '1 day'))
>>
>>>
>>
>> Now I want to apply UDF (this can be any custom function, however here
>> I put it just quick example) rolling window basis like :
>>
>> 1st data point = 1st data point of TS
>> 2nd data point = sum of 1st and 2nd data points of TS
>> 3rd data point = sum of 1st 2nd and 3rd data points of TS
>>
>> so on
>>
>> I am aware of the rollapply() function from zoo, however, appears like
>> it is only for fixed window size.
>>
>> Appreciate any pointer how to achieve above strategy of implementing
>> rolling calculation based on increased window size.
>>
>> Thanks for your time.
>>
>> __
>> 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
> R/Finance 2017 | www.rinfinance.com

__
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] Zoo rolling window with increasing window size

2017-08-10 Thread Christofer Bogaso
Hi again,

I am wondering there is any function for 'zoo' time series, where I
can apply a user defined function rolling window basis, wherein window
size is ever increasing i.e. not fixed. For example, let say I have
below user defined function and a zoo time series :

> library(zoo)

> UDF = function(x) sum(x)

> TS = zoo(rnorm(10), seq(as.Date('2017-01-01'), as.Date('2017-01-10'), by = '1 
> day'))

>

Now I want to apply UDF (this can be any custom function, however here
I put it just quick example) rolling window basis like :

1st data point = 1st data point of TS
2nd data point = sum of 1st and 2nd data points of TS
3rd data point = sum of 1st 2nd and 3rd data points of TS

so on

I am aware of the rollapply() function from zoo, however, appears like
it is only for fixed window size.

Appreciate any pointer how to achieve above strategy of implementing
rolling calculation based on increased window size.

Thanks for your time.

__
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] Strange behaviour to download zip file using R

2017-08-03 Thread Christofer Bogaso
Hi again,

I was trying to download stock market data from below link :

https://www.nseindia.com/products/content/equities/equities/archieve_eq.htm

Input choice :

Select Report: Bhavcopy
Date(DD-MM-): 03-03-2010

If you put manual input as above, then we will get option for manual
download of file :

cm03MAR2010bhav.csv.zip

However I then tried to use R to have some automatic download :

> download.file('https://www.nseindia.com/content/historical/EQUITIES/2010/MAR/cm03MAR2010bhav.csv.zip',
>  'aa.zip')

trying URL 
'https://www.nseindia.com/content/historical/EQUITIES/2010/MAR/cm03MAR2010bhav.csv.zip'

Error in 
download.file("https://www.nseindia.com/content/historical/EQUITIES/2010/MAR/cm03MAR2010bhav.csv.zip;,
 :

  cannot open URL
'https://www.nseindia.com/content/historical/EQUITIES/2010/MAR/cm03MAR2010bhav.csv.zip'

In addition: Warning message:

In 
download.file("https://www.nseindia.com/content/historical/EQUITIES/2010/MAR/cm03MAR2010bhav.csv.zip;,
 :

  cannot open URL
'https://www.nseindia.com/content/historical/EQUITIES/2010/MAR/cm03MAR2010bhav.csv.zip':
HTTP status was '403 Forbidden'

Ofcourse I I place below direct link
'https://www.nseindia.com/content/historical/EQUITIES/2010/MAR/cm03MAR2010bhav.csv.zip'
in address-bar of my Chrome, I am denied permission

Do you have any idea what is going on here? Do I need to get some setting?

Any pointer will be highly appreciated.

__
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] Extracting numeric part from a string

2017-08-02 Thread Christofer Bogaso
Hi again,

I am struggling to extract the number part from below string :

"\"cm_ffm\":\"563.77\""

Basically, I need to extract 563.77 from above. The underlying number
can be a whole number, and there could be comma separator as well.

So far I tried below :

> library(stringr)

> str_extract("\"cm_ffm\":\"563.77\"", "[[:digit:]]+")

[1] "563"

>

However, above code is only extracting the integer part.

Could you please help how to achieve that. Thanks,

__
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] Creating/Reading a complex string in R

2017-07-18 Thread Christofer Bogaso
Thanks for your pointer.

Is there any way in R how to replace " ' " with " /' " programmatically?

My actual string is quite lengthy, so changing it manually may not be
possible. I am aware of gsub() function, however not sure I can apply
it directly on my original string.

Regards,

On Tue, Jul 18, 2017 at 10:27 PM, John McKown
 wrote:
> Try:
>
> String = '
>   
> 

[R] Creating/Reading a complex string in R

2017-07-18 Thread Christofer Bogaso
Hi again,

Let say I have below string (arbitrary)


  

[R] Matching values between 2 data.frame.

2017-05-20 Thread Christofer Bogaso
Hi again,

Let say I have below 2 data frames.

OriginalData = data.frame('Value1' = 1:12, 'Value2' = 11:22, 'AA1' =
c('AA4', 'AA3', 'AA4', 'AA1', 'AA2', 'AA1', 'AA6', 'AA6', 'AA3',
'AA3', 'AA4', 'AA3'), 'Value' = NA)

TargetValue = data.frame('AA' = c('AA1', 'AA2', 'AA3', 'AA4', 'AA5',
'AA6'), 'BB' = c('B', 'B', 'B', 'B', 'CC', 'CC'), 'Value' = c(5, 10,
25, 7, 35, 21))

OriginalData
TargetValue

Now I need to replace OriginalData's 'AA1' column with TargetValue's
'BB' column, based on matched values between 'AA1' & 'AA' columns of
OriginalData & TargetValue respectively. With this same law, I need to
update 'Value' column of  OriginalData with that of TargetValue.

As an example, after replacement by above rule, 1st row of
OriginalData should look like :

> OriginalData

   Value1 Value2 AA1 Value

1   1 11 B7

Values of TargetValue's 'AA' column are unique i.e. no duplication

Previously I have implemented a 'for' loop to implement above, however
since both of my data.frames are quite big, it is taking long time to
execute. Is there any 'R' way to implement this quickly.

Appreciate for any pointer.

Thanks,

__
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] How to calculate Rolling mean for a List object

2017-05-14 Thread Christofer Bogaso
Hi again,

I am looking to find a way on how to calculate Rolling average for the
elements of a list. For example consider below object 'Data'. This is
a list, where each elements are a Matrix. Basically, I am trying to
get Rolling average of those Matrices with rolling window as 5.

Data = structure(list(`2017-03-01` = structure(c(1.24915216491479e-06,
-2.0209685810767e-06, -6.64165527006046e-06, -2.0209685810767e-06,
3.26966891657893e-06, 1.07453495291747e-05, -6.64165527006046e-06,
1.07453495291747e-05, 3.53132196103035e-05), .Dim = c(3L, 3L)),
`2017-03-02` = structure(c(0.00863066441403338, -7.25585852047094e-05,
-0.000950715788640005, -7.25585852047094e-05, 6.10004981580403e-07,
7.99273256915577e-06, -0.000950715788640005, 7.99273256915577e-06,
0.000104726642980084), .Dim = c(3L, 3L)), `2017-03-03` =
structure(c(0.000785677680557358,
0.000283148300122928, 0.000170319078518317, 0.000283148300122928,
0.000102043066573597, 6.13808419844048e-05, 0.000170319078518317,
6.13808419844048e-05, 3.6921741860797e-05), .Dim = c(3L,
3L)), `2017-03-06` = structure(c(0.000100715163251975, 1.80035062425799e-06,
-5.05489732985851e-07, 1.80035062425799e-06, 3.21824665284709e-08,
-9.03596565752718e-09, -5.05489732985851e-07, -9.03596565752718e-09,
2.53705461922188e-09), .Dim = c(3L, 3L)), `2017-03-07` =
structure(c(0.000640065014281149,
-0.000110994847091752, -0.000231235438845606, -0.000110994847091752,
1.92478198402357e-05, 4.00989612058198e-05, -0.000231235438845606,
4.00989612058198e-05, 8.35381203238728e-05), .Dim = c(3L,
3L)), `2017-03-08` = structure(c(7.72648041923266e-06,
-2.11571338014623e-05,
7.82052544997182e-06, -2.11571338014623e-05, 5.79337921544145e-05,
-2.14146538093767e-05, 7.82052544997182e-06, -2.14146538093767e-05,
7.91571517626794e-06), .Dim = c(3L, 3L)), `2017-03-09` =
structure(c(4.43321118550061e-05,
1.90242249279913e-05, 5.68672547310199e-05, 1.90242249279913e-05,
8.16385953582618e-06, 2.44034267661023e-05, 5.68672547310199e-05,
2.44034267661023e-05, 7.29467766214148e-05), .Dim = c(3L,
3L)), `2017-03-10` = structure(c(0.000100081081692311, 1.39245218598852e-05,
2.0935583168872e-05, 1.39245218598852e-05, 1.93735225227204e-06,
2.91281809264057e-06, 2.0935583168872e-05, 2.91281809264057e-06,
4.3794355057858e-06), .Dim = c(3L, 3L)), `2017-03-14` =
structure(c(7.82185299651879e-06,
-3.05963602958646e-05, -4.65590052688468e-05, -3.05963602958646e-05,
0.00011968228804236, 0.000182122586662866, -4.65590052688468e-05,
0.000182122586662866, 0.000277139058045361), .Dim = c(3L,
3L)), `2017-03-15` = structure(c(4.02156693772954e-05, -2.2362610665311e-05,
-2.08706726432905e-05, -2.2362610665311e-05, 1.24351120722764e-05,
1.16054944222453e-05, -2.08706726432905e-05, 1.16054944222453e-05,
1.08312253240602e-05), .Dim = c(3L, 3L)), `2017-03-16` =
structure(c(2.64254966198469e-05,
5.78730550194069e-06, 5.0445603894268e-05, 5.78730550194069e-06,
1.26744656702641e-06, 1.10478196556107e-05, 5.0445603894268e-05,
1.10478196556107e-05, 9.62993804379875e-05), .Dim = c(3L,
3L)), `2017-03-17` = structure(c(0.000138433807049962, 8.72005344938308e-05,
0.00014374477881467, 8.72005344938308e-05, 5.49282966209652e-05,
9.05459570205481e-05, 0.00014374477881467, 9.05459570205481e-05,
0.000149259504428865), .Dim = c(3L, 3L)), `2017-03-20` =
structure(c(3.92058275846982e-05,
1.24332187386233e-05, -1.24235553811814e-05, 1.24332187386233e-05,
3.94290690251335e-06, -3.93984239286701e-06, -1.24235553811814e-05,
-3.93984239286701e-06, 3.93678026502162e-06), .Dim = c(3L,
3L)), `2017-03-21` = structure(c(0.000407544227952838,
-6.22427018306449e-05,
1.90596071859105e-05, -6.22427018306449e-05, 9.50609446890975e-06,
-2.9109023406881e-06, 1.90596071859105e-05, -2.9109023406881e-06,
8.91360007491622e-07), .Dim = c(3L, 3L)), `2017-03-22` =
structure(c(0.000220297355944482,
0.000282600064158173, 8.26030839524992e-05, 0.000282600064158173,
0.000362522718077154, 0.00010596421697645, 8.26030839524992e-05,
0.00010596421697645, 3.09729976068491e-05), .Dim = c(3L,
3L)), `2017-03-23` = structure(c(1.19559010537042e-05, 3.56054556562106e-05,
5.51130473489473e-06, 3.56054556562106e-05, 0.000106035376739222,
1.64130261253175e-05, 5.51130473489473e-06, 1.64130261253175e-05,
2.54054292892148e-06), .Dim = c(3L, 3L)), `2017-03-24` =
structure(c(0.000573948692221572,
-7.36566239512158e-05, 5.40736580500709e-05, -7.36566239512158e-05,
9.45258404700116e-06, -6.93944101735685e-06, 5.40736580500709e-05,
-6.93944101735685e-06, 5.0944632064554e-06), .Dim = c(3L,
3L)), `2017-03-27` = structure(c(6.50931905856128e-06, -6.3937553506226e-07,
3.58314387213273e-06, -6.3937553506226e-07, 6.28024331206322e-08,
-3.51953024554351e-07, 3.58314387213273e-06, -3.51953024554351e-07,
1.97239064376729e-06), .Dim = c(3L, 3L)), `2017-03-28` =

[R] Drawing World map divided into 6 economic regions

2017-05-12 Thread Christofer Bogaso
Hi again,

I am trying to draw a World map which is divided into 6 Economic
regions as available in below link

http://www.worldbank.org/en/about/annual-report/regions

I am aware of various R ways to draw World map based on Countries like
one available in

http://stackoverflow.com/questions/24136868/plot-map-with-values-for-countries-as-color-in-r

However I do not want to put any individual Country boundaries,
instead the individual boundaries of 6 Economic regions in the World.

Can you please suggest how can I achieve such a World map. Any pointer
will be highly appreciated.

Thanks for your time.

__
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   3   >