Re: [R] OFF TOPIC: Nature article on File Drawer Problem in Reserach

2024-07-24 Thread Ogbos Okike
Dear Bert,

You have made my day!! Your post is a great help and very useful in my
field.

The paper is not among the off-the-shelf research output. Some of us, who
get into unenviable conflict and disputation with some reverenced
authorities in our field, understand the weight of the article. I had not
even consumed half of it before I decided to thank you. I will quickly go
back to see how it goes. I am sure it is going to be one of my best
collections for the year!!

Thank you very much. I often follow your posts, even if the topic does not
concern me. Your tough comments always make sense to me. Today, I have
gained something vital I should have lost if I overlooked it because of the
subject heading: "
OFF TOPIC"

Please accept my warmest regards
Ogbos

On Wed, Jul 24, 2024 at 3:44 PM Bert Gunter  wrote:

> Again, this is off topic, not about statistics or R, but I think of
> interest to many on this list. The title is:
>
> "So you got a null result. Will anyone publish it?"
>
> https://www.nature.com/articles/d41586-024-02383-9
>
> Best to all,
> Bert
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] I have Problem using the Pipe Command

2024-06-19 Thread Ogbos Okike
Dear Martin,
I agree with you. I am anxious to upgrade. But I am afraid of losing some
data on my only one system. I do not have enough backup.

I am planning to buy a backup laptop before venturing to upgrade.

But if there is any possibility of upgrading without losing my
documents/data, I would gladly go with that.

Please let me know whether it is possible.

Many thanks for your time.

Warm regards
Ogbos

On Wed, Jun 19, 2024 at 8:38 AM Martin Maechler 
wrote:

> >>>>> Duncan Murdoch
> >>>>> on Tue, 18 Jun 2024 12:25:49 -0400 writes:
>
> > On 2024-06-18 12:17 p.m., Ben Bolker wrote:
> >> You probably have to update your R version. The native pipe |>
> wasn't
> >> introduced until R version 4.4.  R.version.string (among others)
> will
> >> tell you what version you have.
>
> > Typo: it was introduced in R 4.1.0.
>
> > Another possible problem is with line breaks.  This works:
>
> > 1:10 |>
> > mean()
>
> > but this fails:
>
> > 1:10
> > |> mean()
>
> > Duncan Murdoch
>
> Yes, of course (as I know you know), the same way that
>
> >  1:10
> >  + 1
>
> does "not" work.
>
>
>
> >> If you don't want to do that, install and load the 'magrittr'
> package
> >> and change |> to %>% everywhere.
>
> I really think that in June 2024  you (Ogbos) should not run
> "productively" an R version that is older than May 2021 (where R
> 4.1.0 was released) :
>
>   $ R-4.1.0 --version | head 1
>   R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
>
>   $ R-4.1.0 --vanilla -s -e '1:10|>sum()'
>   [1] 55
>   $
>
> So upgrading your R to current (R 4.4.1)  is *very* much recommended.
>
> Martin Maechler
>
>
> >> On 2024-06-18 12:13 p.m., Ogbos Okike wrote:
> >>> Greetings to everyone and thank you for your readiness to help.
> >>>
> >>> I have problems using the pipe command (|>).
> >>>
> >>> Once I have it in any script on my system, it won't.
> >>>
> >>> The error message will say:
> >>>
> >>> unexpected '>'
> >>> I loaded the two packages below to see if it would handle it. But
> the
> >>> problem remains.
> >>> library(magrittr)
> >>> library(dplyr)
> >>>
> >>> I searched to see if there was a way to install the command. But I
> was not
> >>> successful.
> >>>
> >>> Please tell me what to do to be able to use the pipe command on my
> system.
> >>> I would be grateful for any help.
> >>> Thank you.
> >>>
> >>> Sincerely yours
> >>> Ogbos
> >>>
> >>> [[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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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] I have Problem using the Pipe Command: PROBLEM SOLVED!

2024-06-19 Thread Ogbos Okike
Dear Eric,
This is too great! I quickly changed |> to %>% and it worked like margic.
Ben suggested that earlier but I thought I had to open the installed
'magrittr' with gedit in order to edit it.

Following your pointers now, I simply changed the |> in my code to %>% to I
have great success and peace.

Thank you very much.

Thanks too to all others who assisted.

Best regards
Ogbos

On Wed, Jun 19, 2024 at 8:28 AM Eric Berger  wrote:

> So all is good. You are successfully using the R pipe %>%  (before it
> became part of R).
> If you want to use the newer pipe that is part of R, i.e. |> instead of
> %>% you will have to install a more recent version of R.
> Your previous email with sessionInfo() showed that you are using R version
> 3.4.4 from 2018.
> As other people have already told you, you will need to install R version
> 4.1.0 or later.
>
> Good luck
>
>
> On Wed, Jun 19, 2024 at 10:00 AM Ogbos Okike 
> wrote:
>
>> The output of the command is, indeed, 55. See below:
>>
>> > library(magrittr)
>> > 1:10 %>% sum()
>> [1] 55
>>
>> On Wed, Jun 19, 2024 at 7:52 AM Eric Berger 
>> wrote:
>>
>>> In your R session do
>>>
>>> library(magrittr)
>>> 1:10 %>% sum()
>>>
>>> This should output 55.
>>> If that does not work send the results, include the output of
>>> sessionInfo() showing that you have loaded magrittr.
>>>
>>>
>>>
>>> On Wed, Jun 19, 2024 at 9:43 AM Ogbos Okike 
>>> wrote:
>>>
>>>> Dear Eric,
>>>> Good morning from Nigeria.
>>>>
>>>> Please, see the output of the session below:
>>>>
>>>> > sessionInfo()
>>>> R version 3.4.4 (2018-03-15)
>>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>> Running under: Ubuntu 18.04.6 LTS
>>>>
>>>> Matrix products: default
>>>> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
>>>> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
>>>>
>>>> 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
>>>>
>>>>
>>>> loaded via a namespace (and not attached):
>>>> [1] compiler_3.4.4
>>>>
>>>> On Tue, Jun 18, 2024 at 8:31 PM Eric Berger 
>>>> wrote:
>>>>
>>>>> Please show the output of
>>>>> > sessionInfo()
>>>>>
>>>>>
>>>>> On Tue, Jun 18, 2024 at 7:49 PM Ogbos Okike 
>>>>> wrote:
>>>>>
>>>>>> Thanks, Duncan for contributing. I quickly tried entering the command
>>>>>> on a
>>>>>> new line. But the error pointed specifically to the point. It didn't
>>>>>> run.
>>>>>> Best regards
>>>>>> Ogbos
>>>>>>
>>>>>> On Tue, Jun 18, 2024 at 5:38 PM Duncan Murdoch <
>>>>>> murdoch.dun...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>> > On 2024-06-18 12:17 p.m., Ben Bolker wrote:
>>>>>> > > You probably have to update your R version. The native pipe
>>>>>> |> wasn't
>>>>>> > > introduced until R version 4.4.  R.version.string (among others)
>>>>>> will
>>>>>> > > tell you what version you have.
>>>>>> >
>>>>>> > Typo: it was introduced in R 4.1.0.
>>>>>> >
>>>>>> > Another possible problem is with line breaks.  This works:
>>>>>> >
>>>>>> >   1:10 |>
>>>>>> >   mean()
>>>>>> >
>>>>>> > but this fails:
>>>>>> >
>>>>>> >   1:10
>>>>>> >   |> mean()
>>>>>> >
>>>>>> > Duncan Murdoch
>>>>>> >
>>>>>> > >
>>>>>> > > If you don't want to do

Re: [R] I have Problem using the Pipe Command

2024-06-18 Thread Ogbos Okike
Thanks, Duncan for contributing. I quickly tried entering the command on a
new line. But the error pointed specifically to the point. It didn't run.
Best regards
Ogbos

On Tue, Jun 18, 2024 at 5:38 PM Duncan Murdoch 
wrote:

> On 2024-06-18 12:17 p.m., Ben Bolker wrote:
> > You probably have to update your R version. The native pipe |> wasn't
> > introduced until R version 4.4.  R.version.string (among others) will
> > tell you what version you have.
>
> Typo: it was introduced in R 4.1.0.
>
> Another possible problem is with line breaks.  This works:
>
>   1:10 |>
>   mean()
>
> but this fails:
>
>   1:10
>   |> mean()
>
> Duncan Murdoch
>
> >
> > If you don't want to do that, install and load the 'magrittr' package
> > and change |> to %>% everywhere.
> >
> > On 2024-06-18 12:13 p.m., Ogbos Okike wrote:
> >> Greetings to everyone and thank you for your readiness to help.
> >>
> >> I have problems using the pipe command (|>).
> >>
> >> Once I have it in any script on my system, it won't.
> >>
> >> The error message will say:
> >>
> >> unexpected '>'
> >> I loaded the two packages below to see if it would handle it. But the
> >> problem remains.
> >> library(magrittr)
> >> library(dplyr)
> >>
> >> I searched to see if there was a way to install the command. But I was
> not
> >> successful.
> >>
> >> Please tell me what to do to be able to use the pipe command on my
> system.
> >> I would be grateful for any help.
> >> Thank you.
> >>
> >> Sincerely yours
> >> Ogbos
> >>
> >>  [[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-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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] I have Problem using the Pipe Command

2024-06-18 Thread Ogbos Okike
Yes, Ben and others. Many thanks for your swift response. I have quickly
installed the 'magrittr' package. It was installed successfully.

But I tried to edit it using EDIT(magrittr). But it didn't work.

Please, guide me further on how to edit it.

Thank you very much.
Ogbos

On Tue, Jun 18, 2024 at 5:18 PM Ben Bolker  wrote:

>You probably have to update your R version. The native pipe |> wasn't
> introduced until R version 4.4.  R.version.string (among others) will
> tell you what version you have.
>
>If you don't want to do that, install and load the 'magrittr' package
> and change |> to %>% everywhere.
>
> On 2024-06-18 12:13 p.m., Ogbos Okike wrote:
> > Greetings to everyone and thank you for your readiness to help.
> >
> > I have problems using the pipe command (|>).
> >
> > Once I have it in any script on my system, it won't.
> >
> > The error message will say:
> >
> > unexpected '>'
> > I loaded the two packages below to see if it would handle it. But the
> > problem remains.
> > library(magrittr)
> > library(dplyr)
> >
> > I searched to see if there was a way to install the command. But I was
> not
> > successful.
> >
> > Please tell me what to do to be able to use the pipe command on my
> system.
> > I would be grateful for any help.
> > Thank you.
> >
> > Sincerely yours
> > Ogbos
> >
> >   [[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] I have Problem using the Pipe Command

2024-06-18 Thread Ogbos Okike
Greetings to everyone and thank you for your readiness to help.

I have problems using the pipe command (|>).

Once I have it in any script on my system, it won't.

The error message will say:

unexpected '>'
I loaded the two packages below to see if it would handle it. But the
problem remains.
library(magrittr)
library(dplyr)

I searched to see if there was a way to install the command. But I was not
successful.

Please tell me what to do to be able to use the pipe command on my system.
I would be grateful for any help.
Thank you.

Sincerely yours
Ogbos

[[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] Output of tapply function as data frame: Problem Fixed

2024-03-28 Thread Ogbos Okike
This is great!
Many thanks to all for helping to further resolve the problem.
Best wishes
Ogbos

On Fri, Mar 29, 2024 at 6:39 AM Rui Barradas  wrote:

> Às 01:43 de 29/03/2024, Ogbos Okike escreveu:
> > Dear Rui,
> > Thanks again for resolving this. I have already started using the version
> > that works for me.
> >
> > But to clarify the second part, please let me paste the what I did and
> the
> > error message:
> >
> >> set.seed(2024)
> >> data <- data.frame(
> > +Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
> > + TRUE),
> > +count = sample(10L, 100L, TRUE)
> > + )
> >>
> >> # coerce tapply's result to class "data.frame"
> >> res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
> > Error: unexpected '>' in "res <- with(data, tapply(count, Date, mean))
> |>"
> >> # assign a dates column from the row names
> >> res$Date <- row.names(res)
> > Error in row.names(res) : object 'res' not found
> >> # cosmetics
> >> names(res)[2:1] <- names(data)
> > Error in names(res)[2:1] <- names(data) : object 'res' not found
> >> # note that the row names are still tapply's names vector
> >> # and that the columns order is not Date/count. Both are fixed
> >> # after the calculations.
> >> res
> >
> > You can see that the error message is on the pipe. Please, let me know
> > where I am missing it.
> > Thanks.
> >
> > On Wed, Mar 27, 2024 at 10:45 PM Rui Barradas 
> wrote:
> >
> >> Às 08:58 de 27/03/2024, Ogbos Okike escreveu:
> >>> Dear Rui,
> >>> Nice to hear from you!
> >>>
> >>> I am sorry for the omission and I have taken note.
> >>>
> >>> Many thanks for responding. The second solution looks elegant as it
> >> quickly
> >>> resolved the problem.
> >>>
> >>> Please, take a second look at the first solution. It refused to run.
> >> Looks
> >>> as if the pipe is not properly positioned. Efforts to correct it and
> get
> >> it
> >>> run failed. If you can look further, it would be great. If time does
> not
> >>> permit, I am fine too.
> >>>
> >>> But having the too solutions will certainly make the subject more
> >>> interesting.
> >>> Thank you so much.
> >>> With warmest regards from
> >>> Ogbos
> >>>
> >>> On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas 
> >> wrote:
> >>>
> >>>> Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> >>>>> Warm greetings to you all.
> >>>>>
> >>>>> Using the tapply function below:
> >>>>> data<-read.table("FD1month",col.names = c("Dates","count"))
> >>>>> x=data$count
> >>>>> f<-factor(data$Dates)
> >>>>> AB<- tapply(x,f,mean)
> >>>>>
> >>>>>
> >>>>> I made a simple calculation. The result, stored in AB, is of the form
> >>>>> below. But an effort to write AB to a file as a data frame fails.
> When
> >> I
> >>>>> use the write table, it only produces the count column and strip of
> the
> >>>>> first column (date).
> >>>>>
> >>>>> 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> >>>>> 2006-05-01
> >>>>> -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> >>>>> -4.430705
> >>>>> 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> >>>>> 2006-12-01
> >>>>> -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> >>>>> -10.072579
> >>>>> 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> >>>>> 2007-07-01
> >>>>> -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> >>>>> -4.127980
> >>>>> 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> >>>>> 2008-02-01
> >>>>> -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> >>>>> -4.183578
> >>>>> 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> >>>>> 2008-09-01
> 

Re: [R] Output of tapply function as data frame

2024-03-28 Thread Ogbos Okike
Dear Deepayan,
Thanks for your kind response.
Regards
Ogbos

On Thu, Mar 28, 2024 at 3:40 AM Deepayan Sarkar 
wrote:

> For more complicated examples, the (relatively new) array2DF()
> function is also useful:
>
> > with(data, tapply(count, Date, mean)) |> array2DF()
> Var1Value
> 1 2024-03-23 5.416667
> 2 2024-03-24 5.50
> 3 2024-03-25 6.00
> 4 2024-03-26 4.476190
> 5 2024-03-27 6.538462
> 6 2024-03-28 5.20
>
> or
>
> > tapply(data, ~ Date, with, mean(count)) |> array2DF(responseName =
> "count")
> Datecount
> 1 2024-03-23 5.416667
> 2 2024-03-24 5.50
> 3 2024-03-25 6.00
> 4 2024-03-26 4.476190
> 5 2024-03-27 6.538462
> 6 2024-03-28 5.20
>
> Best,
> -Deepayan
>
> On Wed, 27 Mar 2024 at 13:15, Rui Barradas  wrote:
> >
> > Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> > > Warm greetings to you all.
> > >
> > > Using the tapply function below:
> > > data<-read.table("FD1month",col.names = c("Dates","count"))
> > > x=data$count
> > >   f<-factor(data$Dates)
> > > AB<- tapply(x,f,mean)
> > >
> > >
> > > I made a simple calculation. The result, stored in AB, is of the form
> > > below. But an effort to write AB to a file as a data frame fails. When
> I
> > > use the write table, it only produces the count column and strip of the
> > > first column (date).
> > >
> > > 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> > > 2006-05-01
> > >   -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> > >   -4.430705
> > > 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> > > 2006-12-01
> > >   -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> > > -10.072579
> > > 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> > > 2007-07-01
> > >   -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> > >   -4.127980
> > > 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> > > 2008-02-01
> > >   -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> > >   -4.183578
> > > 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> > > 2008-09-01
> > >   -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
> > >   -4.347428
> > > 2008-10-01 2008-11-01 2008-12-01
> > >   -4.029918  -4.260326  -4.454224
> > >
> > > But the normal format I wish to display only appears on the terminal,
> > > leading me to copy it and paste into a text file. That is, when I
> enter AB
> > > on the terminal, it returns a format in the form:
> > >
> > > 008-02-01  -4.183578
> > > 2008-03-01  -4.336969
> > > 2008-04-01  -3.813306
> > > 2008-05-01  -4.296579
> > > 2008-06-01  -4.575095
> > > 2008-07-01  -4.036036
> > > 2008-08-01  -4.727994
> > > 2008-09-01  -4.347428
> > > 2008-10-01  -4.029918
> > > 2008-11-01  -4.260326
> > > 2008-12-01  -4.454224
> > >
> > > Now, my question: How do I write out two columns displayed by AB on the
> > > terminal to a file?
> > >
> > > I have tried using AB<-data.frame(AB) but it doesn't work either.
> > >
> > > Many thanks for your time.
> > > Ogbos
> > >
> > >   [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > Hello,
> >
> > The main trick is to pipe to as.data.frame. But the result will have one
> > column only, you must assign the dates from the df's row names.
> > I also include an aggregate solution.
> >
> >
> >
> > # create a test data set
> > set.seed(2024)
> > data <- data.frame(
> >Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
> > TRUE),
> >count = sample(10L, 100L, TRUE)
> > )
> >
> > # coerce tapply's result to class "data.frame"
> > res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
> > # assign a dates column from the row nam

Re: [R] Output of tapply function as data frame: Problem Fixed

2024-03-28 Thread Ogbos Okike
Dear Rui,
Thanks again for resolving this. I have already started using the version
that works for me.

But to clarify the second part, please let me paste the what I did and the
error message:

> set.seed(2024)
> data <- data.frame(
+Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
+ TRUE),
+count = sample(10L, 100L, TRUE)
+ )
>
> # coerce tapply's result to class "data.frame"
> res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
Error: unexpected '>' in "res <- with(data, tapply(count, Date, mean)) |>"
> # assign a dates column from the row names
> res$Date <- row.names(res)
Error in row.names(res) : object 'res' not found
> # cosmetics
> names(res)[2:1] <- names(data)
Error in names(res)[2:1] <- names(data) : object 'res' not found
> # note that the row names are still tapply's names vector
> # and that the columns order is not Date/count. Both are fixed
> # after the calculations.
> res

You can see that the error message is on the pipe. Please, let me know
where I am missing it.
Thanks.

On Wed, Mar 27, 2024 at 10:45 PM Rui Barradas  wrote:

> Às 08:58 de 27/03/2024, Ogbos Okike escreveu:
> > Dear Rui,
> > Nice to hear from you!
> >
> > I am sorry for the omission and I have taken note.
> >
> > Many thanks for responding. The second solution looks elegant as it
> quickly
> > resolved the problem.
> >
> > Please, take a second look at the first solution. It refused to run.
> Looks
> > as if the pipe is not properly positioned. Efforts to correct it and get
> it
> > run failed. If you can look further, it would be great. If time does not
> > permit, I am fine too.
> >
> > But having the too solutions will certainly make the subject more
> > interesting.
> > Thank you so much.
> > With warmest regards from
> > Ogbos
> >
> > On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas 
> wrote:
> >
> >> Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> >>> Warm greetings to you all.
> >>>
> >>> Using the tapply function below:
> >>> data<-read.table("FD1month",col.names = c("Dates","count"))
> >>> x=data$count
> >>>f<-factor(data$Dates)
> >>> AB<- tapply(x,f,mean)
> >>>
> >>>
> >>> I made a simple calculation. The result, stored in AB, is of the form
> >>> below. But an effort to write AB to a file as a data frame fails. When
> I
> >>> use the write table, it only produces the count column and strip of the
> >>> first column (date).
> >>>
> >>> 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> >>> 2006-05-01
> >>>-4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> >>>-4.430705
> >>> 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> >>> 2006-12-01
> >>>-3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> >>> -10.072579
> >>> 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> >>> 2007-07-01
> >>>-5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> >>>-4.127980
> >>> 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> >>> 2008-02-01
> >>>-3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> >>>-4.183578
> >>> 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> >>> 2008-09-01
> >>>-4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
> >>>-4.347428
> >>> 2008-10-01 2008-11-01 2008-12-01
> >>>-4.029918  -4.260326  -4.454224
> >>>
> >>> But the normal format I wish to display only appears on the terminal,
> >>> leading me to copy it and paste into a text file. That is, when I enter
> >> AB
> >>> on the terminal, it returns a format in the form:
> >>>
> >>> 008-02-01  -4.183578
> >>> 2008-03-01  -4.336969
> >>> 2008-04-01  -3.813306
> >>> 2008-05-01  -4.296579
> >>> 2008-06-01  -4.575095
> >>> 2008-07-01  -4.036036
> >>> 2008-08-01  -4.727994
> >>> 2008-09-01  -4.347428
> >>> 2008-10-01  -4.029918
> >>> 2008-11-01  -4.260326
> >>> 2008-12-01  -4.454224
> >>>
> >>> Now, my question: How do I write out two columns displayed by AB o

[R] Output of tapply function as data frame: Problem Fixed

2024-03-27 Thread Ogbos Okike
Dear Rui,
Nice to hear from you!

I am sorry for the omission and I have taken note.

Many thanks for responding. The second solution looks elegant as it quickly
resolved the problem.

Please, take a second look at the first solution. It refused to run. Looks
as if the pipe is not properly positioned. Efforts to correct it and get it
run failed. If you can look further, it would be great. If time does not
permit, I am fine too.

But having the too solutions will certainly make the subject more
interesting.
Thank you so much.
With warmest regards from
Ogbos

On Wed, Mar 27, 2024 at 8:44 AM Rui Barradas  wrote:

> Às 04:30 de 27/03/2024, Ogbos Okike escreveu:
> > Warm greetings to you all.
> >
> > Using the tapply function below:
> > data<-read.table("FD1month",col.names = c("Dates","count"))
> > x=data$count
> >   f<-factor(data$Dates)
> > AB<- tapply(x,f,mean)
> >
> >
> > I made a simple calculation. The result, stored in AB, is of the form
> > below. But an effort to write AB to a file as a data frame fails. When I
> > use the write table, it only produces the count column and strip of the
> > first column (date).
> >
> > 2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
> > 2006-05-01
> >   -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
> >   -4.430705
> > 2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
> > 2006-12-01
> >   -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
> > -10.072579
> > 2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
> > 2007-07-01
> >   -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
> >   -4.127980
> > 2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
> > 2008-02-01
> >   -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
> >   -4.183578
> > 2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
> > 2008-09-01
> >   -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
> >   -4.347428
> > 2008-10-01 2008-11-01 2008-12-01
> >   -4.029918  -4.260326  -4.454224
> >
> > But the normal format I wish to display only appears on the terminal,
> > leading me to copy it and paste into a text file. That is, when I enter
> AB
> > on the terminal, it returns a format in the form:
> >
> > 008-02-01  -4.183578
> > 2008-03-01  -4.336969
> > 2008-04-01  -3.813306
> > 2008-05-01  -4.296579
> > 2008-06-01  -4.575095
> > 2008-07-01  -4.036036
> > 2008-08-01  -4.727994
> > 2008-09-01  -4.347428
> > 2008-10-01  -4.029918
> > 2008-11-01  -4.260326
> > 2008-12-01  -4.454224
> >
> > Now, my question: How do I write out two columns displayed by AB on the
> > terminal to a file?
> >
> > I have tried using AB<-data.frame(AB) but it doesn't work either.
> >
> > Many thanks for your time.
> > Ogbos
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> Hello,
>
> The main trick is to pipe to as.data.frame. But the result will have one
> column only, you must assign the dates from the df's row names.
> I also include an aggregate solution.
>
>
>
> # create a test data set
> set.seed(2024)
> data <- data.frame(
>Date = sample(seq(Sys.Date() - 5, Sys.Date(), by = "1 days"), 100L,
> TRUE),
>count = sample(10L, 100L, TRUE)
> )
>
> # coerce tapply's result to class "data.frame"
> res <- with(data, tapply(count, Date, mean)) |> as.data.frame()
> # assign a dates column from the row names
> res$Date <- row.names(res)
> # cosmetics
> names(res)[2:1] <- names(data)
> # note that the row names are still tapply's names vector
> # and that the columns order is not Date/count. Both are fixed
> # after the calculations.
> res
> #>   count   Date
> #> 2024-03-22 5.416667 2024-03-22
> #> 2024-03-23 5.50 2024-03-23
> #> 2024-03-24 6.00 2024-03-24
> #> 2024-03-25 4.476190 2024-03-25
> #> 2024-03-26 6.538462 2024-03-26
> #> 2024-03-27 5.20 2024-03-27
>
> # fix the columns' order
> res <- res[2:1]
>
>
>
> # better all in one instruction
> ag

[R] Output of tapply function as data frame

2024-03-26 Thread Ogbos Okike
Warm greetings to you all.

Using the tapply function below:
data<-read.table("FD1month",col.names = c("Dates","count"))
x=data$count
 f<-factor(data$Dates)
AB<- tapply(x,f,mean)


I made a simple calculation. The result, stored in AB, is of the form
below. But an effort to write AB to a file as a data frame fails. When I
use the write table, it only produces the count column and strip of the
first column (date).

2005-11-01 2005-12-01 2006-01-01 2006-02-01 2006-03-01 2006-04-01
2006-05-01
 -4.106887  -4.259154  -5.836090  -4.756757  -4.118011  -4.487942
 -4.430705
2006-06-01 2006-07-01 2006-08-01 2006-09-01 2006-10-01 2006-11-01
2006-12-01
 -3.856727  -6.067103  -6.418767  -4.383031  -3.985805  -4.768196
-10.072579
2007-01-01 2007-02-01 2007-03-01 2007-04-01 2007-05-01 2007-06-01
2007-07-01
 -5.342338  -4.653128  -4.325094  -4.525373  -4.574783  -3.915600
 -4.127980
2007-08-01 2007-09-01 2007-10-01 2007-11-01 2007-12-01 2008-01-01
2008-02-01
 -3.952150  -4.033518  -4.532878  -4.522941  -4.485693  -3.922155
 -4.183578
2008-03-01 2008-04-01 2008-05-01 2008-06-01 2008-07-01 2008-08-01
2008-09-01
 -4.336969  -3.813306  -4.296579  -4.575095  -4.036036  -4.727994
 -4.347428
2008-10-01 2008-11-01 2008-12-01
 -4.029918  -4.260326  -4.454224

But the normal format I wish to display only appears on the terminal,
leading me to copy it and paste into a text file. That is, when I enter AB
on the terminal, it returns a format in the form:

008-02-01  -4.183578
2008-03-01  -4.336969
2008-04-01  -3.813306
2008-05-01  -4.296579
2008-06-01  -4.575095
2008-07-01  -4.036036
2008-08-01  -4.727994
2008-09-01  -4.347428
2008-10-01  -4.029918
2008-11-01  -4.260326
2008-12-01  -4.454224

Now, my question: How do I write out two columns displayed by AB on the
terminal to a file?

I have tried using AB<-data.frame(AB) but it doesn't work either.

Many thanks for your time.
Ogbos

[[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] Jim Lemon RIP

2023-10-04 Thread Ogbos Okike
I'm yet to accept this. I have sent an email to his wife.
Ogbos.

On Thu, Oct 5, 2023, 06:35 Rui Barradas  wrote:

>
> My sympathies for your loss.
> Jim Lemon was a dedicated contributor to the R community and his answers
> were always welcome.
> Jim will be missed.
>
> Rui Barradas
>
> Às 23:36 de 04/10/2023, Jim Lemon escreveu:
> > Hello,
> > I am very sad to let you know that my husband Jim died on 18th
> September. I
> > apologise for not letting you know earlier but I had trouble finding the
> > password for his phone.
> > Kind regards,
> > Juel
> >
>
>
>
>
> --
> Este e-mail foi analisado pelo software antivírus AVG para verificar a
> presença de vírus.
> www.avg.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.
>

[[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 define a new space based on PC1 and PC2

2022-01-16 Thread Ogbos Okike
Dear Experts,
Happy New Year!!, and thank you very much for all the assistance you
rendered to me last year.

I ran a PCA (Principal component analysis) and would like to combine PC1
and PC2 in order to define a new space. The variances associated with PC1
and PC2 are respectively 51% and 14%.

The new space defined by PC1 and PC2 should result in the addition of the
variances of the two PCs, i.e. 51%+14% = 65%.

Some decision boundary lines/curves representing pth = 25%, 50%, 75% should
also be added to the plot combining PC1 and PC2.

I would be extremely happy to receive your help. The quires I tried to
articulate above are indeed comments raised by one of the reviewers of my
manuscript that recently returned for revision. The reviewer seems to have
done such analysis and has sent me a copy of his/her paper where such
analysis is presented in two plots. I would send the paper if anyone would
like to take a look at it.

Many thanks and warm regards
Ogbos

[[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] THANK YOU ALL

2021-07-21 Thread Ogbos Okike
Dear Friends,
I have been scarce here. This is because I am busy implementing what I have
learned from you. You seem to have answered all my queries and I have not
got any new ones. I will quickly contact you as soon as I encounter
challenges in my analysis.

I hope you are well.

I have two recent publications resulting from your assistance (
https://doi.org/10.3847/1538-4357/abfe60, and https://rdcu.be/cpmyg). I
tried to share the complete pdf of the first work but the Journal did not
allow that.

If you can find time to look at the acknowledgment section, you will note
that your efforts were dully acknowledged.

I will ever remain indebted to the group. I consider it plagiarism to
publish any work without indicating my source of analysis tools.

I hope you continue to devote your time to assist the world and humanity in
general. I am sure that many people value your help.

Many, many thanks.

With the warmest regards
Ogbos

[[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] Just Published, Thanks for your assistance

2021-02-12 Thread Ogbos Okike
Dear Experts,
In the first few months of last year, I was asking a question based on of
one my codes. I received useful help here. Many thanks again.

I am glad to share one of the results of the script. I acknowledged the
entire list and some specific individuals that contributed.

Best regards.
Ogbos
https://academic.oup.com/mnras/article/502/1/300/6054537?guestAccessKey=9d83237e-54ae-45b1-b802-90ddb3b9e837


[[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] Fwd: Share your article [ATP_105460] published in Journal of Atmospheric and Solar-Terrestrial Physics

2020-10-07 Thread Ogbos Okike
Dear Friends,
I am really glad to share this link with you. Some of you have been
instrumental to the success of the work. You are acknowledged accordingly.
I am ever indebted.
Best wishes
Ogbos

-- Forwarded message -
From: Elsevier - Article Status 
Date: Wed, Oct 7, 2020 at 10:50 AM
Subject: Share your article [ATP_105460] published in Journal of
Atmospheric and Solar-Terrestrial Physics
To: 


[image: Elsevier] 
Share your article!

[image: cover] 

Dear Dr. Okike,

We are pleased to let you know that the final version of your article
*Automated
detection of simultaneous/non-simultaneous Forbush decreases and the
associated cosmic ray phenomena* is now available online, containing full
bibliographic details.

To help you access and share this work, we have created a Share Link – a
personalized URL providing *50 days' free access* to your article. Anyone
clicking on this link before November 26, 2020 will be taken directly to
the final version of your article on ScienceDirect, which they are welcome
to read or download. No sign up, registration or fees are required.

Your personalized Share Link:
https://authors.elsevier.com/a/1bsqC4sIlkq7Kj

Click on the icons below to share with your network:
[image: Facebook]

[image:
Twitter]

[image:
LinkedIn]

[image:
Mendeley]

[image:
WeChat]


We encourage you to use this Share Link to download a copy of the article
for your own archive. The URL is also a quick and easy way to share your
work with colleagues, co-authors and friends. And you are welcome to add
the Share Link to your homepage or social media profiles, such as Facebook
and Twitter.

You can find out more about Share Links on Elsevier.com

.

Did you know, as an author, you can use your article for a wide range of
scholarly, non-commercial purposes, and share and post your article online
in a variety of ways? For more information visit
www.elsevier.com/sharing-articles.

Kind regards,
Elsevier Researcher Support

*Increase your article's impact*
Our Get Noticed

guide contains a range of practical tips and advice to help you maximize
visibility of your article.

*Publishing Lab*
Do you have ideas on how we can improve the author experience? Sign up for
the Elsevier Publishing Lab  and
help us develop our publishing innovations!

*Have questions or need assistance?*
Please do not reply to this automated message.
For further assistance, please visit our Elsevier Support Center
 where you search for solutions on a range of
topics and find answers to frequently asked questions.
You can also talk to our researcher support team by phone 24 hours a day
from Monday-Friday and 24/7 by live chat and email.

*© 2018 Elsevier Ltd | Privacy Policy* http://www.elsevier.com/privacypolicy
Elsevier Limited, The Boulevard, Langford Lane, Kidlington, Oxford, OX5
1GB, United Kingdom, Registration No. 1982084. This e-mail has been sent to
you from Elsevier Ltd. To ensure delivery to your inbox (not bulk or junk
folders), please add article_sta...@elsevier.com to your address book or
safe senders list.

[[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] Yearly hourly mean and NA

2020-06-04 Thread Ogbos Okike
Dear Jeff,
Thank you so much for your time.
I tried your code. It successfully assigned NA to the zeros.

But the main code seems not to work with the NAs. The mean, for example,
resulted in NA. I am attaching the data for a period of one year  and the
code which I use  in plotting the data. Maybe it might be easier for you to
spot where I run into error (my plot was just empty).
Thanks again.
Best regards
Ogbos


On Wed, Jun 3, 2020 at 8:47 PM Jeff Newmiller 
wrote:

> df[[ 5 ]][ 0 == df[[ 5 ]] ] <- NA
>
> On June 3, 2020 1:59:06 AM PDT, Ogbos Okike 
> wrote:
> >Dear R-Experts,
> >I have a cosmic ray data that span several years. The data frame is of
> >the
> >form:
> >03 01 01 003809
> >03 01 01 013771
> >03 01 01 023743
> >03 01 01 033747
> >03 01 01 043737
> >03 01 01 053751
> >03 01 01 063733
> >03 01 01 073732.
> >where the columns 1 to 5 stand for year, month, day, hour and counts.
> >Some hours when the station does not have data are assigned zero,
> >implying
> >there could be several zeros in column 5. Since my aim is to plot the
> >hourly mean for all the  years, I started learning with one year - year
> >2003.
> >
> >I carefully went through the data, removing any day that contains zero
> >for
> >any of the hours.  Instead of the 365 days in the year 2003, I ended up
> >with 362 days.
> >
> >I saved that as CLMX1C (now stored in Ogbos2 with dput function, see
> >attached please).
> >
> >If I run the data with my script, it gives me what I am expecting. My
> >script is:
> >d<-read.table("CLMX1C",col.names=c("h","count"))
> >y<-d$count
> >data<-(y-mean(y))/mean(y)*100
> >
> >A<-matrix(rep(1:24,362))
> >B<-matrix(data)
> >
> > oodf<-data.frame(A,B)
> > oodf<-data.frame(A,B)
> >library(plotrix)
> >std.error<-function(x) return(sd(x)/(sum(!is.na(x
> >oomean<-as.vector(by(oodf$B,oodf$A,mean))
> >oose<-as.vector(by(oodf$B,oodf$A,std.error))
> >plot(1:24,oomean,type="b",ylim=c(-0.4,0.5),
> > xlab="Hours",ylab="CR count",main="CR daily variation for 2004")
> >dispersion(1:24,oomean,oose,arrow.cap=.01)
> >
> >Now, instead of foraging through the big data removing the day for
> >which
> >there is a missing data for any hour, I wish to try to replace the
> >missing
> >data with NA and hoping that it will do the job for me.
> >
> >I added just three lines in the script above:
> >d<-read.table("2003",col.names=c("y","m","d","h","count"))
> >y<-d$count
> >df<-data.frame(y)#line 1
> >library('dplyr') # line 2
> >y<-na_if(df, 0) #line 3
> >data<-(y-mean(y))/mean(y)*100.
> >Then I started getting error messages:
> >Error in is.data.frame(x) :
> >  (list) object cannot be coerced to type 'double'
> >In addition: There were 26 warnings (use warnings() to see them).
> >
> >I hope you will assist me to deal with the issues of replacing zeros
> >with
> >NA in column 5 in such a way that my code will run.
> >
> >Iam ever indebted!!
> >Best regards
> >Ogbos
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/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] Yearly hourly mean and NA

2020-06-04 Thread Ogbos Okike
Dear Jeff,
Yes. It worked. But I am still fine turning the script.
Please permit me to ask again.

Since I can handle one year. I wish to take on more years. I added extra
two years and now have 2000 to 2002.

I wish to plot the same graph for those years such that the x-axis will be
showing 2000, 2001 and 2002.  I tried to manipulate replicate function with
times and length.
I have a result but it does seem like what I am looking for. For each year,
I should get a similar graph. So the three years will just look like
similar plot repeated with some small differences. When I did per year and
added, I got it. But I could not add the error bars by doing them
separately for each year.

Here is part of my adjusted code:
d<-read.table("3years",col.names=c("y","m","d","h","count"))
y<-d$count
 data<-(y-mean(y,na.rm=TRUE))/mean(y,na.rm=TRUE)*100
A<-matrix(rep(1:24,366))
A1<-matrix(rep(25:49,365))
 A2<-matrix(rep(50:72,365))
A<-matrix(c(A,A1,A2),ncol=1)
I have also attached the complete code and data for the three years.
I am thanking you for any pointer.
Best regards
Ogbos

On Thu, Jun 4, 2020 at 3:14 AM Jeff Newmiller 
wrote:

> Perhaps read ?mean...
>
> On June 3, 2020 6:15:11 PM PDT, Ogbos Okike 
> wrote:
> >Dear Jeff,
> >Thank you so much for your time.
> >I tried your code. It successfully assigned NA to the zeros.
> >
> >But the main code seems not to work with the NAs. The mean, for
> >example,
> >resulted in NA. I am attaching the data for a period of one year  and
> >the
> >code which I use  in plotting the data. Maybe it might be easier for
> >you to
> >spot where I run into error (my plot was just empty).
> >Thanks again.
> >Best regards
> >Ogbos
> >
> >
> >On Wed, Jun 3, 2020 at 8:47 PM Jeff Newmiller
> >
> >wrote:
> >
> >> df[[ 5 ]][ 0 == df[[ 5 ]] ] <- NA
> >>
> >> On June 3, 2020 1:59:06 AM PDT, Ogbos Okike
> >
> >> wrote:
> >> >Dear R-Experts,
> >> >I have a cosmic ray data that span several years. The data frame is
> >of
> >> >the
> >> >form:
> >> >03 01 01 003809
> >> >03 01 01 013771
> >> >03 01 01 023743
> >> >03 01 01 033747
> >> >03 01 01 043737
> >> >03 01 01 053751
> >> >03 01 01 063733
> >> >03 01 01 073732.
> >> >where the columns 1 to 5 stand for year, month, day, hour and
> >counts.
> >> >Some hours when the station does not have data are assigned zero,
> >> >implying
> >> >there could be several zeros in column 5. Since my aim is to plot
> >the
> >> >hourly mean for all the  years, I started learning with one year -
> >year
> >> >2003.
> >> >
> >> >I carefully went through the data, removing any day that contains
> >zero
> >> >for
> >> >any of the hours.  Instead of the 365 days in the year 2003, I ended
> >up
> >> >with 362 days.
> >> >
> >> >I saved that as CLMX1C (now stored in Ogbos2 with dput function, see
> >> >attached please).
> >> >
> >> >If I run the data with my script, it gives me what I am expecting.
> >My
> >> >script is:
> >> >d<-read.table("CLMX1C",col.names=c("h","count"))
> >> >y<-d$count
> >> >data<-(y-mean(y))/mean(y)*100
> >> >
> >> >A<-matrix(rep(1:24,362))
> >> >B<-matrix(data)
> >> >
> >> > oodf<-data.frame(A,B)
> >> > oodf<-data.frame(A,B)
> >> >library(plotrix)
> >> >std.error<-function(x) return(sd(x)/(sum(!is.na(x
> >> >oomean<-as.vector(by(oodf$B,oodf$A,mean))
> >> >oose<-as.vector(by(oodf$B,oodf$A,std.error))
> >> >plot(1:24,oomean,type="b",ylim=c(-0.4,0.5),
> >> > xlab="Hours",ylab="CR count",main="CR daily variation for 2004")
> >> >dispersion(1:24,oomean,oose,arrow.cap=.01)
> >> >
> >> >Now, instead of foraging through the big data removing the day for
> >> >which
> >> >there is a missing data for any hour, I wish to try to replace the
> >> >missing
> >> >data with NA and hoping that it will do the job for me.
> >> >
> >> >I added just three lines in the script above:
> >> >d<-read.table("2003",col.names=c("y","m","d","h","coun

[R] Yearly hourly mean and NA: SOLVED

2020-06-03 Thread Ogbos Okike
Dear Jeff,
It worked!!! I took a second look at "?mean" as you suggested.
I then adjusted my code, inserting rm.na here and there until it was fine.
Thank you very much.
Warm regards.
Ogbos
On Thu, Jun 4, 2020 at 3:14 AM Jeff Newmiller 
wrote:

> Perhaps read ?mean...
>
> On June 3, 2020 6:15:11 PM PDT, Ogbos Okike 
> wrote:
> >Dear Jeff,
> >Thank you so much for your time.
> >I tried your code. It successfully assigned NA to the zeros.
> >
> >But the main code seems not to work with the NAs. The mean, for
> >example,
> >resulted in NA. I am attaching the data for a period of one year  and
> >the
> >code which I use  in plotting the data. Maybe it might be easier for
> >you to
> >spot where I run into error (my plot was just empty).
> >Thanks again.
> >Best regards
> >Ogbos
> >
> >
> >On Wed, Jun 3, 2020 at 8:47 PM Jeff Newmiller
> >
> >wrote:
> >
> >> df[[ 5 ]][ 0 == df[[ 5 ]] ] <- NA
> >>
> >> On June 3, 2020 1:59:06 AM PDT, Ogbos Okike
> >
> >> wrote:
> >> >Dear R-Experts,
> >> >I have a cosmic ray data that span several years. The data frame is
> >of
> >> >the
> >> >form:
> >> >03 01 01 003809
> >> >03 01 01 013771
> >> >03 01 01 023743
> >> >03 01 01 033747
> >> >03 01 01 043737
> >> >03 01 01 053751
> >> >03 01 01 063733
> >> >03 01 01 073732.
> >> >where the columns 1 to 5 stand for year, month, day, hour and
> >counts.
> >> >Some hours when the station does not have data are assigned zero,
> >> >implying
> >> >there could be several zeros in column 5. Since my aim is to plot
> >the
> >> >hourly mean for all the  years, I started learning with one year -
> >year
> >> >2003.
> >> >
> >> >I carefully went through the data, removing any day that contains
> >zero
> >> >for
> >> >any of the hours.  Instead of the 365 days in the year 2003, I ended
> >up
> >> >with 362 days.
> >> >
> >> >I saved that as CLMX1C (now stored in Ogbos2 with dput function, see
> >> >attached please).
> >> >
> >> >If I run the data with my script, it gives me what I am expecting.
> >My
> >> >script is:
> >> >d<-read.table("CLMX1C",col.names=c("h","count"))
> >> >y<-d$count
> >> >data<-(y-mean(y))/mean(y)*100
> >> >
> >> >A<-matrix(rep(1:24,362))
> >> >B<-matrix(data)
> >> >
> >> > oodf<-data.frame(A,B)
> >> > oodf<-data.frame(A,B)
> >> >library(plotrix)
> >> >std.error<-function(x) return(sd(x)/(sum(!is.na(x
> >> >oomean<-as.vector(by(oodf$B,oodf$A,mean))
> >> >oose<-as.vector(by(oodf$B,oodf$A,std.error))
> >> >plot(1:24,oomean,type="b",ylim=c(-0.4,0.5),
> >> > xlab="Hours",ylab="CR count",main="CR daily variation for 2004")
> >> >dispersion(1:24,oomean,oose,arrow.cap=.01)
> >> >
> >> >Now, instead of foraging through the big data removing the day for
> >> >which
> >> >there is a missing data for any hour, I wish to try to replace the
> >> >missing
> >> >data with NA and hoping that it will do the job for me.
> >> >
> >> >I added just three lines in the script above:
> >> >d<-read.table("2003",col.names=c("y","m","d","h","count"))
> >> >y<-d$count
> >> >df<-data.frame(y)#line 1
> >> >library('dplyr') # line 2
> >> >y<-na_if(df, 0) #line 3
> >> >data<-(y-mean(y))/mean(y)*100.
> >> >Then I started getting error messages:
> >> >Error in is.data.frame(x) :
> >> >  (list) object cannot be coerced to type 'double'
> >> >In addition: There were 26 warnings (use warnings() to see them).
> >> >
> >> >I hope you will assist me to deal with the issues of replacing zeros
> >> >with
> >> >NA in column 5 in such a way that my code will run.
> >> >
> >> >Iam ever indebted!!
> >> >Best regards
> >> >Ogbos
> >> >__
> >> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >> >https://stat.ethz.ch/mailman/listinfo/r-help
> >> >PLEASE do read the posting guide
> >> >http://www.R-project.org/posting-guide.html
> >> >and provide commented, minimal, self-contained, reproducible code.
> >>
> >> --
> >> Sent from my phone. Please excuse my brevity.
> >>
>
> --
> Sent from my phone. Please excuse my brevity.
>

[[alternative HTML version deleted]]

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


[R] Yearly hourly mean and NA

2020-06-03 Thread Ogbos Okike
Dear R-Experts,
I have a cosmic ray data that span several years. The data frame is of the
form:
03 01 01 003809
03 01 01 013771
03 01 01 023743
03 01 01 033747
03 01 01 043737
03 01 01 053751
03 01 01 063733
03 01 01 073732.
where the columns 1 to 5 stand for year, month, day, hour and counts.
Some hours when the station does not have data are assigned zero, implying
there could be several zeros in column 5. Since my aim is to plot the
hourly mean for all the  years, I started learning with one year - year
2003.

I carefully went through the data, removing any day that contains zero for
any of the hours.  Instead of the 365 days in the year 2003, I ended up
with 362 days.

I saved that as CLMX1C (now stored in Ogbos2 with dput function, see
attached please).

If I run the data with my script, it gives me what I am expecting. My
script is:
d<-read.table("CLMX1C",col.names=c("h","count"))
y<-d$count
data<-(y-mean(y))/mean(y)*100

A<-matrix(rep(1:24,362))
B<-matrix(data)

 oodf<-data.frame(A,B)
 oodf<-data.frame(A,B)
library(plotrix)
std.error<-function(x) return(sd(x)/(sum(!is.na(x
oomean<-as.vector(by(oodf$B,oodf$A,mean))
oose<-as.vector(by(oodf$B,oodf$A,std.error))
plot(1:24,oomean,type="b",ylim=c(-0.4,0.5),
 xlab="Hours",ylab="CR count",main="CR daily variation for 2004")
dispersion(1:24,oomean,oose,arrow.cap=.01)

Now, instead of foraging through the big data removing the day for which
there is a missing data for any hour, I wish to try to replace the missing
data with NA and hoping that it will do the job for me.

I added just three lines in the script above:
d<-read.table("2003",col.names=c("y","m","d","h","count"))
y<-d$count
df<-data.frame(y)#line 1
library('dplyr') # line 2
y<-na_if(df, 0) #line 3
data<-(y-mean(y))/mean(y)*100.
Then I started getting error messages:
Error in is.data.frame(x) :
  (list) object cannot be coerced to type 'double'
In addition: There were 26 warnings (use warnings() to see them).

I hope you will assist me to deal with the issues of replacing zeros with
NA in column 5 in such a way that my code will run.

Iam ever indebted!!
Best regards
Ogbos
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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 overlap legend to a histogram: FIXED!!!!!!!!!!!!

2020-05-08 Thread Ogbos Okike
Dear Jim,
This is too great!!! I nearly got lost as I struggle to compare my data
with the graph.  I have to use a coincident algorithm to compare the two
datasets with the histogram before I begin to understand what is going on.

Thank you for giving me more than I requested/expected!!! This is the kind
of confusing/complicating diagrams that best suit some reviewers.

I am yet at the verge of understanding the entire results and will surely
return with some more queries as I progress.

Warmest regards
Ogbos

On Fri, May 8, 2020 at 11:32 AM Jim Lemon  wrote:

> Hi Ogbos,
> While this solution is not entirely correct, I think it is a start.
> First I took your data files and made them "sourceable" by adding
> "FD[1|2]<-" at the top and renaming them "FD1.R" and "FD2.R". Running
> the following code produces something that is at least close to what
> you want. The code is fairly well commented so it should be easy to
> see what I have done:
>
> # read in the FD1 data
> source("FD1.R")
> # read in the FD2 data
> source("FD2.R")
> # convert year-month-day columns to dates
> FD1$data.year<-FD1$data.year+ifelse(FD1$data.year < 50,2000,1900)
> FD1$date<-as.Date(paste(FD1$data.year,FD1$data.month,FD1$data.day,sep="-"),
>  format="%Y-%m-%d")
> FD2$data.year<-FD2$data.year+ifelse(FD2$data.year < 50,2000,1900)
> FD2$date<-as.Date(paste(FD2$data.year,FD2$data.month,FD2$data.day,sep="-"),
>  format="%Y-%m-%d")
> # check the ranges for overlap
> range(FD1$date)
> range(FD2$date)
> # get the overall range of the plot
> xlim<-range(c(FD1$date,FD2$date))
> # FD1 spans the date range so xlim is not really needed here
> # now get the counts for each data set
> FD1counts<-as.vector(table(cut(FD1$date,breaks="years")))
> # FD2 is missing 1996, 1997 and 2016 so add zeros at the beginning and end
> FD2counts<-c(0,0,as.vector(table(cut(FD2$date,breaks="years"))),0)
> # set up the bar colors
> barcol<-matrix(c(rep("red",2),rep("blue",18),"red",
>  rep("red",2),rep("green",18),"red"),nrow=2,byrow=TRUE)
> # use barp as barplot can't do the colors
> library(plotrix)
> barp(rbind(FD1counts,FD2counts),names.arg=1996:2016,
>  main="Observation counts for FD1 and FD2",
>  xlab="Year",ylab="Observations",col=barcol)
> legend(12,80,c("FD1 only","FD1 & FD2","FD2 & FD1"),
>  fill=c("red","blue","green"))
>
> This shows the overlap in blue and green. You can make the overlap
> colors whatever you like. It doesn't account for the fact that FD2
> only overlaps for part of a year on both ends. You may not be worried
> about this.
>
> Jim
>
> On Fri, May 8, 2020 at 4:07 PM Ogbos Okike 
> wrote:
> >
> > Dear Jim,
> > Thank you for looking into this.
> > Sorry, there was actually no overlap in the small part of the data I
> reported. My error of omission.
> >
> > So when I run my full data with the adjustment you made, I got some
> thing that was far from what I was expecting. That tell me that I need to
> send the complete data to enable you correctly adjust the code, especially
> in the light of the missing/present overlap.
> > I have used deput function to attach the two files. Please use any
> symbol to depict the color/mark/legend of the overlap dates (just to enable
> the reader visualize what is going on). I am actually trying to display
> event frequency/occurrence per year.
> >
> > Thank you and warmest regards
> > Ogbos
> >
> > On Fri, May 8, 2020 at 1:13 AM Jim Lemon  wrote:
> >>
> >> Hi Ogbos,
> >> I don't think that your example allows us to work out what you are
> >> trying to do. For one thing, "x1" and "x2" do not overlap. Also, you
> >> are plotting the frequencies of dates of observations, which may not
> >> be what you want.
> >> The following code will correctly display your example:
> >>
> >> hist(x1,breaks="years",freq=T,axes=F,xlim=c(9400,11100),col=c1a)
> >> hist(x2,breaks="years",freq=T,axes=F,add=T,col=c2a)
> >>  axis.Date(1, at=seq(as.Date(min(x1)), as.Date(max(x2)), by="years"))
> >>  axis(2)
> >> legend("topleft", c("AUTO", "MANUAL"), fill=c("red", "blue"))
> >>
> >> What it is displaying is the frequency of observations in your two
> >> vectors by calendar year. If this is what you want, and you can
> >> exp

Re: [R] Adding overlap legend to a histogram

2020-05-07 Thread Ogbos Okike
Dear Jim,
Thank you for looking into this.
Sorry, there was actually no overlap in the small part of the data I
reported. My error of omission.

So when I run my full data with the adjustment you made, I got some thing
that was far from what I was expecting. That tell me that I need to send
the complete data to enable you correctly adjust the code, especially in
the light of the missing/present overlap.
I have used deput function to attach the two files. Please use any symbol
to depict the color/mark/legend of the overlap dates (just to enable the
reader visualize what is going on). I am actually trying to display event
frequency/occurrence per year.

Thank you and warmest regards
Ogbos

On Fri, May 8, 2020 at 1:13 AM Jim Lemon  wrote:

> Hi Ogbos,
> I don't think that your example allows us to work out what you are
> trying to do. For one thing, "x1" and "x2" do not overlap. Also, you
> are plotting the frequencies of dates of observations, which may not
> be what you want.
> The following code will correctly display your example:
>
> hist(x1,breaks="years",freq=T,axes=F,xlim=c(9400,11100),col=c1a)
> hist(x2,breaks="years",freq=T,axes=F,add=T,col=c2a)
>  axis.Date(1, at=seq(as.Date(min(x1)), as.Date(max(x2)), by="years"))
>  axis(2)
> legend("topleft", c("AUTO", "MANUAL"), fill=c("red", "blue"))
>
> What it is displaying is the frequency of observations in your two
> vectors by calendar year. If this is what you want, and you can
> explain how you would like "overlap" to be displayed, we can probably
> provide better help.
>
> Jim
>
>
> On Fri, May 8, 2020 at 7:01 AM Ogbos Okike 
> wrote:
> >
> > Dear Experts,
> > Greetings.
> >
> > I am trying to display two datasets in a histogram. I have been able to
> > plot the graph and added the legend for the two colors. I am, however,
> > having difficulties adding a legend to represent the regions of overlap
> > (the third legend).  Below are my data and 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] Adding overlap legend to a histogram

2020-05-07 Thread Ogbos Okike
Dear Experts,
Greetings.

I am trying to display two datasets in a histogram. I have been able to
plot the graph and added the legend for the two colors. I am, however,
having difficulties adding a legend to represent the regions of overlap
(the third legend).  Below are my data and code.

Thank you very much for your kind response.
Best wishes
Ogbos


Part of the two data are:
96 11 28 -5.0439243156971
96 11 30 -6.47673663925309
96 12 03 -6.82839470197342
96 12 05 -6.21642465505491
96 12 07 -6.25580747537018
96 12 10 -5.77540853474434
96 12 14 -3.98857218877879
96 12 16 -4.25191042337454
96 12 20 -3.20551034549018
96 12 24 -4.2702754047348
96 12 28 -6.03085851418479
96 12 31 -6.51403505358144
97 01 02 -6.32673280540791
97 01 08 -5.8537576420137
97 01 13 -5.54092007919419
97 01 23 -4.03617528404112
97 01 28 -6.21414660666954
97 01 30 -5.82248535055029
97 02 02 -4.52703090771556
97 02 04 -4.24731404905759
97 02 06 -5.22553031464346
97 02 10 -3.31737825603324
97 02 13 -1.48147648915881
97 02 16 -1.80195032791485
97 02 19 -2.16701154625054
97 02 21 -2.06571846213066
97 02 24 -3.39623775344558
97 03 02 -4.70829707054833
97 03 07 -3.73377684116639
97 03 11 -2.76476446486583
97 03 19 -2.30766786606313
97 03 21 -2.36150976836853
97 03 24 -1.84664525535518
97 04 01 -4.30618772775492
97 04 12 -4.51646004530582
97 04 19 -4.12507873323636
97 04 23 -3.46413598467606
97 04 25 -2.95371560706153
97 05 02 -4.04170720343953
97 05 13 -5.60975985858423
97 05 15 -5.52471869367602
97 05 23 -3.85761006637094
97 05 26 -3.47054347969788
97 05 29 -3.46506967197854
97 06 04 -0.307928317047413
97 06 08 -2.87534017937205
97 06 11 -3.00325467983916
97 06 14 -3.15331224991201
97 06 26 -3.14375164434693
97 07 02 -1.28362211606

and the second is:
98 05 02 -4.09334391050803
98 06 07 -0.161822520097844
98 06 19 -0.274151702680992
98 06 21 -0.285384620939307
98 06 25 -0.554974659138863
98 08 23 -2.22867947962777
98 08 27 -5.44129410150581
98 09 25 -4.46403021303242
98 11 09 -0.723468433013585
98 12 14 -0.824564697338419
99 01 16 -0.880729288629993
99 01 19 -0.566207577397178
99 01 21 -0.566207577397178
99 01 24 -4.99197737117322
99 02 13 -1.15031932682955
99 02 18 -5.733349976222
99 02 23 -0.869496370371678
99 03 06 -0.319083375714252
99 03 19 -1.35251185547922
99 03 24 -1.33004601896259
99 04 11 -0.229220029647733
99 04 16 -0.521275904363918
99 04 22 -1.2626485094127
99 05 07 -0.453878394814029
99 05 10 -1.35251185547922
99 05 24 -1.97032235968653
99 05 30 -0.330316293972566
99 06 06 -1.24018267289607
99 06 23 -0.0157945827397513
99 06 27 -2.86895582035172
99 07 03 -1.04922306250472
99 07 08 -0.375247967005826
99 07 24 -0.139356683581214
99 07 28 -1.50977271109562
99 07 31 -0.465111313072344
99 08 20 -4.35170103044927
99 08 22 -4.86841527033175
99 08 25 -4.03717931921646
99 09 01 -2.2511453161444
99 09 05 -3.22840920461779
99 09 07 -2.98128500293486
99 09 09 -3.28457379590937
99 09 16 -4.08211099224972
99 09 18 -4.00348056444151
99 09 21 -4.17197433831624
99 09 25 -3.11608002203464
99 09 29 -3.85745262708342
99 10 03 -3.77882219927522

and my code is:
data <- read.table("AUTOFD2a", col.names = c("year", "month", "day","fd"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x1 = data$date

 library(date)

c1a<-rgb(1,0,0,8/9)
hist(x1,breaks="years",freq=T,axes=F,col=c1a)


data <- read.table("MANFD2a", col.names = c("year", "month", "day","fd"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x2 = data$date

c2a=rgb(0,0,1,8/9)
hist(x2,breaks="years",freq=T,axes=F,add=T,col=c2a)
 axis.Date(1, at=seq(as.Date(min(x1)), as.Date(max(x1)), by="years"))
 axis(2)
legend("topright", c("AUTO", "MANUAL"), col=c("red", "blue"), lwd=10)

[[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] Datetime misrepresented on x-axis of a multiple plot: Problem Fixd

2020-05-01 Thread Ogbos Okike
Dear Jim and Rolf Turner,
This is great
The labels on x-axis are now correctly displayed. Jim, your singular code:
axis.POSIXct(1,dta$datetime,format="%a")
made all the required adjustment, making life quite easy for me.

The abline commands are indeed meant to draw a common vertical line across
the different panels. I have quickly achieved that with:
abline(v=as.POSIXct("1978-09-29 00:00:00"))

I have successfully added the rest of the data, displaying seven/more
variables on a single plot and using some common vertical lines to indicate
the variations in several solar wind plasma data/cosmic rays at Earth at
the time of coronal mass ejections from the sun. It makes an interesting
plot to those in our field.

Confusion or "misleading impressions" do not arise at all as the data used
as well as date plotted are usually online for easy verification by
experts/anyone.

Many thanks for all your contributions.

Warmest regards
Ogbos



On Fri, May 1, 2020 at 11:47 PM Jim Lemon  wrote:

> Hi Ogbos,
> The following code may get you close to what you want. I have used the
> names of the columns in "dta" as it is less confusing for me. I think
> you meant to request horizontal ablines as none appeared in the
> example. In order to get the axis tick label "Sun" you would have to
> increase the x axis limits beyond your data.
>
> plot(dta$datetime,dta$B,type="l",axes=FALSE)
> # this is out of range and doesn't appear
> abline(h=-3,col="red")
> axis(2)
> plot(dta$datetime,dta$LAT,type="l",axes=FALSE)
> abline(h=-3,col="red")
> axis(2)
> plot(dta$datetime,dta$BX,type="l",axes=FALSE)
> abline(h=-3,col="red")
> axis(2)
> axis.POSIXct(1,dta$datetime,format="%a")
> mtext("A1", side = 1, outer = TRUE, line = 2.2)
> mtext("B1", side = 2, outer = TRUE, line = 2.2,at =0.2)
> mtext("B2", side = 2, outer = TRUE, line = 2.2,at =0.5)
> mtext("B2", side = 2, outer = TRUE, line = 2.2,at =0.8)
>
> Jim
>
> On Sat, May 2, 2020 at 2:47 AM Ogbos Okike 
> wrote:
> >
> > Dear Contributors,
> > I am trying to do a plot with multiple y-axis on a common x-axis. I have
> > made some progress but I am having difficulties with datetime appearing
> on
> > x-axis. Instead of as date, it appears as large numbers.
> > ...
> > If I do a simple plot of x and B, the x-axis will be fine, appearing as
> > Thu, Fri, Sat, Sun.
> > Please let me know what I am doing wrong with the multiple plot code
> above.
> > I want the same Thu, Fri, Sat, Sun to appear on the common x-axis.
> >
>

[[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] Datetime misrepresented on x-axis of a multiple plot

2020-05-01 Thread Ogbos Okike
Dear Rui Barradas,
Many thanks for your time.

Though I have not used ggplot before, I quickly installed all the required
packages and attempted your code. It produced the plot and solved the
initial problem of the wrong labels on x-axis.
But I noticed several other problems with the plot (some of which I have
circumvented by adjusting the script I displayed earlier). As I am not
quite familiar with ggplot, it was very difficult for me to interact with
your code. I decided to go back to my own code. I tried to use axis(1 ...,
labels=c()...) to assign Thu, Fri  It worked for me before I got a
third response (very helpful) from the list.
Best regards
Ogbos

On Fri, May 1, 2020 at 6:35 PM Rui Barradas  wrote:

> Hello,
>
> I have just noticed that the facets' labels are on the right, in your
> code example they are on the left. Change the following:
>
>
> facet_grid(rows = vars(variable), switch = "y")
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 18:29 de 01/05/20, Rui Barradas escreveu:
> > Hello,
> >
> > If you don't mind a ggplot2 solution, here it is.
> > As usual with ggplot, it's better to have the data in long format so I
> > also load packages dplyr and tidyr. The reshaping accounts for half the
> > code, the code  for the graph itself is not very complicated.
> >
> >
> >
> > library(ggplot2)
> > library(scales)
> > library(dplyr)
> > library(tidyr)
> >
> > dta %>%
> >select(datetime, B, BX, BZ) %>%
> >rename(x = datetime, B1 = B, B2 = BX, B3 = BZ) %>%
> >pivot_longer(
> >  cols = starts_with("B"),
> >  names_to = "variable",
> >  values_to = "value"
> >) %>%
> >ggplot(aes(x, value)) +
> >geom_line() +
> >xlab("") + ylab("") +
> >scale_x_datetime(
> >  breaks = seq(min(x), max(x), by = "days"),
> >  labels = time_format("%a")) +
> >facet_grid(rows = vars(variable)) +
> >theme_bw()
> >
> >
> >
> > Hope this helps,
> >
> > Rui Barradas
> >
> > Às 17:46 de 01/05/20, Ogbos Okike escreveu:
> >> Dear Contributors,
> >> I am trying to do a plot with multiple y-axis on a common x-axis. I have
> >> made some progress but I am having difficulties with datetime
> >> appearing on
> >> x-axis. Instead of as date, it appears as large numbers.
> >>
> >> Sample of my data:
> >> 78 09 28  0 6.7 -40.4 -3.5 2.3 -3.6 278036 5.8 612
> >> 78 09 28  1 5.7 7.3 -4.4 1.4 0.6 261169 4.9 623
> >> 78 09 28  2 5.6 -20.9 -3.6 3.1 -1.8 269323 4.8 625
> >> 78 09 28  3 5.8 -46.9 -3.4 0.2 -3.6 254221 4.7 626
> >> 78 09 28  4 6.2 -41.4 -3.9 1.2 -3.6 248567 4.2 618
> >> 78 09 28  5 6.1 -54.6 -3 1 -4.4 252669 4.4 629
> >> 78 09 28  6 NA NA NA NA NA 220480 4.3 606
> >> 78 09 28  7 7.1 26 -4.8 3.6 2.9 216887 4.4 613
> >> 78 09 28  8 7.1 -21.4 -4.7 3.5 -2.3 249928 4 643
> >> 78 09 28  9 7 -13.6 -2.7 5.2 -1.4 268806 4 656
> >> 78 09 28  10 6.6 -18.5 -3.7 3.6 -1.7 285608 4.2 651
> >> 78 09 28  11 6.7 -6.6 -2.1 4.7 -0.6 280446 4.2 661
> >> 78 09 28  12 6.7 -29.7 -1.9 4 -2.5 281928 4.2 659
> >> 78 09 28  13 6.2 -8.7 -2.1 4.7 -0.8 273465 4.4 651
> >> 78 09 28  14 6.1 31.8 -4.7 0.9 3 212374 4.2 631
> >> 78 09 28  15 5.4 9.3 -4.5 -0.9 0.8 219662 3.9 636
> >> 78 09 28  16 4.9 6.3 -4.5 -0.5 0.5 220610 3.8 628
> >> 78 09 28  17 4.7 4.5 -4.3 -0.6 0.3 214432 3.7 628
> >> 78 09 28  18 4.9 3.1 -4.5 0.3 0.2 202199 3.5 623
> >> 78 09 28  19 5 -13 -4.6 -0.3 -1.1 192859 3.2 619
> >> 78 09 28  20 5.1 -26 -3.5 2 -2 193868 3.1 627
> >> 78 09 28  21 10.1 -37.5 -5.1 4.9 -5.4 284122 5.9 683
> >> 78 09 28  22 8.4 -7.3 -3.6 5.5 -0.8 367499 6.2 694
> >> 78 09 28  23 8.2 -17.7 -4.7 4.4 -2.1 346644 4.9 689
> >> 78 09 29  0 8 6.3 -4.3 5.8 0.8 269569 4.7 708
> >> 78 09 29  1 8.6 35 -3 6.2 4.8 187132 3.2 709
> >> 78 09 29  2 8.1 24.8 -4.1 6 3.3 166644 3.5 689
> >> 78 09 29  3 15.9 29.6 -2.4 9.6 5.6 720902 6.6 866
> >> 78 09 29  4 14.9 18.9 -2.8 13.8 4.8 1587324 8.1 912
> >> 78 09 29  5 14.1 8.2 -10.2 8.3 1.9 1509336 8.1 871
> >> 78 09 29  6 15.6 -2.9 -6.1 11.5 -0.7 968890 7.8 878
> >> 78 09 29  7 19.6 -49.7 1.2 12.1 -14.4 574978 5.4 906
> >> 78 09 29  8 23.5 -44.2 -1.4 11.7 -11.5 287721 4.1 865
> >> 78 09 29  9 25.3 -71.8 -2.4 7.5 -23.9 58521 5.1 859
> >> 78 09 29  10 24.8 -63.1 -2.3 10.9 -22 74956 1.5 821
> >> 78 09 29  11 23.8 -50 -2 15.1 -18.1 64510 3 807

[R] Datetime misrepresented on x-axis of a multiple plot

2020-05-01 Thread Ogbos Okike
Dear Contributors,
I am trying to do a plot with multiple y-axis on a common x-axis. I have
made some progress but I am having difficulties with datetime appearing on
x-axis. Instead of as date, it appears as large numbers.

Sample of my data:
78 09 28  0 6.7 -40.4 -3.5 2.3 -3.6 278036 5.8 612
78 09 28  1 5.7 7.3 -4.4 1.4 0.6 261169 4.9 623
78 09 28  2 5.6 -20.9 -3.6 3.1 -1.8 269323 4.8 625
78 09 28  3 5.8 -46.9 -3.4 0.2 -3.6 254221 4.7 626
78 09 28  4 6.2 -41.4 -3.9 1.2 -3.6 248567 4.2 618
78 09 28  5 6.1 -54.6 -3 1 -4.4 252669 4.4 629
78 09 28  6 NA NA NA NA NA 220480 4.3 606
78 09 28  7 7.1 26 -4.8 3.6 2.9 216887 4.4 613
78 09 28  8 7.1 -21.4 -4.7 3.5 -2.3 249928 4 643
78 09 28  9 7 -13.6 -2.7 5.2 -1.4 268806 4 656
78 09 28  10 6.6 -18.5 -3.7 3.6 -1.7 285608 4.2 651
78 09 28  11 6.7 -6.6 -2.1 4.7 -0.6 280446 4.2 661
78 09 28  12 6.7 -29.7 -1.9 4 -2.5 281928 4.2 659
78 09 28  13 6.2 -8.7 -2.1 4.7 -0.8 273465 4.4 651
78 09 28  14 6.1 31.8 -4.7 0.9 3 212374 4.2 631
78 09 28  15 5.4 9.3 -4.5 -0.9 0.8 219662 3.9 636
78 09 28  16 4.9 6.3 -4.5 -0.5 0.5 220610 3.8 628
78 09 28  17 4.7 4.5 -4.3 -0.6 0.3 214432 3.7 628
78 09 28  18 4.9 3.1 -4.5 0.3 0.2 202199 3.5 623
78 09 28  19 5 -13 -4.6 -0.3 -1.1 192859 3.2 619
78 09 28  20 5.1 -26 -3.5 2 -2 193868 3.1 627
78 09 28  21 10.1 -37.5 -5.1 4.9 -5.4 284122 5.9 683
78 09 28  22 8.4 -7.3 -3.6 5.5 -0.8 367499 6.2 694
78 09 28  23 8.2 -17.7 -4.7 4.4 -2.1 346644 4.9 689
78 09 29  0 8 6.3 -4.3 5.8 0.8 269569 4.7 708
78 09 29  1 8.6 35 -3 6.2 4.8 187132 3.2 709
78 09 29  2 8.1 24.8 -4.1 6 3.3 166644 3.5 689
78 09 29  3 15.9 29.6 -2.4 9.6 5.6 720902 6.6 866
78 09 29  4 14.9 18.9 -2.8 13.8 4.8 1587324 8.1 912
78 09 29  5 14.1 8.2 -10.2 8.3 1.9 1509336 8.1 871
78 09 29  6 15.6 -2.9 -6.1 11.5 -0.7 968890 7.8 878
78 09 29  7 19.6 -49.7 1.2 12.1 -14.4 574978 5.4 906
78 09 29  8 23.5 -44.2 -1.4 11.7 -11.5 287721 4.1 865
78 09 29  9 25.3 -71.8 -2.4 7.5 -23.9 58521 5.1 859
78 09 29  10 24.8 -63.1 -2.3 10.9 -22 74956 1.5 821
78 09 29  11 23.8 -50 -2 15.1 -18.1 64510 3 807
78 09 29  12 21.4 -34.3 0.1 17.6 -12 50247 2.3 795
78 09 29  13 18.4 -20 -2 17 -6.3 59939 2.9 802
78 09 29  14 16.4 -13.9 -2.8 15.6 -3.9 56499 1.4 799
78 09 29  15 15.3 -7.9 -2 14.9 -2.1 49346 1.3 759
78 09 29  16 14.1 -0.5 -2.9 13.8 -0.1 57732 0.5 730
78 09 29  17 12.6 14.7 -3.1 11.5 3.1 44351 1.7 722
78 09 29  18 11.2 74.3 0.6 2.9 10.4 68224 0.4 712
78 09 29  19 10.5 60.5 3.2 4 9.1 48082 0.2 706
78 09 29  20 10 54.7 3.9 4.2 8.1 56404 0.2 710
78 09 29  21 9.3 61.1 3.4 2.9 8.1 68824 0.2 694
78 09 29  22 8.6 64.4 2.6 2.7 7.8 44579 0.2 683
78 09 29  23 7.9 63.3 2 3 7.1 39760 0.2 661
78 09 30  0 7.3 59.8 2.3 2.8 6.3 NA NA NA
78 09 30  1 6.6 65.6 1.7 2.1 6 57382 0.5 664
78 09 30  2 6 70.8 1.3 1.4 5.5 63540 0.5 654
78 09 30  3 4.4 45.1 1 2.7 2.9 60856 2.5 635
78 09 30  4 3.6 -28 -1 -0.3 -0.6 80967 1.9 633
78 09 30  5 4 -47.6 -2.2 -0.1 -2.4 48391 1.2 642
78 09 30  6 4.1 -28.9 -3.1 -1.4 -1.9 45012 1.1 643
78 09 30  7 4.2 -42.7 -2.7 1.2 -2.7 45562 1.1 633
 and part of my code is:
Sys.setenv( TZ="GMT" )
dta<-read.table("IFEDIFIG1D",col.names=c("year", "month", "day",
"hour","B","LAT","BX","BZ","BY","SWT","SWD","SW"))
dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900))
dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year,
month,day,hour,0,0)))
x =  dta$datetime
B=dta$B
LAT=dta$LAT
BX=dta$BX
BZ=dta$BZ
 par(mfcol = c(3, 1), mar = numeric(4), oma = c(4, 4, 1, 1),
mgp = c(2, 0.5, 0))#0.5 here controls x-axis margins
plot(x, B,type="l", axes = FALSE)
abline(v=-3)
axis(2L)
plot(x, LAT,type="l", axes = FALSE)
abline(v=-3)
axis(2L)
 plot(x, BX, type="l",axes = FALSE)
abline(v=-3)
axis(1L)
axis(2L)
mtext("A1", side = 1, outer = TRUE, line = 2.2)
mtext("B1", side = 2, outer = TRUE, line = 2.2,at =0.2)
mtext("B2", side = 2, outer = TRUE, line = 2.2,at =0.5)
mtext("B2", side = 2, outer = TRUE, line = 2.2,at =0.8)

If I do a simple plot of x and B, the x-axis will be fine, appearing as
Thu, Fri, Sat, Sun.
Please let me know what I am doing wrong with the multiple plot code above.
I want the same Thu, Fri, Sat, Sun to appear on the common x-axis.

I am most grateful for your kind response.

Warmest regards
Ogbos

[[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] Isolating Distinct Dates between two data frames

2020-03-01 Thread Ogbos Okike
Dear Sarah,
Thank you for your contribution.

I have tried to use merge function as suggested. But the function
seems to work with data frame. And the file cannot be in the form of
data frame as they have different lengths. I also tried whether I can
use the function without data frame. It didn't work either.

I have used dput function to send all the data.

Please take a second look and see if there is a better way to go.

Thank you.
Best regards
Ogbos

On Sun, Mar 1, 2020 at 10:27 PM Sarah Goslee  wrote:
>
> Look at the all arguments to merge() - you can keep the non-matching
> dates, and look for NA values in the data.
>
> Sarah
>
> On Sun, Mar 1, 2020 at 4:12 PM Ogbos Okike  wrote:
> >
> > Dear Friends,
> > I have two data frame of the form:
> > 1997-11-2219 -2.54910135429339
> > 1997-11- -2.66865640466636
> > 1997-11-2305 -2.60761691358946
> > 1997-12-1104 -2.5323738405159
> > 1997-12-1106 -2.6020470080341
> > 1998-05-0204 -4.49745020062937
> > 1998-05-0209 -4.9462725263541
> > 1998-05-0213 -4.60533021405541
> > 1998-05-0218 -4.24415210827579
> > 1998-05-0220 -4.04368079911755
> > 1998-05-0222 -4.05320945184028
> > 1998-05-0302 -4.97226664313875
> > 1998-05-0307 -3.59108791877756
> > 1998-05-0310 -4.06038057061717
> > 1998-05-0313 -4.25967313751507
> > 1998-05-0316 -3.51896561964782
> > 1998-05-0318 -3.43849389406503
> > 1998-05-0321 -2.85778623531446
> > 1998-05-0323 -2.75731441597261
> > 1998-05-0401 -2.85684255921844
> > 1998-05-0403 -2.69637066510405
> > 1998-05-0408 -4.47519076670884
> > 1998-05-0411 -4.2644827160855
> > 1998-05-0414 -4.20377458198688
> > 1998-05-0417 -4.27306636458818
> > 1998-05-0420 -4.05235806406442
> > 1998-05-0500 -4.19141353436269
> > 1998-05-0506 -4.23999646421515
> > 1998-05-0510 -3.95905156765632
> > 1998-05-0512 -3.63857906459363
> >
> > and
> > 1997-11-2221 -2.04916867404692
> > 1997-11-2303 -1.7285761175751
> > 1998-04-3010 -1.51968127380408
> > 1998-04-3016 -1.51845077174125
> > 1998-05-0101 -1.91660416876407
> > 1998-05-0104 -2.11598840871961
> > 1998-05-0107 -1.99537253619755
> > 1998-05-0109 -1.81496189214167
> > 1998-05-0112 -1.7343458326657
> > 1998-05-0114 -1.77393506418581
> > 1998-05-0121 -1.57249698394961
> > 1998-05-0204 -3.64105829839415
> > 1998-05-0207 -3.5504415342881
> > 1998-05-0209 -3.71003029685917
> > 1998-05-0213 -3.31920767504605
> > 1998-05-0219 -3.98797337595274
> > 1998-05-0300 -3.17694445869443
> > 1998-05-0304 -3.09612110658432
> > 1998-05-0306 -3.29570935794719
> > 1998-05-0308 -3.24529756101203
> > 1998-05-0310 -3.20488571584633
> > 1998-05-0312 -3.16447382251761
> > 1998-05-0314 -2.86406188109331
> > 1998-05-0319 -2.5430318175571
> > 1998-05-0321 -2.87261970832946
> > 1998-05-0400 -2.55200145489882
> > 1998-05-0407 -3.27055844665711
> > 1998-05-0409 -3.24014605168738
> > 1998-05-0412 -3.29952737040137
> > 1998-05-0414 -3.44911485708791
> >
> > Some dates are common among the two.
> >
> > I use few  lines of code to select the common dates:
> > setwd("./")
> >  list1<-read.table("THUL1",col.names=c("V1","V2"))
> >  list2<-read.table("INVK1",col.names=c("V1","V2"))
> >  B<-merge(list1,list2, by ="V1")
> >
> > Now, I wish to do something differently. I want to identify the dates that
> > are in THUL1 but are not in INVK1 or vise versa, that is to identify
> > uncommon dates among the two lists.
> >
> > Could you please assist me to achieve it.
> >
> > Thank you.
> > Best regards
> > Ogbos
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
>
>
> --
> Sarah Goslee (she/her)
> http://www.sarahgoslee.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] Isolating Distinct Dates between two data frames

2020-03-01 Thread Ogbos Okike
Dear Jim,
Many thanks for sparing your time to assist me.

I have tried your codes. It worked very well to some extent for me. At
least it produced the indices you mentioned.

But I got stuck when I think of how to use it in further calculations
as you indicated. I tried including the indices as the first column of
the data. I did the same for each of the station data. That is
including the length (example 1:1609) as the first column. But that
brought me back to the original problem as I had no means of isolating
the uncommon dates using the common dates selected for the two
stations.

I guess that you can point me further to the right direction to use
the indices to discriminate between common dates and uncommon dates
and their associated V2 (Forbush events).

Warm regards
Ogbos

On Sun, Mar 1, 2020 at 10:49 PM Jim Lemon  wrote:
>
> Hi Ogbos,
> One way to get all combinations of common and different dates is:
>
> THULinINVK<-which(THUL1$V1 %in% INVK1$V1)
> THULnotinINVK<-which(!(THUL1$V1 %in% INVK1$V1))
> INVKinTHUL<-which(INVK1$V1 %in% THUL1$V1)
> INVKnotinTHUL<-which(!(INVK1$V1 %in% THUL1$V1))
>
> This produces vectors of indices that can be used in further calculations.
>
> Jim
>
> On Mon, Mar 2, 2020 at 8:12 AM Ogbos Okike  wrote:
> >
> > Dear Friends,
> > I have two data frame of the form:
> > 1997-11-2219 -2.54910135429339
> > 1997-11- -2.66865640466636
> > 1997-11-2305 -2.60761691358946
> > 1997-12-1104 -2.5323738405159
> > 1997-12-1106 -2.6020470080341
> > 1998-05-0204 -4.49745020062937
> > 1998-05-0209 -4.9462725263541
> > 1998-05-0213 -4.60533021405541
> > 1998-05-0218 -4.24415210827579
> > 1998-05-0220 -4.04368079911755
> > 1998-05-0222 -4.05320945184028
> > 1998-05-0302 -4.97226664313875
> > 1998-05-0307 -3.59108791877756
> > 1998-05-0310 -4.06038057061717
> > 1998-05-0313 -4.25967313751507
> > 1998-05-0316 -3.51896561964782
> > 1998-05-0318 -3.43849389406503
> > 1998-05-0321 -2.85778623531446
> > 1998-05-0323 -2.75731441597261
> > 1998-05-0401 -2.85684255921844
> > 1998-05-0403 -2.69637066510405
> > 1998-05-0408 -4.47519076670884
> > 1998-05-0411 -4.2644827160855
> > 1998-05-0414 -4.20377458198688
> > 1998-05-0417 -4.27306636458818
> > 1998-05-0420 -4.05235806406442
> > 1998-05-0500 -4.19141353436269
> > 1998-05-0506 -4.23999646421515
> > 1998-05-0510 -3.95905156765632
> > 1998-05-0512 -3.63857906459363
> >
> > and
> > 1997-11-2221 -2.04916867404692
> > 1997-11-2303 -1.7285761175751
> > 1998-04-3010 -1.51968127380408
> > 1998-04-3016 -1.51845077174125
> > 1998-05-0101 -1.91660416876407
> > 1998-05-0104 -2.11598840871961
> > 1998-05-0107 -1.99537253619755
> > 1998-05-0109 -1.81496189214167
> > 1998-05-0112 -1.7343458326657
> > 1998-05-0114 -1.77393506418581
> > 1998-05-0121 -1.57249698394961
> > 1998-05-0204 -3.64105829839415
> > 1998-05-0207 -3.5504415342881
> > 1998-05-0209 -3.71003029685917
> > 1998-05-0213 -3.31920767504605
> > 1998-05-0219 -3.98797337595274
> > 1998-05-0300 -3.17694445869443
> > 1998-05-0304 -3.09612110658432
> > 1998-05-0306 -3.29570935794719
> > 1998-05-0308 -3.24529756101203
> > 1998-05-0310 -3.20488571584633
> > 1998-05-0312 -3.16447382251761
> > 1998-05-0314 -2.86406188109331
> > 1998-05-0319 -2.5430318175571
> > 1998-05-0321 -2.87261970832946
> > 1998-05-0400 -2.55200145489882
> > 1998-05-0407 -3.27055844665711
> > 1998-05-0409 -3.24014605168738
> > 1998-05-0412 -3.29952737040137
> > 1998-05-0414 -3.44911485708791
> >
> > Some dates are common among the two.
> >
> > I use few  lines of code to select the common dates:
> > setwd("./")
> >  list1<-read.table("THUL1",col.names=c("V1","V2"))
> >  list2<-read.table("INVK1",col.names=c("V1","V2"))
> >  B<-merge(list1,list2, by ="V1")
> >
> > Now, I wish to do something differently. I want to identify the dates that
> > are in THUL1 but are not in INVK1 or vise versa, that is to identify
> > uncommon dates among the two lists.
> >
> > Could you please assist me to achieve it.
> >
> > Thank you.
> > Best regards
> > Ogbos
> >
> > [[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] A new Paper on automatic selection of Turning Point

2020-03-01 Thread Ogbos Okike
Dear Experts,
I asked about a turning identification last few weeks. I got much help
from the list and was really really happy.

When part of the work was published, I was happy to show you and
further thank the contributors. Unfortunately, the moderator didn't
allow the pdf to go. A link was rather recommended.

I am putting the link here for you. Thank you very much. The work I do
using R is acceptable in some high impact journals.

Best regards
Ogbos

Abstract:
https://academic.oup.com/mnras/article-abstract/493/2/1948/5764172
Article (free access):
https://academic.oup.com/mnras/article/493/2/1948/5764172?guestAccessKey=ce6965a5-a228-4b9a-b544-128953e05f17

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Isolating Distinct Dates between two data frames

2020-03-01 Thread Ogbos Okike
Dear Jeff,
I had initially set to plain text. I didn't know when it reverted to
HTML. It has been corrected. Thanks for informing me.

I have checked ?setdiff. The examples are well explained, so it was
not hard for me to use. However, it did not seem to tackle my problem.
I have two columns but it produces results of differences or
similarities using one column. Thus, I lost track of the second
column. Since I need the two columns to plot some graphs, I got a
little confused and thus, could not continue.

I have now used dput function to attach the two files.

As I mentioned in my first mail, each of the files have two columns. I
can select dates common to both using the date column. The output
looks great to me as it outputs each of the second columns in each of
the files. That helps me to do some plotting and other comparisons.  I
used the simple script I indicated to achieve it. Or in case it was
garbled, here it is again:
setwd("./")
 list1<-read.table("THUL1",col.names=c("V1","V2"))
 list2<-read.table("INVK1",col.names=c("V1","V2"))
 B<-merge(list1,list2, by ="V1")
 head(B)

B gives the common date as well as the data in column 2 of each files
associated with the common date.

Now, what I am trying to achieve is to use this common date as a
reference point and run a similar script like the one above
9possibly). But this time, I wish to produce the date and the
associated V2 in THUL1 or INVK1 that is not in the common date. This
common date are technically called simultaneous dates while the
non-common dates describe the globally non-simultaneous events. But
again the associated V2 are useful in each case, else, the date
information alone makes no sense.

So B gives me the common date for both cosmic ray stations and my
problem now is how to use this B to discriminate between the common
date and the unequal or nonidentical dates and their associated V2
data in each of the stations, Inuvick and Thule data.

I would be most grateful for any more help.
Best regards
Ogbos


On Sun, Mar 1, 2020 at 10:42 PM Jeff Newmiller  wrote:
>
> a) Your use of HTML is corrupting your data. Post using plain text, and use 
> dput output instead of trying to insert tables.
>
> b) You should read about ?setdiff.
>
> On March 1, 2020 1:12:04 PM PST, Ogbos Okike  wrote:
> >Dear Friends,
> >I have two data frame of the form:
> >1997-11-2219 -2.54910135429339
> >1997-11- -2.66865640466636
> >1997-11-2305 -2.60761691358946
> >1997-12-1104 -2.5323738405159
> >1997-12-1106 -2.6020470080341
> >1998-05-0204 -4.49745020062937
> >1998-05-0209 -4.9462725263541
> >1998-05-0213 -4.60533021405541
> >1998-05-0218 -4.24415210827579
> >1998-05-0220 -4.04368079911755
> >1998-05-0222 -4.05320945184028
> >1998-05-0302 -4.97226664313875
> >1998-05-0307 -3.59108791877756
> >1998-05-0310 -4.06038057061717
> >1998-05-0313 -4.25967313751507
> >1998-05-0316 -3.51896561964782
> >1998-05-0318 -3.43849389406503
> >1998-05-0321 -2.85778623531446
> >1998-05-0323 -2.75731441597261
> >1998-05-0401 -2.85684255921844
> >1998-05-0403 -2.69637066510405
> >1998-05-0408 -4.47519076670884
> >1998-05-0411 -4.2644827160855
> >1998-05-0414 -4.20377458198688
> >1998-05-0417 -4.27306636458818
> >1998-05-0420 -4.05235806406442
> >1998-05-0500 -4.19141353436269
> >1998-05-0506 -4.23999646421515
> >1998-05-0510 -3.95905156765632
> >1998-05-0512 -3.63857906459363
> >
> >and
> >1997-11-2221 -2.04916867404692
> >1997-11-2303 -1.7285761175751
> >1998-04-3010 -1.51968127380408
> >1998-04-3016 -1.51845077174125
> >1998-05-0101 -1.91660416876407
> >1998-05-0104 -2.11598840871961
> >1998-05-0107 -1.99537253619755
> >1998-05-0109 -1.81496189214167
> >1998-05-0112 -1.7343458326657
> >1998-05-0114 -1.77393506418581
> >1998-05-0121 -1.57249698394961
> >1998-05-0204 -3.64105829839415
> >1998-05-0207 -3.5504415342881
> >1998-05-0209 -3.71003029685917
> >1998-05-0213 -3.31920767504605
> >1998-05-0219 -3.98797337595274
> >1998-05-0300 -3.17694445869443
> >1998-05-0304 -3.09612110658432
> >1998-05-0306 -3.29570935794719
> >1998-05-0308 -3.24529756101203
> >1998-05-0310 -3.20488571584633
> >1998-05-0312 -3.16447382251761
> >1998-05-0314 -2.86406188109331
> >1998-05-0319 -2.5430318175571
> >1998-05-0321 -2.87261970832946
> >1998-05-0400 -2.55200145489882
> >1998-05-0407 -3.27055844665711
> >1998-05-0409 -3.24014605168738
> >1998-05-0412 -3.29952737040137
> >1998-05-0414 -3.44911485708791
> >
> >Some dates are common among the two.
> >
> >I use few  lines of code 

[R] Isolating Distinct Dates between two data frames

2020-03-01 Thread Ogbos Okike
Dear Friends,
I have two data frame of the form:
1997-11-2219 -2.54910135429339
1997-11- -2.66865640466636
1997-11-2305 -2.60761691358946
1997-12-1104 -2.5323738405159
1997-12-1106 -2.6020470080341
1998-05-0204 -4.49745020062937
1998-05-0209 -4.9462725263541
1998-05-0213 -4.60533021405541
1998-05-0218 -4.24415210827579
1998-05-0220 -4.04368079911755
1998-05-0222 -4.05320945184028
1998-05-0302 -4.97226664313875
1998-05-0307 -3.59108791877756
1998-05-0310 -4.06038057061717
1998-05-0313 -4.25967313751507
1998-05-0316 -3.51896561964782
1998-05-0318 -3.43849389406503
1998-05-0321 -2.85778623531446
1998-05-0323 -2.75731441597261
1998-05-0401 -2.85684255921844
1998-05-0403 -2.69637066510405
1998-05-0408 -4.47519076670884
1998-05-0411 -4.2644827160855
1998-05-0414 -4.20377458198688
1998-05-0417 -4.27306636458818
1998-05-0420 -4.05235806406442
1998-05-0500 -4.19141353436269
1998-05-0506 -4.23999646421515
1998-05-0510 -3.95905156765632
1998-05-0512 -3.63857906459363

and
1997-11-2221 -2.04916867404692
1997-11-2303 -1.7285761175751
1998-04-3010 -1.51968127380408
1998-04-3016 -1.51845077174125
1998-05-0101 -1.91660416876407
1998-05-0104 -2.11598840871961
1998-05-0107 -1.99537253619755
1998-05-0109 -1.81496189214167
1998-05-0112 -1.7343458326657
1998-05-0114 -1.77393506418581
1998-05-0121 -1.57249698394961
1998-05-0204 -3.64105829839415
1998-05-0207 -3.5504415342881
1998-05-0209 -3.71003029685917
1998-05-0213 -3.31920767504605
1998-05-0219 -3.98797337595274
1998-05-0300 -3.17694445869443
1998-05-0304 -3.09612110658432
1998-05-0306 -3.29570935794719
1998-05-0308 -3.24529756101203
1998-05-0310 -3.20488571584633
1998-05-0312 -3.16447382251761
1998-05-0314 -2.86406188109331
1998-05-0319 -2.5430318175571
1998-05-0321 -2.87261970832946
1998-05-0400 -2.55200145489882
1998-05-0407 -3.27055844665711
1998-05-0409 -3.24014605168738
1998-05-0412 -3.29952737040137
1998-05-0414 -3.44911485708791

Some dates are common among the two.

I use few  lines of code to select the common dates:
setwd("./")
 list1<-read.table("THUL1",col.names=c("V1","V2"))
 list2<-read.table("INVK1",col.names=c("V1","V2"))
 B<-merge(list1,list2, by ="V1")

Now, I wish to do something differently. I want to identify the dates that
are in THUL1 but are not in INVK1 or vise versa, that is to identify
uncommon dates among the two lists.

Could you please assist me to achieve it.

Thank you.
Best regards
Ogbos

[[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] Identification of Turning Points in a Signal: Problem Fixed

2020-02-16 Thread Ogbos Okike
Dear Abby,
I am very happy to report that the three lines you added have
completely solved the problem. It is great to me. I have, for the past
one week, approached the problem from various angles without much
success.

Thank you.

Warmest regards
Ogbos

On Sun, Feb 16, 2020 at 9:30 PM Abby Spurdle  wrote:
>
> The data are different sizes.
> (As I suggested in my first post).
>
> The turnpoints function removes "ex-aequos".
>
> Replace the following:
> --
> minima<-which(tp$pit & data$residual<= 20)
> -
>
> With:
> --
> pits = rep (FALSE, nrow (data) )
> pits [tp$pos] = tp$pits
> minima<-which(pits & data$residual<= -100)
> --
>
> Should remove the warning.
>
> But there's a second problem:
>
> range (data$residual)
> output:
> [1] -14.97602  11.53771
>
> There are no "residuals less than -100.
> So you'll need to fix that too.
>
>
> B.
>
>
> On Sun, Feb 16, 2020 at 10:32 PM Ogbos Okike  wrote:
> >
> > Dear Abby,
> > Thank you.  I will look at your stimulated data and then run the code with 
> > it.
> >
> > But since I am dealing with real data and also have volumes of it,  I would 
> > like to send my real data to you.
> >
> > The OULU05 is attached with dput function.  It is labeled Ogbos_dput.  I 
> > would be surprised if it was stripped off.  Then I will resend it.  If,  on 
> > the other hand,  you don't want it as dput data,  then I will email the 
> > large data through your private box.
> > Warmest regards
> > Ogbos
> >
> > On Sun, Feb 16, 2020, 08:14 Abby Spurdle  wrote:
> >>
> >> Note that your post does not contain a minimal reproducible example.
> >> I, and presumably most other readers, do not have the file "OULU05".
> >>
> >> Also, your first post referred to "% CR variation", however, your
> >> second post referred to "counts".
> >>
> >> I created a simple simulated data set:
> >>
> >> 
> >> sim.data = function ()
> >> {   year = 1:100
> >> month = (0:99 %% 12) + 1
> >> day = (0:99 %% 28) + 1
> >> counts = sample (1:2000, 100)
> >> data.frame (year, month, day, counts)
> >> }
> >> data = sim.data ()
> >> 
> >>
> >> After replacing the "data" object (as above), everything worked fine.
> >> (Except that the inequality needed modification based on the value of 
> >> counts).
> >>
> >> Maybe the problem is with your dataset...?
> >> Or maybe there's some step in your code that results in missing
> >> values, given your input?
> >>
> >> Also note that the head and tail functions, are useful for both
> >> inspecting data, and describing your data to others.
> >>
> >> 
> >> head (data)
> >> tail (data)
> >> 

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Identification of Turning Points in a Signal

2020-02-16 Thread Ogbos Okike
Dear Abby,
I have run your code with the generated data. Thanks.

The first script still runs OK while the second script had the same
issues with your generated data (it could not identify the pits).

I will try to attach the data, OULU05. The head and tail of the data are:
  year month day counts
15 1   1   6080
25 1   2   6027
35 1   3   5824
45 1   4   5807
55 1   5   5828
65 1   6   5888
 and
 year month day counts
360512  26   6281
361512  27   6288
362512  28   6274
363512  29   6272
364512  30   6258
365512  31   6150
Best regards
Ogbos

On Sun, Feb 16, 2020 at 8:57 AM Ogbos Okike  wrote:
>
> Dear Abby,
> Thank you.  I will look at your stimulated data and then run the code with it.
>
> But since I am dealing with real data and also have volumes of it,  I would 
> like to send my real data to you.
>
> The OULU05 is attached with dput function.  It is labeled Ogbos_dput.  I 
> would be surprised if it was stripped off.  Then I will resend it.  If,  on 
> the other hand,  you don't want it as dput data,  then I will email the large 
> data through your private box.
> Warmest regards
> Ogbos
>
> On Sun, Feb 16, 2020, 08:14 Abby Spurdle  wrote:
>>
>> Note that your post does not contain a minimal reproducible example.
>> I, and presumably most other readers, do not have the file "OULU05".
>>
>> Also, your first post referred to "% CR variation", however, your
>> second post referred to "counts".
>>
>> I created a simple simulated data set:
>>
>> 
>> sim.data = function ()
>> {   year = 1:100
>> month = (0:99 %% 12) + 1
>> day = (0:99 %% 28) + 1
>> counts = sample (1:2000, 100)
>> data.frame (year, month, day, counts)
>> }
>> data = sim.data ()
>> 
>>
>> After replacing the "data" object (as above), everything worked fine.
>> (Except that the inequality needed modification based on the value of 
>> counts).
>>
>> Maybe the problem is with your dataset...?
>> Or maybe there's some step in your code that results in missing
>> values, given your input?
>>
>> Also note that the head and tail functions, are useful for both
>> inspecting data, and describing your data to others.
>>
>> 
>> head (data)
>> tail (data)
>> 
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Identification of Turning Points in a Signal

2020-02-16 Thread Ogbos Okike
Dear Abby,
Thank you.  I will look at your stimulated data and then run the code with
it.

But since I am dealing with real data and also have volumes of it,  I would
like to send my real data to you.

The OULU05 is attached with dput function.  It is labeled Ogbos_dput.  I
would be surprised if it was stripped off.  Then I will resend it.  If,  on
the other hand,  you don't want it as dput data,  then I will email the
large data through your private box.
Warmest regards
Ogbos

On Sun, Feb 16, 2020, 08:14 Abby Spurdle  wrote:

> Note that your post does not contain a minimal reproducible example.
> I, and presumably most other readers, do not have the file "OULU05".
>
> Also, your first post referred to "% CR variation", however, your
> second post referred to "counts".
>
> I created a simple simulated data set:
>
> 
> sim.data = function ()
> {   year = 1:100
> month = (0:99 %% 12) + 1
> day = (0:99 %% 28) + 1
> counts = sample (1:2000, 100)
> data.frame (year, month, day, counts)
> }
> data = sim.data ()
> 
>
> After replacing the "data" object (as above), everything worked fine.
> (Except that the inequality needed modification based on the value of
> counts).
>
> Maybe the problem is with your dataset...?
> Or maybe there's some step in your code that results in missing
> values, given your input?
>
> Also note that the head and tail functions, are useful for both
> inspecting data, and describing your data to others.
>
> 
> head (data)
> tail (data)
> 
>

[[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] Identification of Turning Points in a Signal

2020-02-15 Thread Ogbos Okike
Dear Abby,
Many thanks for your feedback on this.

True, the structure of my question was not clear.  I realized it later
and have been thinking of a better way to re-posting. I am sorry about
that. I will make extra efforts here to make it clearer.

I have just a single data. I have tried to use dput to send the full
data (see attached, Ogbos-dput). This is the raw data with labels
year, month, day and cosmic ray count.

I have two codes for the same data. The first is a combination of
Fourier transform and an R code for pits/trough identification. I am
displaying the script here:
data <- read.table("OULU05", col.names = c("year", "month", "day", "counts"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x = data$date
 y = data$counts
 y1<-approx(x,y,xout=x)$y
 RECON = 12
 f = fft(d<-y1)
p<-1:length(f)
 f[(p > RECON/2 + 1) & (p <= length(d) - RECON/2)] = 0
 f<-fft(f, inverse = TRUE)/length(f)
 data$smooth = abs(f)
 data$residual = y1 - data$smooth

 library(pastecs)
 tp<-turnpoints(data$residual)
 res<-(1:length(data$residual))[tp$pit]
 minima<-which(tp$pit & data$residual<= -100)
 dates<-data$date[minima]
 k<-data$residual[minima]

png("2005A.png")

 plot(x, data$residual/100, type = "l")
 points(dates, k/100, lty = 2, col = 4)
dev.off()

The above runs OK as you may see.

The second code is similar but without the Fourier transform part. I
have only standardized the data in the second script. My aim here is
the same, to pick turning points/pits in the standardized (raw) data.
The script I tried to use is:
data <- read.table("OULU05", col.names = c("year", "month", "day", "counts"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x = data$date
 y = data$counts
y<-c(y-mean(y))/mean(y)*100
  data$residual = y

 library(pastecs)
 tp<-turnpoints(data$residual)
 res<-(1:length(data$residual))[tp$pit]
 minima<-which(tp$pit & data$residual<= -100)
 dates<-data$date[minima]
 k<-data$residual[minima]

png("2005B.png")

 plot(x, data$residual/100, type = "l")
 points(dates, k/100, lty = 2, col = 4)
dev.off()

This second script is where I have issues. It runs with warning/error.
And this is where I need help.


Thanks again for your kind assistance.

Best regards
Ogbos

On Sun, Feb 16, 2020 at 3:31 AM Abby Spurdle  wrote:
>
> Sorry no one replied sooner.
>
> Note that I find your question difficult to follow.
>
> It sounds like you have two datasets, each with different sizes.
> (e.g. Two data.frame objects, each with a different numbers of rows).
>
> Given that tp$pits is a logical index, trying to apply it to a vector
> (or data.frame) of a different size is problematic.
> Assuming that you're dealing with datasets of different sizes, the
> simplest solution is to modify your code, such that they're the same
> size.
>
>
> On Mon, Feb 10, 2020 at 6:40 PM Ogbos Okike  wrote:
> >
> > Dear Friends,
> > Wishing you the best of the day.
> >
> > I have a data (Cosmic Ray) which exhibit flow patterns of a
> > sine/cosine wave, i.e. decreasing/increasing and registering crests
> > (points maximal increases) and troughs/pits (points maximal
> > decreases). These turning points are of interest to me. With pastecs
> > package and a few lines of code as (the residual is coming from
> > Fourier transformation of the data):
> > library(pastecs)
> >  tp<-turnpoints(data$residual)
> >  res<-(1:length(data$residual))[tp$pit]
> >  minima<-which(tp$pit & data$residual<= -100)
> >  dates<-data$date[minima]
> >  k<-data$residual[minima]
> > I usually pick all the turning points (trough) equal or below -100. If
> > I change the <= to >=, I pick all the crests.
> >
> > Now, without first transforming the data, I wish to pick the same
> > turning points in the raw data. Indeed, the difference between the
> > transformed data and the raw data lies only in the amplitude of the
> > crest or trough, otherwise, the crests and trough are the same in both
> > signals.
> >
> > When I tried the above code in the raw signal, the warning/error message is:
> > Warning message:
> > In tp$pit & data$residual <= -100 :
> >   longer object length is not a multiple of shorter object length.
> >
> > A sample of the raw data is:
> > 03 10 01 6.20636953199224
> > 03 10 02 6.90829266565563
> > 03 10 0

[R] Identification of Turning Points in a Signal

2020-02-09 Thread Ogbos Okike
Dear Friends,
Wishing you the best of the day.

I have a data (Cosmic Ray) which exhibit flow patterns of a
sine/cosine wave, i.e. decreasing/increasing and registering crests
(points maximal increases) and troughs/pits (points maximal
decreases). These turning points are of interest to me. With pastecs
package and a few lines of code as (the residual is coming from
Fourier transformation of the data):
library(pastecs)
 tp<-turnpoints(data$residual)
 res<-(1:length(data$residual))[tp$pit]
 minima<-which(tp$pit & data$residual<= -100)
 dates<-data$date[minima]
 k<-data$residual[minima]
I usually pick all the turning points (trough) equal or below -100. If
I change the <= to >=, I pick all the crests.

Now, without first transforming the data, I wish to pick the same
turning points in the raw data. Indeed, the difference between the
transformed data and the raw data lies only in the amplitude of the
crest or trough, otherwise, the crests and trough are the same in both
signals.

When I tried the above code in the raw signal, the warning/error message is:
Warning message:
In tp$pit & data$residual <= -100 :
  longer object length is not a multiple of shorter object length.

A sample of the raw data is:
03 10 01 6.20636953199224
03 10 02 6.90829266565563
03 10 03 6.40434785174345
03 10 04 6.33235573547028
03 10 05 5.99039318317273
03 10 06 5.09049172975812
03 10 07 4.35257253795814
03 10 08 4.49655677050448
03 10 09 4.49655677050448
03 10 10 4.4425626832996
03 10 11 5.16248384603129
03 10 12 5.72042274714835
03 10 13 6.26036361919711
03 10 14 5.8284109215581
03 10 15 5.30646807857763
03 10 16 5.32446610764592
03 10 17 5.68442668901176
03 10 18 6.33235573547028
03 10 19 6.80030449124588
03 10 20 7.26825324702148
03 10 21 6.83630054938246
03 10 22 2.53477160206063
03 10 23 2.55276963112892
03 10 24 2.39078736951429
03 10 25 -0.48889728141246
03 10 26 -0.110938670978323
03 10 27 0.303015997592397
03 10 28 1.81485043932894
03 10 29 -8.04806949009518
03 10 30 -16.1471825708267
03 10 31 -17.0470840242413
03 11 01 -13.6094604721975
03 11 02 -8.98396700164638
03 11 03 -6.28426264140255
03 11 04 -5.78031782749036
03 11 05 -3.72854251370505
03 11 06 -2.95462726376849
03 11 07 -4.52045579270991
03 11 08 -3.54856222302213
03 11 09 -0.884853920914888
03 11 10 0.447000230138735
03 11 11 0.0150475324997218
03 11 12 -0.308916990729538
03 11 13 0.0690416197045984
03 11 14 -0.110938670978323
03 11 15 -0.938848008119764
03 11 16 -3.02661938004166
03 11 17 -3.92652083345627
03 11 18 -3.24259572886117
03 11 19 -1.67676719991974
03 11 20 -2.30669821730997
03 11 21 -2.9366292347002
03 11 22 -2.75664894401728
03 11 23 -3.44057404861238
03 11 24 -4.34047550202699
03 11 25 -3.87252674625139
03 11 26 -2.72065288588069
03 11 27 -2.25270413010509
03 11 28 -1.37080070575878
03 11 29 -0.0389465547051547
03 11 30 0.033045561568014
the first three columns are year, month and day, the last column % CR variation.

abline (h=0) specifies values below the average. I am interested in
picking the time and magnitude of all the turning points below zero.

Thank you for assisting me.
Best regards
Ogbos

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Convert Long DOY time format to yyyymmdd hh format: Problem Fixed

2020-01-23 Thread Ogbos Okike
Dear Gurus,
I am so happy to thank you all for your great help!!!
Jim's code first did it.
Thanks again to everyone.
Warmest regards
Ogbos
On Thu, Jan 23, 2020 at 10:42 AM Jim Lemon  wrote:
>
> Hi Ogbos,
> Try this:
>
> oodates<-read.table(text="1963 335 0
> 1963 335 1
> 1963 335 2
> 1963 335 3
> 1963 335 4
> 1963 335 5
> 1963 335 6
> 1963 335 7
> 1963 335 8
> 1963 335 9
> 1996 202 20
> 1996 202 21
> 1996 202 22
> 1996 202 23
> 1996 203 0
> 1996 203 1
> 1996 203 2
> 1996 203 3
> 2018 365 20
> 2018 365 21
> 2018 365 22
> 2018 365 23")
> oodates$Pdate<-strptime(paste(oodates[,1],oodates[,2],oodates[,3]),
>  format="%Y %j %H")
>
> Jim
>
> On Thu, Jan 23, 2020 at 8:24 PM Ogbos Okike  wrote:
> >
> > Dear Experts,
> > I have a data spanning 56 years from 1963 to 2018.
> > The datetime format is in DOY hour:
> > 1963 335 0
> > 1963 335 1
> > 1963 335 2
> > 1963 335 3
> > 1963 335 4
> > 1963 335 5
> > 1963 335 6
> > 1963 335 7
> > 1963 335 8
> > 1963 335 9
> > 1996 202 20
> > 1996 202 21
> > 1996 202 22
> > 1996 202 23
> > 1996 203 0
> > 1996 203 1
> > 1996 203 2
> > 1996 203 3
> > 2018 365 20
> > 2018 365 21
> > 2018 365 22
> > 2018 365 23
> > When I used:
> > as.Date(335,origin="1963-01-01"), for the first row, I got:
> > [1] "1963-12-02"
> > This is the format I want, though it is not yet complete. Time is missing.
> >
> > Again, I can't be doing this one after the other. I guess you have a
> > better way of handling this. I have spent some time trying to get it
> > right but I am really stuck. I would be most glad if you could spare
> > your busy time to help me again.
> >
> > Thank you very much for your usual kind assistance.
> >
> > Best regards
> > Ogbos
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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] Convert Long DOY time format to yyyymmdd hh format

2020-01-23 Thread Ogbos Okike
Dear Experts,
I have a data spanning 56 years from 1963 to 2018.
The datetime format is in DOY hour:
1963 335 0
1963 335 1
1963 335 2
1963 335 3
1963 335 4
1963 335 5
1963 335 6
1963 335 7
1963 335 8
1963 335 9
1996 202 20
1996 202 21
1996 202 22
1996 202 23
1996 203 0
1996 203 1
1996 203 2
1996 203 3
2018 365 20
2018 365 21
2018 365 22
2018 365 23
When I used:
as.Date(335,origin="1963-01-01"), for the first row, I got:
[1] "1963-12-02"
This is the format I want, though it is not yet complete. Time is missing.

Again, I can't be doing this one after the other. I guess you have a
better way of handling this. I have spent some time trying to get it
right but I am really stuck. I would be most glad if you could spare
your busy time to help me again.

Thank you very much for your usual kind assistance.

Best regards
Ogbos

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Incorrect Conversion of Datetime: Fixed

2020-01-08 Thread Ogbos Okike
Dear ALL,
I am really happy. Erinco has pointed out the error.

Out of the the 5 stations'  Cosmic ray data I am staking together to
show some similar effects, I wrongly (and I am sorry for taking your
time) copied one of the dates, including January 1, 1998 instead of
May.
Others were correct and it will never occur to me, except for the keen
eye of Erinco, that the problem is from any of the data.

This singular correction has also changed my plot and all the
attendant analysis.
Thank you all for your kind suggestions.
Warmest regards
Ogbos
On Wed, Jan 8, 2020 at 10:17 PM Jim Lemon  wrote:
>
> Enrico seems to have found the problem - you can't change dates much
> by changing the time zone, but transposing month and day will do the
> trick nicely. The mm/dd/ format and others like it are so common
> that you always have to be on the lookout for it. Is the sample data
> you included in your first email taken from the file you are reading
> in? When I read in that sample data the correct result was returned. I
> would open the original file in a text editor, read the data in using
> your commands and then:
>
> head(dta)
>
> and compare what appears with the original file. You may see the
> problem straightaway.
>
> Jim
>
>
> On Thu, Jan 9, 2020 at 7:50 AM Enrico Schumann  
> wrote:
> > ...
> > The data that you read in has January (1) as month.
> > So whatever goes wrong, seems to go wrong when you read
> > the data.  Are you quite sure you read the file you
> > read is the file you have shown?
> >

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

2020-01-08 Thread Ogbos Okike
Dear Jeff,
Thank you very much for looking into this.

I have made some search on ?OlsonNames.
System time zones indicates Africa/Lagos whereas the data I am trying
to convert are Cosmic ray data prepared at different time zones
including Oulu station (Russia), Climax station (America), many parts
of Europe, etc.

Including:
 Sys.timezone()
str(OlsonNames())

in my code gives:
[1] "1998-01-05 02:00:00 WAT" "1998-01-05 03:00:00 WAT"
 [3] "1998-01-05 04:00:00 WAT" "1998-01-05 05:00:00 WAT"
 [5] "1998-01-05 06:00:00 WAT" "1998-01-05 07:00:00 WAT"
 [7] "1998-01-05 08:00:00 WAT" "1998-01-05 09:00:00 WAT"
 [9] "1998-01-05 10:00:00 WAT" "1998-01-05 11:00:00 WAT"
[11] "1998-01-05 12:00:00 WAT" "1998-01-05 13:00:00 WAT"
[13] "1998-01-05 14:00:00 WAT" "1998-01-05 15:00:00 WAT"
[15] "1998-01-05 16:00:00 WAT" "1998-01-05 17:00:00 WAT"
[17] "1998-01-05 18:00:00 WAT" "1998-01-05 19:00:00 WAT"
[19] "1998-01-05 20:00:00 WAT" "1998-01-05 21:00:00 WAT"
[21] "1998-01-05 22:00:00 WAT" "1998-01-05 23:00:00 WAT"
[23] "1998-01-06 00:00:00 WAT" "1998-01-06 01:00:00 WAT"
[25] "1998-01-06 02:00:00 WAT" "1998-01-06 03:00:00 WAT"
[27] "1998-01-06 04:00:00 WAT" "1998-01-06 05:00:00 WAT"
[29] "1998-01-06 06:00:00 WAT"

Replacing the two lines above with:
Sys.setenv( TZ="" )
gives:
[1] "1998-01-05 02:00:00 UTC" "1998-01-05 03:00:00 UTC"
 [3] "1998-01-05 04:00:00 UTC" "1998-01-05 05:00:00 UTC"
 [5] "1998-01-05 06:00:00 UTC" "1998-01-05 07:00:00 UTC"
 [7] "1998-01-05 08:00:00 UTC" "1998-01-05 09:00:00 UTC"
 [9] "1998-01-05 10:00:00 UTC" "1998-01-05 11:00:00 UTC"
[11] "1998-01-05 12:00:00 UTC" "1998-01-05 13:00:00 UTC"
[13] "1998-01-05 14:00:00 UTC" "1998-01-05 15:00:00 UTC"
[15] "1998-01-05 16:00:00 UTC" "1998-01-05 17:00:00 UTC"
[17] "1998-01-05 18:00:00 UTC" "1998-01-05 19:00:00 UTC"
[19] "1998-01-05 20:00:00 UTC" "1998-01-05 21:00:00 UTC"
[21] "1998-01-05 22:00:00 UTC" "1998-01-05 23:00:00 UTC"
[23] "1998-01-06 00:00:00 UTC" "1998-01-06 01:00:00 UTC"
[25] "1998-01-06 02:00:00 UTC" "1998-01-06 03:00:00 UTC"
[27] "1998-01-06 04:00:00 UTC" "1998-01-06 05:00:00 UTC"
[29] "1998-01-06 06:00:00 UTC"

All these are still not correct and I am yet longing for further help.

Best regards
Ogbos

On Wed, Jan 8, 2020 at 4:22 PM Jeff Newmiller  wrote:
>
> In your first email you said you were using
>
> Sys.setenv( TZ="GMT" )
>
> in your code, which defines the default assumption for time conversion 
> timezone (at least until you change it). Keep in mind that you may be dealing 
> with data from other timezones than your local one that the operating system 
> uses, so the OS timezone only gets used if TZ is blank (and even that 
> behavior can be OS-dependent I think).
>
> Read
>
> ?OlsonNames
>
> because AEST may not be a valid specification for TZ.
>
> On January 8, 2020 4:09:01 AM PST, Ogbos Okike  
> wrote:
> >Dear Jim,
> >In order to check whether I have a correct time on my system, I run:
> >$ timedatectl
> >
> > and it gives:
> >Local time: Wed 2020-01-08 13:03:44 WAT
> >  Universal time: Wed 2020-01-08 12:03:44 UTC
> >RTC time: Wed 2020-01-08 12:03:44
> >   Time zone: Africa/Lagos (WAT, +0100)
> >   System clock synchronized: yes
> >systemd-timesyncd.service active: yes
> > RTC in local TZ: no.
> >
> >The time is correct as it agrees with the system time.
> >
> >I don't know if there are other things I need to change.
> >
> >Thank you for any suggestions.
> >Ogbos
> >
> >On Wed, Jan 8, 2020 at 12:55 PM Ogbos Okike 
> >wrote:
> >>
> >> Dear Jim,
> >> Thank you for coming my assist me.
> >> I have tried all you suggested but the same result keep coming.
> >> I tried, for example:
> >> dta <- read.table("Ohr1may98", col.names = c("year", "month", "day",
> >> "hour", "counts"))
> >>
> >> dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900))
> >> dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour),
> >>  "%Y %m %d %H")
> >> a =  dta$date
> >> and obtained

Re: [R] Incorrect Conversion of Datetime

2020-01-08 Thread Ogbos Okike
Dear Enrico,
Thanks for your time.
I have tried to learn how to use dput in R. I have not yet made much progress.

I have succeeded in using dput to store my data frame. I first
converted my data into a data frame and then used:
dput(dd,file="Ogbos2",control = c("keepNA", "keepInteger",
"showAttributes")) to output the dput file. dd is my data frame.

When I opened the file, I didn't like its content as it differs very
much from my data frame. But I don't know whether that makes sense to
you. I am attaching the file.
I am thanking you in advance for additional suggestions.
Best wishes
Ogbos

On Wed, Jan 8, 2020 at 1:07 PM Enrico Schumann  wrote:
>
>
> Quoting Ogbos Okike :
>
> > Dear Friends,
> > A sample of my data is:
> > 98 05 01 028541
> > 98 05 01 038548
> > 98 05 01 048512
> > 98 05 01 058541
> > 98 05 01 068509
> > 98 05 01 078472
> > 98 05 01 088454
> > 98 05 01 098461
> > 98 05 01 108462
> > 98 05 01 118475
> > 98 05 01 128433
> > 98 05 01 138479
> > 98 05 01 148417
> > 98 05 01 158463
> > 98 05 01 168473
> > 98 05 01 178450
> > 98 05 01 188433
> > 98 05 01 198437
> > 98 05 01 208437
> > 98 05 01 218438
> > 98 05 01 228421
> > 98 05 01 238420
> > 98 05 02 008371
> > 98 05 02 018338
> > 98 05 02 028251
> > 98 05 02 038204
> > 98 05 02 048183
> > 98 05 02 058231
> > 98 05 02 068242
> > Columns 1, 2, 3, 4 and 5 stands for year, month, day , hour and count.
> >
> > Using:
> > Sys.setenv( TZ="GMT" )
> >
> >
> > dta <- read.table("Ohr1may98", col.names = c("year", "month", "day",
> > "hour", "counts"))
> > dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900))
> > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, 
> > month,day,hour,0,0)))
> > a =  dta$datetime
> > I converted the datetime and plotted the graph of count vs a. The plot
> > was great but I have issues with the date.
> >
> > The raw data is for some hours for Ist and second day of may 1998 as
> > is evident from the sample data. But the result of date stored in "a"
> > above shows:
> >> a
> >  [1] "1998-01-05 02:00:00 GMT" "1998-01-05 03:00:00 GMT"
> >  [3] "1998-01-05 04:00:00 GMT" "1998-01-05 05:00:00 GMT"
> >  [5] "1998-01-05 06:00:00 GMT" "1998-01-05 07:00:00 GMT"
> >  [7] "1998-01-05 08:00:00 GMT" "1998-01-05 09:00:00 GMT"
> >  [9] "1998-01-05 10:00:00 GMT" "1998-01-05 11:00:00 GMT"
> > [11] "1998-01-05 12:00:00 GMT" "1998-01-05 13:00:00 GMT"
> > [13] "1998-01-05 14:00:00 GMT" "1998-01-05 15:00:00 GMT"
> > [15] "1998-01-05 16:00:00 GMT" "1998-01-05 17:00:00 GMT"
> > [17] "1998-01-05 18:00:00 GMT" "1998-01-05 19:00:00 GMT"
> > [19] "1998-01-05 20:00:00 GMT" "1998-01-05 21:00:00 GMT"
> > [21] "1998-01-05 22:00:00 GMT" "1998-01-05 23:00:00 GMT"
> > [23] "1998-01-06 00:00:00 GMT" "1998-01-06 01:00:00 GMT"
> > [25] "1998-01-06 02:00:00 GMT" "1998-01-06 03:00:00 GMT"
> > [27] "1998-01-06 04:00:00 GMT" "1998-01-06 05:00:00 GMT"
> > [29] "1998-01-06 06:00:00 GMT"
> > This seems to suggest day 5 and 6 in January 1998 instead of day 1 and
> > 2 in May of 1998.
> >
> > I have spent some time trying to resolve this but I have not been 
> > successful.
> >
> > I would be thankful if you could help me to check where I went astray.
> >
> > Thank you.
> > Best wishes
> > Ogbos
> >
>
> I cannot reproduce these results. Could you please provide a fully
> reproducible example, by providing a small example dataset via 'dput(dta)'?
>
>
> --
> Enrico Schumann
> Lucerne, Switzerland
> http://enricoschumann.net
>
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Incorrect Conversion of Datetime

2020-01-08 Thread Ogbos Okike
Dear Jim,
In order to check whether I have a correct time on my system, I run:
$ timedatectl

 and it gives:
Local time: Wed 2020-01-08 13:03:44 WAT
  Universal time: Wed 2020-01-08 12:03:44 UTC
RTC time: Wed 2020-01-08 12:03:44
   Time zone: Africa/Lagos (WAT, +0100)
   System clock synchronized: yes
systemd-timesyncd.service active: yes
 RTC in local TZ: no.

The time is correct as it agrees with the system time.

I don't know if there are other things I need to change.

Thank you for any suggestions.
Ogbos

On Wed, Jan 8, 2020 at 12:55 PM Ogbos Okike  wrote:
>
> Dear Jim,
> Thank you for coming my assist me.
> I have tried all you suggested but the same result keep coming.
> I tried, for example:
> dta <- read.table("Ohr1may98", col.names = c("year", "month", "day",
> "hour", "counts"))
>
> dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900))
> dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour),
>  "%Y %m %d %H")
> a =  dta$date
> and obtained:
> > a
>  [1] "1998-01-05 14:00:00 GMT" "1998-01-05 15:00:00 GMT"
>  [3] "1998-01-05 16:00:00 GMT" "1998-01-05 17:00:00 GMT"
>  [5] "1998-01-05 18:00:00 GMT" "1998-01-05 19:00:00 GMT"
>  [7] "1998-01-05 20:00:00 GMT" "1998-01-05 21:00:00 GMT"
>  [9] "1998-01-05 22:00:00 GMT" "1998-01-05 23:00:00 GMT"
> [11] "1998-01-06 00:00:00 GMT" "1998-01-06 01:00:00 GMT"
> [13] "1998-01-06 02:00:00 GMT" "1998-01-06 03:00:00 GMT"
> [15] "1998-01-06 04:00:00 GMT" "1998-01-06 05:00:00 GMT"
> [17] "1998-01-06 06:00:00 GMT"
>
> Instead of getting AEST as in your own result, mine remains GMT.
>
> I think the problem is coming from my system or location, I am not sure.
>
> Please have a look again and advise further.
>
> Thank you.
>
> On Wed, Jan 8, 2020 at 11:05 AM Jim Lemon  wrote:
> >
> > Hi again,
> > Small typo, should be
> >
> > dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour),
> >  "%Y %m %d %H"
> >
> > as I tried it both with and without the century just to check and
> > copied the wrong line.
> >
> > On Wed, Jan 8, 2020 at 9:03 PM Jim Lemon  wrote:
> > >
> > > Hi Ogbos,
> > > I get the correct result using strptime:
> > >
> > > dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour),
> > >  "%y %m %d %H"
> > > )
> > > > dta$date
> > > [1] "1998-05-01 02:00:00 AEST" "1998-05-01 03:00:00 AEST"
> > > [3] "1998-05-01 04:00:00 AEST" "1998-05-01 05:00:00 AEST"
> > > [5] "1998-05-01 06:00:00 AEST" "1998-05-01 07:00:00 AEST"
> > > [7] "1998-05-01 08:00:00 AEST" "1998-05-01 09:00:00 AEST"
> > > [9] "1998-05-01 10:00:00 AEST" "1998-05-01 11:00:00 AEST"
> > > [11] "1998-05-01 12:00:00 AEST" "1998-05-01 13:00:00 AEST"
> > > [13] "1998-05-01 14:00:00 AEST" "1998-05-01 15:00:00 AEST"
> > > [15] "1998-05-01 16:00:00 AEST" "1998-05-01 17:00:00 AEST"
> > > [17] "1998-05-01 18:00:00 AEST" "1998-05-01 19:00:00 AEST"
> > > [19] "1998-05-01 20:00:00 AEST" "1998-05-01 21:00:00 AEST"
> > > [21] "1998-05-01 22:00:00 AEST" "1998-05-01 23:00:00 AEST"
> > > [23] "1998-05-02 00:00:00 AEST" "1998-05-02 01:00:00 AEST"
> > > [25] "1998-05-02 02:00:00 AEST" "1998-05-02 03:00:00 AEST"
> > > [27] "1998-05-02 04:00:00 AEST" "1998-05-02 05:00:00 AEST"
> > > [29] "1998-05-02 06:00:00 AEST"
> > >
> > > Same result with
> > >
> > > ISOdatetime(dta$year,dta$month,dta$day,dta$hour,0,0,tz="GMT")
> > > as.POSIXct(ISOdatetime(dta$year,dta$month,dta$day,dta$hour,0,0,tz="GMT"))
> > >
> > > As it should be as the lower two call strptime. I can't see from your
> > > code why the month and day are transcribed.
> > >
> > > Jim

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

2020-01-08 Thread Ogbos Okike
Dear Jim,
Thank you for coming my assist me.
I have tried all you suggested but the same result keep coming.
I tried, for example:
dta <- read.table("Ohr1may98", col.names = c("year", "month", "day",
"hour", "counts"))

dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900))
dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour),
 "%Y %m %d %H")
a =  dta$date
and obtained:
> a
 [1] "1998-01-05 14:00:00 GMT" "1998-01-05 15:00:00 GMT"
 [3] "1998-01-05 16:00:00 GMT" "1998-01-05 17:00:00 GMT"
 [5] "1998-01-05 18:00:00 GMT" "1998-01-05 19:00:00 GMT"
 [7] "1998-01-05 20:00:00 GMT" "1998-01-05 21:00:00 GMT"
 [9] "1998-01-05 22:00:00 GMT" "1998-01-05 23:00:00 GMT"
[11] "1998-01-06 00:00:00 GMT" "1998-01-06 01:00:00 GMT"
[13] "1998-01-06 02:00:00 GMT" "1998-01-06 03:00:00 GMT"
[15] "1998-01-06 04:00:00 GMT" "1998-01-06 05:00:00 GMT"
[17] "1998-01-06 06:00:00 GMT"

Instead of getting AEST as in your own result, mine remains GMT.

I think the problem is coming from my system or location, I am not sure.

Please have a look again and advise further.

Thank you.

On Wed, Jan 8, 2020 at 11:05 AM Jim Lemon  wrote:
>
> Hi again,
> Small typo, should be
>
> dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour),
>  "%Y %m %d %H"
>
> as I tried it both with and without the century just to check and
> copied the wrong line.
>
> On Wed, Jan 8, 2020 at 9:03 PM Jim Lemon  wrote:
> >
> > Hi Ogbos,
> > I get the correct result using strptime:
> >
> > dta$date<-strptime(paste(dta$year,dta$month,dta$day,dta$hour),
> >  "%y %m %d %H"
> > )
> > > dta$date
> > [1] "1998-05-01 02:00:00 AEST" "1998-05-01 03:00:00 AEST"
> > [3] "1998-05-01 04:00:00 AEST" "1998-05-01 05:00:00 AEST"
> > [5] "1998-05-01 06:00:00 AEST" "1998-05-01 07:00:00 AEST"
> > [7] "1998-05-01 08:00:00 AEST" "1998-05-01 09:00:00 AEST"
> > [9] "1998-05-01 10:00:00 AEST" "1998-05-01 11:00:00 AEST"
> > [11] "1998-05-01 12:00:00 AEST" "1998-05-01 13:00:00 AEST"
> > [13] "1998-05-01 14:00:00 AEST" "1998-05-01 15:00:00 AEST"
> > [15] "1998-05-01 16:00:00 AEST" "1998-05-01 17:00:00 AEST"
> > [17] "1998-05-01 18:00:00 AEST" "1998-05-01 19:00:00 AEST"
> > [19] "1998-05-01 20:00:00 AEST" "1998-05-01 21:00:00 AEST"
> > [21] "1998-05-01 22:00:00 AEST" "1998-05-01 23:00:00 AEST"
> > [23] "1998-05-02 00:00:00 AEST" "1998-05-02 01:00:00 AEST"
> > [25] "1998-05-02 02:00:00 AEST" "1998-05-02 03:00:00 AEST"
> > [27] "1998-05-02 04:00:00 AEST" "1998-05-02 05:00:00 AEST"
> > [29] "1998-05-02 06:00:00 AEST"
> >
> > Same result with
> >
> > ISOdatetime(dta$year,dta$month,dta$day,dta$hour,0,0,tz="GMT")
> > as.POSIXct(ISOdatetime(dta$year,dta$month,dta$day,dta$hour,0,0,tz="GMT"))
> >
> > As it should be as the lower two call strptime. I can't see from your
> > code why the month and day are transcribed.
> >
> > Jim

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

2020-01-08 Thread Ogbos Okike
Dear Friends,
A sample of my data is:
98 05 01 028541
98 05 01 038548
98 05 01 048512
98 05 01 058541
98 05 01 068509
98 05 01 078472
98 05 01 088454
98 05 01 098461
98 05 01 108462
98 05 01 118475
98 05 01 128433
98 05 01 138479
98 05 01 148417
98 05 01 158463
98 05 01 168473
98 05 01 178450
98 05 01 188433
98 05 01 198437
98 05 01 208437
98 05 01 218438
98 05 01 228421
98 05 01 238420
98 05 02 008371
98 05 02 018338
98 05 02 028251
98 05 02 038204
98 05 02 048183
98 05 02 058231
98 05 02 068242
Columns 1, 2, 3, 4 and 5 stands for year, month, day , hour and count.

Using:
Sys.setenv( TZ="GMT" )


dta <- read.table("Ohr1may98", col.names = c("year", "month", "day",
"hour", "counts"))
dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900))
dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, month,day,hour,0,0)))
a =  dta$datetime
I converted the datetime and plotted the graph of count vs a. The plot
was great but I have issues with the date.

The raw data is for some hours for Ist and second day of may 1998 as
is evident from the sample data. But the result of date stored in "a"
above shows:
> a
 [1] "1998-01-05 02:00:00 GMT" "1998-01-05 03:00:00 GMT"
 [3] "1998-01-05 04:00:00 GMT" "1998-01-05 05:00:00 GMT"
 [5] "1998-01-05 06:00:00 GMT" "1998-01-05 07:00:00 GMT"
 [7] "1998-01-05 08:00:00 GMT" "1998-01-05 09:00:00 GMT"
 [9] "1998-01-05 10:00:00 GMT" "1998-01-05 11:00:00 GMT"
[11] "1998-01-05 12:00:00 GMT" "1998-01-05 13:00:00 GMT"
[13] "1998-01-05 14:00:00 GMT" "1998-01-05 15:00:00 GMT"
[15] "1998-01-05 16:00:00 GMT" "1998-01-05 17:00:00 GMT"
[17] "1998-01-05 18:00:00 GMT" "1998-01-05 19:00:00 GMT"
[19] "1998-01-05 20:00:00 GMT" "1998-01-05 21:00:00 GMT"
[21] "1998-01-05 22:00:00 GMT" "1998-01-05 23:00:00 GMT"
[23] "1998-01-06 00:00:00 GMT" "1998-01-06 01:00:00 GMT"
[25] "1998-01-06 02:00:00 GMT" "1998-01-06 03:00:00 GMT"
[27] "1998-01-06 04:00:00 GMT" "1998-01-06 05:00:00 GMT"
[29] "1998-01-06 06:00:00 GMT"
This seems to suggest day 5 and 6 in January 1998 instead of day 1 and
2 in May of 1998.

I have spent some time trying to resolve this but I have not been successful.

I would be thankful if you could help me to check where I went astray.

Thank you.
Best wishes
Ogbos

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

2020-01-01 Thread Ogbos Okike
Dear Friends,
Happy New Year.
Best regards
Ogbos

[[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] Stacking two graphs with different x and y scale on the same graph

2019-11-26 Thread Ogbos Okike
Dear Rui,
Many thanks. It is indeed close to what I am looking for apart from
the issues on the axes.

I am attaching the result plot. The minimum and maximum values of y1
are respectively -5.470919 and 1.298329 while they are 0.0002937659
and 4.808186 for y2.

New problems are: (1) I can't labelled the axis as (x1,x2) persist
when I tried to label the axes. (2) The two plots are merging at some
points. I only want them close but not merging as that does not allow
for meaningful comparison.

It would be great if you could adjust the code further to minimize
these problems.

Thank you.
Best wishes
Ogbos

On Wed, Nov 27, 2019 at 7:58 AM Rui Barradas  wrote:
>
> Hello,
>
> The following is not a complete solution, the axis ranges are wrong, but
> it gets you closer, I think.
>
>
> op <- par(mar = c(5, 5, 5, 5))
>
> plot(c(x1, x2), c(y1, y2), type = "n",xaxt="n", yaxt="n",
>   ylim = range(c(y1, y2)))
>
> par(new=TRUE)
> plot(x1,y1,pch=0,type="b",col="red",yaxt="n",
>   xlab = "", ylab="")
> axis(side=2, at=c(-5,0,2))
> mtext("red line", side = 2, line=2.5, at=0)
>
> par(new=TRUE)
> plot(x2, y2, pch = 1,type="b",col="blue",
>   xaxt="n", yaxt="n",
>   xlab="", ylab="")
> axis(side=4, at=c(-5,-1,0), labels=c("98%","100%","102%"))
> mtext("blue line", side=4, line=2.5, at=0)
>
> par(op)
>
>
>
> Hope this helps,
>
> Rui Barradas
>
> Às 02:53 de 27/11/19, Ogbos Okike escreveu:
> > Dear Contributors,
> > I have two data. A is of the form:
> > 05 01 01  -0.00376058013285748
> > 05 01 02  -0.0765481943910918
> > 05 01 03  -1.28158758599964
> > 05 01 04  -1.51612545416506
> > 05 01 05  -1.39481276373467
> > 05 01 06  -1.17644992095997
> > 05 01 07  -0.788249311582716
> > 05 01 08  -0.925737027403825
> > 05 01 09  -1.02278717974814
> > 05 01 10  -0.982349616271341
> > 05 01 11  -0.61032403228481
> > 05 01 12  -0.197860884821482
> > 05 01 13  -0.173598346735404
> > 05 01 14  -0.270648499079717
> > 05 01 15  -0.173598346735404
> > 05 01 16  -0.343436113337951
> > 05 01 17  -0.94565489903
> > 05 01 18  -3.60270372956778
> > 05 01 19  -5.47091916219579
> > 05 01 20  -4.67834291805057
> > 05 01 21  -5.42239408602363
> > 05 01 22  -4.19309215632901
> > 05 01 23  -1.79918839850264
> > 05 01 24  -1.04704971783422
> > 05 01 25  -0.642674083066247
> > 05 01 26  -0.505186367245138
> > 05 01 27  -0.472836316463701
> > 05 01 28  -0.537536418026576
> > 05 01 29  -0.311086062556513
> > 05 01 30  -0.00376058013285748
> > 05 01 31  -0.254473473688998
> > 05 02 01  -0.197860884821482
> > 05 02 02  -0.23021093560292
> > 05 02 03  -0.238298448298279
> > 05 02 04  -0.157423321344685
> > 05 02 05  -0.060373169000373
> > 05 02 06  0.109464597602174
> > 05 02 07  0.02858947064858
> > 05 02 08  -0.0846357070864511
> > 05 02 09  -0.189773372126123
> > 05 02 10  -0.278736011775076
> > 05 02 11  -0.302998549861154
> > 05 02 12  -0.0684606816957324
> > 05 02 13  0.0852020595160955
> > 05 02 14  0.133727135688252
> > 05 02 15  0.0528520087346581
> > 05 02 16  0.0771145468207362
> > 05 02 17  -0.0361106309142949
> > 05 02 18  -0.205948397516842
> > 05 02 19  -0.383873676814748
> > 05 02 20  -0.383873676814748
> > 05 02 21  -0.294911037165795
> > 05 02 22  -0.197860884821482
> > 05 02 23  -0.214035910212201
> > 05 02 24  -0.165510834040045
> > 05 02 25  -0.0522856563050137
> > 05 02 26  0.0366769833439393
> > 05 02 27  0.141814648383611
> > 05 02 28  0.101377084906814
> > 05 03 01  0.15798967377433
> > 05 03 02  0.222689775337205
> > 05 03 03  0.27930236420472
> > 05 03 04  0.327827440376876
> > 05 03 05  0.214602262641845
> > 05 03 06  0.133727135688252
> > 05 03 07  0.166077186469689
> >   and B is of the form:
> > 05 01 03  1.0401704890785
> > 05 01 04  1.1881431442713
> > 05 01 05  0.899433543239033
> > 05 01 06  0.495029973508058
> > 05 01 18  2.51141960034673
> > 05 01 19  4.80818567931821
> > 05 01 20  3.82649399122216
> > 05 01 21  4.75619054623929
> > 05 01 22  3.25702525028531
> > 05 01 23  0.328654748869008
> > 05 02 10  0.0689360507407491
> > 05 02 11  0.192369729879942
> > 05 02 15  0.0684297713902015
> > 05 02 16  0.100584435166215
> > 05 02 17  0.295302934161718
> > 05 02 18  0.552388788420635
> > 05 02 19  0.811

[R] Stacking two graphs with different x and y scale on the same graph

2019-11-26 Thread Ogbos Okike
Dear Contributors,
I have two data. A is of the form:
05 01 01  -0.00376058013285748
05 01 02  -0.0765481943910918
05 01 03  -1.28158758599964
05 01 04  -1.51612545416506
05 01 05  -1.39481276373467
05 01 06  -1.17644992095997
05 01 07  -0.788249311582716
05 01 08  -0.925737027403825
05 01 09  -1.02278717974814
05 01 10  -0.982349616271341
05 01 11  -0.61032403228481
05 01 12  -0.197860884821482
05 01 13  -0.173598346735404
05 01 14  -0.270648499079717
05 01 15  -0.173598346735404
05 01 16  -0.343436113337951
05 01 17  -0.94565489903
05 01 18  -3.60270372956778
05 01 19  -5.47091916219579
05 01 20  -4.67834291805057
05 01 21  -5.42239408602363
05 01 22  -4.19309215632901
05 01 23  -1.79918839850264
05 01 24  -1.04704971783422
05 01 25  -0.642674083066247
05 01 26  -0.505186367245138
05 01 27  -0.472836316463701
05 01 28  -0.537536418026576
05 01 29  -0.311086062556513
05 01 30  -0.00376058013285748
05 01 31  -0.254473473688998
05 02 01  -0.197860884821482
05 02 02  -0.23021093560292
05 02 03  -0.238298448298279
05 02 04  -0.157423321344685
05 02 05  -0.060373169000373
05 02 06  0.109464597602174
05 02 07  0.02858947064858
05 02 08  -0.0846357070864511
05 02 09  -0.189773372126123
05 02 10  -0.278736011775076
05 02 11  -0.302998549861154
05 02 12  -0.0684606816957324
05 02 13  0.0852020595160955
05 02 14  0.133727135688252
05 02 15  0.0528520087346581
05 02 16  0.0771145468207362
05 02 17  -0.0361106309142949
05 02 18  -0.205948397516842
05 02 19  -0.383873676814748
05 02 20  -0.383873676814748
05 02 21  -0.294911037165795
05 02 22  -0.197860884821482
05 02 23  -0.214035910212201
05 02 24  -0.165510834040045
05 02 25  -0.0522856563050137
05 02 26  0.0366769833439393
05 02 27  0.141814648383611
05 02 28  0.101377084906814
05 03 01  0.15798967377433
05 03 02  0.222689775337205
05 03 03  0.27930236420472
05 03 04  0.327827440376876
05 03 05  0.214602262641845
05 03 06  0.133727135688252
05 03 07  0.166077186469689
 and B is of the form:
05 01 03  1.0401704890785
05 01 04  1.1881431442713
05 01 05  0.899433543239033
05 01 06  0.495029973508058
05 01 18  2.51141960034673
05 01 19  4.80818567931821
05 01 20  3.82649399122216
05 01 21  4.75619054623929
05 01 22  3.25702525028531
05 01 23  0.328654748869008
05 02 10  0.0689360507407491
05 02 11  0.192369729879942
05 02 15  0.0684297713902015
05 02 16  0.100584435166215
05 02 17  0.295302934161718
05 02 18  0.552388788420635
05 02 19  0.811732847306371
05 02 20  0.843313045760178
05 02 21  0.757193220375875
05 02 22  0.65352100387166
05 02 23  0.68252482652902
05 02 24  0.624510062816789
05 02 25  0.479854370620533
05 02 26  0.359002279153697
05 02 27  0.212459089641907
05 02 28  0.240784160160447
05 03 01  0.144583652487177
05 03 02  0.0345028244394553
05 03 21  0.023582430982633
05 03 22  0.000293765928922767
05 03 27  0.0440288222469235
05 03 28  0.106263428254761
05 03 29  0.291212461872628
05 03 30  0.198305017329253
05 03 31  0.186935599530143
05 04 01  0.316471519561273
05 04 02  0.266260602009615
05 04 03  0.0456391152384458
05 04 04  0.113939833419049
05 04 05  0.140500137811164
05 04 06  0.374670064516577
05 04 07  0.295820206701906
05 04 08  0.0833493810907385
05 04 10  0.0253248646840757
05 04 11  0.188773903020133
05 04 12  0.206619775067284
05 04 13  0.408503282817833
05 04 14  0.344129922512134
05 04 15  0.283273728250647
05 04 16  0.155780334719261
05 04 17  0.0815692243668445
B is extracted from A and I wish to plot A and B on the same x-axis
but different y axis on the same graph. Stacking very close helps to
illustrates the common rapid variations in A, represented in B.

One of the codes I tried without success is:
data <- read.table("A", col.names = c("year", "month", "day", "counts"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x1 = data$date
y1=data$counts
#y1=scale(data$counts)


data <- read.table("B", col.names = c("year", "month", "day", "counts"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x2 = data$date
y2=data$counts


pdf("PLOT.pdf")

 par(mar=c(5,5,5,5))

plot(x1,y1,pch=0,type="b",col="red",yaxt="n",ylim=c(-5.470919,1.298329),ylab="")
axis(side=2, at=c(-6,0,2))
mtext("red line", side = 2, line=2.5, at=0)

par(new=TRUE)
plot(x2,y2,pch=1,type="b",col="blue",yaxt="n",ylim=c(-4.808186,0.0), ylab="")
axis(side=4, at=c(-5,-1,0), labels=c("98%","100%","102%"))
mtext("blue line", side=4, line=2.5, at=100)
dev.off()

Your assistance is ever appreciated.
Best wishes
Ogbos

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Datetime in doubly y-axis plot: Solved

2019-11-21 Thread Ogbos Okike
Dear Jim and Petr,

Thank you.

The last code by Jim worked like magic. A great relief. Thank you very much.
Best wishes
Ogbos

On Thu, Nov 21, 2019 at 10:59 AM Jim Lemon  wrote:
>
> Hi Ogbos,
> As Petr says, you can use twoord.plot for this:
>
> dta<-read.table(text="year month day hour Li CR x1 x2
> 04 12 31 10  8637 4992 0.310676228913214 49.7113438132607
> 04 12 31 11  8634 4183 0.275834035016405 25.4492290005748
> 04 12 31 12  8652 4160 0.484887198397259 24.7594531777172
> 04 12 31 13  8626 3411 0.182921517958247 2.2967535550946
> 04 12 31 15  8618 3904 0.09000900090009 17.0819483667808
> 04 12 31 16  8620 3428 0.113237130164629 2.80658785894585
> 04 12 31 17  8603 3041 -0.0842019685839552 -8.79964011696198
> 04 12 31 18  8579 2340 -0.362939519758427 -29.8228075875341
> 04 12 31 19  8588 3006 -0.258412938068 -9.8492989778322
> 04 12 31 20  8604 3280 -0.0725879039516855 -1.63196960987679
> 04 12 31 21  8568 3696 -0.490694230713394 10.8439757078949
> 04 12 31 22  8567 2307 -0.502308295345664 -30.8124859420688
> 04 12 31 23  8570 2726 -0.467466101448855 -18.2465698647939
> 05 01 01 00  8579 2879 -0.568878758318289 8.46755203918244
> 05 01 01 01  8581 1586 -0.545698639133843 -40.2467740416313
> 05 01 01 02  8562 1183 -0.765909771386082 -55.4299708015447
> 05 01 01 03  8602 1491 -0.302307387697159 -43.8259395309409
> 05 01 01 04  8576 1742 -0.603648937094958 -34.369407553923
> 05 01 01 05  8622 2001 -0.0705061958526974 -24.6114721672789
> 05 01 01 06  8613 2675 -0.174816732182705 0.781765093717623
> 05 01 01 07  8622 3293 -0.0705061958526974 24.0651784873316
> 05 01 01 08  8628 4333 -0.00096583829935895 63.2476217387209
> 05 01 01 09  8669 16 0.474226604981787 -99.3971931807479
> 05 01 01 10  8698 3671 0.810338333156256 38.3064895921635
> 05 01 01 11  8671 3856 0.497406724166233 45.2764434397664
> 05 01 01 12  8679 3411 0.590127200904018 28.5108787793162
> 05 01 01 13  8647 3428 0.219245293952879 29.1513610247716
> 05 01 01 14  8651 4596 0.265605532321772 73.156258830178
> 05 01 01 15  8638 3154 0.114934757622872 18.8282942450786
> 05 01 01 16  8635 2365 0.0801645788462025 -10.8976170292926
> 05 01 01 17  8628 2697 -0.00096583829935895 1.61062447018932
> 05 01 01 18  8653 3231 0.288785651506218 21.7293020627296
> 05 01 01 19  8657 3548 0.33514588987511 33.6724121691627
> 05 01 01 20  8650 2645 0.254015472729549 -0.348497692380145
> 05 01 01 21  8605 2153 -0.26753720892049 -18.8848073843835
> 05 01 01 22  8600 1759 -0.325487506881605 -33.7289253084676",
> header=TRUE,stringsAsFactors=FALSE)
> library(plotrix)
> dta$year<-ifelse(dta$year < 50,dta$year+2000,dta$year+1900)
> dta$date<-strptime(paste(paste(paste(dta$year,dta$month,dta$day,sep="-"),
>  paste(dta$hour,0,0,sep=":"),sep=" ")),"%Y-%m-%d %H:%M:%S")
> xlim<-range(as.numeric(dta$date))
> xorigin<-as.POSIXct("1970-01-01 0:0:0","%Y-%m-%d %H:%M:%S")
> xticks<-as.POSIXct(pretty(range(as.numeric(dta$date))),origin=xorigin)
> twoord.plot(dta$date,dta$Li,dta$date,dta$CR,xlim=xlim,xaxt="n",
>  main="Lightning and GCR frequency",
>  xlab="Date",ylab="Lightning count/day",rylab="GCR count/day",
>  xtickpos=xticks,xticklab=format(xticks,"%Y-%m-%d %H"))
>
> Jim
>
> On Thu, Nov 21, 2019 at 7:49 PM Ogbos Okike  wrote:
> >
> > Dear Members,
> > I have some hourly data. Usin:
> > dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900))
> > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, 
> > month,day,hour,0,0)))
> > I converted the hour to time format and stored in Year.
> > The data consists of two different observations and I wish to plot
> > same on one graph (two y-axis and common x-axis).
> >

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

2019-11-21 Thread Ogbos Okike
Dear Members,
I have some hourly data. Usin:
dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900))
dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, month,day,hour,0,0)))
I converted the hour to time format and stored in Year.
The data consists of two different observations and I wish to plot
same on one graph (two y-axis and common x-axis).

Part of my script is of the form:
library(plotrix)
plot(Year,Li,pch=16,axes=FALSE,xlab="",ylab="",type="l",col="black",ylim=c(1,22909))
axis(2, ylim=c(1,22909),col="black",las=1)
mtext("Lightning count/day", side=2, line=4)
box()
par(new=TRUE)
plot(Year,CR, pch=15,
xlab="",ylab="",ylim=c(7302,9983),axes=FALSE,type="l",col="red")
mtext("GCR count/day",side=4,col="red",line=3)
axis(4, ylim=c(7302,9983), col="red",col.axis="red",las=1)
The two y-axis worked and looked fine.

But I have difficulties with x-axis.
I tried things like in an attempt to draw the x-axis.
## Draw the time axis
#axis(1,pretty(range(Year),10))
axis(side=1,at=c(as.datetime("2005-01-01 01:00:00
GMT"),as.datetime("2007-01-01 01:00:00 GMT"),as.datetime("2009-01-01
01:00:00 GMT"),labels=c("2005","2007","2009"))
#axis(side=1, at =Year)
#axis(1,Year)

But none worked.

However, when I plotted the two graphs separately, the x-axis was
correctly labelled from 2005 to 2010 (the time range of my data).

Small portion of the data is:
04 12 31 10  8637 4992 0.310676228913214 49.7113438132607
04 12 31 11  8634 4183 0.275834035016405 25.4492290005748
04 12 31 12  8652 4160 0.484887198397259 24.7594531777172
04 12 31 13  8626 3411 0.182921517958247 2.2967535550946
04 12 31 15  8618 3904 0.09000900090009 17.0819483667808
04 12 31 16  8620 3428 0.113237130164629 2.80658785894585
04 12 31 17  8603 3041 -0.0842019685839552 -8.79964011696198
04 12 31 18  8579 2340 -0.362939519758427 -29.8228075875341
04 12 31 19  8588 3006 -0.258412938068 -9.8492989778322
04 12 31 20  8604 3280 -0.0725879039516855 -1.63196960987679
04 12 31 21  8568 3696 -0.490694230713394 10.8439757078949
04 12 31 22  8567 2307 -0.502308295345664 -30.8124859420688
04 12 31 23  8570 2726 -0.467466101448855 -18.2465698647939
05 01 01 00  8579 2879 -0.568878758318289 8.46755203918244
05 01 01 01  8581 1586 -0.545698639133843 -40.2467740416313
05 01 01 02  8562 1183 -0.765909771386082 -55.4299708015447
05 01 01 03  8602 1491 -0.302307387697159 -43.8259395309409
05 01 01 04  8576 1742 -0.603648937094958 -34.369407553923
05 01 01 05  8622 2001 -0.0705061958526974 -24.6114721672789
05 01 01 06  8613 2675 -0.174816732182705 0.781765093717623
05 01 01 07  8622 3293 -0.0705061958526974 24.0651784873316
05 01 01 08  8628 4333 -0.00096583829935895 63.2476217387209
05 01 01 09  8669 16 0.474226604981787 -99.3971931807479
05 01 01 10  8698 3671 0.810338333156256 38.3064895921635
05 01 01 11  8671 3856 0.497406724166233 45.2764434397664
05 01 01 12  8679 3411 0.590127200904018 28.5108787793162
05 01 01 13  8647 3428 0.219245293952879 29.1513610247716
05 01 01 14  8651 4596 0.265605532321772 73.156258830178
05 01 01 15  8638 3154 0.114934757622872 18.8282942450786
05 01 01 16  8635 2365 0.0801645788462025 -10.8976170292926
05 01 01 17  8628 2697 -0.00096583829935895 1.61062447018932
05 01 01 18  8653 3231 0.288785651506218 21.7293020627296
05 01 01 19  8657 3548 0.33514588987511 33.6724121691627
05 01 01 20  8650 2645 0.254015472729549 -0.348497692380145
05 01 01 21  8605 2153 -0.26753720892049 -18.8848073843835
05 01 01 22  8600 1759 -0.325487506881605 -33.7289253084676
Where the first four columns are year, month, day and hour. The last
four columns are the parameters of interest which I am trying to plot,
taking two at a time.
I will remain indebted for your assistance.
Best Regards
Ogbos

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Ogbos Okike
Dear All,
Many thanks for all your contributions, suggestions and advice.
I find them all useful.
Best wishes
Ogbos

On Mon, Sep 9, 2019 at 9:35 PM Rui Barradas  wrote:
>
> Hello,
>
> I cannot reproduce the error but I coerce to class "Date" first.
>
>
> MOSCFD50[[1]] <- as.Date(MOSCFD50[[1]])
> names(MOSCFD50) <- c("date", "value")
>
> # Your subset
> Year <- subset(MOSCFD50, date > "1998-01-01" & date < "2005-12-31")
>
> # Another way, if there are NA's, use which(i)
> i <- MOSCFD50$date > "1998-01-01" & MOSCFD50$date < "2005-12-31"
> Year2 <- MOSCFD50[i, ]
>
> identical(Year, Year2)
> #[1] TRUE
>
>
> Data:
>
>
> MOSCFD50 <- read.table(text = "
> 1997-11-23 -2.91709629064653
> 1997-12-07 -0.960255426066815
> 1997-12-11 -1.98210752999868
> 1997-12-20 -1.10800598439855
> 1998-01-01 -1.00090115428118
> 1998-01-29 -1.03056081882709
> 1998-03-27 -0.873243859498216
> 1998-04-09 -2.06378384750109
> 1998-04-12 -2.06826431469008
> 1998-04-19 -2.49834620746286
> 1998-05-02 -6.4357083781542
> 1998-05-17 -2.25359807972754
> 1998-05-21 -2.55799006865995
> 1999-08-22 -2.25114162617707
> 1999-08-25 -1.47905397376409
> 1999-09-05 -0.641589808755325
> 1999-09-09 -0.648954682695949
> 1999-09-13 -0.726364489272492
> 1999-09-16 -1.28445236942011
> ")
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> Às 20:14 de 09/09/19, Ogbos Okike escreveu:
> > Dear Bert and Jeff,
> > Thank you for looking at this.
> > I am surprised my message was not in plain text. It has been
> > configured to send message to the list in plain text earlier before.
> >
> > The data again please.
> >
> > 1997-11-23 -2.91709629064653
> > 1997-12-07 -0.960255426066815
> > 1997-12-11 -1.98210752999868
> > 1997-12-20 -1.10800598439855
> > 1998-01-01 -1.00090115428118
> > 1998-01-29 -1.03056081882709
> > 1998-03-27 -0.873243859498216
> > 1998-04-09 -2.06378384750109
> > 1998-04-12 -2.06826431469008
> > 1998-04-19 -2.49834620746286
> > 1998-05-02 -6.4357083781542
> > 1998-05-17 -2.25359807972754
> > 1998-05-21 -2.55799006865995
> > 1999-08-22 -2.25114162617707
> > 1999-08-25 -1.47905397376409
> > 1999-09-05 -0.641589808755325
> > 1999-09-09 -0.648954682695949
> > 1999-09-13 -0.726364489272492
> > 1999-09-16 -1.28445236942011
> >
> > The first column is  date and the second is another data of interest.
> >
> > The date is long but note sequential. Runs randomly from 1953 to 2019.
> >
> > I would like to select any range of date from year A to year B.
> >
> > Thank you again for your help.
> > Best
> > Ogbos
> >
> >
> > On Mon, Sep 9, 2019 at 6:18 PM Jeff Newmiller  
> > wrote:
> >>
> >> Or the column is not named "date", or it is a factor... and the question 
> >> is not posted in plain text
> >>
> >> On September 9, 2019 9:55:48 AM PDT, Bert Gunter  
> >> wrote:
> >>> I would guess that you first need to convert your textual dates to a
> >>> date-time object via as.date, but as you failed to provide a
> >>> reproducible
> >>> example (e.g. via dput) I may be wrong. Maybe others may have greater
> >>> insight.
> >>>
> >>> 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 Mon, Sep 9, 2019 at 8:55 AM Ogbos Okike 
> >>> wrote:
> >>>
> >>>> Dear Contributors,
> >>>> I have a data frame of the form:
> >>>> 1997-11-23 -2.91709629064653
> >>>> 1997-12-07 -0.960255426066815
> >>>> 1997-12-11 -1.98210752999868
> >>>> 1997-12-20 -1.10800598439855
> >>>> 1998-01-01 -1.00090115428118
> >>>> 1998-01-29 -1.03056081882709
> >>>> 1998-03-27 -0.873243859498216
> >>>> 1998-04-09 -2.06378384750109
> >>>> 1998-04-12 -2.06826431469008
> >>>> 1998-04-19 -2.49834620746286
> >>>> 1998-05-02 -6.4357083781542
> >>>> 1998-05-17 -2.25359807972754
> >>>> 1998-05-21 -2.55799006865995
> >>>> 1999-08-22 -2.25114162617707
> >>>> 1999-08

[R] Choosing specific Date Range from non-sequential Date: Problem Fixed

2019-09-09 Thread Ogbos Okike
Dear Bert and Jeff,
The result is an output of another code and it will be too long or
unnecessary to show all I'm I did to arrive at the given data frame.

Since my single line code works for Jeff, I had to take a second look
and try to get it working for me. I then read the data frame using
d<-read.table("MOSC",colClasses=c("Date","numeric"))  and tried:
Year <- subset(d1, d1[[1]] > "1998-01-01" & d1[[1]] < "2006-01-01")
and arrived at my goal.

Thank you for the hint.
Best regards
Ogbos


On Mon, Sep 9, 2019 at 8:22 PM Jeff Newmiller  wrote:
>
> Works for me. Apparently you are not showing us everything you are doing. As 
> Bert recommended, you need to use the dput function rather than dumping 
> numbers into the email if we are to know how your data are stored in memory 
> which will affect what results you get. I highly recommend using the reprex 
> package to verify that your example is reproducible.
>
> On September 9, 2019 12:14:50 PM PDT, Ogbos Okike  
> wrote:
> >Dear Bert and Jeff,
> >Thank you for looking at this.
> >I am surprised my message was not in plain text. It has been
> >configured to send message to the list in plain text earlier before.
> >
> >The data again please.
> >
> >1997-11-23 -2.91709629064653
> >1997-12-07 -0.960255426066815
> >1997-12-11 -1.98210752999868
> >1997-12-20 -1.10800598439855
> >1998-01-01 -1.00090115428118
> >1998-01-29 -1.03056081882709
> >1998-03-27 -0.873243859498216
> >1998-04-09 -2.06378384750109
> >1998-04-12 -2.06826431469008
> >1998-04-19 -2.49834620746286
> >1998-05-02 -6.4357083781542
> >1998-05-17 -2.25359807972754
> >1998-05-21 -2.55799006865995
> >1999-08-22 -2.25114162617707
> >1999-08-25 -1.47905397376409
> >1999-09-05 -0.641589808755325
> >1999-09-09 -0.648954682695949
> >1999-09-13 -0.726364489272492
> >1999-09-16 -1.28445236942011
> >
> >The first column is  date and the second is another data of interest.
> >
> >The date is long but note sequential. Runs randomly from 1953 to 2019.
> >
> >I would like to select any range of date from year A to year B.
> >
> >Thank you again for your help.
> >Best
> >Ogbos
> >
> >
> >On Mon, Sep 9, 2019 at 6:18 PM Jeff Newmiller
> > wrote:
> >>
> >> Or the column is not named "date", or it is a factor... and the
> >question is not posted in plain text
> >>
> >> On September 9, 2019 9:55:48 AM PDT, Bert Gunter
> > wrote:
> >> >I would guess that you first need to convert your textual dates to a
> >> >date-time object via as.date, but as you failed to provide a
> >> >reproducible
> >> >example (e.g. via dput) I may be wrong. Maybe others may have
> >greater
> >> >insight.
> >> >
> >> >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 Mon, Sep 9, 2019 at 8:55 AM Ogbos Okike
> >
> >> >wrote:
> >> >
> >> >> Dear Contributors,
> >> >> I have a data frame of the form:
> >> >> 1997-11-23 -2.91709629064653
> >> >> 1997-12-07 -0.960255426066815
> >> >> 1997-12-11 -1.98210752999868
> >> >> 1997-12-20 -1.10800598439855
> >> >> 1998-01-01 -1.00090115428118
> >> >> 1998-01-29 -1.03056081882709
> >> >> 1998-03-27 -0.873243859498216
> >> >> 1998-04-09 -2.06378384750109
> >> >> 1998-04-12 -2.06826431469008
> >> >> 1998-04-19 -2.49834620746286
> >> >> 1998-05-02 -6.4357083781542
> >> >> 1998-05-17 -2.25359807972754
> >> >> 1998-05-21 -2.55799006865995
> >> >> 1999-08-22 -2.25114162617707
> >> >> 1999-08-25 -1.47905397376409
> >> >> 1999-09-05 -0.641589808755325
> >> >> 1999-09-09 -0.648954682695949
> >> >> 1999-09-13 -0.726364489272492
> >> >> 1999-09-16 -1.28445236942011
> >> >>
> >> >> The events happen randomly and so the date is non-sequential. It
> >run
> >> >form
> >> >> 1953 to 2019.
> >> >>
> >> >> I would like to select all the events/dates between 1998 to 2005.
> >> >>
> >> >

Re: [R] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Ogbos Okike
Dear Bert and Jeff,
Thank you for looking at this.
I am surprised my message was not in plain text. It has been
configured to send message to the list in plain text earlier before.

The data again please.

1997-11-23 -2.91709629064653
1997-12-07 -0.960255426066815
1997-12-11 -1.98210752999868
1997-12-20 -1.10800598439855
1998-01-01 -1.00090115428118
1998-01-29 -1.03056081882709
1998-03-27 -0.873243859498216
1998-04-09 -2.06378384750109
1998-04-12 -2.06826431469008
1998-04-19 -2.49834620746286
1998-05-02 -6.4357083781542
1998-05-17 -2.25359807972754
1998-05-21 -2.55799006865995
1999-08-22 -2.25114162617707
1999-08-25 -1.47905397376409
1999-09-05 -0.641589808755325
1999-09-09 -0.648954682695949
1999-09-13 -0.726364489272492
1999-09-16 -1.28445236942011

The first column is  date and the second is another data of interest.

The date is long but note sequential. Runs randomly from 1953 to 2019.

I would like to select any range of date from year A to year B.

Thank you again for your help.
Best
Ogbos


On Mon, Sep 9, 2019 at 6:18 PM Jeff Newmiller  wrote:
>
> Or the column is not named "date", or it is a factor... and the question is 
> not posted in plain text
>
> On September 9, 2019 9:55:48 AM PDT, Bert Gunter  
> wrote:
> >I would guess that you first need to convert your textual dates to a
> >date-time object via as.date, but as you failed to provide a
> >reproducible
> >example (e.g. via dput) I may be wrong. Maybe others may have greater
> >insight.
> >
> >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 Mon, Sep 9, 2019 at 8:55 AM Ogbos Okike 
> >wrote:
> >
> >> Dear Contributors,
> >> I have a data frame of the form:
> >> 1997-11-23 -2.91709629064653
> >> 1997-12-07 -0.960255426066815
> >> 1997-12-11 -1.98210752999868
> >> 1997-12-20 -1.10800598439855
> >> 1998-01-01 -1.00090115428118
> >> 1998-01-29 -1.03056081882709
> >> 1998-03-27 -0.873243859498216
> >> 1998-04-09 -2.06378384750109
> >> 1998-04-12 -2.06826431469008
> >> 1998-04-19 -2.49834620746286
> >> 1998-05-02 -6.4357083781542
> >> 1998-05-17 -2.25359807972754
> >> 1998-05-21 -2.55799006865995
> >> 1999-08-22 -2.25114162617707
> >> 1999-08-25 -1.47905397376409
> >> 1999-09-05 -0.641589808755325
> >> 1999-09-09 -0.648954682695949
> >> 1999-09-13 -0.726364489272492
> >> 1999-09-16 -1.28445236942011
> >>
> >> The events happen randomly and so the date is non-sequential. It run
> >form
> >> 1953 to 2019.
> >>
> >> I would like to select all the events/dates between 1998 to 2005.
> >>
> >> One of the things I tried is:
> >> Year <- subset(MOSCFD50, date > "1998-01-01" & date < "2005-12-31").
> >>
> >> But it didn't work.
> >>
> >> I would be thankful if you could please redirect me.
> >>
> >> Thank you very much.
> >> Best regards
> >> Ogbos
> >>
> >> [[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.
>
> --
> 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] Choosing specific Date Range from non-sequential Date

2019-09-09 Thread Ogbos Okike
Dear Contributors,
I have a data frame of the form:
1997-11-23 -2.91709629064653
1997-12-07 -0.960255426066815
1997-12-11 -1.98210752999868
1997-12-20 -1.10800598439855
1998-01-01 -1.00090115428118
1998-01-29 -1.03056081882709
1998-03-27 -0.873243859498216
1998-04-09 -2.06378384750109
1998-04-12 -2.06826431469008
1998-04-19 -2.49834620746286
1998-05-02 -6.4357083781542
1998-05-17 -2.25359807972754
1998-05-21 -2.55799006865995
1999-08-22 -2.25114162617707
1999-08-25 -1.47905397376409
1999-09-05 -0.641589808755325
1999-09-09 -0.648954682695949
1999-09-13 -0.726364489272492
1999-09-16 -1.28445236942011

The events happen randomly and so the date is non-sequential. It run form
1953 to 2019.

I would like to select all the events/dates between 1998 to 2005.

One of the things I tried is:
Year <- subset(MOSCFD50, date > "1998-01-01" & date < "2005-12-31").

But it didn't work.

I would be thankful if you could please redirect me.

Thank you very much.
Best regards
Ogbos

[[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] Labeling Dates of different length on two in axis plot

2019-08-25 Thread Ogbos Okike
Dear Bert and Jim,
Here is the code:
data <- read.table("CLMX.txt", col.names = c("year", "month", "day", "CLMX"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x1 = data$date


 Li<-data$CLMX
###
data <- read.table("DPRV.txt", col.names = c("year", "month", "day", "DPRV"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x2 = data$date


CR<-data$DPRV



 ###
  date_x1<-seq(as.Date("1953-01-02"),as.Date("2006-11-15"),length.out=1575)
date_x2<-seq(as.Date("1957-07-26"),as.Date("1994-07-17"),length.out=1203)


pdf("CLMXandDPRV.pdf")
 par(mar = c(5, 4, 4, 4) + 2)
library(plotrix)
plot(date_x1,Li,pch=16,axes=FALSE,xlab="",ylab="",type="l",col="black",ylim=c(-0.5001663,-10.27402))
points(date_x1,Li,col="black")
axis(2, ylim=c(-0.5001663,-10.27402),col="black",las=1)
mtext("FD (%)", side=2, line=4)
text(as.Date("1992-02-21"),3523,"FD1")

text(as.Date("1972-02-28"),-8,"Total FDs = 1203",col="red")
text(as.Date("1972-03-02"),-9,"Total FDs = 1575")
#box()

par(new=TRUE)
plot(date_x2,CR, pch=16,
xlab="",ylab="",ylim=c(-0.5030138,-14.39884),axes=FALSE,type="l",col="red")
points(date_x2,CR,col="red")
mtext("FD (%)",side=4,col="red",line=3)
axis(4, ylim=c(-0.5030138,-14.39884), col="red",col.axis="red",las=1)




mtext("Date",side=1,col="black",line=2.5)

legend("topleft",col=c("red","black"),lty=1,legend=c("DPRV","CLMX"))

dev.off()

Thanks again.
Best wishes
Ogbos


On Sun, Aug 25, 2019 at 4:52 PM Ogbos Okike  wrote:
>
> Dear Jim and Bert,
> Thank your for looking into this for me. I will try to reproduce a
> part of my data and the plot I have.
>
> Data 1:
> 53 01 02 -1.28792560381641
> 53 01 06 -1.1854773963453
> 53 01 08 -1.55920165458006
> 53 01 15 -1.29196482429683
> 53 01 20 -1.06082194329819
> 53 01 22 -1.15430411152234
> 53 01 24 -1.14775155345262
> 53 01 26 -1.19116423468105
> 53 01 28 -0.924542121164923
> 53 01 31 -0.869543637175866
> 53 02 03 -0.764466677206437
> 53 02 05 -0.707705051599105
> 53 02 07 -0.750908466521414
> 53 02 16 -1.6848903649715
> 53 02 20 -0.760876361940755
> 53 02 22 -0.803816591115474
> 53 02 26 -0.818160891300922
> 53 02 28 -0.831013020625678
> 53 03 04 -1.06661138281899
> till the year 2006. The length is 1575
>
> Data B:
> 57 07 26 -3.62351759422703
> 57 07 29 -4.51297753038541
> 57 08 02 -3.29214621128099
> 57 08 05 -6.44144118698436
> 57 08 16 -3.09828319252649
> 57 08 22 -1.58619965424759
> 57 08 28 -4.3638763217976
> 57 08 30 -9.93305062749234
> 57 09 03 -9.29132498735799
> 57 09 05 -8.50042591710719
> 57 09 13 -5.58659819576993
> 57 09 19 -2.4834966827445
> 57 09 23 -5.69132573226493
> 57 09 26 -3.6296458026372
> to  the year 1994. The length is 1203.
>
> The plot is attached. How to label the x-axis is the problem.
> I will send the code in another email so that the moderator will let it go.
> Thank again
> Best
> Ogbos
>
> On Sun, Aug 25, 2019 at 3:58 PM Bert Gunter  wrote:
> >
> > I think you will need to show us your code to get useful help (see the 
> > posting guide). A small subset of your data and a reprex may also be 
> > needed. R has several different graphics systems, and the answer depends on 
> > which you are using. In base graphics, the axis() function (see its Help 
> > page) may be what you need, but that's just a guess. Others may be able to 
> > be more specific.
> >
> > 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 Sat, Aug 24, 2019 at 9:49 PM Ogbos Okike  
> > wrote:
> >>
> >> Dear Contributors,
> >> I have two dataset of different lengths, each containing year, month,
> >> day and counts.
> >> After converting the date using as.Date function, I plotted the two
> >> dateset on one graph. That was fine.
> >>
> >> I am, however, having problems with the axis 1 whe

Re: [R] Labeling Dates of different length on two in axis plot

2019-08-25 Thread Ogbos Okike
Dear Jim and Bert,
Thank your for looking into this for me. I will try to reproduce a
part of my data and the plot I have.

Data 1:
53 01 02 -1.28792560381641
53 01 06 -1.1854773963453
53 01 08 -1.55920165458006
53 01 15 -1.29196482429683
53 01 20 -1.06082194329819
53 01 22 -1.15430411152234
53 01 24 -1.14775155345262
53 01 26 -1.19116423468105
53 01 28 -0.924542121164923
53 01 31 -0.869543637175866
53 02 03 -0.764466677206437
53 02 05 -0.707705051599105
53 02 07 -0.750908466521414
53 02 16 -1.6848903649715
53 02 20 -0.760876361940755
53 02 22 -0.803816591115474
53 02 26 -0.818160891300922
53 02 28 -0.831013020625678
53 03 04 -1.06661138281899
till the year 2006. The length is 1575

Data B:
57 07 26 -3.62351759422703
57 07 29 -4.51297753038541
57 08 02 -3.29214621128099
57 08 05 -6.44144118698436
57 08 16 -3.09828319252649
57 08 22 -1.58619965424759
57 08 28 -4.3638763217976
57 08 30 -9.93305062749234
57 09 03 -9.29132498735799
57 09 05 -8.50042591710719
57 09 13 -5.58659819576993
57 09 19 -2.4834966827445
57 09 23 -5.69132573226493
57 09 26 -3.6296458026372
to  the year 1994. The length is 1203.

The plot is attached. How to label the x-axis is the problem.
I will send the code in another email so that the moderator will let it go.
Thank again
Best
Ogbos

On Sun, Aug 25, 2019 at 3:58 PM Bert Gunter  wrote:
>
> I think you will need to show us your code to get useful help (see the 
> posting guide). A small subset of your data and a reprex may also be needed. 
> R has several different graphics systems, and the answer depends on which you 
> are using. In base graphics, the axis() function (see its Help page) may be 
> what you need, but that's just a guess. Others may be able to be more 
> specific.
>
> 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 Sat, Aug 24, 2019 at 9:49 PM Ogbos Okike  wrote:
>>
>> Dear Contributors,
>> I have two dataset of different lengths, each containing year, month,
>> day and counts.
>> After converting the date using as.Date function, I plotted the two
>> dateset on one graph. That was fine.
>>
>> I am, however, having problems with the axis 1 where I am trying to
>> put the dates.
>> Since the two dates are not exactly the same, I stored the first date
>> as x1 and the second x2. x1 runs from 1953-01-02 to 2006-11-15 while
>> the range of x2 is between 1957-07-26 and 1994-07-17.
>> I tired a number of approaches but the one that seems to come close to
>> what I am looking for is: axis.Date(1, at=seq(min(x1), max(x1), by="50
>> mon"), format="%Y").
>>
>> Unfortunately, it only labeled the axis up to 1994 even when I tried
>> to replace x1 with x2 in the code. Since one of the dates is up to
>> 2006, I I wish to display the minimum (1953) and maximum  (2006) dates
>> and some possible intermediary dates.
>> I am always indebted to you.
>>
>> Best wishes
>> Ogbos
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.


Ogbos.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Labeling Dates of different length on two in axis plot

2019-08-24 Thread Ogbos Okike
Dear Contributors,
I have two dataset of different lengths, each containing year, month,
day and counts.
After converting the date using as.Date function, I plotted the two
dateset on one graph. That was fine.

I am, however, having problems with the axis 1 where I am trying to
put the dates.
Since the two dates are not exactly the same, I stored the first date
as x1 and the second x2. x1 runs from 1953-01-02 to 2006-11-15 while
the range of x2 is between 1957-07-26 and 1994-07-17.
I tired a number of approaches but the one that seems to come close to
what I am looking for is: axis.Date(1, at=seq(min(x1), max(x1), by="50
mon"), format="%Y").

Unfortunately, it only labeled the axis up to 1994 even when I tried
to replace x1 with x2 in the code. Since one of the dates is up to
2006, I I wish to display the minimum (1953) and maximum  (2006) dates
and some possible intermediary dates.
I am always indebted to you.

Best wishes
Ogbos

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

2019-02-28 Thread Ogbos Okike
Dear Ben and Micheal,
Your contributions are quite useful to me!!!

Although my question is quite difficult to articulate, your attempt to
understand what I intend to do and my desperate efforts to get my
points across to you have, interestingly, combined to solve the
problem.

Indeed, the problem is specific (epoch/Chree analysis) and they are
yet a lot of misunderstanding even among scientists using them. I
initially felt quite odd asking you about it and it took me several
days before I decided to  post the question. Though I didn't receive
much of a response, I was happy that I was not trashed.

On the issue of textbook, my reviewer already pointed the example
he/she would like me to follow (a published article). I have but that
option if I want the paper to go soon.

So I spent about 3 days looking at the paper and similar ones. It was
in the course of trying to re-construct my question and re-post
yesterday that I got the idea of how to do it.

As Micheal pointed out, it is Monte Carlo technique that I was after.
If I am to follow the paper recommended, one hundred epoch selected
out of the original epoch will do the job. That will then be used to
judge the statistical significance of the observed decreases.

After posting the question yesterday, the problem became clearer to me
and the next few attempts got me to the destination.

I am thus indebted you.

With the very best wishes
Ogbos
On Thu, Feb 28, 2019 at 3:56 PM Meyners, Michael  wrote:
>
> Ogbos,
>
> To share data (in particularly lengthy one as yours), check out ?dput
>
> To replicate sampling, look at ?replicate (will output to a data frame to use 
> further) - that should answer your Q1.
>
> Apart from that (and regarding Q2), the task you are after is getting more 
> and more obscure to me. I don't see what you really want to test - between 
> levels of n (or A in oodf)? If so, you would need to permute levels within 
> each set (are they sets of -5:10, or are all observations completely 
> independent? In the latter case, across all sets). What is the null 
> hypothesis you want to test? And what is the data exactly? I don't understand 
> what the two columns indicate. Then you need to decide on what the test 
> statistic is you want to use. The average? The difference between each pair 
> of averages? Anything like that? Do you want to test all levels 
> simultaneously, or by pairs?
>
> Clearly, your way of sampling is inappropriate for a randomization test. You 
> are rather simulating data that can take any value between min and max with 
> equal probability. That does not seem to be the right null model to me (it 
> might be, though, depending on your null hypothesis). It would not make a 
> randomization test either way, but rather a Monte Carlo simulation under the 
> null hypothesis. Then you would determine your test statistic(s) (whichever 
> they are) and subsequently repeat that often enough and check whether your 
> observed value is higher than 90 or 99% of the simulated ones. Again, that 
> would be a simulation, not a randomization test.
>
> For the latter, you'd need to permute the data in an appropriate way (again 
> depending on the null hypothesis, and on the structure, i.e. are they are 
> coming in blocks of any kind, or all independent), and then recalculate the 
> test statistic every time, and then proceed as before. I'm not sure whether 
> the data was the result of a randomized experiment - if not, you can still 
> use the idea, but fall into something that some refer to as "permutation 
> testing" - the difference being that you need to make much stronger 
> assumptions on independence etc of the data. Many use the terms equivalently, 
> but just so you are aware.
>
> I really think you need to look into a textbook (eg. Edgington & Onghena) or 
> some papers to understand the concept of randomization tests, or consult with 
> a statistician with good background in that field. What you are suggesting is 
> not near it, and unless you have a clear hypothesis and a good understanding 
> of how the data was generated, it is impossible for you (and anyone else) to 
> say how such a test might be designed.
>
> Michael
>
>
> > -Original Message-
> > From: Ogbos Okike 
> > Sent: Mittwoch, 27. Februar 2019 22:53
> > To: Meyners, Michael 
> > Cc: r-help 
> > Subject: Re: [R] Randomization Test
> >
> > Dear Kind List,
> >
> > I am still battling with this. I have, however, made some progress with the
> > suggestions of Micheal and others. At least, I have a better picture of 
> > what I
> > want to do now as I will attempt a detailed description here.
> >
> > I am aware I should show you just a small part of my code and data.
> > But w

Re: [R] Randomization Test

2019-02-27 Thread Ogbos Okike
th of sample data.
Q1: Please how do I generate many samples as x above, say up to 5000
or 10,000? I manually generated and stored as x1,x2, x3 up to x100.

Q2: Please how do I use this randomly generated numbers to test the
statistical significance level of the signal generated by
plot(-5:10,oomean,type="l",ylim=c(8890,9100),  )?

I wish to test for 90% and 99% percentile.

I am sorry that this is too long.

Many thanks for your kind contributions

Best
Ogbos







On Sun, Feb 10, 2019 at 3:55 PM Ogbos Okike  wrote:
>
> Dear Michael,
> This is great! Thank you.
>
> I have not really got any response other than yours.
>
> I have long before now included what I have in a paper submitted to a journal.
>
> I am awaiting the feedback of the reviewer. I will compare the
> comments with your input here and determine the corrections to make
> and probably return to the list for additional help.
>
> Best wishes
> Ogbos
>
> On Fri, Feb 8, 2019 at 4:31 PM Meyners, Michael  wrote:
> >
> > Ogbos,
> >
> > You do not seem to have received a reply over the list yet, which might be 
> > due to the fact that this seems rather a stats than an R question. Neither 
> > got your attachment (Figure) through - see posting guide.
> >
> > I'm not familiar with epoch analysis, so not sure what exactly you are 
> > doing / trying to achieve, but some general thoughts:
> >
> > * You do NOT want to restrict your re-randomizations in a way that "none of 
> > the dates corresponds with the ones in the real event" - actually, as a 
> > general principle, the true data must be an admissible re-randomization as 
> > well. You seem to have excluded that (and a lot of other randomizations at 
> > the same time which might have occurred, i.e. dates 1 and 2 reversed but 
> > all others the same), thereby rendering the test invalid. Any restrictions 
> > you have on your re-randomizations must've applied to the original 
> > randomization as well.
> > * If you have rather observational data (which I suspect, but not sure), 
> > Edgington & Onghena (2007) would rather refer to this as a permutation test 
> > - the difference being that you have to make strong assumptions (similar to 
> > parametric tests) on the nature of the data, which are designed-in to be 
> > true for randomization tests. It might be a merely linguistic 
> > discrimination, but it is important to note which assumptions have to be 
> > (implicitly) made.
> > * I'm not sure what you mean by "mean differences" of the events - is that 
> > two groups you are comparing? If so, that seems reasonable, but just make 
> > sure the test statistic you use is reasonable and sensitive against the 
> > alternatives you are mostly interested in. The randomization/permutation 
> > test will never proof that, e.g., means are significantly different, but 
> > only that there is SOME difference. By selecting the appropriate test 
> > statistic, you can influence what will pop up more easily and what not, but 
> > you can never be sure (unless you make strong assumptions about everything 
> > else, like in many parametric tests).
> > * For any test statistic, you would then determine the proportion of its 
> > values among the 5000 samples where it is as large or larger than the one 
> > observed (or as small or smaller, or either, depending on the nature of the 
> > test statistic and whether you aim for a one- or a two-sided test). That is 
> > your p value. If small enough, conclude significance. At least conceptually 
> > important: The observed test statistic is always part of the 
> > re-randomization (i.e. your 5000) - so you truly only do 4999 plus the one 
> > you observed. Otherwise the test may be more or less liberal. Your p value 
> > is hence no smaller than 1/n, where n is the total number of samples you 
> > looked at (including the observed one), a p value of 0 is not possible in 
> > randomization tests (nor in other tests, of course).
> >
> > I hope this is helpful, but you will need to go through these and refer to 
> > your own setup to check whether you adhered to the principles or not, which 
> > is impossible for me to judge based on the information provided (and I 
> > won't be able to look at excessive code to check either).
> >
> > Michael
> >
> > > -Original Message-
> > > From: R-help  On Behalf Of Ogbos Okike
> > > Sent: Montag, 28. Januar 2019 19:42
> > > To: r-help 
> > > Subject: [R] Randomization Test
> > >
> > > Dear Contributors,
> > >
> > > I conducting e

[R] Extending my code: RESOLVED

2019-02-16 Thread Ogbos Okike
Dear Jeff and Jim,
Thank you for sorting out this for me.
Replacing text(as.Date("2005-03-13"),5900,"b") with:
text(as.POSIXct(("2005-03-13 09:00:00"),5900,"b") resolved the problem.
Warmest regards
Ogbos
On Sun, Feb 17, 2019 at 3:05 AM Jim Lemon  wrote:
>
> Hi Ogbos,
> Remember that there is an underlying numeric representation of dates.
> as.Date assigns dates a number of days from an agreed origin
> (1970-01-01) while POSIX dates assign a number of seconds. If you plot
> in one system and then try to add points in another, it's not going to
> work.
>
> Jim
>
> On Sun, Feb 17, 2019 at 12:55 PM Ogbos Okike  wrote:
> >
> > Dear Jim,
> > Thank you and welcome back. It seems you have been away as you have not 
> > been responding to people's questions as before.
> >
> > I have just made a correction on my original question. Please have a look 
> > and check if I can still go the way u have suggested or if the correction 
> > would call for another approach.
> > Best regards
> > Ogbos
> >
> >
> > On Sun, Feb 17, 2019, 02:22 Jim Lemon  wrote:
> >>
> >> Hi Ogbos,
> >> It may be easier to use strptime:
> >>
> >> dta<-data.frame(year=rep(2005,5),month=rep("05",5),
> >>  day=c("01","06","11","16","21"),
> >>  hour=c(2,4,6,8,10),minute=rep(0,5),second=rep(0,5),value=1:5)
> >> dta$Ptime<-strptime(paste(paste(dta$year,dta$month,dta$day,sep="-"),
> >>  paste(dta$hour,dta$minute,dta$second,sep=":")),"%Y-%m-%d %H:%M:%S")
> >> plot(dta$Ptime,dta$value)
> >> text(strptime("2005-05-04 09:00:00","%Y-%m-%d %H:%M:%S"),4,"b")
> >>
> >> Jim
> >>
> >> > On February 16, 2019 1:08:38 PM PST, Ogbos Okike 
> >> >  wrote:
> >> > >Dear Jeff,
> >> > >One more problem please.
> >> > >
> >> > >When I used as.Date(ISOdate(dta$year, dta$month, dta$day,dta$hour)) to
> >> > >handle date, I could use text(as.Date("2005-03-13"),-9,"b") to label
> >> > >my plot.
> >> > >
> >> > >Now that I am using as.POSIXct(ISOdatetime(year,
> >> > >month,day,hour,0,0))), can you please tell me how to text "b" on the
> >> > >point corresponding with 1960-05-04 09:00:00 on my plot.
> >> > >
> >> > >Many thanks for your extra time.
> >> > >
> >> > >Best wishes
> >> > >Ogbos

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

2019-02-16 Thread Ogbos Okike
Dear Jeff,
My error please and sorry about that.

 Not "1960-05-04 09:00:00".
I meant to write as.Date("2005-03-13"),-9,"b") and "2005-03-13 09:00:00".
My problem is the additional time factor.

I can text anywhere on my plot when dealing with /mm/dd but I can't
handle the new /mm/dd/hh/mm/ss.

Thank you for your patience.

Best regards
Ogbos.

I have no idea how text(as.Date("2005-03-13"),-9,"b") would mark your plot
> anywhere near 1960-05-04 09:00:00. Perhaps someone else does. Or perhaps
> you can provide an actual minimal working example of what you had working
> before you changed to POSIXct.
>
> On February 16, 2019 1:08:38 PM PST, Ogbos Okike 
> wrote:
> >Dear Jeff,
> >One more problem please.
> >
> >When I used as.Date(ISOdate(dta$year, dta$month, dta$day,dta$hour)) to
> >handle date, I could use text(as.Date("2005-03-13"),-9,"b") to label
> >my plot.
> >
> >Now that I am using as.POSIXct(ISOdatetime(year,
> >month,day,hour,0,0))), can you please tell me how to text "b" on the
> >point corresponding with 1960-05-04 09:00:00 on my plot.
> >
> >Many thanks for your extra time.
> >
> >Best wishes
> >Ogbos
> >
> >On Fri, Feb 15, 2019 at 8:25 AM Ogbos Okike 
> >wrote:
> >>
> >> Dear Jeff,
> >>
> >> Please hold.
> >> It is begging to work. There was an error somewhere. One ")" is
> >> missing and as I went back to check the lines one by one with cursor,
> >> I stubbed on non matching bracket.
> >>
> >> I completed, run the code again and got some result.
> >>
> >> Will get back to you once I am through.
> >>
> >> Thanks in a hurry.
> >> Best regards
> >> Ogbos
> >>
> >>
> >> On Fri, Feb 15, 2019 at 8:15 AM Ogbos Okike
> > wrote:
> >> >
> >> > Dear Jeff,
> >> >
> >> > Thank you so much.
> >> >
> >> > I ran the code but got an error message. I then try to  run them
> >line by line.
> >> >
> >> > The problem is in:
> >> > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year,
> >month,day,hour,0,0)))
> >> > Error in with(dta, as.POSIXct(ISOdatetime(year, month, day, hour,
> >0, 0))) :
> >> >   object 'dta' not found
> >> >
> >> > Thanks for another time.
> >> > Best
> >> > Ogbos
> >> >
> >> > On Fri, Feb 15, 2019 at 7:51 AM Jeff Newmiller
> > wrote:
> >> > >
> >> > > The Date class is not designed to handle time... you need to use
> >the ISOdatetime function and convert to POSIXct instead of Date. Just
> >be sure to set your timezone to some appropriate value before you
> >convert any times into datetime types.
> >> > >
> >> > > Sys.setenv( TZ="GMT" )
> >> > > # avoid using `data` as that is the name of a base R function
> >> > > dta <- read.table("CALG.txt", col.names = c("year", "month",
> >"day", "hour", "counts"))
> >> > > dta$year <- with( dta, ifelse(year < 50, year + 2000, year +
> >1900)
> >> > > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year,
> >month,day,hour,0,0)))
> >> > >
> >> > > I don't see why you feel obliged to copy the timestamp out of the
> >data frame into x, but that is your business.
> >> > >
> >> > > Appropriate timezone values can be reviewed with the OlsonNames()
> >function.
> >> > >
> >> > >
> >> > > On February 14, 2019 10:29:58 PM PST, Ogbos Okike
> > wrote:
> >> > > >Dear List,
> >> > > >I have a simple code with which I convert year, month, and day
> >to a
> >> > > >date format.
> >> > > >My data looks like:
> >> > > >67 01 2618464
> >> > > >67 01 2618472
> >> > > >67 01 2618408
> >> > > >67 01 2618360
> >> > > >67 01 2618328
> >> > > >67 01 2618320
> >> > > >67 01 2618296
> >> > > >
> >> > > >while my code is:
> >> > > >
> >> > > >
> >> > > >data <- read.table("CALG.txt", col.names = c("year", "month",
> >&q

Re: [R] Extending my code

2019-02-16 Thread Ogbos Okike
Dear Jeff,
One more problem please.

When I used as.Date(ISOdate(dta$year, dta$month, dta$day,dta$hour)) to
handle date, I could use text(as.Date("2005-03-13"),-9,"b") to label
my plot.

Now that I am using as.POSIXct(ISOdatetime(year,
month,day,hour,0,0))), can you please tell me how to text "b" on the
point corresponding with 1960-05-04 09:00:00 on my plot.

Many thanks for your extra time.

Best wishes
Ogbos

On Fri, Feb 15, 2019 at 8:25 AM Ogbos Okike  wrote:
>
> Dear Jeff,
>
> Please hold.
> It is begging to work. There was an error somewhere. One ")" is
> missing and as I went back to check the lines one by one with cursor,
> I stubbed on non matching bracket.
>
> I completed, run the code again and got some result.
>
> Will get back to you once I am through.
>
> Thanks in a hurry.
> Best regards
> Ogbos
>
>
> On Fri, Feb 15, 2019 at 8:15 AM Ogbos Okike  wrote:
> >
> > Dear Jeff,
> >
> > Thank you so much.
> >
> > I ran the code but got an error message. I then try to  run them line by 
> > line.
> >
> > The problem is in:
> > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, 
> > month,day,hour,0,0)))
> > Error in with(dta, as.POSIXct(ISOdatetime(year, month, day, hour, 0, 0))) :
> >   object 'dta' not found
> >
> > Thanks for another time.
> > Best
> > Ogbos
> >
> > On Fri, Feb 15, 2019 at 7:51 AM Jeff Newmiller  
> > wrote:
> > >
> > > The Date class is not designed to handle time... you need to use the 
> > > ISOdatetime function and convert to POSIXct instead of Date. Just be sure 
> > > to set your timezone to some appropriate value before you convert any 
> > > times into datetime types.
> > >
> > > Sys.setenv( TZ="GMT" )
> > > # avoid using `data` as that is the name of a base R function
> > > dta <- read.table("CALG.txt", col.names = c("year", "month", "day", 
> > > "hour", "counts"))
> > > dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900)
> > > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, 
> > > month,day,hour,0,0)))
> > >
> > > I don't see why you feel obliged to copy the timestamp out of the data 
> > > frame into x, but that is your business.
> > >
> > > Appropriate timezone values can be reviewed with the OlsonNames() 
> > > function.
> > >
> > >
> > > On February 14, 2019 10:29:58 PM PST, Ogbos Okike 
> > >  wrote:
> > > >Dear List,
> > > >I have a simple code with which I convert year, month, and day to a
> > > >date format.
> > > >My data looks like:
> > > >67 01 2618464
> > > >67 01 2618472
> > > >67 01 2618408
> > > >67 01 2618360
> > > >67 01 2618328
> > > >67 01 2618320
> > > >67 01 2618296
> > > >
> > > >while my code is:
> > > >
> > > >
> > > >data <- read.table("CALG.txt", col.names = c("year", "month", "day",
> > > >"counts"))
> > > > new.century <- data$year < 50
> > > >data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
> > > >data$date <- as.Date(ISOdate(data$year, data$month, data$day))
> > > >x = data$date
> > > > y = data$counts
> > > >
> > > >I now wish to extend this code to be able to include hour for another
> > > >data of the format:
> > > >05 01 01 004009
> > > >05 01 01 013969
> > > >05 01 01 023946
> > > >05 01 01 033975
> > > >05 01 01 043960
> > > >05 01 01 053974
> > > >05 01 01 063971
> > > >05 01 01 073970
> > > >That is, I now would like to include hour in:
> > > >data <- read.table("CALG.txt", col.names = c("year", "month", "day",
> > > >"counts")).
> > > >
> > > >I am aware there are many other way of conversion but I have a
> > > >specific interest here. This code is a preamble to a larger code and
> > > >changing it to another format other than what I have will not be
> > > >compatible with the general code. Or will rather be difficult for me
> > > >to get another format fit into my main code.
> > > >

[R] Extending my code: SOLVED

2019-02-14 Thread Ogbos Okike
Dear Jeff,
I am alright now

Please accept my indebtedness!!!

Warmest regards
Ogbos
On Fri, Feb 15, 2019 at 8:25 AM Ogbos Okike  wrote:
>
> Dear Jeff,
>
> Please hold.
> It is begging to work. There was an error somewhere. One ")" is
> missing and as I went back to check the lines one by one with cursor,
> I stubbed on non matching bracket.
>
> I completed, run the code again and got some result.
>
> Will get back to you once I am through.
>
> Thanks in a hurry.
> Best regards
> Ogbos
>
>
> On Fri, Feb 15, 2019 at 8:15 AM Ogbos Okike  wrote:
> >
> > Dear Jeff,
> >
> > Thank you so much.
> >
> > I ran the code but got an error message. I then try to  run them line by 
> > line.
> >
> > The problem is in:
> > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, 
> > month,day,hour,0,0)))
> > Error in with(dta, as.POSIXct(ISOdatetime(year, month, day, hour, 0, 0))) :
> >   object 'dta' not found
> >
> > Thanks for another time.
> > Best
> > Ogbos
> >
> > On Fri, Feb 15, 2019 at 7:51 AM Jeff Newmiller  
> > wrote:
> > >
> > > The Date class is not designed to handle time... you need to use the 
> > > ISOdatetime function and convert to POSIXct instead of Date. Just be sure 
> > > to set your timezone to some appropriate value before you convert any 
> > > times into datetime types.
> > >
> > > Sys.setenv( TZ="GMT" )
> > > # avoid using `data` as that is the name of a base R function
> > > dta <- read.table("CALG.txt", col.names = c("year", "month", "day", 
> > > "hour", "counts"))
> > > dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900)
> > > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, 
> > > month,day,hour,0,0)))
> > >
> > > I don't see why you feel obliged to copy the timestamp out of the data 
> > > frame into x, but that is your business.
> > >
> > > Appropriate timezone values can be reviewed with the OlsonNames() 
> > > function.
> > >
> > >
> > > On February 14, 2019 10:29:58 PM PST, Ogbos Okike 
> > >  wrote:
> > > >Dear List,
> > > >I have a simple code with which I convert year, month, and day to a
> > > >date format.
> > > >My data looks like:
> > > >67 01 2618464
> > > >67 01 2618472
> > > >67 01 2618408
> > > >67 01 2618360
> > > >67 01 2618328
> > > >67 01 2618320
> > > >67 01 2618296
> > > >
> > > >while my code is:
> > > >
> > > >
> > > >data <- read.table("CALG.txt", col.names = c("year", "month", "day",
> > > >"counts"))
> > > > new.century <- data$year < 50
> > > >data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
> > > >data$date <- as.Date(ISOdate(data$year, data$month, data$day))
> > > >x = data$date
> > > > y = data$counts
> > > >
> > > >I now wish to extend this code to be able to include hour for another
> > > >data of the format:
> > > >05 01 01 004009
> > > >05 01 01 013969
> > > >05 01 01 023946
> > > >05 01 01 033975
> > > >05 01 01 043960
> > > >05 01 01 053974
> > > >05 01 01 063971
> > > >05 01 01 073970
> > > >That is, I now would like to include hour in:
> > > >data <- read.table("CALG.txt", col.names = c("year", "month", "day",
> > > >"counts")).
> > > >
> > > >I am aware there are many other way of conversion but I have a
> > > >specific interest here. This code is a preamble to a larger code and
> > > >changing it to another format other than what I have will not be
> > > >compatible with the general code. Or will rather be difficult for me
> > > >to get another format fit into my main code.
> > > >
> > > >So if you would be kind enough to assist me to run the read.table in
> > > >the format:
> > > >
> > > >data <- read.table("CALG.txt", col.names = c("year", "month",
> > > >"day","hour", "counts"))
> > > >
> > > >and then run the rest as:
> > > >
> > > >new.century <- data$year < 50
> > > >data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
> > > >data$date <- as.Date(ISOdate(data$year, data$month,
> > > >data$day,data$hour))
> > > >x = data$date
> > > >
> > > >such that year, month, day and hour will be stored in x,
> > > >
> > > >I will be very thankful.
> > > >
> > > >Thank you so much for your kind assistance.
> > > >Best regards
> > > >Ogbos
> > > >
> > > >__
> > > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > > >https://stat.ethz.ch/mailman/listinfo/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] Extending my code

2019-02-14 Thread Ogbos Okike
Dear Jeff,

Please hold.
It is begging to work. There was an error somewhere. One ")" is
missing and as I went back to check the lines one by one with cursor,
I stubbed on non matching bracket.

I completed, run the code again and got some result.

Will get back to you once I am through.

Thanks in a hurry.
Best regards
Ogbos


On Fri, Feb 15, 2019 at 8:15 AM Ogbos Okike  wrote:
>
> Dear Jeff,
>
> Thank you so much.
>
> I ran the code but got an error message. I then try to  run them line by line.
>
> The problem is in:
> dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, month,day,hour,0,0)))
> Error in with(dta, as.POSIXct(ISOdatetime(year, month, day, hour, 0, 0))) :
>   object 'dta' not found
>
> Thanks for another time.
> Best
> Ogbos
>
> On Fri, Feb 15, 2019 at 7:51 AM Jeff Newmiller  
> wrote:
> >
> > The Date class is not designed to handle time... you need to use the 
> > ISOdatetime function and convert to POSIXct instead of Date. Just be sure 
> > to set your timezone to some appropriate value before you convert any times 
> > into datetime types.
> >
> > Sys.setenv( TZ="GMT" )
> > # avoid using `data` as that is the name of a base R function
> > dta <- read.table("CALG.txt", col.names = c("year", "month", "day", "hour", 
> > "counts"))
> > dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900)
> > dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, 
> > month,day,hour,0,0)))
> >
> > I don't see why you feel obliged to copy the timestamp out of the data 
> > frame into x, but that is your business.
> >
> > Appropriate timezone values can be reviewed with the OlsonNames() function.
> >
> >
> > On February 14, 2019 10:29:58 PM PST, Ogbos Okike 
> >  wrote:
> > >Dear List,
> > >I have a simple code with which I convert year, month, and day to a
> > >date format.
> > >My data looks like:
> > >67 01 2618464
> > >67 01 2618472
> > >67 01 2618408
> > >67 01 2618360
> > >67 01 2618328
> > >67 01 2618320
> > >67 01 2618296
> > >
> > >while my code is:
> > >
> > >
> > >data <- read.table("CALG.txt", col.names = c("year", "month", "day",
> > >"counts"))
> > > new.century <- data$year < 50
> > >data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
> > >data$date <- as.Date(ISOdate(data$year, data$month, data$day))
> > >x = data$date
> > > y = data$counts
> > >
> > >I now wish to extend this code to be able to include hour for another
> > >data of the format:
> > >05 01 01 004009
> > >05 01 01 013969
> > >05 01 01 023946
> > >05 01 01 033975
> > >05 01 01 043960
> > >05 01 01 053974
> > >05 01 01 063971
> > >05 01 01 073970
> > >That is, I now would like to include hour in:
> > >data <- read.table("CALG.txt", col.names = c("year", "month", "day",
> > >"counts")).
> > >
> > >I am aware there are many other way of conversion but I have a
> > >specific interest here. This code is a preamble to a larger code and
> > >changing it to another format other than what I have will not be
> > >compatible with the general code. Or will rather be difficult for me
> > >to get another format fit into my main code.
> > >
> > >So if you would be kind enough to assist me to run the read.table in
> > >the format:
> > >
> > >data <- read.table("CALG.txt", col.names = c("year", "month",
> > >"day","hour", "counts"))
> > >
> > >and then run the rest as:
> > >
> > >new.century <- data$year < 50
> > >data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
> > >data$date <- as.Date(ISOdate(data$year, data$month,
> > >data$day,data$hour))
> > >x = data$date
> > >
> > >such that year, month, day and hour will be stored in x,
> > >
> > >I will be very thankful.
> > >
> > >Thank you so much for your kind assistance.
> > >Best regards
> > >Ogbos
> > >
> > >__
> > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > >https://stat.ethz.ch/mailman/listinfo/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] Extending my code

2019-02-14 Thread Ogbos Okike
Dear Jeff,

Thank you so much.

I ran the code but got an error message. I then try to  run them line by line.

The problem is in:
dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, month,day,hour,0,0)))
Error in with(dta, as.POSIXct(ISOdatetime(year, month, day, hour, 0, 0))) :
  object 'dta' not found

Thanks for another time.
Best
Ogbos

On Fri, Feb 15, 2019 at 7:51 AM Jeff Newmiller  wrote:
>
> The Date class is not designed to handle time... you need to use the 
> ISOdatetime function and convert to POSIXct instead of Date. Just be sure to 
> set your timezone to some appropriate value before you convert any times into 
> datetime types.
>
> Sys.setenv( TZ="GMT" )
> # avoid using `data` as that is the name of a base R function
> dta <- read.table("CALG.txt", col.names = c("year", "month", "day", "hour", 
> "counts"))
> dta$year <- with( dta, ifelse(year < 50, year + 2000, year + 1900)
> dta$datetime <- with( dta, as.POSIXct(ISOdatetime(year, month,day,hour,0,0)))
>
> I don't see why you feel obliged to copy the timestamp out of the data frame 
> into x, but that is your business.
>
> Appropriate timezone values can be reviewed with the OlsonNames() function.
>
>
> On February 14, 2019 10:29:58 PM PST, Ogbos Okike  
> wrote:
> >Dear List,
> >I have a simple code with which I convert year, month, and day to a
> >date format.
> >My data looks like:
> >67 01 2618464
> >67 01 2618472
> >67 01 2618408
> >67 01 2618360
> >67 01 2618328
> >67 01 2618320
> >67 01 2618296
> >
> >while my code is:
> >
> >
> >data <- read.table("CALG.txt", col.names = c("year", "month", "day",
> >"counts"))
> > new.century <- data$year < 50
> >data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
> >data$date <- as.Date(ISOdate(data$year, data$month, data$day))
> >x = data$date
> > y = data$counts
> >
> >I now wish to extend this code to be able to include hour for another
> >data of the format:
> >05 01 01 004009
> >05 01 01 013969
> >05 01 01 023946
> >05 01 01 033975
> >05 01 01 043960
> >05 01 01 053974
> >05 01 01 063971
> >05 01 01 073970
> >That is, I now would like to include hour in:
> >data <- read.table("CALG.txt", col.names = c("year", "month", "day",
> >"counts")).
> >
> >I am aware there are many other way of conversion but I have a
> >specific interest here. This code is a preamble to a larger code and
> >changing it to another format other than what I have will not be
> >compatible with the general code. Or will rather be difficult for me
> >to get another format fit into my main code.
> >
> >So if you would be kind enough to assist me to run the read.table in
> >the format:
> >
> >data <- read.table("CALG.txt", col.names = c("year", "month",
> >"day","hour", "counts"))
> >
> >and then run the rest as:
> >
> >new.century <- data$year < 50
> >data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
> >data$date <- as.Date(ISOdate(data$year, data$month,
> >data$day,data$hour))
> >x = data$date
> >
> >such that year, month, day and hour will be stored in x,
> >
> >I will be very thankful.
> >
> >Thank you so much for your kind assistance.
> >Best regards
> >Ogbos
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/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] Extending my code

2019-02-14 Thread Ogbos Okike
Dear List,
I have a simple code with which I convert year, month, and day to a date format.
My data looks like:
67 01 2618464
67 01 2618472
67 01 2618408
67 01 2618360
67 01 2618328
67 01 2618320
67 01 2618296

while my code is:


data <- read.table("CALG.txt", col.names = c("year", "month", "day", "counts"))
 new.century <- data$year < 50
data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x = data$date
 y = data$counts

I now wish to extend this code to be able to include hour for another
data of the format:
05 01 01 004009
05 01 01 013969
05 01 01 023946
05 01 01 033975
05 01 01 043960
05 01 01 053974
05 01 01 063971
05 01 01 073970
That is, I now would like to include hour in:
data <- read.table("CALG.txt", col.names = c("year", "month", "day", "counts")).

I am aware there are many other way of conversion but I have a
specific interest here. This code is a preamble to a larger code and
changing it to another format other than what I have will not be
compatible with the general code. Or will rather be difficult for me
to get another format fit into my main code.

So if you would be kind enough to assist me to run the read.table in the format:

data <- read.table("CALG.txt", col.names = c("year", "month",
"day","hour", "counts"))

and then run the rest as:

new.century <- data$year < 50
data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
data$date <- as.Date(ISOdate(data$year, data$month, data$day,data$hour))
x = data$date

such that year, month, day and hour will be stored in x,

I will be very thankful.

Thank you so much for your kind assistance.
Best regards
Ogbos

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

2019-02-10 Thread Ogbos Okike
Dear Michael,
This is great! Thank you.

I have not really got any response other than yours.

I have long before now included what I have in a paper submitted to a journal.

I am awaiting the feedback of the reviewer. I will compare the
comments with your input here and determine the corrections to make
and probably return to the list for additional help.

Best wishes
Ogbos

On Fri, Feb 8, 2019 at 4:31 PM Meyners, Michael  wrote:
>
> Ogbos,
>
> You do not seem to have received a reply over the list yet, which might be 
> due to the fact that this seems rather a stats than an R question. Neither 
> got your attachment (Figure) through - see posting guide.
>
> I'm not familiar with epoch analysis, so not sure what exactly you are doing 
> / trying to achieve, but some general thoughts:
>
> * You do NOT want to restrict your re-randomizations in a way that "none of 
> the dates corresponds with the ones in the real event" - actually, as a 
> general principle, the true data must be an admissible re-randomization as 
> well. You seem to have excluded that (and a lot of other randomizations at 
> the same time which might have occurred, i.e. dates 1 and 2 reversed but all 
> others the same), thereby rendering the test invalid. Any restrictions you 
> have on your re-randomizations must've applied to the original randomization 
> as well.
> * If you have rather observational data (which I suspect, but not sure), 
> Edgington & Onghena (2007) would rather refer to this as a permutation test - 
> the difference being that you have to make strong assumptions (similar to 
> parametric tests) on the nature of the data, which are designed-in to be true 
> for randomization tests. It might be a merely linguistic discrimination, but 
> it is important to note which assumptions have to be (implicitly) made.
> * I'm not sure what you mean by "mean differences" of the events - is that 
> two groups you are comparing? If so, that seems reasonable, but just make 
> sure the test statistic you use is reasonable and sensitive against the 
> alternatives you are mostly interested in. The randomization/permutation test 
> will never proof that, e.g., means are significantly different, but only that 
> there is SOME difference. By selecting the appropriate test statistic, you 
> can influence what will pop up more easily and what not, but you can never be 
> sure (unless you make strong assumptions about everything else, like in many 
> parametric tests).
> * For any test statistic, you would then determine the proportion of its 
> values among the 5000 samples where it is as large or larger than the one 
> observed (or as small or smaller, or either, depending on the nature of the 
> test statistic and whether you aim for a one- or a two-sided test). That is 
> your p value. If small enough, conclude significance. At least conceptually 
> important: The observed test statistic is always part of the re-randomization 
> (i.e. your 5000) - so you truly only do 4999 plus the one you observed. 
> Otherwise the test may be more or less liberal. Your p value is hence no 
> smaller than 1/n, where n is the total number of samples you looked at 
> (including the observed one), a p value of 0 is not possible in randomization 
> tests (nor in other tests, of course).
>
> I hope this is helpful, but you will need to go through these and refer to 
> your own setup to check whether you adhered to the principles or not, which 
> is impossible for me to judge based on the information provided (and I won't 
> be able to look at excessive code to check either).
>
> Michael
>
> > -Original Message-
> > From: R-help  On Behalf Of Ogbos Okike
> > Sent: Montag, 28. Januar 2019 19:42
> > To: r-help 
> > Subject: [R] Randomization Test
> >
> > Dear Contributors,
> >
> > I conducting epoch analysis. I tried to test the significance of my result 
> > using
> > randomization test.
> >
> > Since I have 71 events, I randomly selected another 71 events, making sure
> > that none of the dates in the random events corresponds with the ones in
> > the real event.
> >
> > Following the code I found here
> > (https://www.uvm.edu/~dhowell/StatPages/R/RandomizationTestsWithR/R
> > andom2Sample/TwoIndependentSamplesR.html),
> > I combined these two data set and used them to generate another 5000
> > events. I then plotted the graph of the mean differences for the 5000
> > randomly generated events. On the graph, I indicated the region of the
> > mean difference between the real 71 epoch and the randomly selected 71
> > epoch.
> >
> > Since the two tail test shows that the mean difference falls at the e

[R] Randomization Test

2019-01-28 Thread Ogbos Okike
Dear Contributors,

I conducting epoch analysis. I tried to test the significance of my
result using randomization test.

Since I have 71 events, I randomly selected another 71 events, making
sure that none of the dates in the random events corresponds with the
ones in the real event.

Following the code I found here
(https://www.uvm.edu/~dhowell/StatPages/R/RandomizationTestsWithR/Random2Sample/TwoIndependentSamplesR.html),
I combined these two data set and used them to generate another 5000
events. I then plotted the graph of the mean differences for the 5000
randomly generated events. On the graph, I indicated the region of the
mean difference between the real 71 epoch and the randomly selected 71
epoch.

Since the two tail test shows that the mean difference falls at the
extreme of the randomly selected events, I concluded that my result is
statistically significant.



I am attaching the graph to assistance you in you suggestions.

I can attach both my code and the real and randomly generated events
if you ask for it.

My request is that you help me to understand if I am on the right
track or no. This is the first time I am doing this and except the
experts decide, I am not quite sure whether I am right or not.

Many thanks for your kind concern.

Best
Ogbos
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Plotting Very Large lat-lon data in x-y axes graph: SOLVED

2018-12-14 Thread Ogbos Okike
Dear Jim,
Good news to me!! Welcome.

I am fine. The code elegantly displayed the color.

I also tried to adjust the line:
draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon])/100,
border=countcol[lat,lon],col=countcol[lat,lon]) in order to reduce
the radius of the circle in order to plot the whole data.

I am really really grateful. I will immediately include the result in
a draft manuscript to Astrophysical Journal.

With the warmest regards
Ogbos

On Thu, Dec 13, 2018 at 9:04 PM Jim Lemon  wrote:
>
> Hi Ogbos,
> Back on the air after a few days off. I don't have your data ("QUERY
> 2"), but I think this will fix your problem.
>
> library(maps)
> map("world")
> box()
> library(plotrix)
> color.legend(-180,-150,100,-130,legend=c(0,25000,5,75000,10),
>  rect.col=color.scale(1:5,extremes=c("blue","red")),gradient="x")
>
> Notice that I have swapped the "yb" and "yt" values so that they are
> in increasing order. If they are reversed, the numbers will appear
> within the color bar. Also you don't need to call color.gradient, just
> pass the output of a five increment color scale from blue to red (or
> whatever you like) to the rect.col argument.
>
> Jim

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Plotting Very Large lat-lon data in x-y axes graph

2018-12-11 Thread Ogbos Okike
Dear All,

Thank you for your advice.

I have looked at the plotrix package and with what I gathered, I
tinkered with the code below and obtain the attached graph:
oolt<-read.table("QUERY2",col.names=c("Lat","Lon"))
 latlim<-c(20,45)
lonlim<-c(-180,180)
latbreaks<-seq(latlim[1],latlim[2],by=5)
lonbreaks<-seq(lonlim[1],lonlim[2],by=10)

mids<-function(x) {
 lenx<-length(x)
 return((x[1:(lenx-1)]+x[2:lenx])/2)
}
lonmids<-mids(lonbreaks)
latmids<-mids(latbreaks)
oolt$loncuts<-cut(oolt$Lon,lonbreaks)
oolt$latcuts<-cut(oolt$Lat,latbreaks)
counts<-table(oolt$latcuts,oolt$loncuts)
png("test.png")
library(plotrix)
countcol<-color.scale(counts,extremes=c("blue","red"))
library(maps)
map("world",xlim=c(-180,180),ylim=c(20,45))
w = map("world")
for(lon in 1:length(lonmids)) {
 for(lat in 1:length(latmids)) {
  if(counts[lat,lon] > 0)
   draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]),
border=countcol[lat,lon],col=countcol[lat,lon])
 }
}
box()
axis(1)
axis(2)
 x<-seq(-180,180,30)
 y<-seq(-90,90,30)
nx = 12
 ny = 6
grid(nx,ny,col = "red",lty="dotted",lwd=par("lwd"),equilogs=TRUE)
testcol<-color.gradient(c(10,30),0,c(30,10),nslices=5)
color.legend(-180,-130,100,-150,countcol,testcol,gradient="x")

I now have the horizontal color legend.

But I have two major problems still.
(1) The black line on top of the color bar is meaningless and I want it go.
(2) I want the numerical values plotted to appear on the color bar
(see the color.legend.png attached please) such that it can be used to
interpret the map.

I would be most grateful for any further assistance.

Very best wishes
Ogbos
On Tue, Dec 11, 2018 at 11:14 AM Jim Lemon  wrote:
>
> Hi Ogbos,
> I have been off the air for a couple of days. Look at the color.legend
> function in the plotrix package.
>
> Jim
> On Tue, Dec 11, 2018 at 12:39 PM Ogbos Okike  wrote:
> >
> > Dear Jim,
> > I am still having trouble with the colour code. I await your help when
> > you are less busy.
> >
> > Thank you.
> > Best
> > Ogbos
> > On Mon, Dec 10, 2018 at 6:25 AM Ogbos Okike  
> > wrote:
> > >
> > > Dear Jim,
> > >
> > > I used a bit of my data in my attempt to follow the code.
> > >
> > > I got the attached plot after some tweaks.
> > >
> > > I would like to add horizontal color bar legend that could be used to
> > > explain the number of lightning counts at different points on the
> > > latitude band as plotted.
> > >
> > > Thank you
> > > Warm regards
> > > Ogbos
> > >
> > > On Sun, Dec 9, 2018 at 9:46 PM Jim Lemon  wrote:
> > > >
> > > > Hi Ogbos,
> > > > Here is a slight modification of a method I use to display trip
> > > > density on a map:
> > > >
> > > > oolt<-read.table(text="Lat Lon
> > > > 30.1426 104.7854
> > > > 30.5622 105.0837
> > > > 30.0966 104.6213
> > > > 29.9795 104.8430
> > > > 39.2802 147.7295
> > > > 30.2469 104.6543
> > > > 26.4428 157.7293
> > > > 29.4782 104.5590
> > > > 32.3839 105.3293
> > > > 26.4746 157.8411
> > > > 25.1014 159.6959
> > > > 25.1242 159.6558
> > > > 30.1607 104.9100
> > > > 31.4900 -71.8919
> > > > 43.3655 -74.9994
> > > > 30.0811 104.8462
> > > > 29.0912 -85.5138
> > > > 26.6204 -80.9342
> > > > 31.5462 -71.9638
> > > > 26.8619 97.3844
> > > > 30.2534 104.6134
> > > > 29.9311 -85.3434
> > > > 26.1524 159.6806
> > > > 26.5112 158.0233
> > > > 26.5441 158.0565
> > > > 27.8901 -105.8554
> > > > 30.3175 104.7135
> > > > 26.4822 157.6127
> > > > 30.1887 104.5986
> > > > 29.5058 104.5661
> > > > 26.4010 157.5749
> > > > 30.2281 104.7585
> > > > 31.4556 110.5619
> > > > 30.1700 104.5861
> > > > 26.3911 157.4776
> > > > 30.6493 104.9949
> > > > 30.2209 104.6629
> > > > 26.0488 97.3608
> > > > 30.2142 104.8023
> > > > 30.1806 104.8158
> > > > 25.2107 160.1690
> > > > 30.6708 104.9385
> > > > 30.4152 104.7002
> > > > 30.2446 104.7804
> > > > 29.5760 -85.1535
> > > > 26.4484 92.4312
> > > > 26.3914 157.4189
> > > > 26.3986 157.4421
> > > > 30.4903 -88.2271
> > > > 3

Re: [R] Plotting Very Large lat-lon data in x-y axes graph

2018-12-09 Thread Ogbos Okike
Dear Jim,

I used a bit of my data in my attempt to follow the code.

I got the attached plot after some tweaks.

I would like to add horizontal color bar legend that could be used to
explain the number of lightning counts at different points on the
latitude band as plotted.

Thank you
Warm regards
Ogbos

On Sun, Dec 9, 2018 at 9:46 PM Jim Lemon  wrote:
>
> Hi Ogbos,
> Here is a slight modification of a method I use to display trip
> density on a map:
>
> oolt<-read.table(text="Lat Lon
> 30.1426 104.7854
> 30.5622 105.0837
> 30.0966 104.6213
> 29.9795 104.8430
> 39.2802 147.7295
> 30.2469 104.6543
> 26.4428 157.7293
> 29.4782 104.5590
> 32.3839 105.3293
> 26.4746 157.8411
> 25.1014 159.6959
> 25.1242 159.6558
> 30.1607 104.9100
> 31.4900 -71.8919
> 43.3655 -74.9994
> 30.0811 104.8462
> 29.0912 -85.5138
> 26.6204 -80.9342
> 31.5462 -71.9638
> 26.8619 97.3844
> 30.2534 104.6134
> 29.9311 -85.3434
> 26.1524 159.6806
> 26.5112 158.0233
> 26.5441 158.0565
> 27.8901 -105.8554
> 30.3175 104.7135
> 26.4822 157.6127
> 30.1887 104.5986
> 29.5058 104.5661
> 26.4010 157.5749
> 30.2281 104.7585
> 31.4556 110.5619
> 30.1700 104.5861
> 26.3911 157.4776
> 30.6493 104.9949
> 30.2209 104.6629
> 26.0488 97.3608
> 30.2142 104.8023
> 30.1806 104.8158
> 25.2107 160.1690
> 30.6708 104.9385
> 30.4152 104.7002
> 30.2446 104.7804
> 29.5760 -85.1535
> 26.4484 92.4312
> 26.3914 157.4189
> 26.3986 157.4421
> 30.4903 -88.2271
> 30.6727 104.8768
> 30.2518 104.6466
> 41.6979 -78.4136
> 33.7575 72.1089
> 26.8333 -80.9485
> 25.3103 124.0978
> 30.1742 104.7554
> 30.6345 104.9739
> 30.2075 104.7960
> 30.2226 104.7517
> 30.5948 105.0532",
> header=TRUE)
> latlim<-c(20,45)
> lonlim<-c(-90,160)
> latbreaks<-seq(latlim[1],latlim[2],by=5)
> lonbreaks<-seq(lonlim[1],lonlim[2],by=10)
>
> mids<-function(x) {
>  lenx<-length(x)
>  return((x[1:(lenx-1)]+x[2:lenx])/2)
> }
> lonmids<-mids(lonbreaks)
> latmids<-mids(latbreaks)
> oolt$loncuts<-cut(oolt$Lon,lonbreaks)
> oolt$latcuts<-cut(oolt$Lat,latbreaks)
> counts<-table(oolt$latcuts,oolt$loncuts)
> library(plotrix)
> countcol<-color.scale(counts,extremes=c("blue","red"))
> map("world",xlim=c(-90,160),ylim=c(20,45))
> for(lon in 1:length(lonmids)) {
>  for(lat in 1:length(latmids)) {
>   if(counts[lat,lon] > 0)
>draw.circle(lonmids[lon],latmids[lat],radius=sqrt(counts[lat,lon]),
> border=countcol[lat,lon],col=countcol[lat,lon])
>  }
> }
>
> If you have very large counts in some places you may need to adjust
> the radius of the circles.
>
> Jim
> On Mon, Dec 10, 2018 at 2:50 AM Ogbos Okike  wrote:
> >
> > Dear Contributors,
> >
> > I have a data of the form:
> > Lat  Lon
> > 30.1426 104.7854
> > 30.5622 105.0837
> > 30.0966 104.6213
> > 29.9795 104.8430
> > 39.2802 147.7295
> > 30.2469 104.6543
> > 26.4428 157.7293
> > 29.4782 104.5590
> > 32.3839 105.3293
> > 26.4746 157.8411
> > 25.1014 159.6959
> > 25.1242 159.6558
> > 30.1607 104.9100
> > 31.4900 -71.8919
> > 43.3655 -74.9994
> > 30.0811 104.8462
> > 29.0912 -85.5138
> > 26.6204 -80.9342
> > 31.5462 -71.9638
> > 26.8619 97.3844
> > 30.2534 104.6134
> > 29.9311 -85.3434
> > 26.1524 159.6806
> > 26.5112 158.0233
> > 26.5441 158.0565
> > 27.8901 -105.8554
> > 30.3175 104.7135
> > 26.4822 157.6127
> > 30.1887 104.5986
> > 29.5058 104.5661
> > 26.4010 157.5749
> > 30.2281 104.7585
> > 31.4556 110.5619
> > 30.1700 104.5861
> > 26.3911 157.4776
> > 30.6493 104.9949
> > 30.2209 104.6629
> > 26.0488 97.3608
> > 30.2142 104.8023
> > 30.1806 104.8158
> > 25.2107 160.1690
> > 30.6708 104.9385
> > 30.4152 104.7002
> > 30.2446 104.7804
> > 29.5760 -85.1535
> > 26.4484 92.4312
> > 26.3914 157.4189
> > 26.3986 157.4421
> > 30.4903 -88.2271
> > 30.6727 104.8768
> > 30.2518 104.6466
> > 41.6979 -78.4136
> > 33.7575 72.1089
> > 26.8333 -80.9485
> > 25.3103 124.0978
> > 30.1742 104.7554
> > 30.6345 104.9739
> > 30.2075 104.7960
> > 30.2226 104.7517
> > 30.5948 105.0532.
> > The record is for lightning flashes in the continental U.S. and
> > surrounding waters within the latitudinal band between
> > 258 and 458N.
> >
> > I want to display the result in x-y co-ordinate plot. However, the
> > data is very large such that when plotted, everything just appeared
> > b

[R] Plotting Very Large lat-lon data in x-y axes graph

2018-12-09 Thread Ogbos Okike
Dear Contributors,

I have a data of the form:
Lat  Lon
30.1426 104.7854
30.5622 105.0837
30.0966 104.6213
29.9795 104.8430
39.2802 147.7295
30.2469 104.6543
26.4428 157.7293
29.4782 104.5590
32.3839 105.3293
26.4746 157.8411
25.1014 159.6959
25.1242 159.6558
30.1607 104.9100
31.4900 -71.8919
43.3655 -74.9994
30.0811 104.8462
29.0912 -85.5138
26.6204 -80.9342
31.5462 -71.9638
26.8619 97.3844
30.2534 104.6134
29.9311 -85.3434
26.1524 159.6806
26.5112 158.0233
26.5441 158.0565
27.8901 -105.8554
30.3175 104.7135
26.4822 157.6127
30.1887 104.5986
29.5058 104.5661
26.4010 157.5749
30.2281 104.7585
31.4556 110.5619
30.1700 104.5861
26.3911 157.4776
30.6493 104.9949
30.2209 104.6629
26.0488 97.3608
30.2142 104.8023
30.1806 104.8158
25.2107 160.1690
30.6708 104.9385
30.4152 104.7002
30.2446 104.7804
29.5760 -85.1535
26.4484 92.4312
26.3914 157.4189
26.3986 157.4421
30.4903 -88.2271
30.6727 104.8768
30.2518 104.6466
41.6979 -78.4136
33.7575 72.1089
26.8333 -80.9485
25.3103 124.0978
30.1742 104.7554
30.6345 104.9739
30.2075 104.7960
30.2226 104.7517
30.5948 105.0532.
The record is for lightning flashes in the continental U.S. and
surrounding waters within the latitudinal band between
258 and 458N.

I want to display the result in x-y co-ordinate plot. However, the
data is very large such that when plotted, everything just appeared
blurred.


Is there a way of using color codes to  indicate the regions of higher
or lower flash densities?

I can attach the plot I generated but I am not sure if the moderator
will allow it to go with this.

I will send it in a separate email if required.

Thank you so much for sparing your time.

Best
Ogbos

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Correct x-axis of two in one graph

2018-11-30 Thread Ogbos Okike
Dear Petr,

Great!!! It worked. The years are interestingly displayed.

Please one thing more. I want all the data points represented by lines
only and not points. I tried to change type = type to type="l". But it
did work.

Thanks for more assistance.

Ogbos
On Fri, Nov 30, 2018 at 9:24 AM PIKAL Petr  wrote:
>
> Hi
>
> You cannot expect any code to give you results precisely according to your 
> wishes just out of the box.
>
> You could modify x axis by changing format parameter. It is preset to = 
> "%d/%m",so you could change it to "%Y", if you want to display only year.
>
> format parameter goes to this line in my code.
>
> axis(1, at = x[seq(1, l, length = length)], labels = 
> format(as.POSIXct(x[seq(1,  l, length = length)]), format = format))
>
> The code actually has several other parameters which you could modify or you 
> are free to modify the code itself.
>
> Cheers
> Petr
>
> > -Original Message-
> > From: Ogbos Okike 
> > Sent: Thursday, November 29, 2018 5:17 PM
> > To: PIKAL Petr 
> > Cc: r-help 
> > Subject: Re: [R] Correct x-axis of two in one graph
> >
> > Dear Petr,
> >
> > Thank you so much for your contribution.
> >
> > Let me show you what I have please.
> >
> > I am attaching two plots. The first (twoineone) is my own while the second
> > (testrun) is plotted with the code you send.
> >
> > The first is closer to my interest. The major problem I have is the date. 
> > Those
> > were set arbitrary with:
> > axis(side=1,at=c(1,400,800,1200,1500),labels=c("2004","2005","2006","2007",
> > "2008"))
> > and they seem not to be correct.
> >
> > The second one does not show date and date is very important to me here.
> >
> > Is there a way your code can implement the correct date on x-axis? I would 
> > be
> > very glad for further assistance.
> >
> > Thank you again.
> > Best wishes
> > Ogbos
> > On Thu, Nov 29, 2018 at 3:03 PM PIKAL Petr  wrote:
> > >
> > > Hi
> > >
> > > If I understand correctly you want Li and CR appear in one plot with the 
> > > same
> > x axis. Although it is not usually recommended you could use twoord.plot 
> > from
> > plotrix or undocumented code below.
> > >
> > > plot.yy <- function (x, yright, yleft, yleftlim = NULL, yrightlim = NULL, 
> > >   xlab =
> > NULL, yylab = list(NA, NA), pch = c(1, 2), col = c(1,2), linky = F, 
> > smooth = 0,
> > lwds = 1, length = 10, format = "%d/%m",rect = NULL, type = "p", ...)
> > > {
> > > par(mar = c(5, 4, 4, 2), oma = c(0, 0, 0, 3))
> > > plot(x, yright, ylim = yrightlim, axes = F, ylab = "", xlab = xlab,  
> > > pch = pch[1],
> > col = col[1], type = type, ...)
> > > if (!is.null(rect))
> > > rect(x[rect[1]], rect[2], x[rect[3]], rect[4], col = "grey")
> > > points(x, yright, ylim = yrightlim, ylab = "", xlab = xlab, pch = 
> > > pch[1], col =
> > col[1], ...)
> > > axis(4, pretty(range(yright, na.rm = T), 10), col = col[1])
> > > if (linky)
> > > lines(x, yright, col = col[1], ...)
> > > if (smooth != 0)
> > > lines(supsmu(x, yright, span = smooth), col = col[1],   lwd = 
> > > lwds, ...)
> > > if (is.na(yylab[[1]]))
> > > mtext(deparse(substitute(yright)), side = 4, outer = T,   line = 
> > > 1, col =
> > col[1], ...)  else mtext(yylab[[1]], side = 4, outer = T, line = 1, col = 
> > col[1],...)
> > > par(new = T)
> > > plot(x, yleft, ylim = yleftlim, ylab = "", axes = F, xlab = xlab,
> > > pch = pch[2], col = col[2], ...)
> > > box()
> > > axis(2, pretty(range(yleft, na.rm = T), 10), col = col[2],
> > > col.axis = col[2])
> > > if (!inherits(x, c("Date", "POSIXt")))
> > > axis(1, pretty(range(x, na.rm = T), 10))
> > >     else {
> > > l <- length(x)
> > > axis(1, at = x[seq(1, l, length = length)], labels =
> > format(as.POSIXct(x[seq(1,  l, length = length)]), format = format))
> > > }
> > > if (is.na(yylab[[2]]))
> > > mtext(deparse(substitute(yleft)), side = 2, line = 2,   col = 
> > > col[2], ...)
> > > else mtext(yylab[[2]], side = 2, line = 2, col = col[2],...)
> > > if (linky)
>

Re: [R] Correct x-axis of two in one graph

2018-11-29 Thread Ogbos Okike
Dear Petr,

Thank you so much for your contribution.

Let me show you what I have please.

I am attaching two plots. The first (twoineone) is my own while the
second (testrun) is plotted with the code you send.

The first is closer to my interest. The major problem I have is the
date. Those were set arbitrary with:
axis(side=1,at=c(1,400,800,1200,1500),labels=c("2004","2005","2006","2007","2008"))
and they seem not to be correct.

The second one does not show date and date is very important to me here.

Is there a way your code can implement the correct date on x-axis? I
would be very glad for further assistance.

Thank you again.
Best wishes
Ogbos
On Thu, Nov 29, 2018 at 3:03 PM PIKAL Petr  wrote:
>
> Hi
>
> If I understand correctly you want Li and CR appear in one plot with the same 
> x axis. Although it is not usually recommended you could use twoord.plot from 
> plotrix or undocumented code below.
>
> plot.yy <- function (x, yright, yleft, yleftlim = NULL, yrightlim = NULL,   
> xlab = NULL, yylab = list(NA, NA), pch = c(1, 2), col = c(1,2), linky = 
> F, smooth = 0, lwds = 1, length = 10, format = "%d/%m",rect = NULL, type 
> = "p", ...)
> {
> par(mar = c(5, 4, 4, 2), oma = c(0, 0, 0, 3))
> plot(x, yright, ylim = yrightlim, axes = F, ylab = "", xlab = xlab,  pch 
> = pch[1], col = col[1], type = type, ...)
> if (!is.null(rect))
> rect(x[rect[1]], rect[2], x[rect[3]], rect[4], col = "grey")
> points(x, yright, ylim = yrightlim, ylab = "", xlab = xlab, pch = pch[1], 
> col = col[1], ...)
> axis(4, pretty(range(yright, na.rm = T), 10), col = col[1])
> if (linky)
> lines(x, yright, col = col[1], ...)
> if (smooth != 0)
> lines(supsmu(x, yright, span = smooth), col = col[1],   lwd = lwds, 
> ...)
> if (is.na(yylab[[1]]))
> mtext(deparse(substitute(yright)), side = 4, outer = T,   line = 1, 
> col = col[1], ...)  else mtext(yylab[[1]], side = 4, outer = T, line = 1, col 
> = col[1],...)
> par(new = T)
> plot(x, yleft, ylim = yleftlim, ylab = "", axes = F, xlab = xlab,
> pch = pch[2], col = col[2], ...)
> box()
> axis(2, pretty(range(yleft, na.rm = T), 10), col = col[2],
> col.axis = col[2])
> if (!inherits(x, c("Date", "POSIXt")))
> axis(1, pretty(range(x, na.rm = T), 10))
> else {
> l <- length(x)
> axis(1, at = x[seq(1, l, length = length)], labels = 
> format(as.POSIXct(x[seq(1,  l, length = length)]), format = format))
> }
> if (is.na(yylab[[2]]))
> mtext(deparse(substitute(yleft)), side = 2, line = 2,   col = col[2], 
> ...)
> else mtext(yylab[[2]], side = 2, line = 2, col = col[2],...)
> if (linky)
> lines(x, yleft, col = col[2], lty = 2, ...)
> if (smooth != 0)
> lines(supsmu(x, yleft, span = smooth), col = col[2],lty = 2, lwd 
> = lwds, ...)
> }
>
> something like
>
> plot.yy(Year, Li, CR)
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help  On Behalf Of Ogbos Okike
> > Sent: Thursday, November 29, 2018 2:33 PM
> > To: r-help 
> > Subject: [R] Correct x-axis of two in one graph
> >
> > Dear Contributors,
> >
> > I have a data of the form:
> > 4 8 10 8590 12516
> > 4 8 11 8641 98143
> > 4 8 12 8705 98916
> > 4 8 13 8750 89911
> > 4 8 14 8685 104835
> > 4 8 15 8629 121963
> > 4 8 16 8676 77655
> > 4 8 17 8577 81081
> > 4 8 18 8593 83385
> > 4 8 19 8642 112164
> > 4 8 20 8708 103684
> > 4 8 21 8622 83982
> > 4 8 22 8593 75944
> > 4 8 23 8600 97036
> > 4 8 24 8650 104911
> > 4 8 25 8730 114098
> > 4 8 26 8731 99421
> > 4 8 27 8715 85707
> > 4 8 28 8717 81273
> > 4 8 29 8739 106462
> > 4 8 30 8684 110635
> > 4 8 31 8713 105214
> > 4 9 1 8771 92456
> > 4 9 2 8759 109270
> > 4 9 3 8762 99150
> > 4 9 4 8730 77306
> > 4 9 5 8780 86324
> > 4 9 6 8804 90214
> > 4 9 7 8797 99894
> > 4 9 8 8863 95177
> > 4 9 9 8873 95910
> > 4 9 10 8827 108511
> > 4 9 11 8806 115636
> > 4 9 12 8869 85542
> > 4 9 13 8854 111018
> > 4 9 14 8571 93247
> > 4 9 15 8533 85105
> > 4 9 16 8553 114725
> > 4 9 17 8561 122195
> > 4 9 18 8532 100945
> > 4 9 19 8560 108552
> > 4 9 20 8634 108707
> > 4 9 21 8646 117420
> > 4 9 22 8633 113823
> > 4 9 23 8680 82763
> > 4 9 24 8765 121072
> > 4 9 25 8756 89835
> > 4 9 26 8750 104578
> > 4 9 27 8790 88429
> > 4 9 28 8824 84022
>

[R] Correct x-axis of two in one graph

2018-11-29 Thread Ogbos Okike
Dear Contributors,

I have a data of the form:
4 8 10 8590 12516
4 8 11 8641 98143
4 8 12 8705 98916
4 8 13 8750 89911
4 8 14 8685 104835
4 8 15 8629 121963
4 8 16 8676 77655
4 8 17 8577 81081
4 8 18 8593 83385
4 8 19 8642 112164
4 8 20 8708 103684
4 8 21 8622 83982
4 8 22 8593 75944
4 8 23 8600 97036
4 8 24 8650 104911
4 8 25 8730 114098
4 8 26 8731 99421
4 8 27 8715 85707
4 8 28 8717 81273
4 8 29 8739 106462
4 8 30 8684 110635
4 8 31 8713 105214
4 9 1 8771 92456
4 9 2 8759 109270
4 9 3 8762 99150
4 9 4 8730 77306
4 9 5 8780 86324
4 9 6 8804 90214
4 9 7 8797 99894
4 9 8 8863 95177
4 9 9 8873 95910
4 9 10 8827 108511
4 9 11 8806 115636
4 9 12 8869 85542
4 9 13 8854 111018
4 9 14 8571 93247
4 9 15 8533 85105
4 9 16 8553 114725
4 9 17 8561 122195
4 9 18 8532 100945
4 9 19 8560 108552
4 9 20 8634 108707
4 9 21 8646 117420
4 9 22 8633 113823
4 9 23 8680 82763
4 9 24 8765 121072
4 9 25 8756 89835
4 9 26 8750 104578
4 9 27 8790 88429
4 9 28 8824 84022
4 9 29 8843 80413
4 9 30 8795 118462
4 10 1 8795 139761
4 10 2 8805 103049
4 10 3 8826 104996
4 10 4 8841 104496
4 10 5 8882 75603
4 10 6 8865 89768
4 10 7 8875 93353
4 10 8 8898 98410
4 10 9 8920 114540
4 10 10 8937 95220
4 10 11 8926 104083
4 10 12 8912 106089
4 10 13 8898 116228
4 10 14 8926 149610
4 10 15 8954 109594
4 10 16 8941 75008
4 10 17 8952 119182
4 10 18 9003 151011
4 10 19 9002 146797
4 10 20 8995 145769
4 10 21 8969 121248
4 10 22 8954 107991
4 10 23 8992 128
4 10 24 8981 23036
4 10 25 8920 137485
4 10 26 8899 131756
4 10 27 8913 108729
4 10 28 8874 109478
4 10 29 8846 119627
4 10 30 8867 8
4 10 31 8868 64833
4 11 1 9004 95864
4 11 2 9028 82322
4 11 3 8969 95591
4 11 4 8932 69378
4 11 5 8929 74281
4 11 6 8916 103261
4 11 7 8807 92473
4 11 8 8449 84344
4 11 9 8484 127415
4 11 10 8148 123826
4 11 11 8282 100029
4 11 12 8305 76205
4 11 13 8380 105162
4 11 14 8530 119533
4 11 15 8642 106490
4 11 16 8780 114771
4 11 17 8890 55593
4 11 18 8962 227
4 11 19 8949 109699
4 11 20 8974 86004
4 11 21 8956 74496
4 11 22 8881 109350
4 11 23 8872 134020
4 11 24 8847 105212
4 11 25 8868 91512
where columns 1= year 2004, 2 = month, 3= day, 4= CR data, 5= Lightning data.

The data range is 2004/8/10 to 2008/8/22.
With the code below:
data <- read.table("CRandWWLLNremzro", col.names = c("year", "month",
"day", "CR","WW"))


new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x = data$date
 CR = data$CR
WWLLN=data$WW

Year<-x
Li<-WWLLN
CR<-CR

setEPS()
 postscript("twoinone2.eps")
 par(mar = c(5, 4, 4, 4) + 2) # Leave space for z axis
library(plotrix)
plot(Year,Li,pch=16,axes=F,xlab="",ylab="",type="l",col="black")
axis(2, col="black",las=1)  ## las=1 makes horizontal labels
mtext("Lightning Stroke/day", side=2, line=4)
#box()
par(new=TRUE)
plot(Year,CR, pch=15, xlab="",ylab="",axes=FALSE,type="l",col="red")
mtext("GCR count/day",side=4,col="red",line=3)
axis(4, ylim=c(-7499,9684), col="red",col.axis="red",las=1)



axis(side=1) ##
mtext("YEAR",side=1,col="black",line=2.5)
mtext("Long-term Variation betwenn WWLLN and GCRs",side=3,col="black",line=2.5)


legend("topleft",col=c("red","black"),lty=1,legend=c("GCRs","WWLLN"))

dev.off()

  I got the correct axes except that the x-axis is not what I want. I
want the date to appear on the x-axis. i actually got that by using:
axis(side=1,at=c(1,400,800,1200,1500),labels=c("2004","2005","2006","2007","2008"))

But there is a little time shift, indicating that the above line may
not have been assigned correctly.

I then fiddled with  axis(side=1) to see if the correct date can
naturally appear. I could not succeed.

I can attach the plot I generated. Instead of date appearing on the
x-axis, ordinary numbers appeared.

I guess the best way of getting the correct date on x-axis is to allow
the system to fix the date as data points are many. But I don't know
how to do that.

Thank you in advance for your usual kind help.
Best regards
Ogbos

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] ] Applying a certain formula to a repeated sample data: RESOLVED

2018-11-28 Thread Ogbos Okike
Dear Jeff,

This is great to me!!! Many, many thanks.

I have also clicked the send plain text mode button and I hope this
message will appear in plain text mode.

Thanks again.

Warmest regards.
Ogbos

On Wed, Nov 28, 2018 at 7:06 AM Jeff Newmiller  wrote:
>
> Thank you for providing a clarifying example. I think a useful function
> for you to get familiar with is the "ave" function. It is kind of like
> aggregate except that it works when the operation you want to apply to the
> group of elements will returns the same number of elements as were given
> to it.
>
> Also, in the future please figure out how to tell gmail to send plain text
> to the mailing list instead of HTML. You were lucky this time, but often
> HTML email gets horribly mangled as it goes through the mailing list and
> gets all the formatting removed.
>
> ###
> dta <- read.table( text =
> "n CR WW
> 1 8590 12516
> 2 8641 98143
> 3 8705 98916
> 4 8750 89911
> 5 8685 104835
> 6 8629 121963
> 7 8676 77655
> 1 8577 81081
> 2 8593 83385
> 3 8642 112164
> 4 8708 103684
> 5 8622 83982
> 6 8593 75944
> 7 8600 97036
> 1 8650 104911
> 2 8730 114098
> 3 8731 99421
> 4 8715 85707
> 5 8717 81273
> 6 8739 106462
> 7 8684 110635
> 1 8713 105214
> 2 8771 92456
> 3 8759 109270
> 4 8762 99150
> 5 8730 77306
> 6 8780 86324
> 7 8804 90214
> 1 8797 99894
> 2 8863 95177
> 3 8873 95910
> 4 8827 108511
> 5 8806 115636
> 6 8869 85542
> 7 8854 111018
> 1 8571 93247
> 2 8533 85105
> 3 8553 114725
> 4 8561 122195
> 5 8532 100945
> 6 8560 108552
> 7 8634 108707
> 1 8646 117420
> 2 8633 113823
> 3 8680 82763
> 4 8765 121072
> 5 8756 89835
> 6 8750 104578
> 7 8790 88429
> ",header=TRUE)
>
> # one way to make a grouping vector
> dta$G <- cumsum( c( 1, diff( dta$n ) < 0 )
> )
> # your operation
> fn <- function( x ) {
>m <- mean( x )
>   ( x - m ) / m * 100
> }
> # your operation, computing for each group
> gn <- function( x, g ) {
>ave( x, g, FUN = fn )
> }
> # do the computations
> dta$CRpct <- gn( dta$CR, dta$G )
> dta$WWpct <- gn( dta$WW, dta$G )
> dta
> #>n   CR WW GCRpct   WWpct
> #> 1  1 8590  12516 1 -0.899861560 -85.4932369
> #> 2  2 8641  98143 1 -0.311490540  13.7533758
> #> 3  3 8705  98916 1  0.426857407  14.6493272
> #> 4  4 8750  89911 1  0.946008306   4.2120148
> #> 5  5 8685 104835 1  0.196123673  21.5097882
> #> 6  6 8629 121963 1 -0.449930780  41.3621243
> #> 7  7 8676  77655 1  0.092293493  -9.9933934
> #> 8  1 8577  81081 2 -0.490594182 -10.9385886
> #> 9  2 8593  83385 2 -0.304963951  -8.4078170
> #> 10 3 8642 112164 2  0.263528632  23.2037610
> #> 11 4 8708 103684 2  1.029253336  13.8891155
> #> 12 5 8622  83982 2  0.031490843  -7.7520572
> #> 13 6 8593  75944 2 -0.304963951 -16.5811987
> #> 14 7 8600  97036 2 -0.223750725   6.5867850
> #> 15 1 8650 104911 3 -0.682347538   4.5366096
> #> 16 2 8730 114098 3  0.236197225  13.6908244
> #> 17 3 8731  99421 3  0.247679034  -0.9337985
> #> 18 4 8715  85707 3  0.063970082 -14.5988581
> #> 19 5 8717  81273 3  0.086933701 -19.0170347
> #> 20 6 8739 106462 3  0.339533510   6.0820746
> #> 21 7 8684 110635 3 -0.291966014  10.2401827
> #> 22 1 8713 105214 4 -0.534907614  11.6017662
> #> 23 2 8771  92456 4  0.127203640  -1.9307991
> #> 24 3 8759 109270 4 -0.009784895  15.9040146
> #> 25 4 8762  99150 4  0.024462238   5.1696079
> #> 26 5 8730  77306 4 -0.340840523 -18.0005879
> #> 27 6 8780  86324 4  0.229945042  -8.4350859
> #> 28 7 8804  90214 4  0.503922112  -4.3089157
> #> 29 1 8797  99894 5 -0.500896767  -1.7465519
> #> 30 2 8863  95177 5  0.245600995  -6.3860849
> #> 31 3 8873  95910 5  0.358706717  -5.6651229
> #> 32 4 8827 108511 5 -0.161579602   6.7289318
> #> 33 5 8806 115636 5 -0.399101617  13.7369184
> #> 34 6 8869  85542 5  0.313464428 -15.8628500
> #> 35 7 8854 111018 5  0.143805846   9.1947595
> #> 36 1 8571  93247 6  0.088415855 -11.0088128
> #> 37 2 8533  85105 6 -0.355331643 -18.7792102
> #> 38 3 8553 114725 6 -0.121780328   9.4889267
> #> 39 4 8561 122195 6 -0.028359802  16.6179943
> #> 40 5 8532 100945 6 -0.367009209  -3.6621512
> #> 41 6 8560 108552 6 -0.040037368   3.5976637
> #> 42 7 8634 108707 6  0.824102496   3.7455895
> #> 43 1 8646 117420 7 -0.816125860  14.4890796
> #> 44 2 8633 113823 7 -0.965257293  10.9818643
> #> 45 3 8680  82763 7 -0.426089807 -19.3028471
> #> 46 4 8765 121072 7  0.549000328  18.0499220
> #> 47 5 8756  89835 7  0.445755490 -12.4073713
&g

Re: [R] Applying a certain formula to a repeated sample data

2018-11-27 Thread Ogbos Okike
Dear Jim,

I don't think my problem is clear the way I put.

I have been trying to manually apply the formula to some rows.

This is what I have done.
I cut and past some rows from 1-7 and save each with a different file as
shown below:

1 8590 12516
2 8641 98143
3 8705 98916
4 8750 89911
5 8685 104835
6 8629 121963
7 8676 77655


1 8577 81081
2 8593 83385
3 8642 112164
4 8708 103684
5 8622 83982
6 8593 75944
7 8600 97036


1 8650 104911
2 8730 114098
3 8731 99421
4 8715 85707
5 8717 81273
6 8739 106462
7 8684 110635


1 8713 105214
2 8771 92456
3 8759 109270
4 8762 99150
5 8730 77306
6 8780 86324
7 8804 90214


1 8797 99894
2 8863 95177
3 8873 95910
4 8827 108511
5 8806 115636
6 8869 85542
7 8854 111018


1 8571 93247
2 8533 85105
3 8553 114725
4 8561 122195
5 8532 100945
6 8560 108552
7 8634 108707


1 8646 117420
2 8633 113823
3 8680 82763
4 8765 121072
5 8756 89835
6 8750 104578
7 8790 88429

Each of them are then read as:
d1<-read.table("dat1",col.names=c("n","CR","WW"))
d2<-read.table("dat2",col.names=c("n","CR","WW"))
d3<-read.table("dat3",col.names=c("n","CR","WW"))
d4<-read.table("dat4",col.names=c("n","CR","WW"))
d5<-read.table("dat5",col.names=c("n","CR","WW"))
d6<-read.table("dat6",col.names=c("n","CR","WW"))
d7<-read.table("dat7",col.names=c("n","CR","WW"))

And my formula for percentage change applied as follows for column 2:
a1<-((d1$CR-mean(d1$CR))/mean(CR))*100
a2<-((d2$CR-mean(d2$CR))/mean(CR))*100
a3<-((d3$CR-mean(d3$CR))/mean(CR))*100
a4<-((d4$CR-mean(d4$CR))/mean(CR))*100
a5<-((d5$CR-mean(d5$CR))/mean(CR))*100
a6<-((d6$CR-mean(d6$CR))/mean(CR))*100
a7<-((d7$CR-mean(d7$CR))/mean(CR))*100

a1-a7 actually gives percentage change in the data.

Instead of doing this one after the other, can you please give an
indication on how I may apply this formula to the data frame with probably
a code.

Thank you again.

Best
Ogbos

On Wed, Nov 28, 2018 at 5:15 AM Ogbos Okike 
wrote:

> Dear Jim,
>
> I wish also to use the means calculated and apply a certain formula on
> the  same data frame. In particular, I would like to subtract the means of
> each of these seven days from each of the seven days and and divide the
> outcome by the same means. If I represent m1 by the means of each seven
> days in column 1, and c1 is taken as column 1 data. My formula will be of
> the form:
> aa<-(c1-m1)/m1.
>
> I tried it on the first 7 rows and I have what I am looking for.:
>  -0.0089986156
>   -0.0031149054
>0.0042685741
>0.0094600831
>0.0019612367
>   -0.0044993078
>0.0009229349
>
> But doing it manually will take much time.
>
> Many thanks for going a step further to assist me.
>
> Warmest regards.
> Ogbos
>
> On Wed, Nov 28, 2018 at 4:31 AM Jim Lemon  wrote:
>
>> Hi Ogbos,
>> If we assume that you have a 3 column data frame named oodf, how about:
>>
>> oodf[,4]<-floor((cumsum(oodf[,1])-1)/28)
>> col2means<-by(oodf[,2],oodf[,4],mean)
>> col3means<-by(oodf[,3],oodf[,4],mean)
>>
>> Jim
>>
>> On Wed, Nov 28, 2018 at 2:06 PM Ogbos Okike 
>> wrote:
>> >
>> > Dear List,
>> > I have three data-column data. The data is of the form:
>> > 1 8590 12516
>> > 2 8641 98143
>> > 3 8705 98916
>> > 4 8750 89911
>> > 5 8685 104835
>> > 6 8629 121963
>> > 7 8676 77655
>> > 1 8577 81081
>> > 2 8593 83385
>> > 3 8642 112164
>> > 4 8708 103684
>> > 5 8622 83982
>> > 6 8593 75944
>> > 7 8600 97036
>> > 1 8650 104911
>> > 2 8730 114098
>> > 3 8731 99421
>> > 4 8715 85707
>> > 5 8717 81273
>> > 6 8739 106462
>> > 7 8684 110635
>> > 1 8713 105214
>> > 2 8771 92456
>> > 3 8759 109270
>> > 4 8762 99150
>> > 5 8730 77306
>> > 6 8780 86324
>> > 7 8804 90214
>> > 1 8797 99894
>> > 2 8863 95177
>> > 3 8873 95910
>> > 4 8827 108511
>> > 5 8806 115636
>> > 6 8869 85542
>> > 7 8854 111018
>> > 1 8571 93247
>> > 2 8533 85105
>> > 3 8553 114725
>> > 4 8561 122195
>> > 5 8532 100945
>> > 6 8560 108552
>> > 7 8634 108707
>> > 1 8646 117420
>> > 2 8633 113823
>> > 3 8680 82763
>> > 4 8765 121072
>> > 5 8756 89835
>> > 6 8750 104578
>> > 7 8790 88429
>> >
>> > I wish to calc

Re: [R] Applying a certain formula to a repeated sample data

2018-11-27 Thread Ogbos Okike
Dear Jim,

I wish also to use the means calculated and apply a certain formula on the
same data frame. In particular, I would like to subtract the means of each
of these seven days from each of the seven days and and divide the outcome
by the same means. If I represent m1 by the means of each seven days in
column 1, and c1 is taken as column 1 data. My formula will be of the form:
aa<-(c1-m1)/m1.

I tried it on the first 7 rows and I have what I am looking for.:
 -0.0089986156
  -0.0031149054
   0.0042685741
   0.0094600831
   0.0019612367
  -0.0044993078
   0.0009229349

But doing it manually will take much time.

Many thanks for going a step further to assist me.

Warmest regards.
Ogbos

On Wed, Nov 28, 2018 at 4:31 AM Jim Lemon  wrote:

> Hi Ogbos,
> If we assume that you have a 3 column data frame named oodf, how about:
>
> oodf[,4]<-floor((cumsum(oodf[,1])-1)/28)
> col2means<-by(oodf[,2],oodf[,4],mean)
> col3means<-by(oodf[,3],oodf[,4],mean)
>
> Jim
>
> On Wed, Nov 28, 2018 at 2:06 PM Ogbos Okike 
> wrote:
> >
> > Dear List,
> > I have three data-column data. The data is of the form:
> > 1 8590 12516
> > 2 8641 98143
> > 3 8705 98916
> > 4 8750 89911
> > 5 8685 104835
> > 6 8629 121963
> > 7 8676 77655
> > 1 8577 81081
> > 2 8593 83385
> > 3 8642 112164
> > 4 8708 103684
> > 5 8622 83982
> > 6 8593 75944
> > 7 8600 97036
> > 1 8650 104911
> > 2 8730 114098
> > 3 8731 99421
> > 4 8715 85707
> > 5 8717 81273
> > 6 8739 106462
> > 7 8684 110635
> > 1 8713 105214
> > 2 8771 92456
> > 3 8759 109270
> > 4 8762 99150
> > 5 8730 77306
> > 6 8780 86324
> > 7 8804 90214
> > 1 8797 99894
> > 2 8863 95177
> > 3 8873 95910
> > 4 8827 108511
> > 5 8806 115636
> > 6 8869 85542
> > 7 8854 111018
> > 1 8571 93247
> > 2 8533 85105
> > 3 8553 114725
> > 4 8561 122195
> > 5 8532 100945
> > 6 8560 108552
> > 7 8634 108707
> > 1 8646 117420
> > 2 8633 113823
> > 3 8680 82763
> > 4 8765 121072
> > 5 8756 89835
> > 6 8750 104578
> > 7 8790 88429
> >
> > I wish to calculate average of the second and third columns based on the
> > first column for each repeated 7 days. The length of the data is 1442.
> That
> > is 206 by 7. So I should arrive at 207 data points for each of the two
> > columns after calculating the mean of each group 1-7.
> >
> > I have both tried factor/tapply and aggregate functions but seem not to
> be
> > making progress.
> >
> > Thank you very much for your idea.
> >
> > Best wishes
> > Ogbos
> >
> > [[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] Applying a certain formula to a repeated sample data: SOLVED

2018-11-27 Thread Ogbos Okike
On Wed, Nov 28, 2018 at 4:31 AM Jim Lemon  wrote:

> Hi Ogbos,
> If we assume that you have a 3 column data frame named oodf, how about:
>
> Dear Jim,

Thank you so much.

The code just made life very easier for me.

best regards
Ogbos



> oodf[,4]<-floor((cumsum(oodf[,1])-1)/28)
> col2means<-by(oodf[,2],oodf[,4],mean)
> col3means<-by(oodf[,3],oodf[,4],mean)
>
> Jim
>
> On Wed, Nov 28, 2018 at 2:06 PM Ogbos Okike 
> wrote:
> >
> > Dear List,
> > I have three data-column data. The data is of the form:
> > 1 8590 12516
> > 2 8641 98143
> > 3 8705 98916
> > 4 8750 89911
> > 5 8685 104835
> > 6 8629 121963
> > 7 8676 77655
> > 1 8577 81081
> > 2 8593 83385
> > 3 8642 112164
> > 4 8708 103684
> > 5 8622 83982
> > 6 8593 75944
> > 7 8600 97036
> > 1 8650 104911
> > 2 8730 114098
> > 3 8731 99421
> > 4 8715 85707
> > 5 8717 81273
> > 6 8739 106462
> > 7 8684 110635
> > 1 8713 105214
> > 2 8771 92456
> > 3 8759 109270
> > 4 8762 99150
> > 5 8730 77306
> > 6 8780 86324
> > 7 8804 90214
> > 1 8797 99894
> > 2 8863 95177
> > 3 8873 95910
> > 4 8827 108511
> > 5 8806 115636
> > 6 8869 85542
> > 7 8854 111018
> > 1 8571 93247
> > 2 8533 85105
> > 3 8553 114725
> > 4 8561 122195
> > 5 8532 100945
> > 6 8560 108552
> > 7 8634 108707
> > 1 8646 117420
> > 2 8633 113823
> > 3 8680 82763
> > 4 8765 121072
> > 5 8756 89835
> > 6 8750 104578
> > 7 8790 88429
> >
> > I wish to calculate average of the second and third columns based on the
> > first column for each repeated 7 days. The length of the data is 1442.
> That
> > is 206 by 7. So I should arrive at 207 data points for each of the two
> > columns after calculating the mean of each group 1-7.
> >
> > I have both tried factor/tapply and aggregate functions but seem not to
> be
> > making progress.
> >
> > Thank you very much for your idea.
> >
> > Best wishes
> > Ogbos
> >
> > [[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] Applying a certain formula to a repeated sample data

2018-11-27 Thread Ogbos Okike
Dear List,
I have three data-column data. The data is of the form:
1 8590 12516
2 8641 98143
3 8705 98916
4 8750 89911
5 8685 104835
6 8629 121963
7 8676 77655
1 8577 81081
2 8593 83385
3 8642 112164
4 8708 103684
5 8622 83982
6 8593 75944
7 8600 97036
1 8650 104911
2 8730 114098
3 8731 99421
4 8715 85707
5 8717 81273
6 8739 106462
7 8684 110635
1 8713 105214
2 8771 92456
3 8759 109270
4 8762 99150
5 8730 77306
6 8780 86324
7 8804 90214
1 8797 99894
2 8863 95177
3 8873 95910
4 8827 108511
5 8806 115636
6 8869 85542
7 8854 111018
1 8571 93247
2 8533 85105
3 8553 114725
4 8561 122195
5 8532 100945
6 8560 108552
7 8634 108707
1 8646 117420
2 8633 113823
3 8680 82763
4 8765 121072
5 8756 89835
6 8750 104578
7 8790 88429

I wish to calculate average of the second and third columns based on the
first column for each repeated 7 days. The length of the data is 1442. That
is 206 by 7. So I should arrive at 207 data points for each of the two
columns after calculating the mean of each group 1-7.

I have both tried factor/tapply and aggregate functions but seem not to be
making progress.

Thank you very much for your idea.

Best wishes
Ogbos

[[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] as.Date and ylim in empty plot: RESOLVED

2018-09-19 Thread Ogbos Okike
Hi David,
That's it!!! The outcome is attached.

Many thanks please.

Best
Ogbos

On Wed, Sep 19, 2018 at 11:34 PM David Winsemius 
wrote:

>
> > On Sep 19, 2018, at 7:55 AM, Ogbos Okike 
> wrote:
> >
> > Dear Experts,
> > I generated the plot attached. Every other thing is OK except the black
> > horizontal lines which should appear like points or dots as the coloured
> > ones. I can't understand why.
> >
> > I tried to change it to look like dots by calling empty plots so that I
> > will add them as points.
> >
> > Since I have a range of date that can fall any where within 2005, I
> tried:
> >
> > plot(1, type="n", xlab="", ylab="",
> > xlim=c(as.Date("2005-01-01"),as.Date("2005-12-31")), ylim=c(-.5, -10))
> >
> > ylim worked fine but xlim instead of appearing like date as indicated on
> > the x-axes of the attached plot, translated to ordinary numbers (12800,
> > 12900,13000, 13100).
> >
> > All the data is of the same format:
> > 2005-01-04 -2.76105935648091
> > 2005-01-19 -9.60813496025994
> > 2005-01-22 -7.92101965866777
> > 2005-02-19 -1.61308152604905
> > 2005-02-24 -1.51497015807712
> > 2005-05-09 -2.06465797304654
> > 2005-05-11 -1.14840389007051
> > 2005-05-16 -3.85281900888504
> > 2005-06-13 -1.18659683796617
> > 2005-06-17 -3.48787712566258
> > 2005-06-22 -1.14223758296308
> > 2005-07-18 -4.96013018907366
> > 2005-08-03 -1.24313324914368
> > 2005-08-07 -2.96672894841722
> > 2005-08-10 -1.11868063781156
> > 2005-08-25 -1.46453734930983
> > 2005-09-13 -8.00895215754776
> > 2005-09-15 -6.63439065989452
> > 2005-10-13 -2.25054996925846
> > 2005-12-15 -1.08933890547705
>
> You did not succeed in creating a plot that the rhelp mail server would
> accept. My guess is that the first column is a factor variable and that you
> did not use colClasses when doing your data input.
>
> dd <- read.table(text="2005-01-04 -2.76105935648091
> 2005-01-19 -9.60813496025994
> 2005-01-22 -7.92101965866777
> 2005-02-19 -1.61308152604905
> 2005-02-24 -1.51497015807712
> 2005-05-09 -2.06465797304654
> 2005-05-11 -1.14840389007051
> 2005-05-16 -3.85281900888504
> 2005-06-13 -1.18659683796617
> 2005-06-17 -3.48787712566258
> 2005-06-22 -1.14223758296308
> 2005-07-18 -4.96013018907366
> 2005-08-03 -1.24313324914368
> 2005-08-07 -2.96672894841722
> 2005-08-10 -1.11868063781156
> 2005-08-25 -1.46453734930983
> 2005-09-13 -8.00895215754776
> 2005-09-15 -6.63439065989452
> 2005-10-13 -2.25054996925846
> 2005-12-15 -1.08933890547705", colClasses=c("Date","numeric")
> )
>
>
> No problems with:
>
>  plot(dd[[1]], dd[[2]],
> xlim=c(as.Date("2005-01-01"),as.Date("2005-12-31")))
>
>
> (Not a particularly good test of the use of an xlim argument since nothing
> was excluded.)
>
> PDF's are accepted. PNGs are not.
>
> --
> David.
> >
> > Thank you so much for your input.
> >
> > Best regards
> > Ogbos
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
> 'Any technology distinguishable from magic is insufficiently advanced.'
>  -Gehm's Corollary to Clarke's Third Law
>
>
>
>
>
>


Ogbos.pdf
Description: Adobe PDF document
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] as.Date and ylim in empty plot

2018-09-19 Thread Ogbos Okike
Dear Experts,
I generated the plot attached. Every other thing is OK except the black
horizontal lines which should appear like points or dots as the coloured
ones. I can't understand why.

I tried to change it to look like dots by calling empty plots so that I
will add them as points.

Since I have a range of date that can fall any where within 2005, I tried:

plot(1, type="n", xlab="", ylab="",
xlim=c(as.Date("2005-01-01"),as.Date("2005-12-31")), ylim=c(-.5, -10))

ylim worked fine but xlim instead of appearing like date as indicated on
the x-axes of the attached plot, translated to ordinary numbers (12800,
12900,13000, 13100).

All the data is of the same format:
2005-01-04 -2.76105935648091
2005-01-19 -9.60813496025994
2005-01-22 -7.92101965866777
2005-02-19 -1.61308152604905
2005-02-24 -1.51497015807712
2005-05-09 -2.06465797304654
2005-05-11 -1.14840389007051
2005-05-16 -3.85281900888504
2005-06-13 -1.18659683796617
2005-06-17 -3.48787712566258
2005-06-22 -1.14223758296308
2005-07-18 -4.96013018907366
2005-08-03 -1.24313324914368
2005-08-07 -2.96672894841722
2005-08-10 -1.11868063781156
2005-08-25 -1.46453734930983
2005-09-13 -8.00895215754776
2005-09-15 -6.63439065989452
2005-10-13 -2.25054996925846
2005-12-15 -1.08933890547705

Thank you so much for your input.

Best regards
Ogbos
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] customizing the number of decimal places in xtable: RESOLVED

2018-09-18 Thread Ogbos Okike
Dear Jeff,

Great!! Thanks for your concern/good advice.

Best regards
Ogbos

On Tue, Sep 18, 2018 at 8:24 AM Jeff Newmiller 
wrote:

> I gather you find the content of the help page for the xtable function
> hard to understand, but you need to build the skill of reading them and
> gathering clues about functions you call from them.
>
> * They always have a usage section that briefly summarizes how the
> function is called and what the default values are for those parameters
> that do have defaults.
>
> * They always mention what each parameter is for. (The help page may not
> always be thorough enough to suit your preference, but CRAN requires the
> author to make some effort to describe every parameter. Note that people
> posting packages on GitHub have no one insisting that they put in this
> effort, so beware that quality may vary more if you start using non-CRAN
> packages.) The digits parameter is used by many data formatting functions,
> and it can usually be specified as a vector with each element affecting a
> corresponding column of data in order.
>
> * They always indicate what kind of Value will be returned from the
> function.
>
> * They usually have Notes on how the function reacts to different input
> values.
>
> * They often have Examples of how to use the function.
>
> * They often have  a See Also section indicating what other functions you
> might find relevant when using this function.
>
> * They sometimes have a section listing References to read to learn more
> about the theory behind the function.
>
> Not all authors of help pages put the same level of effort into making
> help pages readable, and there is undoubtedly some shorthand notation that
> gives you key information more compactly than you might wish for as a
> beginner. However, if you ask for help interpreting specific help pages
> then you may learn more about how they work or the authors may re-write
> certain help pages based on your questions to address the source of your
> confusion.  Beware that if you don't read them first and mention why they
> didn't answer your question then you may get less helpful responses when
> when you do ask questions.
>
> On September 17, 2018 10:49:43 PM PDT, Ogbos Okike <
> giftedlife2...@gmail.com> wrote:
> >Dear Jeff,
> >
> >Thank you please.
> >
> >I did search before but could not get it resolved. But with your query
> >now,
> >just typed ?xtable as key  search word and the first document I opened
> >gave
> >an indication of digits. Without knowing what it was saying, I tried it
> >in
> >my data and it gave the result I have been looking for.
> >
> >xtable(data, digits=12) and I am fine.
> >
> >Thank you so much.
> >
> >Ogbos
> >
> >On Tue, Sep 18, 2018 at 6:27 AM Jeff Newmiller
> >
> >wrote:
> >
> >> Have you read
> >>
> >> ?xtable
> >>
> >>
> >> On September 17, 2018 7:24:37 PM PDT, Ogbos Okike <
> >> giftedlife2...@gmail.com> wrote:
> >> >Dear Volunteers,
> >> >
> >> >I have a table involving many decimal places:
> >> >2005-01-04 -2.13339817688037
> >> >2005-01-19 -6.86312349695117
> >> >2005-01-22 -4.33662370554386
> >> >2005-02-10 -1.40789214441639
> >> >2005-02-13 -1.1334121785854
> >> >2005-02-19 -1.28411233010119
> >> >2005-05-09 -1.6895978161324
> >> >2005-05-16 -3.07664523496947
> >> >2005-06-17 -1.69904491217129
> >> >2005-07-17 -3.44289318667434
> >> >2005-08-07 -2.29676435700659
> >> >2005-08-10 -1.08915071542227
> >> >2005-08-24 -1.8244123081697
> >> >2005-09-13 -4.57899147546373
> >> >2005-09-15 -3.96591895962343
> >> > I used xtable to covert this to form of latex table.
> >> >
> >> >The result I have is:
> >> >1 & 2005-01-04 & -2.13 \\
> >> >  2 & 2005-01-19 & -6.86 \\
> >> >  3 & 2005-01-22 & -4.34 \\
> >> >  4 & 2005-02-10 & -1.41 \\
> >> >  5 & 2005-02-13 & -1.13 \\
> >> >  6 & 2005-02-19 & -1.28 \\
> >> >  7 & 2005-05-09 & -1.69 \\
> >> >  8 & 2005-05-16 & -3.08 \\
> >> >  9 & 2005-06-17 & -1.70 \\
> >> >  10 & 2005-07-17 & -3.44 \\
> >> >  11 & 2005-08-07 & -2.30 \\
> >> >  12 & 2005-08-10 & -1.09 \\
> >> >  13 & 2005-08-24 & -1.82 \\
> >> >  14 & 2005-09-13 & -4.58 \\
> >> > 

Re: [R] customizing the number of decimal places in xtable: RESOLVED

2018-09-17 Thread Ogbos Okike
Dear Jeff,

Thank you please.

I did search before but could not get it resolved. But with your query now,
just typed ?xtable as key  search word and the first document I opened gave
an indication of digits. Without knowing what it was saying, I tried it in
my data and it gave the result I have been looking for.

xtable(data, digits=12) and I am fine.

Thank you so much.

Ogbos

On Tue, Sep 18, 2018 at 6:27 AM Jeff Newmiller 
wrote:

> Have you read
>
> ?xtable
>
>
> On September 17, 2018 7:24:37 PM PDT, Ogbos Okike <
> giftedlife2...@gmail.com> wrote:
> >Dear Volunteers,
> >
> >I have a table involving many decimal places:
> >2005-01-04 -2.13339817688037
> >2005-01-19 -6.86312349695117
> >2005-01-22 -4.33662370554386
> >2005-02-10 -1.40789214441639
> >2005-02-13 -1.1334121785854
> >2005-02-19 -1.28411233010119
> >2005-05-09 -1.6895978161324
> >2005-05-16 -3.07664523496947
> >2005-06-17 -1.69904491217129
> >2005-07-17 -3.44289318667434
> >2005-08-07 -2.29676435700659
> >2005-08-10 -1.08915071542227
> >2005-08-24 -1.8244123081697
> >2005-09-13 -4.57899147546373
> >2005-09-15 -3.96591895962343
> > I used xtable to covert this to form of latex table.
> >
> >The result I have is:
> >1 & 2005-01-04 & -2.13 \\
> >  2 & 2005-01-19 & -6.86 \\
> >  3 & 2005-01-22 & -4.34 \\
> >  4 & 2005-02-10 & -1.41 \\
> >  5 & 2005-02-13 & -1.13 \\
> >  6 & 2005-02-19 & -1.28 \\
> >  7 & 2005-05-09 & -1.69 \\
> >  8 & 2005-05-16 & -3.08 \\
> >  9 & 2005-06-17 & -1.70 \\
> >  10 & 2005-07-17 & -3.44 \\
> >  11 & 2005-08-07 & -2.30 \\
> >  12 & 2005-08-10 & -1.09 \\
> >  13 & 2005-08-24 & -1.82 \\
> >  14 & 2005-09-13 & -4.58 \\
> >  15 & 2005-09-15 & -3.97 \\.
> >
> >It has truncated the long decimal places. Since it is not want I want,
> >I
> >have to copy from the original table and place into xtable.
> >
> >Can you please tell me how to customize the xtable so that I will be
> >responsible for the number of decimal places it displays.
> >
> >Many thanks for your precious time.
> >
> >Warmest regards
> >Ogbos
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>

[[alternative HTML version deleted]]

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


[R] customizing the number of decimal places in xtable

2018-09-17 Thread Ogbos Okike
Dear Volunteers,

I have a table involving many decimal places:
2005-01-04 -2.13339817688037
2005-01-19 -6.86312349695117
2005-01-22 -4.33662370554386
2005-02-10 -1.40789214441639
2005-02-13 -1.1334121785854
2005-02-19 -1.28411233010119
2005-05-09 -1.6895978161324
2005-05-16 -3.07664523496947
2005-06-17 -1.69904491217129
2005-07-17 -3.44289318667434
2005-08-07 -2.29676435700659
2005-08-10 -1.08915071542227
2005-08-24 -1.8244123081697
2005-09-13 -4.57899147546373
2005-09-15 -3.96591895962343
 I used xtable to covert this to form of latex table.

The result I have is:
1 & 2005-01-04 & -2.13 \\
  2 & 2005-01-19 & -6.86 \\
  3 & 2005-01-22 & -4.34 \\
  4 & 2005-02-10 & -1.41 \\
  5 & 2005-02-13 & -1.13 \\
  6 & 2005-02-19 & -1.28 \\
  7 & 2005-05-09 & -1.69 \\
  8 & 2005-05-16 & -3.08 \\
  9 & 2005-06-17 & -1.70 \\
  10 & 2005-07-17 & -3.44 \\
  11 & 2005-08-07 & -2.30 \\
  12 & 2005-08-10 & -1.09 \\
  13 & 2005-08-24 & -1.82 \\
  14 & 2005-09-13 & -4.58 \\
  15 & 2005-09-15 & -3.97 \\.

It has truncated the long decimal places. Since it is not want I want, I
have to copy from the original table and place into xtable.

Can you please tell me how to customize the xtable so that I will be
responsible for the number of decimal places it displays.

Many thanks for your precious time.

Warmest regards
Ogbos

[[alternative HTML version deleted]]

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


Re: [R] Data.frame of Different Length

2018-09-17 Thread Ogbos Okike
Dear Jeff,

Yours is like reciting A, B,C or 1, 2, 3 ...

I am greatly relieved.

Many thanks.
Ogbos

On Mon, Sep 17, 2018 at 9:07 AM Jeff Newmiller 
wrote:

> There are many ways to combine data frames, but the method you have chosen
> is extremely rare because you do not appear to be creating sensible
> relationships in the rows of the data frame, so your final result seems
> unlikely to be understandable by normal interpretation of tabular data. See
> ?merge for more normal ways to combine data frames.
>
> However, with respect to your questions:
>
> 1) The usual way to remove a column is to use negative integer indexing:
> a <- a[ , -2 ]
>
> 2) To add more columns, just do it again with the answer you have. I do
> think you are taking an over-complicated approach:
>
> n <- max( nrow(d1), nrow(d2), nrow(d3))
> ix <- seq.int( n )
> a <- data.frame( d1_date=d1$date[ix], d2_date=d2$date[ix],
> d3_date=d3$date[ix] )
>
> On September 17, 2018 12:17:03 AM PDT, Ogbos Okike <
> giftedlife2...@gmail.com> wrote:
> >Dear Contributors,
> >
> >I have two data frame of different column lengths. I am trying to have
> >them
> >in one data frame.
> >Using
> >A<-d1$date
> >B<-d2$date
> >a<-data.table(A )[ , I := .I][data.table(B )[ , I := .I], on = "I"]
> >I got
> >1: 2005-01-04  1 2005-01-04
> > 2: 2005-01-19  2 2005-01-19
> > 3: 2005-01-22  3 2005-01-22
> > 4: 2005-02-24  4 2005-02-19
> > 5: 2005-05-09  5 2005-02-24
> > 6: 2005-05-16  6 2005-05-09
> > 7: 2005-06-17  7 2005-05-11
> > 8: 2005-07-17  8 2005-05-16
> > 9: 2005-08-07  9 2005-06-13
> >10: 2005-09-11 10 2005-06-17
> >11: 2005-09-13 11 2005-06-22
> >12: 2005-09-15 12 2005-07-18
> >13: NA 13 2005-08-03
> >14: NA 14 2005-08-07
> >15: NA 15 2005-08-10
> >16: NA 16 2005-08-25
> >17: NA 17 2005-09-13
> >18: NA 18 2005-09-15
> >19: NA 19 2005-10-13
> >20: NA 20 2005-12-15
> >which is fine.
> >
> >I have two more problems:
> >1) how to remove the nos 1 to 20 inserted at the middle of the dates.
> >
> >2) how to include more columns.
> >
> >I have about 5 columns of different lengths which I wish to have in one
> >data frame.
> >
> >I will remain grateful if assisted.
> >
> >Best regards
> >Ogbos
> >
> >   [[alternative HTML version deleted]]
> >
> >__
> >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide
> >http://www.R-project.org/posting-guide.html
> >and provide commented, minimal, self-contained, reproducible code.
>
> --
> Sent from my phone. Please excuse my brevity.
>

[[alternative HTML version deleted]]

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


[R] Data.frame of Different Length

2018-09-17 Thread Ogbos Okike
Dear Contributors,

I have two data frame of different column lengths. I am trying to have them
in one data frame.
Using
A<-d1$date
B<-d2$date
a<-data.table(A )[ , I := .I][data.table(B )[ , I := .I], on = "I"]
I got
1: 2005-01-04  1 2005-01-04
 2: 2005-01-19  2 2005-01-19
 3: 2005-01-22  3 2005-01-22
 4: 2005-02-24  4 2005-02-19
 5: 2005-05-09  5 2005-02-24
 6: 2005-05-16  6 2005-05-09
 7: 2005-06-17  7 2005-05-11
 8: 2005-07-17  8 2005-05-16
 9: 2005-08-07  9 2005-06-13
10: 2005-09-11 10 2005-06-17
11: 2005-09-13 11 2005-06-22
12: 2005-09-15 12 2005-07-18
13: NA 13 2005-08-03
14: NA 14 2005-08-07
15: NA 15 2005-08-10
16: NA 16 2005-08-25
17: NA 17 2005-09-13
18: NA 18 2005-09-15
19: NA 19 2005-10-13
20: NA 20 2005-12-15
which is fine.

I have two more problems:
1) how to remove the nos 1 to 20 inserted at the middle of the dates.

2) how to include more columns.

I have about 5 columns of different lengths which I wish to have in one
data frame.

I will remain grateful if assisted.

Best regards
Ogbos

[[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] Equal Standard Error bar

2018-09-04 Thread Ogbos Okike
Hi David,

You are right. Thanks for your time.

The problem is certainly with the data. Plotting part of it gives different
results, usually quite different from the output when the total data is
used. In fact, just as you mentioned, it will look as if it is not the same
code that is used to plot it.

The range is  33469-281856.

Instead of taking time to explain how I fiddled with the range before
getting the plot I attached, let me just attach the whole data. I really
had issues with the range when plotting the whole data (see attached
please).

Many thanks again.

Ogbos



On Tue, Sep 4, 2018 at 9:58 PM David L Carlson  wrote:

> Thank you for the reproducible data, but it is not the data used in the
> plot you attached and does not plot anything with the code you included.
> The ylim= argument must be modified:
>
> plot(-5:10, oomean, type="b", ylim=c(4, 12),
>   xlab="days (epoch is the day of Fd)", ylab="strikes/day",
>   main="Superposed Epoch of all the Events")
> dispersion(-5:10, oomean, oose, arrow.cap=.01)
>
> On the plot of these data it is clear that the error bars are different
> sizes:
>
> range(oose)
> [1] 1728.234 6890.916
>
> What was the range of oose values for the data in the plot you included
> with your message?
>
> 
> David L Carlson
> Department of Anthropology
> Texas A&M University
> College Station, TX 77843-4352
>
> -Original Message-
> From: R-help  On Behalf Of Ogbos Okike
> Sent: Tuesday, September 4, 2018 2:35 PM
> To: r-help 
> Subject: [R] Equal Standard Error bar
>
> Dear List,
>
> I have a dataset of high variability. I conducted epoch analysis and
> attempted to plot the standard error bar alongside.
>
> I am, however, surprised that the error bars are of equal length. I do not
> think that the variability in the data is captured, except there is a kind
> of averaging that smooths out the differences in daily variations. Should
> that be the case, I don't know how and as such need your assistance to
> explain what is going on.
>
> The plot is attached. 71 events are represented in the plot.
>
> The code I use to generate the plot is:
> oodf<-data.frame(A,B)
> library(plotrix)
> std.error<-function(x) return(sd(x)/(sum(!is.na(x
> oomean<-as.vector(by(oodf$B,oodf$A,mean))
> oose<-as.vector(by(oodf$B,oodf$A,std.error))
> plot(-5:10,oomean,type="b",ylim=c(145000,162000),
>  xlab="days (epoch is the day of Fd)",ylab="strikes/day",main="Superposed
> Epoch of all the Events")
> dispersion(-5:10,oomean,oose).
>
> The sample data is:
> -5 64833
> -4 95864
> -3 82322
> -2 95591
> -1 69378
> 0 74281
> 1 103261
> 2 92473
> 3 84344
> 4 127415
> 5 123826
> 6 100029
> 7 76205
> 8 105162
> 9 119533
> 10 106490
> -5 82322
> -4 95591
> -3 69378
> -2 74281
> -1 103261
> 0 92473
> 1 84344
> 2 127415
> 3 123826
> 4 100029
> 5 76205
> 6 105162
> 7 119533
> 8 106490
> 9 114771
> 10 55593
> -5 85694
> -4 65205
> -3 80995
> -2 51723
> -1 62310
> 0 53401
> 1 65677
> 2 76094
> 3 64035
> 4 68290
> 5 73306
> 6 82176
> 7 75566
> 8 89762
> 9 88063
> 10 94395
> -5 80651
> -4 81291
> -3 63702
> -2 70297
> -1 64117
> 0 71219
> 1 57354
> 2 62111
> 3 42252
> 4 35454
> 5 33469
> 6 38899
> 7 64981
> 8 85694
> 9 79452
> 10 85216
> -5 71219
> -4 57354
> -3 62111
> -2 42252
> -1 35454
> 0 33469
> 1 38899
> 2 64981
> 3 85694
> 4 79452
> 5 85216
> 6 81721
> 7 91231
> 8 107074
> 9 108103
> 10 75768
>
>
> You kind help will be greatly appreciated.
>
> Many thanks
>
> Ogbos
>
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Equal Standard Error bar

2018-09-04 Thread Ogbos Okike
Dear List,

I have a dataset of high variability. I conducted epoch analysis and
attempted to plot the standard error bar alongside.

I am, however, surprised that the error bars are of equal length. I do not
think that the variability in the data is captured, except there is a kind
of averaging that smooths out the differences in daily variations. Should
that be the case, I don't know how and as such need your assistance to
explain what is going on.

The plot is attached. 71 events are represented in the plot.

The code I use to generate the plot is:
oodf<-data.frame(A,B)
library(plotrix)
std.error<-function(x) return(sd(x)/(sum(!is.na(x
oomean<-as.vector(by(oodf$B,oodf$A,mean))
oose<-as.vector(by(oodf$B,oodf$A,std.error))
plot(-5:10,oomean,type="b",ylim=c(145000,162000),
 xlab="days (epoch is the day of Fd)",ylab="strikes/day",main="Superposed
Epoch of all the Events")
dispersion(-5:10,oomean,oose).

The sample data is:
-5 64833
-4 95864
-3 82322
-2 95591
-1 69378
0 74281
1 103261
2 92473
3 84344
4 127415
5 123826
6 100029
7 76205
8 105162
9 119533
10 106490
-5 82322
-4 95591
-3 69378
-2 74281
-1 103261
0 92473
1 84344
2 127415
3 123826
4 100029
5 76205
6 105162
7 119533
8 106490
9 114771
10 55593
-5 85694
-4 65205
-3 80995
-2 51723
-1 62310
0 53401
1 65677
2 76094
3 64035
4 68290
5 73306
6 82176
7 75566
8 89762
9 88063
10 94395
-5 80651
-4 81291
-3 63702
-2 70297
-1 64117
0 71219
1 57354
2 62111
3 42252
4 35454
5 33469
6 38899
7 64981
8 85694
9 79452
10 85216
-5 71219
-4 57354
-3 62111
-2 42252
-1 35454
0 33469
1 38899
2 64981
3 85694
4 79452
5 85216
6 81721
7 91231
8 107074
9 108103
10 75768


You kind help will be greatly appreciated.

Many thanks

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

2018-08-22 Thread Ogbos Okike
Dear Erick,

This is great!!
Many thanks for resolving the problem.
Ogbos

On Wed, Aug 22, 2018 at 5:44 PM Eric Berger  wrote:

> Hi Ogbos,
> I took a closer look at your code.
> Here's a modified version (using dummy data) that seems to do what you
> want.
> Hopefully this will make it clear what you need to to.
>
> nn <- 100
> lDf <- data.frame(Li=rnorm(nn),CR=rnorm(nn))
>
> fit<-lm(Li~CR, data=lDf)
> a<-summary(fit)
>
> N <- nrow(lDf)
> C <- 50 # desired number of subsamples
> S <- 38 # desired sample size
>
> sumb2 <- 0
> for (i in 1:C){   # a loop over the number of subsamples
>   set.seed(3*i)   # a different seed for each subsample
>   subsample <- lDf[sample(1:N, size=S, replace=TRUE), ]
>   mod <- lm(Li~CR,data=subsample)
>   #sum b2 for all subsamples:
>   sumb2 <- sumb2 + coef(mod)[[2]]
> }
> print(sumb2/C, digits = 3)
>
> Best,
> Eric
>
>
>
> On Wed, Aug 22, 2018 at 7:28 PM, Ogbos Okike 
> wrote:
>
>> Hello Erick,
>>
>> Thanks again.
>> Another line indicated error:
>>
>> source("script.R")
>> Error in eval(predvars, data, env) :
>>   numeric 'envir' arg not of length one
>> Thank you for additional assitance.
>> Ogbos
>>
>>
>>
>> On Wed, Aug 22, 2018 at 5:23 PM Eric Berger 
>> wrote:
>>
>>> You have an extra comma ... it should be
>>>
>>> Li[sample(1:N, size = S, replace = TRUE)]
>>>
>>> i.e. no comma after the closing parenthesis
>>>
>>>
>>>
>>> On Wed, Aug 22, 2018 at 7:20 PM, Ogbos Okike 
>>> wrote:
>>>
>>>> Hello Eric,
>>>> Thanks for this.
>>>>
>>>> I tried it. It went but another problem prevents the code from
>>>> running.
>>>>  source("script.R")
>>>> Error in Li[sample(1:N, size = S, replace = TRUE), ] :
>>>>   incorrect number of dimensions
>>>>
>>>> The error is coming from the line:
>>>>  subsample <- Li[sample(1:N, size=S, replace=TRUE), ]
>>>>
>>>> I tried to replace Li with N but it didn't go. I also tried replacing
>>>> it with length(Li). The same error remains.
>>>>
>>>> Thank so much for looking at this again.
>>>>
>>>> Ogbos
>>>>
>>>>
>>>> On Wed, Aug 22, 2018 at 5:06 PM Eric Berger 
>>>> wrote:
>>>>
>>>>> Li is defined as d1$a which is a vector. You should use
>>>>>
>>>>> N <- length(Li)
>>>>>
>>>>> HTH,
>>>>> Eric
>>>>>
>>>>>
>>>>> On Wed, Aug 22, 2018 at 6:02 PM, Ogbos Okike >>>> > wrote:
>>>>>
>>>>>> Kind R-users,
>>>>>> I run a simple regression. I am interested in using the Monte Carlo
>>>>>> to test
>>>>>> the slope parameter.
>>>>>> Here is what I have done:
>>>>>> d1<-read.table("Lightcor",col.names=c("a"))
>>>>>> d2<-read.table("CRcor",col.names=c("a"))
>>>>>>  Li<-d1$a
>>>>>> CR<-d2$a
>>>>>>
>>>>>>  fit<-lm(Li~CR)
>>>>>>  a<-summary(fit)
>>>>>> a gives the slope as 88.15
>>>>>>
>>>>>> Problem: I now what to repeat the samples to access this coefficient.
>>>>>> Following one of the related examples I got online, I did (tried to
>>>>>> modify):
>>>>>>
>>>>>> N <- nrow(Li) # returns the number of observations in the dataset
>>>>>> C <- 50 # desired number of subsamples
>>>>>> S <- 38 # desired sample size
>>>>>>
>>>>>> sumb2 <- 0
>>>>>> for (i in 1:C){   # a loop over the number of subsamples
>>>>>>   set.seed(3*i)   # a different seed for each subsample
>>>>>>   subsample <- Li[sample(1:N, size=S, replace=TRUE), ]
>>>>>>   mod <- lm(Li~CR,data=subsample)
>>>>>>   #sum b2 for all subsamples:
>>>>>>   sumb2 <- sumb2 + coef(mod)[[2]]
>>>>>> }
>>>>>> print(sumb2/C, digits = 3)
>>>>>>
>>>>>>But when I run the script, I had error message:
>>

Re: [R] Monte Carlo on simple regression

2018-08-22 Thread Ogbos Okike
Hello Erick,

Thanks again.
Another line indicated error:

source("script.R")
Error in eval(predvars, data, env) :
  numeric 'envir' arg not of length one
Thank you for additional assitance.
Ogbos



On Wed, Aug 22, 2018 at 5:23 PM Eric Berger  wrote:

> You have an extra comma ... it should be
>
> Li[sample(1:N, size = S, replace = TRUE)]
>
> i.e. no comma after the closing parenthesis
>
>
>
> On Wed, Aug 22, 2018 at 7:20 PM, Ogbos Okike 
> wrote:
>
>> Hello Eric,
>> Thanks for this.
>>
>> I tried it. It went but another problem prevents the code from running.
>>  source("script.R")
>> Error in Li[sample(1:N, size = S, replace = TRUE), ] :
>>   incorrect number of dimensions
>>
>> The error is coming from the line:
>>  subsample <- Li[sample(1:N, size=S, replace=TRUE), ]
>>
>> I tried to replace Li with N but it didn't go. I also tried replacing it
>> with length(Li). The same error remains.
>>
>> Thank so much for looking at this again.
>>
>> Ogbos
>>
>>
>> On Wed, Aug 22, 2018 at 5:06 PM Eric Berger 
>> wrote:
>>
>>> Li is defined as d1$a which is a vector. You should use
>>>
>>> N <- length(Li)
>>>
>>> HTH,
>>> Eric
>>>
>>>
>>> On Wed, Aug 22, 2018 at 6:02 PM, Ogbos Okike 
>>> wrote:
>>>
>>>> Kind R-users,
>>>> I run a simple regression. I am interested in using the Monte Carlo to
>>>> test
>>>> the slope parameter.
>>>> Here is what I have done:
>>>> d1<-read.table("Lightcor",col.names=c("a"))
>>>> d2<-read.table("CRcor",col.names=c("a"))
>>>>  Li<-d1$a
>>>> CR<-d2$a
>>>>
>>>>  fit<-lm(Li~CR)
>>>>  a<-summary(fit)
>>>> a gives the slope as 88.15
>>>>
>>>> Problem: I now what to repeat the samples to access this coefficient.
>>>> Following one of the related examples I got online, I did (tried to
>>>> modify):
>>>>
>>>> N <- nrow(Li) # returns the number of observations in the dataset
>>>> C <- 50 # desired number of subsamples
>>>> S <- 38 # desired sample size
>>>>
>>>> sumb2 <- 0
>>>> for (i in 1:C){   # a loop over the number of subsamples
>>>>   set.seed(3*i)   # a different seed for each subsample
>>>>   subsample <- Li[sample(1:N, size=S, replace=TRUE), ]
>>>>   mod <- lm(Li~CR,data=subsample)
>>>>   #sum b2 for all subsamples:
>>>>   sumb2 <- sumb2 + coef(mod)[[2]]
>>>> }
>>>> print(sumb2/C, digits = 3)
>>>>
>>>>But when I run the script, I had error message:
>>>> Error in 1:N : argument of length 0
>>>> My data:
>>>> LiCR
>>>> 74281 8449
>>>> 92473 8148
>>>> 62310 8520
>>>> 71219 8264
>>>> 33469 8389
>>>> 75768 7499
>>>> 61636 7821
>>>> 103829 8468
>>>> 87336 8568
>>>> 129443 8190
>>>> 97682 8539
>>>> 106918 8502
>>>> 97171 8578
>>>> 48012 8181
>>>> 93086 8631
>>>> 92374 8562
>>>> 113010 8404
>>>> 66956 8592
>>>> 133037 8632
>>>> 108849 8644
>>>> 81544 8442
>>>> 105072 8615
>>>> 143437 7724
>>>> 153294 7829
>>>> 123735 8682
>>>> 154738 8756
>>>> 100760 8839
>>>> 108034 8839
>>>> 81826 8858
>>>> 116901 8847
>>>> 80780 8869
>>>> 122684 8736
>>>> 141716 9087
>>>> 144315 9166
>>>> 162078 9147
>>>> 163184 9267
>>>> 150688 9275
>>>> 200848 9259
>>>> 221570 8943
>>>> 192424 8564
>>>> 173024 9282
>>>> 197326 9318
>>>> 209344 9293
>>>> 220201 9242
>>>> 212626 9324
>>>> 218115 9319
>>>> 170001 9314
>>>> 187490 9346
>>>> 172440 9350
>>>> 180330 9349
>>>> 200807 9355
>>>> 234994 9350
>>>> 139053 9284
>>>> 150048 9361
>>>> 203650 9346
>>>> 21 9369
>>>> 198790 9340
>>>> 164060 9382
>>>> 198000 9401
>>>> 201707 9355
>>>> 179257 9369
>>>> 188736 9298
>>>> 243392 9393
>>>> 246040 9374
>>>> 269058 9364
>>>> 201657 9370
>>>> 187942 9354
>>>> 228514 9305
>>>> 234000 9392
>>>> 224431 9395
>>>> 163502 9398
>>>> I would be most glad for your great assistance.
>>>> Many thanks.
>>>> Ogbos
>>>>
>>>> [[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] Monte Carlo on simple regression

2018-08-22 Thread Ogbos Okike
Hello Eric,
Thanks for this.

I tried it. It went but another problem prevents the code from running.
 source("script.R")
Error in Li[sample(1:N, size = S, replace = TRUE), ] :
  incorrect number of dimensions

The error is coming from the line:
 subsample <- Li[sample(1:N, size=S, replace=TRUE), ]

I tried to replace Li with N but it didn't go. I also tried replacing it
with length(Li). The same error remains.

Thank so much for looking at this again.

Ogbos


On Wed, Aug 22, 2018 at 5:06 PM Eric Berger  wrote:

> Li is defined as d1$a which is a vector. You should use
>
> N <- length(Li)
>
> HTH,
> Eric
>
>
> On Wed, Aug 22, 2018 at 6:02 PM, Ogbos Okike 
> wrote:
>
>> Kind R-users,
>> I run a simple regression. I am interested in using the Monte Carlo to
>> test
>> the slope parameter.
>> Here is what I have done:
>> d1<-read.table("Lightcor",col.names=c("a"))
>> d2<-read.table("CRcor",col.names=c("a"))
>>  Li<-d1$a
>> CR<-d2$a
>>
>>  fit<-lm(Li~CR)
>>  a<-summary(fit)
>> a gives the slope as 88.15
>>
>> Problem: I now what to repeat the samples to access this coefficient.
>> Following one of the related examples I got online, I did (tried to
>> modify):
>>
>> N <- nrow(Li) # returns the number of observations in the dataset
>> C <- 50 # desired number of subsamples
>> S <- 38 # desired sample size
>>
>> sumb2 <- 0
>> for (i in 1:C){   # a loop over the number of subsamples
>>   set.seed(3*i)   # a different seed for each subsample
>>   subsample <- Li[sample(1:N, size=S, replace=TRUE), ]
>>   mod <- lm(Li~CR,data=subsample)
>>   #sum b2 for all subsamples:
>>   sumb2 <- sumb2 + coef(mod)[[2]]
>> }
>> print(sumb2/C, digits = 3)
>>
>>But when I run the script, I had error message:
>> Error in 1:N : argument of length 0
>> My data:
>> LiCR
>> 74281 8449
>> 92473 8148
>> 62310 8520
>> 71219 8264
>> 33469 8389
>> 75768 7499
>> 61636 7821
>> 103829 8468
>> 87336 8568
>> 129443 8190
>> 97682 8539
>> 106918 8502
>> 97171 8578
>> 48012 8181
>> 93086 8631
>> 92374 8562
>> 113010 8404
>> 66956 8592
>> 133037 8632
>> 108849 8644
>> 81544 8442
>> 105072 8615
>> 143437 7724
>> 153294 7829
>> 123735 8682
>> 154738 8756
>> 100760 8839
>> 108034 8839
>> 81826 8858
>> 116901 8847
>> 80780 8869
>> 122684 8736
>> 141716 9087
>> 144315 9166
>> 162078 9147
>> 163184 9267
>> 150688 9275
>> 200848 9259
>> 221570 8943
>> 192424 8564
>> 173024 9282
>> 197326 9318
>> 209344 9293
>> 220201 9242
>> 212626 9324
>> 218115 9319
>> 170001 9314
>> 187490 9346
>> 172440 9350
>> 180330 9349
>> 200807 9355
>> 234994 9350
>> 139053 9284
>> 150048 9361
>> 203650 9346
>> 21 9369
>> 198790 9340
>> 164060 9382
>> 198000 9401
>> 201707 9355
>> 179257 9369
>> 188736 9298
>> 243392 9393
>> 246040 9374
>> 269058 9364
>> 201657 9370
>> 187942 9354
>> 228514 9305
>> 234000 9392
>> 224431 9395
>> 163502 9398
>> I would be most glad for your great assistance.
>> Many thanks.
>> Ogbos
>>
>> [[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] Monte Carlo on simple regression

2018-08-22 Thread Ogbos Okike
Kind R-users,
I run a simple regression. I am interested in using the Monte Carlo to test
the slope parameter.
Here is what I have done:
d1<-read.table("Lightcor",col.names=c("a"))
d2<-read.table("CRcor",col.names=c("a"))
 Li<-d1$a
CR<-d2$a

 fit<-lm(Li~CR)
 a<-summary(fit)
a gives the slope as 88.15

Problem: I now what to repeat the samples to access this coefficient.
Following one of the related examples I got online, I did (tried to modify):

N <- nrow(Li) # returns the number of observations in the dataset
C <- 50 # desired number of subsamples
S <- 38 # desired sample size

sumb2 <- 0
for (i in 1:C){   # a loop over the number of subsamples
  set.seed(3*i)   # a different seed for each subsample
  subsample <- Li[sample(1:N, size=S, replace=TRUE), ]
  mod <- lm(Li~CR,data=subsample)
  #sum b2 for all subsamples:
  sumb2 <- sumb2 + coef(mod)[[2]]
}
print(sumb2/C, digits = 3)

   But when I run the script, I had error message:
Error in 1:N : argument of length 0
My data:
LiCR
74281 8449
92473 8148
62310 8520
71219 8264
33469 8389
75768 7499
61636 7821
103829 8468
87336 8568
129443 8190
97682 8539
106918 8502
97171 8578
48012 8181
93086 8631
92374 8562
113010 8404
66956 8592
133037 8632
108849 8644
81544 8442
105072 8615
143437 7724
153294 7829
123735 8682
154738 8756
100760 8839
108034 8839
81826 8858
116901 8847
80780 8869
122684 8736
141716 9087
144315 9166
162078 9147
163184 9267
150688 9275
200848 9259
221570 8943
192424 8564
173024 9282
197326 9318
209344 9293
220201 9242
212626 9324
218115 9319
170001 9314
187490 9346
172440 9350
180330 9349
200807 9355
234994 9350
139053 9284
150048 9361
203650 9346
21 9369
198790 9340
164060 9382
198000 9401
201707 9355
179257 9369
188736 9298
243392 9393
246040 9374
269058 9364
201657 9370
187942 9354
228514 9305
234000 9392
224431 9395
163502 9398
I would be most glad for your great assistance.
Many thanks.
Ogbos

[[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] tapply and error bars: Problem Fixed

2018-06-24 Thread Ogbos Okike
HI Jim,

This is great!! It is also tricky!!! The problem lies in the choice of
ylim. And looking at the data and choosing ylim based on the maximum and
minimum values of y is a waste of time. And choosing it by other means was
yet much more difficult.

I had to start plotting part of the data with incremental step of 80 data
points and manually varying ylim till I got to the last data point 1136,
where I finally used ylim=c(15,162000) which has nothing to do with the
raw data.

Many, many thanks.
Best wishes
Ogbos

On Sun, Jun 24, 2018 at 9:51 PM, Jim Lemon  wrote:

> Hi Ogbos,
> The problem is almost certainly with the data. I get the plot I expect
> with the sample data that you first posted, so I know that the code
> works. If you try thIs what do you get?
>
> oodf<-read.table(text="S/N  AB
> 1-5  64833
> 2-4  95864
> 3-3  82322
> 4-2  95591
> 5-1  69378
> 6 0  74281
> 7 1 103261
> 8 2  92473
> 9 3  84344
> 104 127415
> 115 123826
> 126 100029
> 137  76205
> 148 105162
> 159 119533
> 16   10 106490
> 17   -5  82322
> 18   -4  95591
> 19   -3  69378
> 20   -2  74281
> 21   -1 103261
> 220  92473
> 231  84344
> 242 127415
> 253 123826
> 264 100029
> 275  76205
> 286 105162
> 297 119533
> 308 106490
> 319 114771
> 32   10  55593
> 33   -5  85694
> 34   -4  65205
> 35   -3  80995
> 36   -2  51723
> 37   -1  62310
> 380  53401
> 391  65677
> 402  76094
> 413  64035
> 424  68290
> 435  73306
> 446  82176
> 457  75566
> 468  89762
> 479  88063
> 48   10  94395
> 49   -5  80651
> 50   -4  81291
> 51   -3  63702
> 52   -2  70297
> 53   -1  64117
> 540  71219
> 551  57354
> 562  62111
> 573  42252
> 584  35454
> 595  33469
> 606  38899
> 617  64981
> 628  85694
> 639  79452
> 64   10  85216
> 65   -5  71219
> 66   -4  57354
> 67   -3  62111
> 68   -2  42252
> 69   -1  35454
> 700  33469
> 711  38899
> 722  64981
> 733  85694
> 744  79452
> 755  85216
> 766  81721
> 777  91231
> 788 107074
> 799 108103
> 80   10  7576",
> header=TRUE)
> library(plotrix)
> std.error<-function(x) return(sd(x)/(sum(!is.na(x
> oomean<-as.vector(by(oodf$B,oodf$A,mean))
> oose<-as.vector(by(oodf$B,oodf$A,std.error))
> plot(-5:10,oomean,type="b",ylim=c(5,11),
>  xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
> dispersion(-5:10,oomean,oose)
>
> I get the attached plot;
>
> Jim
>
> On Mon, Jun 25, 2018 at 1:58 AM, Ogbos Okike 
> wrote:
> > Hi Jim
> >
> > Thanks again for returning to this.
> > please not that the line "oomean<-as.vector(by(oodf$B,oodf$A,mean))" was
> > omitted (not sure whether deliberate)  after you introduced the standard
> > error function.
> > When I used it, empty plot window with the correct axes were generated
> but
> > no data was displayed. No error too.
> >
> > library(plotrix)
> > std.error<-function(x) return(sd(x)/(sum(!is.na(x
> > oose<-as.vector(by(oodf$B,oodf$A,std.error))
> > plot(-5:10,oomean,type="b",ylim=c(5,11),
> >  xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
> > dispersion(-5:10,oomean,oose)
> >
> > When I included the line, the same empty graph window was generated but
> with
> > the former error "Error in FUN(X[[1L]], ...) : could not find function
> > "FUN""
> > library(plotrix)
> > std.error<-function(x) return(sd(x)/(sum(!is.na(x
> > oomean<-as.vector(by(oodf$B,oodf$A,mean))
> > oose<-as.vector(by(oodf$B,oodf$A,std.error))
> > plot(-5:10,oomean,type="b",ylim=c(5,11),
> >  xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
> > dispersion(-5:10,oomean,oose)
> >
> > I am sure am missing something but can't place it. Please have a look
> again
> > to track my mistake.
> >
> > Warmest regards
> > Ogbos
> >
>

[[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] tapply and error bars

2018-06-24 Thread Ogbos Okike
Hi Jim

Thanks again for returning to this.
please not that the line "oomean<-as.vector(by(oodf$B,oodf$A,mean))" was
omitted (not sure whether deliberate)  after you introduced the standard
error function.
When I used it, empty plot window with the correct axes were generated but
no data was displayed. No error too.

library(plotrix)
std.error<-function(x) return(sd(x)/(sum(!is.na(x
oose<-as.vector(by(oodf$B,oodf$A,std.error))
plot(-5:10,oomean,type="b",ylim=c(5,11),
 xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
dispersion(-5:10,oomean,oose)

When I included the line, the same empty graph window was generated but
with the former error "Error in FUN(X[[1L]], ...) : could not find function
"FUN""
library(plotrix)
std.error<-function(x) return(sd(x)/(sum(!is.na(x
oomean<-as.vector(by(oodf$B,oodf$A,mean))
oose<-as.vector(by(oodf$B,oodf$A,std.error))
plot(-5:10,oomean,type="b",ylim=c(5,11),
 xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
dispersion(-5:10,oomean,oose)

I am sure am missing something but can't place it. Please have a look again
to track my mistake.

Warmest regards
Ogbos

On Sun, Jun 24, 2018 at 11:24 AM, Jim Lemon  wrote:

> Hi Ogbos,
> If I use the example data that you sent, I get the error after this line:
>
> oose<-as.vector(by(oodf$B,oodf$A,std.error))
> Error in FUN(X[[i]], ...) : object 'std.error' not found
>
> The reason is that you have not defined std.error as a function, but
> as the result of a calculation. When I rewrite it like this:
>
> std.error<-function(x) return(sd(x)/(sum(!is.na(x
> oose<-as.vector(by(oodf$B,oodf$A,std.error))
> plot(-5:10,oomean,type="b",ylim=c(5,110000),
>  xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
> dispersion(-5:10,oomean,oose)
>
> I get the expected plot.
>
> Jim
>
>
> On Sat, Jun 23, 2018 at 9:36 PM, Ogbos Okike 
> wrote:
> > Hi Jim,
> >
> > Thanks for assisting. Here is what I did:
> >
> > A<-matrix(rep(-5:10,71))
> > B<-matrix(data)
> > std.error = sd(B)/sqrt(sum(!is.na(B)))
> >  oodf<-data.frame(A,B)
> >
> >  oomean<-as.vector(by(oodf$B,oodf$A,mean))
> > oose<-as.vector(by(oodf$B,oodf$A,std.error))
> > plot(-5:10,oomean,type="b",ylim=c(5,11),
> >  xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
> > dispersion(-5:10,oomean,oose)
> >
> > And the error says:
> > Error in FUN(X[[1L]], ...) : could not find function "FUN"
> >
> > Please note that I use:
> > std.error = sd(B)/sqrt(sum(!is.na(B)))
> >  to calculate the standard error as it requested for it.
> >
> > Thanks
> > Ogbos
> >
> > On Sat, Jun 23, 2018 at 10:09 AM, Jim Lemon 
> wrote:
> >>
> >> Hi Ogbos,
> >> This may help:
> >>
> >> # assume your data frame is named "oodf"
> >> oomean<-as.vector(by(oodf$B,oodf$A,mean))
> >> oose<-as.vector(by(oodf$B,oodf$A,std.error))
> >> plot(-5:10,oomean,type="b",ylim=c(5,11),
> >>  xlab="days (epoch is the day of Fd)",ylab="strikes/km2/day")
> >> dispersion(-5:10,oomean,oose)
> >>
> >> Jim
> >>
> >> On Sat, Jun 23, 2018 at 4:35 PM, Ogbos Okike 
> >> wrote:
> >> > Dear workers,
> >> > I have a data of length 1136. Below is the code I use to get the means
> >> > B.
> >> > It worked fine and I had the mean calculated and plotted.
> >> >
> >> > I wish to plot the error bars as well. I already plotted such means
> with
> >> > error bars before. Please see attached for example.
> >> >
> >> > I tried to redo the same plot but unlikely could not get around it as
> I
> >> > lost my system containing the script.
> >> > Among many attempts, I tried:
> >> > library(gplots)
> >> >
> >> >  plotmeans(errors~AB,xlab="Factor A",ylab="mean errors", p=.68,
> >> > main="Main
> >> >   effect Plot",barcol="black")
> >> > Nothing worked.
> >> >
> >> > I would really be thankful should somebody return me to the track.
> >> > Many, many thanks for your time.
> >> > Ogbos
> >> >
> >> > A sample of the data is:
> >> > S/N  AB
> >> > 1-5  64833
> >> > 2-4  95864
> >> > 3-3  82

[R] as.Date and Legend in a plot: Fixed

2018-06-23 Thread Ogbos Okike
Dear List,
I am happy to report that the problem is fixed. as.Date("1998-02-10") as
suggested by David handled the problem with easy. Many thanks to everybody.
as.Date(1998-02-10) really resulted in error. It is my oversight. I really
tried many things the day I was working on that and have forgotten some of
the errors.

Thanks again.



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

2018-06-22 Thread Ogbos Okike
Dear workers,
I have a data of length 1136. Below is the code I use to get the means B.
It worked fine and I had the mean calculated and plotted.

I wish to plot the error bars as well. I already plotted such means with
error bars before. Please see attached for example.

I tried to redo the same plot but unlikely could not get around it as I
lost my system containing the script.
Among many attempts, I tried:
library(gplots)

 plotmeans(errors~AB,xlab="Factor A",ylab="mean errors", p=.68, main="Main
  effect Plot",barcol="black")
Nothing worked.

I would really be thankful should somebody return me to the track.
Many, many thanks for your time.
Ogbos

A sample of the data is:
S/N  AB
1-5  64833
2-4  95864
3-3  82322
4-2  95591
5-1  69378
6 0  74281
7 1 103261
8 2  92473
9 3  84344
104 127415
115 123826
126 100029
137  76205
148 105162
159 119533
16   10 106490
17   -5  82322
18   -4  95591
19   -3  69378
20   -2  74281
21   -1 103261
220  92473
231  84344
242 127415
253 123826
264 100029
275  76205
286 105162
297 119533
308 106490
319 114771
32   10  55593
33   -5  85694
34   -4  65205
35   -3  80995
36   -2  51723
37   -1  62310
380  53401
391  65677
402  76094
413  64035
424  68290
435  73306
446  82176
457  75566
468  89762
479  88063
48   10  94395
49   -5  80651
50   -4  81291
51   -3  63702
52   -2  70297
53   -1  64117
540  71219
551  57354
562  62111
573  42252
584  35454
595  33469
606  38899
617  64981
628  85694
639  79452
64   10  85216
65   -5  71219
66   -4  57354
67   -3  62111
68   -2  42252
69   -1  35454
700  33469
711  38899
722  64981
733  85694
744  79452
755  85216
766  81721
777  91231
788 107074
799 108103
80   10  7576

A<-matrix(rep(-5:10,71))
B<-matrix(data)
 AB<-data.frame(A,B)

x= B

 f<-factor(A)
AB<- tapply(x,f,mean)
x<--5:10
plot(x,AB,type="l")
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] as.Date and Legend in a plot

2018-06-22 Thread Ogbos Okike
Dear Contributors,

I am surprised that I cannot add legend to a certain plot. Although the
x-axis indicates years, the actual data was in year, month and day format.
I then used as.Date to play around and get what I am looking for. I am,
however, worried that I cannot add legend to the plot no matter how I
tried. Looking at the axis, I tried:
legend(1998,3, c("Climax", "Thule", "Sopo"), lty = 1, col =
c("black","red","blue")). I also tried:

legend(as.Date(1998-02-10),3, c("Climax", "Thule", "Sopo"), lty = 1, col =
c("black","red","blue"))
but no result and no error.

I have attached the plot in case it will assist in your suggestions.

Many thanks for your time.

Ogbos
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Manipulating two large dataset differing by date and time

2018-01-22 Thread Ogbos Okike
Hello Jim,

Thank you so much for your attention. It handled the hourly data with ease.
Best wishes
Ogbos

On Mon, Jan 22, 2018 at 8:21 AM, Jim Lemon  wrote:

> Hi Ogbos,
> You can just use ISOdate. If you pass more values, it will process them:
>
> ISOdate(2018,01,22)
> [1] "2018-01-22 12:00:00 GMT"
> > ISOdate(2018,01,22,18,17)
> [1] "2018-01-22 18:17:00 GMT"
>
> Add something like:
>
> if(is.null(data$hour),data$hour<-12
>
> then pass data$hour as it will default to the same value as if you
> hadn't passed it.
>
> Jim
>
> On Mon, Jan 22, 2018 at 6:01 PM, Ogbos Okike 
> wrote:
> > Dear Members,
> >
> > Compliments of the Season!!
> >
> >
> > Below is a part of a code I use for Fourier analysis of signals. The code
> > handles data with the format 05 01 018628 (year, month, day and
> count)
> >   05 01 028589 (year, month, day and
> count)
> > The sample data is attached as 2005daily.txt.
> >
> > I would like to adapt the code to handle data of the form:
> > 05 01 01 004009 (year, month, day, hour and count)
> > 05 01 01 013969 (year, month, day, hour and count)
> >
> > The sample is also attached as 2005hourly.txt.
> >
> > Thank you very much for your kind inputs.
> >
> > Ogbos
> >
> >
> >
> >
> > data <- read.table("2005daily.txt", col.names = c("year", "month", "day",
> > "counts"))
> >
> > new.century <- data$year < 50
> >
> > data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)
> >
> > data$date <- as.Date(ISOdate(data$year, data$month, data$day))
> > x1 = data$date
> >  y = data$counts
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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] Manipulating two large dataset differing by date and time

2018-01-21 Thread Ogbos Okike
Dear Members,

Compliments of the Season!!


Below is a part of a code I use for Fourier analysis of signals. The code
handles data with the format 05 01 018628 (year, month, day and count)
  05 01 028589 (year, month, day and count)
The sample data is attached as 2005daily.txt.

I would like to adapt the code to handle data of the form:
05 01 01 004009 (year, month, day, hour and count)
05 01 01 013969 (year, month, day, hour and count)

The sample is also attached as 2005hourly.txt.

Thank you very much for your kind inputs.

Ogbos




data <- read.table("2005daily.txt", col.names = c("year", "month", "day",
"counts"))

new.century <- data$year < 50

data$year <- ifelse(new.century, data$year + 2000, data$year + 1900)

data$date <- as.Date(ISOdate(data$year, data$month, data$day))
x1 = data$date
 y = data$counts
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/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] Install GARPFRM package

2016-05-19 Thread Ogbos Okike
Hi Saba,
Your main worry may be that of non- zero status and hence your attempt to
load what the system claims you have. I have encountered such problems
severally. You can try two things: run it several times ( network issues
might play a role) or try different crab mirrors.
Ogbos
On May 19, 2016 5:53 AM, "Saba Sehrish via R-help" 
wrote:

> Hi
>
> I am trying to install GARPFRM package to R (version: 3.3.0) by following
> steps:
>
> (a)  install.packages("GARPFRM", repos="http://R-Forge.R-project.org";)
>
> It gives following Warning messages:
>
> 1: running command '"C:/PROGRA~1/R/R-33~1.0/bin/i386/R" CMD INSTALL -l
> "C:\Users\ssehrish\Documents\R\win-library\3.3"
> C:\Users\ssehrish\AppData\Local\Temp\RtmpU3JvBo/downloaded_packages/GARPFRM_0.1.0.tar.gz'
> had status 1
>
>
> 2: In install.packages("GARPFRM", repos = "http://R-Forge.R-project.org";)
> :  installation of package ‘GARPFRM’ had non-zero exit status
>
>
> (b) library(GARPFRM)
>
> It gives following error :  Error in library(GARPFRM) : there is no
> package called ‘GARPFRM’
>
> Please help me in this regard.
>
> Thanks
> Saba
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/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.

  1   2   >