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
111,1994
ross your
head, you could continue your way.
Cheers
Petr
-Original Message-
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://proj
1035284691, 8.6464271477849, 10.3412351841865, 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.4755
66, 10.5220100705827, 8.74921668696853,
> 8.56415116683662, 12.1348451793815, 10.9496674323819, 9.64443817181322,
> 9.52977454697087, 10.4281877186725, 8.52701721410292, 11.6911584965782,
> 10.2300108250139, 8.65368821276485, 11.7733431942379, 10.2060233777681,
> 9.57291673029552, 9.8268
Cheers
Petr
> -Original Message-
> 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>
> Subje
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.
>>
>>>
(value column, list(format(date column, "%m.%Y"), 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
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 201
returnB 24.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
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 the
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 tw
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 cre
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 29-12-2
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 alternativ
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 us
17 matches
Mail list logo