Re: [R] "XLConnect" packages; Excel dates read incorrectly

2017-09-24 Thread Eric Berger
Hi John,
I was able to reproduce your problem in my environment.
I modified the statement
date11<-as.Date(a_col$date, format="%Y-%m-%d")
to
date11<-as.Date(as.POSIXlt(a_col$date),format="%Y-%m-%d")
which then gives the output you would like to see (at least on my system)

> date11
[1] "2004-01-01" "2004-01-02" "2004-01-05" "2004-01-06" "2004-01-07"
"2004-01-08" "2004-01-09" "2004-01-12"
 [9] "2004-01-13" "2004-01-14" "2004-01-15" "2004-01-16" "2004-01-19"
"2004-01-20" "2004-01-21" "2004-01-22"
[17] "2004-01-23" "2004-01-26" "2004-01-27" "2004-01-28" "2004-01-29"
"2004-01-30" "2004-02-02"

HTH,

Eric

p.s.
you can also just use the shorter
date11<-as.Date(as.POSIXlt(a_col$date))



On Sun, Sep 24, 2017 at 8:51 AM, John  wrote:

> Hi,
>
>Thank you for all your responses.
>For Eric, The files are attached. (I believe it was also attached in my
> first message)
>For David, Could you send me the link regarding possible solutions or a
> more comprehensive description of the problem?
>
>Thanks,
>
> John
>
>
> 2017-09-23 22:29 GMT-07:00 David Winsemius :
>
>>
>> > On Sep 23, 2017, at 6:30 AM, Eric Berger  wrote:
>> >
>> > Jim,
>> > I don't see how that link could be related to John's issue. Symptoms
>> > related to your link involve discrepancies of four years whereas John is
>> > seeing discrepancies of one day.
>> >
>>
>> The MS Excel starting point was off by one day. R does not repeat that
>> error. MS claims that their  error is justified by needing to copy the
>> error made by Lotus123 and then because they wanted backward compatibility.
>>
>> I'm not sure why the XLConnect package does not fix the error. They just
>> use the integer from Excel and let R apply it correctly.
>> --
>> David.
>>
>>
>> > John,
>> > I do not see any attached files.
>> >
>> > Regards
>> >
>> > On Sat, Sep 23, 2017 at 1:30 PM, Jim Lemon 
>> wrote:
>> >
>> >> Hi John,
>> >> It could be due to this:
>> >>
>> >> https://support.microsoft.com/en-au/help/214330/differences-
>> >> between-the-1900-and-the-1904-date-system-in-excel
>> >>
>> >> Jim
>> >>
>> >>
>> >> On Sat, Sep 23, 2017 at 1:04 PM, John  wrote:
>> >>> Hi,
>> >>>
>> >>>   I tried to read xlsx files by "XLConnect" packages, but the dates
>> are
>> >>> one day earlier than it is supposed to be. I moved from California to
>> >>> Taiwan (Eastern Asia), and it worked well in California, but not in
>> >> Taiwan.
>> >>> Even if I adjust my Mac time to California time zone, it gives the
>> wrong
>> >>> dates. I don't know which part of the setting (in RStudio or in my
>> Mac?)
>> >> I
>> >>> should adjust. The codes and the data are attached.
>> >>>
>> >>>   My data are on weekdays, Monday to Friday every week, but they are
>> >> read
>> >>> as Sunday to Thursday.
>> >>>
>> >>> Data:
>> >>> 2004-01-01 (Th)
>> >>> 2004-01-02 (F)
>> >>> 2004-01-05 (M)
>> >>> 2004-01-06 (T)
>> >>> 2004-01-07 (W)
>> >>> 2004-01-08 (Th)
>> >>> 2004-01-09 (F)
>> >>>
>> >>> The data are read as:
>> >>> "2003-12-31" (W)
>> >>> "2004-01-01" (Th)
>> >>> "2004-01-04" (Su)
>> >>> "2004-01-05" (M)
>> >>> "2004-01-06" (Tu)
>> >>> "2004-01-07" (W)
>> >>> "2004-01-08" (Th)
>> >>>
>> >>>
>> >>>
>> >>> The codes are (also attached):
>> >>>
>> >>>
>> >>> rm(list=ls())
>> >>> library(XLConnect)
>> >>> library(xlsx)
>> >>>
>> >>> fl<-paste("allData_out3.xlsx")
>> >>> a1<-readWorksheetFromFile(fl, sheet="first", colTypes="numeric")
>> >>> b1<-readWorksheetFromFile(fl, sheet="second", colTypes="numeric")
>> >>> a_col<-readWorksheetFromFile(fl, sheet="first")
>> >>> date11<-as.Date(a_col$date, format="%Y-%m-%d")
>> >>>
>> >>>
>> >>> The output:
>>  date11
>> >>> [1] "2003-12-31" "2004-01-01" "2004-01-04" "2004-01-05" "2004-01-06"
>> >>> "2004-01-07"
>> >>> [7] "2004-01-08" "2004-01-11" "2004-01-12" "2004-01-13" "2004-01-14"
>> >>> "2004-01-15"
>> >>> [13] "2004-01-18" "2004-01-19" "2004-01-20" "2004-01-21" "2004-01-22"
>> >>> "2004-01-25"
>> >>> [19] "2004-01-26" "2004-01-27" "2004-01-28" "2004-01-29" "2004-02-01"
>> 
>> >>>
>> >>>
>> >>> 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.
>> >>
>> >
>> >   [[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:

Re: [R] "XLConnect" packages; Excel dates read incorrectly

2017-09-24 Thread Jeff Newmiller
FYI: Most files you might attach to an email sent to the mailing list will not 
transmitted to us due to virus propagation policies of the mailing list (they 
are removed see the Posting Guide). The best method for sharing binary 
files is to to put them on a website like Dropbox or Google Drive. For most R 
questions the best possible solution would be to use the dput function to 
create an R statement that we can execute to get the object in our R session.  
[1][2][3] This technique allows you to send your entire question in the email 
body, with no risk of losing pieces. Obviously this would be difficult with 
this particular question. 

The mailing list is also a plain text mailing list, so when you send HTML it 
often gets mangled... take the time to set your email format to plain text 
before sending to the list. 

---

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

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

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette) 
-- 
Sent from my phone. Please excuse my brevity.

On September 23, 2017 10:51:16 PM PDT, John  wrote:
>Hi,
>
>   Thank you for all your responses.
>For Eric, The files are attached. (I believe it was also attached in my
>first message)
>For David, Could you send me the link regarding possible solutions or a
>more comprehensive description of the problem?
>
>   Thanks,
>
>John
>
>
>2017-09-23 22:29 GMT-07:00 David Winsemius :
>
>>
>> > On Sep 23, 2017, at 6:30 AM, Eric Berger 
>wrote:
>> >
>> > Jim,
>> > I don't see how that link could be related to John's issue.
>Symptoms
>> > related to your link involve discrepancies of four years whereas
>John is
>> > seeing discrepancies of one day.
>> >
>>
>> The MS Excel starting point was off by one day. R does not repeat
>that
>> error. MS claims that their  error is justified by needing to copy
>the
>> error made by Lotus123 and then because they wanted backward
>compatibility.
>>
>> I'm not sure why the XLConnect package does not fix the error. They
>just
>> use the integer from Excel and let R apply it correctly.
>> --
>> David.
>>
>>
>> > John,
>> > I do not see any attached files.
>> >
>> > Regards
>> >
>> > On Sat, Sep 23, 2017 at 1:30 PM, Jim Lemon 
>wrote:
>> >
>> >> Hi John,
>> >> It could be due to this:
>> >>
>> >> https://support.microsoft.com/en-au/help/214330/differences-
>> >> between-the-1900-and-the-1904-date-system-in-excel
>> >>
>> >> Jim
>> >>
>> >>
>> >> On Sat, Sep 23, 2017 at 1:04 PM, John  wrote:
>> >>> Hi,
>> >>>
>> >>>   I tried to read xlsx files by "XLConnect" packages, but the
>dates are
>> >>> one day earlier than it is supposed to be. I moved from
>California to
>> >>> Taiwan (Eastern Asia), and it worked well in California, but not
>in
>> >> Taiwan.
>> >>> Even if I adjust my Mac time to California time zone, it gives
>the
>> wrong
>> >>> dates. I don't know which part of the setting (in RStudio or in
>my
>> Mac?)
>> >> I
>> >>> should adjust. The codes and the data are attached.
>> >>>
>> >>>   My data are on weekdays, Monday to Friday every week, but they
>are
>> >> read
>> >>> as Sunday to Thursday.
>> >>>
>> >>> Data:
>> >>> 2004-01-01 (Th)
>> >>> 2004-01-02 (F)
>> >>> 2004-01-05 (M)
>> >>> 2004-01-06 (T)
>> >>> 2004-01-07 (W)
>> >>> 2004-01-08 (Th)
>> >>> 2004-01-09 (F)
>> >>>
>> >>> The data are read as:
>> >>> "2003-12-31" (W)
>> >>> "2004-01-01" (Th)
>> >>> "2004-01-04" (Su)
>> >>> "2004-01-05" (M)
>> >>> "2004-01-06" (Tu)
>> >>> "2004-01-07" (W)
>> >>> "2004-01-08" (Th)
>> >>>
>> >>>
>> >>>
>> >>> The codes are (also attached):
>> >>>
>> >>>
>> >>> rm(list=ls())
>> >>> library(XLConnect)
>> >>> library(xlsx)
>> >>>
>> >>> fl<-paste("allData_out3.xlsx")
>> >>> a1<-readWorksheetFromFile(fl, sheet="first", colTypes="numeric")
>> >>> b1<-readWorksheetFromFile(fl, sheet="second", colTypes="numeric")
>> >>> a_col<-readWorksheetFromFile(fl, sheet="first")
>> >>> date11<-as.Date(a_col$date, format="%Y-%m-%d")
>> >>>
>> >>>
>> >>> The output:
>>  date11
>> >>> [1] "2003-12-31" "2004-01-01" "2004-01-04" "2004-01-05"
>"2004-01-06"
>> >>> "2004-01-07"
>> >>> [7] "2004-01-08" "2004-01-11" "2004-01-12" "2004-01-13"
>"2004-01-14"
>> >>> "2004-01-15"
>> >>> [13] "2004-01-18" "2004-01-19" "2004-01-20" "2004-01-21"
>"2004-01-22"
>> >>> "2004-01-25"
>> >>> [19] "2004-01-26" "2004-01-27" "2004-01-28" "2004-01-29"
>"2004-02-01"
>> 
>> >>>
>> >>>
>> >>> 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

Re: [R] gsDesign Pocock & OBF boundary

2017-09-24 Thread Jeff Newmiller
Still failed. 

The first secret is in your email program settings, to use Plain Text format 
(at least for emails you send to this mailing list).

The second secret tool to use is the reprex package to let you verify that your 
code example will do on our computers what it is doing on your computer before 
you send it to us. That will also involve giving us some sample data or 
referencing some data already available to us in a relevant package. See [1], 
[2] and [3] for more discussion of how to succeed at communicating on the 
Internet regarding R. 

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

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

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette) 
-- 
Sent from my phone. Please excuse my brevity.

On September 23, 2017 9:53:05 PM PDT, array chip via R-help 
 wrote:
>Sorry for messed up text. Here it goes again:
>I am learning to use the gsDesign package.
>I have a question about Pocock and OBF boundary. As far as I can
>understand, these 2 boundaries require equal spacing between interim
>analyses (maybe this is not correct?). But looks like I can still use
>gsDesign to run an analysis based on unequal spacing: 
>> gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock')
>Symmetric two-sided group sequential design with 90 %power and 5 % Type
>I Error.Spending computations assume trial stops if a bound is
>crossed.          Sample          Size  Analysis Ratio*  Z  Nominal p 
>Spend        1  0.796 1.82    0.0346 0.0346        2  1.061 1.82   
>0.0346 0.0154    Total                      0.0500 ++alpha spending:
>Pocock boundary.*Sample size ratio compared to fixed design with no
>interim 
>Can anyone share some light whether the above analysis is still valid?
>Or for unequal spacing, I have to use Lan-Demet’s error spending
>function approximations? Thank you,
>
>
>
>  From: Berend Hasselman 
> To: array chip  
>Cc: R-help Mailing List 
> Sent: Friday, September 22, 2017 11:46 PM
> Subject: Re: [R] gsDesign Pocock & OBF boundary
>   
>
>> On 23 Sep 2017, at 01:32, array chip via R-help
> wrote:
>> 
>> Hi, 
>> 
>> I am learning to use your gsDesign package! I have a question about
>Pocock and OBF boundary. As far as Iunderstand, these 2 boundaries
>require equal spacing between interim analyses(maybe this is not
>correct?). But I can still use gsDesign to run an analysisbased on
>unequal spacing:
>gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock')Symmetrictwo-sided
>group sequential design with90 %power and 5 % Type I
>Error.Spendingcomputations assume trial stops if a bound is crossed.   
>      Sample          Size  AnalysisRatio*  Z  Nominal p  Spend       
>1  0.796 1.82    0.0346 0.0346        2  1.061 1.82    0.0346 0.0154   
>Total                      0.0500  ++alpha
>spending:Pocockboundary.*Sample size ratio compared to fixed design
>with no interim Can anyone share some light whether the above analysis
>is stillvalid? Or for unequal spacing, I have to use Lan-Demet’s error
>spendingfunction approximations? Thank you,
>>     [[alternative HTML version deleted]]
>> 
>
>Your example code is a complete mess.
>Do NOT post in html. This is a plain text mailing list.
>Read the Posting Guide (https://www.r-project.org/posting-guide.html).
>
>Berend Hasselman]
>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
>   
>   [[alternative HTML version deleted]]
>
>__
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

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

Re: [R] "XLConnect" packages; Excel dates read incorrectly

2017-09-24 Thread John
Hi Eric,

   Thank you for your message! It does work in my system!!
   I follow you by typing it:
date11<-as.Date(as.POSIXlt(a_col$date),format="%Y-%m-%d")

   Then I typed it:
   date12<-as.Date(a_col$date, format="%Y-%m-%d")
   date12 yields exactly the same results as date11.

   Then my system time zone has changed:  (I reset my Mac time zone to
California time when I found the problem a few days ago, but I did not
restart the system until the last night, so I am not sure whether your line
changes it or restarting my Mac changes it)
> Sys.time()
[1] "2017-09-24 00:41:32 PDT"

   If it worked as it did yesterday, then system time should return
"2017-09-24 15:41:32 CST". 15:41:32 is my local time (In Taiwan, same time
zone as Singapore, China, and Malaysia), but CST is a time zone int the US.

John



2017-09-24 0:19 GMT-07:00 Eric Berger :

> Hi John,
> I was able to reproduce your problem in my environment.
> I modified the statement
> date11<-as.Date(a_col$date, format="%Y-%m-%d")
> to
> date11<-as.Date(as.POSIXlt(a_col$date),format="%Y-%m-%d")
> which then gives the output you would like to see (at least on my system)
>
> > date11
> [1] "2004-01-01" "2004-01-02" "2004-01-05" "2004-01-06" "2004-01-07"
> "2004-01-08" "2004-01-09" "2004-01-12"
>  [9] "2004-01-13" "2004-01-14" "2004-01-15" "2004-01-16" "2004-01-19"
> "2004-01-20" "2004-01-21" "2004-01-22"
> [17] "2004-01-23" "2004-01-26" "2004-01-27" "2004-01-28" "2004-01-29"
> "2004-01-30" "2004-02-02"
>
> HTH,
>
> Eric
>
> p.s.
> you can also just use the shorter
> date11<-as.Date(as.POSIXlt(a_col$date))
>
>
>
> On Sun, Sep 24, 2017 at 8:51 AM, John  wrote:
>
>> Hi,
>>
>>Thank you for all your responses.
>>For Eric, The files are attached. (I believe it was also attached in
>> my first message)
>>For David, Could you send me the link regarding possible solutions or
>> a more comprehensive description of the problem?
>>
>>Thanks,
>>
>> John
>>
>>
>> 2017-09-23 22:29 GMT-07:00 David Winsemius :
>>
>>>
>>> > On Sep 23, 2017, at 6:30 AM, Eric Berger 
>>> wrote:
>>> >
>>> > Jim,
>>> > I don't see how that link could be related to John's issue. Symptoms
>>> > related to your link involve discrepancies of four years whereas John
>>> is
>>> > seeing discrepancies of one day.
>>> >
>>>
>>> The MS Excel starting point was off by one day. R does not repeat that
>>> error. MS claims that their  error is justified by needing to copy the
>>> error made by Lotus123 and then because they wanted backward compatibility.
>>>
>>> I'm not sure why the XLConnect package does not fix the error. They just
>>> use the integer from Excel and let R apply it correctly.
>>> --
>>> David.
>>>
>>>
>>> > John,
>>> > I do not see any attached files.
>>> >
>>> > Regards
>>> >
>>> > On Sat, Sep 23, 2017 at 1:30 PM, Jim Lemon 
>>> wrote:
>>> >
>>> >> Hi John,
>>> >> It could be due to this:
>>> >>
>>> >> https://support.microsoft.com/en-au/help/214330/differences-
>>> >> between-the-1900-and-the-1904-date-system-in-excel
>>> >>
>>> >> Jim
>>> >>
>>> >>
>>> >> On Sat, Sep 23, 2017 at 1:04 PM, John  wrote:
>>> >>> Hi,
>>> >>>
>>> >>>   I tried to read xlsx files by "XLConnect" packages, but the dates
>>> are
>>> >>> one day earlier than it is supposed to be. I moved from California to
>>> >>> Taiwan (Eastern Asia), and it worked well in California, but not in
>>> >> Taiwan.
>>> >>> Even if I adjust my Mac time to California time zone, it gives the
>>> wrong
>>> >>> dates. I don't know which part of the setting (in RStudio or in my
>>> Mac?)
>>> >> I
>>> >>> should adjust. The codes and the data are attached.
>>> >>>
>>> >>>   My data are on weekdays, Monday to Friday every week, but they are
>>> >> read
>>> >>> as Sunday to Thursday.
>>> >>>
>>> >>> Data:
>>> >>> 2004-01-01 (Th)
>>> >>> 2004-01-02 (F)
>>> >>> 2004-01-05 (M)
>>> >>> 2004-01-06 (T)
>>> >>> 2004-01-07 (W)
>>> >>> 2004-01-08 (Th)
>>> >>> 2004-01-09 (F)
>>> >>>
>>> >>> The data are read as:
>>> >>> "2003-12-31" (W)
>>> >>> "2004-01-01" (Th)
>>> >>> "2004-01-04" (Su)
>>> >>> "2004-01-05" (M)
>>> >>> "2004-01-06" (Tu)
>>> >>> "2004-01-07" (W)
>>> >>> "2004-01-08" (Th)
>>> >>>
>>> >>>
>>> >>>
>>> >>> The codes are (also attached):
>>> >>>
>>> >>>
>>> >>> rm(list=ls())
>>> >>> library(XLConnect)
>>> >>> library(xlsx)
>>> >>>
>>> >>> fl<-paste("allData_out3.xlsx")
>>> >>> a1<-readWorksheetFromFile(fl, sheet="first", colTypes="numeric")
>>> >>> b1<-readWorksheetFromFile(fl, sheet="second", colTypes="numeric")
>>> >>> a_col<-readWorksheetFromFile(fl, sheet="first")
>>> >>> date11<-as.Date(a_col$date, format="%Y-%m-%d")
>>> >>>
>>> >>>
>>> >>> The output:
>>>  date11
>>> >>> [1] "2003-12-31" "2004-01-01" "2004-01-04" "2004-01-05" "2004-01-06"
>>> >>> "2004-01-07"
>>> >>> [7] "2004-01-08" "2004-01-11" "2004-01-12" "2004-01-13" "2004-01-14"
>>> >>> "2004-01-15"
>>> >>> [13] "2004-01-18" "2004-01-19" "2004-01-20" "2004-01-21" "2004-01-22"
>>> >>> "2004-01-25"
>>> >>> [19] "2004-01-26" "2004-01-27" "2004-01-28" "2004-0

Re: [R] gsDesign Pocock & OBF boundary

2017-09-24 Thread array chip via R-help
Sorry it didn 't work again. I am on yahoo mail, and just found a switch to 
change from Rick text to Plain text, so here it goes again:


I am learning to use the gsDesign package. 

I have a question about Pocock and OBF boundary. As far as I can understand, 
these 2 boundaries require equal spacing between interim analyses (maybe this 
is not correct?). But looks like I can still use gsDesign to run an analysis 
based on unequal spacing: 

> library(gsDesign)
> gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock') 


Symmetric two-sided group sequential design with 
90 % power and 5 % Type I Error. 
Spending computations assume trial stops 
if a bound is crossed. 

 Sample 
 Size 
Analysis Ratio*  Z   Nominal p  Spend 
   1  0.796  1.82   0.0346 0.0346 
   2  1.061  1.82   0.0346 0.0154 
   Total  0.0500 

++ alpha spending: 
Pocock boundary. 
* Sample size ratio compared to fixed design with no interim 
  

Can anyone share some light whether the above analysis is still valid? Or for 
unequal spacing, I have to use Lan-Demet’s error spending function 
approximations? Thank you,





From: Jeff Newmiller 

oject.org>; Berend Hasselman  
Cc: R-help Mailing List 
Sent: Sunday, September 24, 2017 12:41 AM
Subject: Re: [R] gsDesign Pocock & OBF boundary



Still failed. 

The first secret is in your email program settings, to use Plain Text format 
(at least for emails you send to this mailing list).

The second secret tool to use is the reprex package to let you verify that your 
code example will do on our computers what it is doing on your computer before 
you send it to us. That will also involve giving us some sample data or 
referencing some data already available to us in a relevant package. See [1], 
[2] and [3] for more discussion of how to succeed at communicating on the 
Internet regarding R. 

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

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

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the 
vignette) 
-- 
Sent from my phone. Please excuse my brevity.


On September 23, 2017 9:53:05 PM PDT, array chip via R-help 
 wrote:
>Sorry for messed up text. Here it goes again:
>I am learning to use the gsDesign package.
>I have a question about Pocock and OBF boundary. As far as I can
>understand, these 2 boundaries require equal spacing between interim
>analyses (maybe this is not correct?). But looks like I can still use
>gsDesign to run an analysis based on unequal spacing: 
>> gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock')
>Symmetric two-sided group sequential design with 90 %power and 5 % Type
>I Error.Spending computations assume trial stops if a bound is
>crossed.  Sample  Size  Analysis Ratio*  Z  Nominal p 
>Spend1  0.796 1.820.0346 0.03462  1.061 1.82   
>0.0346 0.0154Total  0.0500 ++alpha spending:
>Pocock boundary.*Sample size ratio compared to fixed design with no
>interim 
>Can anyone share some light whether the above analysis is still valid?
>Or for unequal spacing, I have to use Lan-Demet’s error spending
>function approximations? Thank you,
>
>
>
>  From: Berend Hasselman 

>Cc: R-help Mailing List 
> Sent: Friday, September 22, 2017 11:46 PM
> Subject: Re: [R] gsDesign Pocock & OBF boundary
>  
>
>> On 23 Sep 2017, at 01:32, array chip via R-help
> wrote:
>> 
>> Hi, 
>> 
>> I am learning to use your gsDesign package! I have a question about
>Pocock and OBF boundary. As far as Iunderstand, these 2 boundaries
>require equal spacing between interim analyses(maybe this is not
>correct?). But I can still use gsDesign to run an analysisbased on
>unequal spacing:
>gsDesign(k=2,test.type=2,timing=c(0.75,1),alpha=0.05,sfu='Pocock')Symmetrictwo-sided
>group sequential design with90 %power and 5 % Type I
>Error.Spendingcomputations assume trial stops if a bound is crossed.   
>  Sample  Size  AnalysisRatio*  Z  Nominal p  Spend   
>1  0.796 1.820.0346 0.03462  1.061 1.820.0346 0.0154   
>Total  0.0500  ++alpha
>spending:Pocockboundary.*Sample size ratio compared to fixed design
>with no interim Can anyone share some light whether the above analysis
>is stillvalid? Or for unequal spacing, I have to use Lan-Demet’s error
>spendingfunction approximations? Thank you,
>> [[alternative HTML version deleted]]
>> 
>
>Your example code is a complete mess.
>Do NOT post in html. This is a plain text mailing list.
>Read the Posting Guide (https://www.r-project.org/posting-guide.html).
>
>Berend Hasselman]
>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>> and provide comment

[R] R version 3.3.2, Windows 10: gstat package: Error in fitting a variogram model using 'fit.variogram' function

2017-09-24 Thread Rathore, Saubhagya Singh
Dear Members,



I am trying to fit a variogram model using fit.variogram function from the 
gstat package. The figure showing my experimental variogram can be seen here: 
https://i.stack.imgur.com/UZXw4.png

My code line for this operation is:

> c2.vgm.fit<-fit.variogram(c2.vgm.exp,vgm(nugget=0, 
> psill=400,model="Exp",range =4),fit.method = 7)

The system throws following error message:

Error in switch(model, exponential = fit.exponential(v.object, c0 = nugget,  :

  EXPR must be a length 1 vector

Any help to know the cause of the error and avoiding it would be highly 
appreciated.

Thank you very much
Saubhagya Singh Rathore
PhD Candidate
Civil and Environmental Engineering
Georgia Institute of Technology



[[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] Remove spacing at the top and bottom of a plot

2017-09-24 Thread AbouEl-Makarim Aboueissa
Dear All:

Is there is away to remove spacing at the top and the bottom of a plot? If
so, any help will be appreciated.


Please use this code as an example:


par(mfrow=c(1,2))


lizard <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,8.8, 8.8,
9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9)

n.draw <- 100
mu <- 9
n <- 24
SD <- sd(lizard)
draws <- matrix(rnorm(n.draw * n, mu, SD), n)

get.conf.int <- function(x) {
  t.test(x)$conf.int
}

conf.int <- apply(draws, 2, get.conf.int)

plot(range(conf.int), c(0, 1 + n.draw), type = "n", xlab = "mean tail
length", ylab = "sample run")

for (i in 1:n.draw)  {
  if(conf.int[1,i] <= mu & conf.int[2,i] >= mu ){
lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'green')
lines(conf.int[, i], rep(i, 2), lwd = 2)
  }
  else {
lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'red')
  }
}

abline(v = 9, lwd = 3, col='blue')    lty = 2,





Thank you very much for your help.


with many thanks
abou
__
AbouEl-Makarim Aboueissa, PhD

Professor of Statistics
Department of Mathematics and Statistics
University of Southern Maine

[[alternative HTML version deleted]]

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


Re: [R] R version 3.3.2, Windows 10: gstat package: Error in fitting a variogram model using 'fit.variogram' function

2017-09-24 Thread Bert Gunter
No reproducible example makes it difficult to diagnose the source of the
error.

Did you try using traceback() after the error? That might give you a hint.

I am unfamiliar with the package and function, but check the "range"
argument to make sure it's supposed to be a single value and not a vector
(just a wild guess on my party -- therefore likely wrong).

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, Sep 24, 2017 at 1:12 PM, Rathore, Saubhagya Singh <
saubha...@gatech.edu> wrote:

> Dear Members,
>
>
>
> I am trying to fit a variogram model using fit.variogram function from the
> gstat package. The figure showing my experimental variogram can be seen
> here: https://i.stack.imgur.com/UZXw4.png
>
> My code line for this operation is:
>
> > c2.vgm.fit<-fit.variogram(c2.vgm.exp,vgm(nugget=0,
> psill=400,model="Exp",range =4),fit.method = 7)
>
> The system throws following error message:
>
> Error in switch(model, exponential = fit.exponential(v.object, c0 =
> nugget,  :
>
>   EXPR must be a length 1 vector
>
> Any help to know the cause of the error and avoiding it would be highly
> appreciated.
>
> Thank you very much
> Saubhagya Singh Rathore
> PhD Candidate
> Civil and Environmental Engineering
> Georgia Institute of Technology
>
>
>
> [[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] Remove spacing at the top and bottom of a plot

2017-09-24 Thread David L Carlson
The default margins are set as lines below, left, top, and right using 
mar=c(5.1, 4.1, 4.1, 2.1). Just change the top margin something like 1.1:

par(mfrow=c(1,2), mar=c(5.1, 4.1, 1.1, 2.1))

---
David L. Carlson
Department of Anthropology
Texas A&M University

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of AbouEl-Makarim 
Aboueissa
Sent: Sunday, September 24, 2017 3:59 PM
To: R mailing list 
Subject: [R] Remove spacing at the top and bottom of a plot

Dear All:

Is there is away to remove spacing at the top and the bottom of a plot? If
so, any help will be appreciated.


Please use this code as an example:


par(mfrow=c(1,2))


lizard <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,8.8, 8.8,
9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9)

n.draw <- 100
mu <- 9
n <- 24
SD <- sd(lizard)
draws <- matrix(rnorm(n.draw * n, mu, SD), n)

get.conf.int <- function(x) {
  t.test(x)$conf.int
}

conf.int <- apply(draws, 2, get.conf.int)

plot(range(conf.int), c(0, 1 + n.draw), type = "n", xlab = "mean tail
length", ylab = "sample run")

for (i in 1:n.draw)  {
  if(conf.int[1,i] <= mu & conf.int[2,i] >= mu ){
lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'green')
lines(conf.int[, i], rep(i, 2), lwd = 2)
  }
  else {
lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'red')
  }
}

abline(v = 9, lwd = 3, col='blue')    lty = 2,





Thank you very much for your help.


with many thanks
abou
__
AbouEl-Makarim Aboueissa, PhD

Professor of Statistics
Department of Mathematics and Statistics
University of Southern Maine

[[alternative HTML version deleted]]

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

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


Re: [R] Remove spacing at the top and bottom of a plot

2017-09-24 Thread AbouEl-Makarim Aboueissa
Dear David:

Thank you very much.

with thanks
abou

On Sun, Sep 24, 2017 at 5:28 PM, David L Carlson  wrote:

> The default margins are set as lines below, left, top, and right using
> mar=c(5.1, 4.1, 4.1, 2.1). Just change the top margin something like 1.1:
>
> par(mfrow=c(1,2), mar=c(5.1, 4.1, 1.1, 2.1))
>
> ---
> David L. Carlson
> Department of Anthropology
> Texas A&M University
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of
> AbouEl-Makarim Aboueissa
> Sent: Sunday, September 24, 2017 3:59 PM
> To: R mailing list 
> Subject: [R] Remove spacing at the top and bottom of a plot
>
> Dear All:
>
> Is there is away to remove spacing at the top and the bottom of a plot? If
> so, any help will be appreciated.
>
>
> Please use this code as an example:
>
>
> par(mfrow=c(1,2))
>
>
> lizard <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,8.8, 8.8,
> 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9)
>
> n.draw <- 100
> mu <- 9
> n <- 24
> SD <- sd(lizard)
> draws <- matrix(rnorm(n.draw * n, mu, SD), n)
>
> get.conf.int <- function(x) {
>   t.test(x)$conf.int
> }
>
> conf.int <- apply(draws, 2, get.conf.int)
>
> plot(range(conf.int), c(0, 1 + n.draw), type = "n", xlab = "mean tail
> length", ylab = "sample run")
>
> for (i in 1:n.draw)  {
>   if(conf.int[1,i] <= mu & conf.int[2,i] >= mu ){
> lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'green')
> lines(conf.int[, i], rep(i, 2), lwd = 2)
>   }
>   else {
> lines(conf.int[, i], rep(i, 2), lwd = 2, col = 'red')
>   }
> }
>
> abline(v = 9, lwd = 3, col='blue')    lty = 2,
>
>
>
>
>
> Thank you very much for your help.
>
>
> with many thanks
> abou
> __
> AbouEl-Makarim Aboueissa, PhD
>
> Professor of Statistics
> Department of Mathematics and Statistics
> University of Southern Maine
>
> [[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.
>



-- 
__
AbouEl-Makarim Aboueissa, PhD
Professor of Statistics
Department of Mathematics and Statistics
University of Southern Maine

[[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] Shift the normal curve to the top or near to the top of the histogram

2017-09-24 Thread AbouEl-Makarim Aboueissa
Dear All:

One more thing.

I want to add the normal curve to the histogram. Is there away to stretch
the peak of the curve to the top of the histogram or at least near to the
top of the histogram.

Please see the code below.


Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5,
8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9)

x<-seq(5,12, 0.001)

hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail
Lengths")

curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)),
add=TRUE, col=2, lwd = 2)



with many thanks
abou
__
AbouEl-Makarim Aboueissa, PhD
Professor of Statistics
Department of Mathematics and Statistics
University of Southern Maine

[[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] Shift the normal curve to the top or near to the top of the histogram

2017-09-24 Thread Jim Lemon
Hi Abou,
Try this:

library(plotrix)
 curve(rescale(dnorm(x
,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)),
c(0,6)),add=TRUE, col=2, lwd = 2)

Jim


On Mon, Sep 25, 2017 at 9:35 AM, AbouEl-Makarim Aboueissa
 wrote:
> Dear All:
>
> One more thing.
>
> I want to add the normal curve to the histogram. Is there away to stretch
> the peak of the curve to the top of the histogram or at least near to the
> top of the histogram.
>
> Please see the code below.
>
>
> Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5,
> 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9)
>
> x<-seq(5,12, 0.001)
>
> hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail
> Lengths")
>
> curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)),
> add=TRUE, col=2, lwd = 2)
>
>
>
> with many thanks
> abou
> __
> AbouEl-Makarim Aboueissa, PhD
> Professor of Statistics
> Department of Mathematics and Statistics
> University of Southern Maine
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Shift the normal curve to the top or near to the top of the histogram

2017-09-24 Thread AbouEl-Makarim Aboueissa
Dear Jim:

Thank you very much

abou

On Sun, Sep 24, 2017 at 8:18 PM, Jim Lemon  wrote:

> Hi Abou,
> Try this:
>
> library(plotrix)
>  curve(rescale(dnorm(x
> ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)),
> c(0,6)),add=TRUE, col=2, lwd = 2)
>
> Jim
>
>
> On Mon, Sep 25, 2017 at 9:35 AM, AbouEl-Makarim Aboueissa
>  wrote:
> > Dear All:
> >
> > One more thing.
> >
> > I want to add the normal curve to the histogram. Is there away to stretch
> > the peak of the curve to the top of the histogram or at least near to the
> > top of the histogram.
> >
> > Please see the code below.
> >
> >
> > Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5,
> > 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9)
> >
> > x<-seq(5,12, 0.001)
> >
> > hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail
> > Lengths")
> >
> > curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.
> lengths)),
> > add=TRUE, col=2, lwd = 2)
> >
> >
> >
> > with many thanks
> > abou
> > __
> > AbouEl-Makarim Aboueissa, PhD
> > Professor of Statistics
> > Department of Mathematics and Statistics
> > University of Southern Maine
> >
> > [[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.
>



-- 
__
AbouEl-Makarim Aboueissa, PhD
Professor of Statistics
Department of Mathematics and Statistics
University of Southern Maine

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