2, 2018 10:53 AM
To: PIKAL Petr ; r-help mailing list
Subject: Re: [R] read txt file - date - no space
Dear Petr,
I have read the file:
MyData <- read.csv(file="obs_prec.csv",header=TRUE, sep=",")
I have used POSIXct to convert properly the date
MyData$date2<-as.P
but also how to dealwith learning.
Can I ask you anover question about aggregate?
Again thanks
Diego
On 2 August 2018 at 10:10, PIKAL Petr wrote:
> Hi
>
>
>
> *From:* Diego Avesani
> *Sent:* Thursday, August 2, 2018 10:03 AM
> *To:* PIKAL Petr
> *Subject
nd please do not post HTML formated messages, it could be
> scrammbled)
>
>
>
> *From:* Diego Avesani
> *Sent:* Thursday, August 2, 2018 8:56 AM
> *To:* jim holtman ; PIKAL Petr >
> *Cc:* R mailing list
> *Subject:* Re: [R] read txt file - date - no space
>
>
>
d to POSIX correctly, are some of them NA?
Aggregate your values (not by lubridate function day) and store them in another
object
Cheers
Petr
From: Diego Avesani
Sent: Thursday, August 2, 2018 9:31 AM
To: jim holtman ; PIKAL Petr
Cc: R mailing list
Subject: Re: [R] read txt file - date - no s
Dear all,
I have found and error in the date conversion. Now it looks like:
MyData <- read.csv(file="obs_prec.csv",header=TRUE, sep=",")
# change date to real
MyData$date<-as.POSIXct(MyData$date, format="%*m*/%*d*/%Y %H:%M")
After that I apply the PIKAL's suggestions:
aggregate(MyData[,-1],
Hi
see in line (and please do not post HTML formated messages, it could be
scrammbled)
From: Diego Avesani
Sent: Thursday, August 2, 2018 8:56 AM
To: jim holtman ; PIKAL Petr
Cc: R mailing list
Subject: Re: [R] read txt file - date - no space
Dear
I have check the one of the line
Dear
I have check the one of the line that gives me problem. I mean, which give
NA after R processing. I think that is similar to the others:
10/12/1998 10:00,0,0,0
10/12/1998 11:00,0,0,0
10/12/1998 12:00,0,0,0
10/12/1998 13:00,0,0,0
10/12/1998 14:00,0,0,0
10/12/1998 15:00,0,0,0
10/12/1998
Try this:
> library(lubridate)
> library(tidyverse)
> input <- read.csv(text = "date,str1,str2,str3
+ 10/1/1998 0:00,0.6,0,0
+ 10/1/1998 1:00,0.2,0.2,0.2
+ 10/1/1998 2:00,0.6,0.2,0.4
+ 10/1/1998 3:00,0,0,0.6
+ 10/1/1998
Hi
see in line
From: Diego Avesani
Sent: Wednesday, August 1, 2018 2:30 PM
To: PIKAL Petr
Cc: r-help mailing list
Subject: Re: [R] read txt file - date - no space
Dear Pikal, Deal all,
again really thank.
it seems not working.
Some specifications: My non data are -999, but I could change
library(lubridate)
>>
>> # aggregate your object(s) and use lubridate function
>>
>> > aggregate(test[,-1], list(day(test$date)), mean)
>> Group.1 str1 str2 str3
>> 1 10 0.2 0.05 0.15
>>
>> # or format function
>>
>> > aggregate(te
>
> str(yourdata)
>
> or preferably
>
> dput(yourdata[1:20,])
>
> Cheers
> Petr
>
>
> > -Original Message-
> > From: R-help On Behalf Of Diego Avesani
> > Sent: Wednesday, August 1, 2018 8:55 AM
> > To: Jeff Newmiller
> > Cc:
Avesani
> Sent: Wednesday, August 1, 2018 8:55 AM
> To: Jeff Newmiller
> Cc: r-help mailing list
> Subject: Re: [R] read txt file - date - no space
>
> Dear all,
> I am sorry, I did a lot of confusion. I am sorry, I have to relax and stat
> all again
> in order to
Dear all,
I am sorry, I did a lot of confusion. I am sorry, I have to relax and stat
all again in order to understand.
If I could I would like to start again, without mixing strategy and waiting
for your advice.
I am really appreciate you help, really really.
Here my new file, a *.csv file (buy
... and the most common source of NA values in time data is wrong timezones.
You really need to make sure the timezone that is assumed when the character
data are converted to POSIXt agrees with the data. In most cases the easiest
way to insure this is to use
Sys.setenv(TZ="US/Pacific")
or
Hi Diego,
I think the error is due to NA values in your data file. If I extend
your example and run it, I get no errors:
MyData<-read.table(text="103001930 103001580 103001530
1998-10-01 00:00:00 0.6 0 0
1998-10-01 01:00:00 0.2 0.2 0.2
1998-10-01 02:00:00 0.6 0.2 0.4
1998-10-01 03:00:00 0 0 0.6
Dear all,
I have still problem with date.
Could you please tel me how to use POSIXct.
Indeed I have found this command:
timeAverage, but I am not able to convert MyDate to properly date.
Thank a lot
I hope to no bother you, at least too much
Diego
On 31 July 2018 at 11:12, Diego Avesani
Dear Jim, Dear all,
thanks a lot.
Unfortunately, I get the following error:
st1_daily<-by(MyData$st1,MyData$date,mean)Error in
tapply(seq_len(0L), list(`MyData$date` = c(913L, 914L, 925L, :
arguments must have same length
This is particularly strange. indeed, if I apply
Dear all,
I have found the error, my fault. Sorry.
There was an extra come in the headers line.
Thanks again.
If I can I would like to ask you another questions about the imported data.
I would like to compute the daily average of the different date. Basically
I have hourly data, I would like to
Dear all,
I move to csv file because originally the date where in csv file.
In addition, due to the fact that, as you told me, read.csv is a special
case of read.table, I prefer start to learn from the simplest one.
After that, I will try also the *.txt format.
with read.csv, something strange
Hi Diego,
One way you can get daily means is:
st1_daily<-by(MyData$st1,MyData$date,mean)
st2_daily<-by(MyData$st2,MyData$date,mean)
st3_daily<-by(MyData$st3,MyData$date,mean)
Jim
On Tue, Jul 31, 2018 at 6:51 PM, Diego Avesani wrote:
> Dear all,
> I have found the error, my fault. Sorry.
>
Or, without removing the first line
dadf <- read.table("xxx.txt", stringsAsFactors=FALSE, skip=1)
Another alternative,
dadf$datetime <- as.POSIXct(paste(dadf$V1,dadf$V2))
since the dates appear to be in the default format.
(I generally prefer to work with datetimes in POSIXct class rather
Hi Diego,
You may have to do some conversion as you have three fields in the
first line using the default space separator and five fields in
subsequent lines. If the first line doesn't contain any important data
you can just delete it or replace it with a meaningful header line
with five fields
1) No.
2) The read.csv function is a s special case use of the more general read.table
function that can handle any simple field separator.
3) Read the data in as character (I recommend using the stringsAsFactors=FALSE
argument to read.table) and convert to an appropriate type from that form.
Dear all,
I am dealing with the reading of a *.txt file.
The txt file the following shape:
103001930 103001580 103001530
1998-10-01 00:00:00 0.6 0 0
1998-10-01 01:00:00 0.2 0.2 0.2
1998-10-01 02:00:00 0.6 0.2 0.4
1998-10-01 03:00:00 0 0 0.6
1998-10-01 04:00:00 0 0 0
1998-10-01 05:00:00 0 0 0
24 matches
Mail list logo