Re: [R] histogram of time-stamp data

2012-07-17 Thread e-letter
On 16/07/2012, Rui Barradas ruipbarra...@sapo.pt wrote:
 Hello,

 Em 16-07-2012 22:45, e-letter escreveu:
 On 16/07/2012, r-help-requ...@r-project.org
   r-help-requ...@r-project.org wrote:
--
   
Message: 77
Date: Mon, 16 Jul 2012 10:48:39 +0100
From: Rui Barradas ruipbarra...@sapo.pt
To: e-letter inp...@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] histogram of time-stamp data
Message-ID: 5003e377.3000...@sapo.pt
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
   
   
timestamps - as.POSIXct(Sys.Date()) + sample(24*60*60, 1e3, TRUE)
   

   Why is it necessary to apply the sample to the current date? Looking
   at the dataframe, I noticed that values have been changed:

 No! That instruction is just to create a data example with more
 date/time values, in this case with a total of 1e3 different values.
 What's important is the way to plot the histogram, namely, the cut()
 with two example time periods, and that hist() needs numbers, not cut's
 levels.


With the original data provided, R reports an error, that 'x' must be numeric'.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] histogram of time-stamp data

2012-07-17 Thread Rui Barradas

Hello,

That's not the error I've had. You must be aware that read.table creates 
a data.frame and therefore the object 'timestamps' is NOT holding time 
stamps, it's holding a vector, 'V1', of time stamps.



timestamps - read.table(text=
12:19:00
09:30:00
16:56:00
01:56:00
10:44:00
10:31:00
02:14:00
05:05:00
12:52:00
21:50:00
, stringsAsFactors=FALSE)
str(timestamps)

timestamps - as.POSIXct(timestamps$V1, format=%H:%M:%S)  # here

h1 - cut(timestamps, breaks=hour)
h2 - cut(timestamps, breaks=15 mins)

op - par(mfrow=c(1, 2))
hist(as.integer(h1))
hist(as.integer(h2))
par(op)


And the rest works.

Rui Barradas

Em 17-07-2012 07:11, e-letter escreveu:

On 16/07/2012, Rui Barradas ruipbarra...@sapo.pt wrote:

Hello,

Em 16-07-2012 22:45, e-letter escreveu:

On 16/07/2012, r-help-requ...@r-project.org
   r-help-requ...@r-project.org wrote:
--
   
Message: 77
Date: Mon, 16 Jul 2012 10:48:39 +0100
From: Rui Barradas ruipbarra...@sapo.pt
To: e-letter inp...@gmail.com
Cc: r-help@r-project.org
Subject: Re: [R] histogram of time-stamp data
Message-ID: 5003e377.3000...@sapo.pt
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
   
   
timestamps - as.POSIXct(Sys.Date()) + sample(24*60*60, 1e3, TRUE)
   

   Why is it necessary to apply the sample to the current date? Looking
   at the dataframe, I noticed that values have been changed:


No! That instruction is just to create a data example with more
date/time values, in this case with a total of 1e3 different values.
What's important is the way to plot the histogram, namely, the cut()
with two example time periods, and that hist() needs numbers, not cut's
levels.



With the original data provided, R reports an error, that 'x' must be numeric'.



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] histogram of time-stamp data

2012-07-17 Thread e-letter
On 17/07/2012, Rui Barradas ruipbarra...@sapo.pt wrote:
 Hello,

 That's not the error I've had. You must be aware that read.table creates
 a data.frame and therefore the object 'timestamps' is NOT holding time
 stamps, it's holding a vector, 'V1', of time stamps.


Was not aware of the significance of the data frame of vector values.

 ..., stringsAsFactors=FALSE)


Can confirm the success of adding this parameter to the command 'read.table'

 timestamps - as.POSIXct(timestamps$V1, format=%H:%M:%S)  # here

 h1 - cut(timestamps, breaks=hour)

 And the rest works.


Confirmed, thanks.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] histogram of time-stamp data

2012-07-16 Thread e-letter
Readers,

A data set consists of time-stamp values:

00:00:00
23:11:00
06:22:00

The data set was imported:

timestamps-read.table(path/to/timestampsvalues)
hist(timestamps)

...error... x must be numeric

Then tried:

plot(timestamps).

How to adjust the graph to create a histogram where the intervals
ranges can be specified, e.g. intervals of 60 minutes?

Thanks in advance.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] histogram of time-stamp data

2012-07-16 Thread Jessica Streicher
pDates-as.POSIXct(times,format=%H:%M:%S)
 hist(pDates,hours)

On 16.07.2012, at 10:47, e-letter wrote:

 Readers,
 
 A data set consists of time-stamp values:
 
 00:00:00
 23:11:00
 06:22:00
 
 The data set was imported:
 
 timestamps-read.table(path/to/timestampsvalues)
 hist(timestamps)
 
 ...error... x must be numeric
 
 Then tried:
 
 plot(timestamps).
 
 How to adjust the graph to create a histogram where the intervals
 ranges can be specified, e.g. intervals of 60 minutes?
 
 Thanks in advance.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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
https://stat.ethz.ch/mailman/listinfo/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] histogram of time-stamp data

2012-07-16 Thread Rui Barradas

Hello,

Try the following.


timestamps - as.POSIXct(Sys.Date()) + sample(24*60*60, 1e3, TRUE)

h1 - cut(timestamps, breaks=hour)
h2 - cut(timestamps, breaks=15 mins)

op - par(mfrow=c(1, 2))
hist(as.integer(h1))
hist(as.integer(h2))
par(op)


Hope this helps,

Rui Barradas

Em 16-07-2012 09:47, e-letter escreveu:

Readers,

A data set consists of time-stamp values:

00:00:00
23:11:00
06:22:00

The data set was imported:

timestamps-read.table(path/to/timestampsvalues)
hist(timestamps)

...error... x must be numeric

Then tried:

plot(timestamps).

How to adjust the graph to create a histogram where the intervals
ranges can be specified, e.g. intervals of 60 minutes?

Thanks in advance.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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
https://stat.ethz.ch/mailman/listinfo/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] histogram of time-stamp data

2012-07-16 Thread e-letter
On 16/07/2012, r-help-requ...@r-project.org
 r-help-requ...@r-project.org wrote:
  --
 
  Message: 77
  Date: Mon, 16 Jul 2012 10:48:39 +0100
  From: Rui Barradas ruipbarra...@sapo.pt
  To: e-letter inp...@gmail.com
  Cc: r-help@r-project.org
  Subject: Re: [R] histogram of time-stamp data
  Message-ID: 5003e377.3000...@sapo.pt
  Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 
 
  timestamps - as.POSIXct(Sys.Date()) + sample(24*60*60, 1e3, TRUE)
 

 Why is it necessary to apply the sample to the current date? Looking
 at the dataframe, I noticed that values have been changed:

 file 'test.txt':
 12:19:00
 09:30:00
 16:56:00
 01:56:00
 10:44:00
 10:31:00
 02:14:00
 05:05:00
 12:52:00
 21:50:00

 R command terminal input:
  timestamps-read.table(test.txt)
  timestamps
  V1
 1  12:19:00
 2  09:30:00
 3  16:56:00
 4  01:56:00
 5  10:44:00
 6  10:31:00
 7  02:14:00
 8  05:05:00
 9  12:52:00
 10 21:50:00
  timestamps - as.POSIXct(Sys.Date()) + sample(24*60*60, 1e3, TRUE)
  write.csv(timestamps,file=test1.txt)

 test1.txt:
 ,x
 1,2012-07-16 04:52:48
 2,2012-07-16 21:21:28
 3,2012-07-16 18:58:27
 4,2012-07-16 22:17:25
 5,2012-07-16 11:13:52
 6,2012-07-16 03:17:35
 7,2012-07-16 02:14:17
 8,2012-07-16 14:18:27
 9,2012-07-16 14:39:16

 Why is this happening?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] histogram of time-stamp data

2012-07-16 Thread Rui Barradas

Hello,

Em 16-07-2012 22:45, e-letter escreveu:

On 16/07/2012, r-help-requ...@r-project.org
  r-help-requ...@r-project.org wrote:
   --
  
   Message: 77
   Date: Mon, 16 Jul 2012 10:48:39 +0100
   From: Rui Barradas ruipbarra...@sapo.pt
   To: e-letter inp...@gmail.com
   Cc: r-help@r-project.org
   Subject: Re: [R] histogram of time-stamp data
   Message-ID: 5003e377.3000...@sapo.pt
   Content-Type: text/plain; charset=ISO-8859-1; format=flowed
  
  
   timestamps - as.POSIXct(Sys.Date()) + sample(24*60*60, 1e3, TRUE)
  

  Why is it necessary to apply the sample to the current date? Looking
  at the dataframe, I noticed that values have been changed:


No! That instruction is just to create a data example with more 
date/time values, in this case with a total of 1e3 different values. 
What's important is the way to plot the histogram, namely, the cut() 
with two example time periods, and that hist() needs numbers, not cut's 
levels.


Rui Barradas



  file 'test.txt':
  12:19:00
  09:30:00
  16:56:00
  01:56:00
  10:44:00
  10:31:00
  02:14:00
  05:05:00
  12:52:00
  21:50:00

  R command terminal input:
   timestamps-read.table(test.txt)
   timestamps
   V1
  1  12:19:00
  2  09:30:00
  3  16:56:00
  4  01:56:00
  5  10:44:00
  6  10:31:00
  7  02:14:00
  8  05:05:00
  9  12:52:00
  10 21:50:00
   timestamps - as.POSIXct(Sys.Date()) + sample(24*60*60, 1e3, TRUE)
   write.csv(timestamps,file=test1.txt)

  test1.txt:
  ,x
  1,2012-07-16 04:52:48
  2,2012-07-16 21:21:28
  3,2012-07-16 18:58:27
  4,2012-07-16 22:17:25
  5,2012-07-16 11:13:52
  6,2012-07-16 03:17:35
  7,2012-07-16 02:14:17
  8,2012-07-16 14:18:27
  9,2012-07-16 14:39:16

  Why is this happening?



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