Hi there,

I am new to R and programming in general and am looking for help with
writing a function with dates and times. I have checked around but am still
a bit stuck.

Basically, I have data in the format "dd/mm/YYYY HH:MM" and I have to
calculate how much time has passed between various events.

I have given the following command ( where "date" is the column in my data
frame that indicates the date and time)
date=as.Date.factor(date,format="%d/%m/%Y %H:%M")
However, this displays only the date, without the time.

I also have tried:
date=substr(argo1$date,1,907)
And it shows the date and time.

However, when I try to find the difference between two dates i.e.the time
that has passed with the command: difftime(date[2],date[3],unit="secs"), it
returns that 0 seconds have passed.

When I try to find the difference with the command:
date[3]-date[2]
it tells me Error in date[3] - date[2] : non-numeric argument to binary
operator

The class(date) is "character".

Any idea what I am doing wrong?
Thank you very much in advance!


On 19 December 2013 15:22, <r-help-request@r-project.org> wrote:

> Welcome to the R-help@r-project.org mailing list!
>
> To post to this list, send your message to:
>
>   r-help@r-project.org
>
> General information about the mailing list is at:
>
>   https://stat.ethz.ch/mailman/listinfo/r-help
>
> If you ever want to unsubscribe or change your options (eg, switch to
> or from digest mode, change your password, etc.), visit your
> subscription page at:
>
>   https://stat.ethz.ch/mailman/options/r-help/lydiakeppler%40gmail.com
>
> You can also make such adjustments via email by sending a message to:
>
>   R-help-request@r-project.org
>
> with the word `help' in the subject or body (don't include the
> quotes), and you will get back a message with instructions.
>
> You must know your password to change your options (including changing
> the password, itself) or to unsubscribe without confirmation.  It is:
>
>   whaletail27
>
> Normally, Mailman will remind you of your r-project.org mailing list
> passwords once every month, although you can disable this if you
> prefer.  This reminder will also include instructions on how to
> unsubscribe or change your account options.  There is also a button on
> your options page that will email your current password to you.
>



-- 
*Protect the environment: think before you print*
><((((º>

	[[alternative HTML version deleted]]

