Hi Subhamitra,
This is not the only way to do this, but if you only want the monthly
averages, it is simple:
# I had to change the "soft" tabs in your email to commas
# in order to read the data in
spdf<-read.table(text="PERMNO,DATE,Spread
111,19940103,0.025464308
111,19940104,0.064424296
PM
To: PIKAL Petr <mailto:petr.pi...@precheza.cz>; r-help mailing list
<mailto:r-help@r-project.org>
Subject: Re: [R] Query about calculating the monthly average of daily
data
columns
Dear PIKAL,
Thank you very much for your suggestion.
I tried your previous suggested code and getting t
1865, 10.7577574534162,
> > 11.1124067479261, 9.91627943243343, 10.6356898895291, 10.2107566441478,
> > 10.0672734202575, 10.2385787014999, 11.7112606160069, 10.0453801263575,
> > 8.84654136100724, 10.2173421609193, 9.27919801705716, 10.4755578829547,
> > 7.69340209082122, 9.24705253
lculations.
>
> Please suggest me in this regard.
>
> Thank you.
>
>
>
>
>
>
> https://mailtrack.io?utm_source=gmail_medium=signature_campaign=signaturevirality5;
> Sender notified by
>
> https://mailtrack.io?utm_source=gmail_medium=signature_campaign=s
; From: R-help <mailto:r-help-boun...@r-project.org> On Behalf Of Subhamitra
> Patra
> Sent: Friday, September 13, 2019 3:20 PM
> To: Jim Lemon <mailto:drjimle...@gmail.com>; r-help mailing list http://project.org>
> Subject: Re: [R] Query about calculating the monthly average of
Sorry, forgot to include the list.
On Sat, Sep 14, 2019 at 10:27 AM Jim Lemon wrote:
>
> See inline
>
> On Fri, Sep 13, 2019 at 11:20 PM Subhamitra Patra
> wrote:
>>
>> Dear Sir,
>>
>> Yes, I understood the logic. But, still, I have a few queries that I
>> mentioned below your answers.
>>
>>>
quot;), country
> column), mean)
>
> But if you insist to scratch your left ear with right hand accross your
> head, you could continue your way.
>
> Cheers
> Petr
>
> > -Original Message-
> > From: R-help On Behalf Of Subhamitra
> > Patra
> > Sen
gt; From: R-help On Behalf Of Subhamitra
> Patra
> Sent: Friday, September 13, 2019 3:20 PM
> To: Jim Lemon ; r-help mailing list project.org>
> Subject: Re: [R] Query about calculating the monthly average of daily data
> columns
>
> Dear Sir,
>
> Yes, I understood the
Dear Sir,
Yes, I understood the logic. But, still, I have a few queries that I
mentioned below your answers.
"# if you only have to get the monthly averages, it can be done this way
> spdat$month<-sapply(strsplit(spdat$dates,"-"),"["*,2*)
> spdat$year<-sapply(strsplit(spdat$dates,"-"),"[",*3*)"
Hi Subhamitra,
I'll try to write my answers adjacent to your questions below.
On Fri, Sep 13, 2019 at 6:08 PM Subhamitra Patra
wrote:
> Dear Sir,
>
> Thank you very much for your suggestion.
>
> Yes, your suggested code worked. But, actually, I have data from 3rd
> January 1994 to 3rd August
4.26667
4 02.1994 returnB 30.03571
Cheers
Petr
> -Original Message-
> From: R-help On Behalf Of Subhamitra
> Patra
> Sent: Friday, September 13, 2019 10:08 AM
> To: Jim Lemon
> Cc: r-help mailing list
> Subject: Re: [R] Query about calculating the monthly average o
Dear Sir,
Thank you very much for your suggestion.
Yes, your suggested code worked. But, actually, I have data from 3rd
January 1994 to 3rd August 2017 for very large (i.e. for 84 countries)
sample. From this, I have given the example of the years up to 2000. Before
applying the same code for
Hi Subhamitra,
Your data didn't make it through, so I guess the first thing is to
guess what it looks like. Here's a try at just January and February of
1994 so that we can see the result on the screen. The logic will work
just as well for the whole seven years.
# create fake data for the first
Hello,
Inline.
Às 17:33 de 12/09/19, Bert Gunter escreveu:
But she wants *monthly* averages, Rui.
Thanks, my mistake.
Ergo ave() or tidyData
equivalent, right?
Maybe. But ave() returns as many values as the input length, this seems
more suited for tapply or aggregate.
I will first
Hello,
Please include data, say
dput(head(data, 20)) # post the output of this
But, is the problem as simple as
rowMeans(data[2:3], na.rm = TRUE)
?
Hope this helps,
Rui Barradas
Às 15:53 de 12/09/19, Subhamitra Patra escreveu:
Dear R-users,
I have daily data from 03-01-1994 to
No reproducible example, so hard to say. What class is your "date" column?
-- factor, character, Date? See ?Date
Once you have an object of appropriate class -- see ?format.Date -- ?months
can extract the month and ?ave can do your averaging. No explicit looping
is needed.
The tidydata
Dear R-users,
I have daily data from 03-01-1994 to 29-12-2000. In my datafile, he first
column is date and the second and third columns are the returns of the
country A, and B. Here, the date column is same for both countries. I want
to calculate the monthly average of both country's returns by
17 matches
Mail list logo