Manipulating two large dataset differing by date and time

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Manipulating two large dataset differing by date and time

Ogbos
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 01    8628 (year, month, day and count)
                              05 01 02    8589 (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 00    4009 (year, month, day, hour and count)
05 01 01 01    3969 (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
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating two large dataset differing by date and time

Jim Lemon-4
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 <[hidden email]> 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 01    8628 (year, month, day and count)
>                               05 01 02    8589 (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 00    4009 (year, month, day, hour and count)
> 05 01 01 01    3969 (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
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Manipulating two large dataset differing by date and time

Ogbos
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 <[hidden email]> 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 <[hidden email]>
> 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 01    8628 (year, month, day and
> count)
> >                               05 01 02    8589 (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 00    4009 (year, month, day, hour and count)
> > 05 01 01 01    3969 (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
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/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]]

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