Hello, I have a data with two variables nodes and index, I want to extract
3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA etc to
OND. Was wondering how to go about it. Kindly find data sample below, data
is in csv format.
Any help will be appreciated.
My data sample;
era...1. Node_freq MEI
1 1980-01-01 -0.389855332 0.3394196488
2 1980-02-01 -0.728019153 0.2483738232
3 1980-03-01 -1.992457784 0.3516954904
4 1980-04-01 0.222760284 0.5736836269
5 1980-05-01 0.972601798 0.6289249144
6 1980-06-01 0.570725954 0.5736836269
7 1980-07-01 -0.977966324 0.4120517119
8 1980-08-01 0.056128836 -0.0104418383
9 1980-09-01 0.987304573 -0.0687520861
10 1980-10-01 1.188242495 -0.1403611624
11 1980-11-01 1.693037763 -0.0963727298
12 1980-12-01 1.173539720 -0.2539126977
13 1981-01-01 0.423698206 -0.6140040528
14 1981-02-01 -2.208098481 -0.5209122536
15 1981-03-01 -0.786830252 0.1133395650
16 1981-04-01 -0.110502611 0.3302127675
17 1981-05-01 -1.272021820 -0.1894645290
18 1981-06-01 0.394292656 -0.3736021538
19 1981-07-01 1.452892441 -0.4032687711
20 1981-08-01 0.698150002 -0.4441882433
21 1981-09-01 0.997106423 -0.1720737534
22 1981-10-01 0.247264908 -0.2436828296
23 1981-11-01 0.771663876 -0.3909929295
24 1981-12-01 -0.316341458 -0.4943145967
Regards,
?Kwesi?
Try not to become a man of success but rather a man of value-Albert Einstein
University of Cape Coast|College of Agriculture and Natural Sciences|Department
of Physics|
Team Leader|Recycle Up! Ghana|Technology Without Borders|
Other emails: kwesi.quagraine at ucc.edu.gh|kwesi.quagraine at teog.de|
Mobile: +233266173582
Skype: quagraine_cwasi
Twitter: @Pkdilly
[[alternative HTML version deleted]]
Here is one thought. Assign each month a value of 0, 1 or 2. Then do a
simple linear regression analysis where the value of the month
is the independent variable. You can also do multiple linear regression
with the value you assigned to the month plus the other factors that
you believe are causing a change to your data. Time is the one that
comes to my mind. You can do this with the standard R function lm.
I hope this helps.
Bob
On 1/30/2017 9:11 AM, Kwesi Quagraine wrote:
Hello, I have a data with two variables nodes and index, I want to extract
3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA etc to
OND. Was wondering how to go about it. Kindly find data sample below, data
is in csv format.
Any help will be appreciated.
My data sample;
era...1. Node_freq MEI
1 1980-01-01 -0.389855332 0.3394196488
2 1980-02-01 -0.728019153 0.2483738232
3 1980-03-01 -1.992457784 0.3516954904
4 1980-04-01 0.222760284 0.5736836269
5 1980-05-01 0.972601798 0.6289249144
6 1980-06-01 0.570725954 0.5736836269
7 1980-07-01 -0.977966324 0.4120517119
8 1980-08-01 0.056128836 -0.0104418383
9 1980-09-01 0.987304573 -0.0687520861
10 1980-10-01 1.188242495 -0.1403611624
11 1980-11-01 1.693037763 -0.0963727298
12 1980-12-01 1.173539720 -0.2539126977
13 1981-01-01 0.423698206 -0.6140040528
14 1981-02-01 -2.208098481 -0.5209122536
15 1981-03-01 -0.786830252 0.1133395650
16 1981-04-01 -0.110502611 0.3302127675
17 1981-05-01 -1.272021820 -0.1894645290
18 1981-06-01 0.394292656 -0.3736021538
19 1981-07-01 1.452892441 -0.4032687711
20 1981-08-01 0.698150002 -0.4441882433
21 1981-09-01 0.997106423 -0.1720737534
22 1981-10-01 0.247264908 -0.2436828296
23 1981-11-01 0.771663876 -0.3909929295
24 1981-12-01 -0.316341458 -0.4943145967
Regards,
?Kwesi?
How you proceed depends on how consistent the data are and on what you want to do with those sets of three months after you have identified them.
One approach is to create a matrix where each row contains the values corresponding to the "second previous", "previous", and "current" months data, respectively using the embed() function. The first two rows would be incomplete because the earlier data are missing there:
d3 <- embed( dta$MEI )
with which you could compute whatever metric you wanted. For example you could compute rolling means:
dta$MEImeans <- rowMeans( d3 )
If your data have missing rows you might need to use the aggregate or merge functions instead.
For specific layouts of data or metrics you can find specialized functions in various packages. You might want to search using the R "sos" package or Google for your analysis method of choice.
Sent from my phone. Please excuse my brevity.
On January 30, 2017 6:11:48 AM PST, Kwesi Quagraine <starskykwesi at gmail.com> wrote:
>Hello, I have a data with two variables nodes and index, I want to
>extract
>3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA etc
>to
>OND. Was wondering how to go about it. Kindly find data sample below,
>data
>is in csv format.
>Any help will be appreciated.
>
>My data sample;
>
> era...1. Node_freq MEI
>1 1980-01-01 -0.389855332 0.3394196488
>2 1980-02-01 -0.728019153 0.2483738232
>3 1980-03-01 -1.992457784 0.3516954904
>4 1980-04-01 0.222760284 0.5736836269
>5 1980-05-01 0.972601798 0.6289249144
>6 1980-06-01 0.570725954 0.5736836269
>7 1980-07-01 -0.977966324 0.4120517119
>8 1980-08-01 0.056128836 -0.0104418383
>9 1980-09-01 0.987304573 -0.0687520861
>10 1980-10-01 1.188242495 -0.1403611624
>11 1980-11-01 1.693037763 -0.0963727298
>12 1980-12-01 1.173539720 -0.2539126977
>13 1981-01-01 0.423698206 -0.6140040528
>14 1981-02-01 -2.208098481 -0.5209122536
>15 1981-03-01 -0.786830252 0.1133395650
>16 1981-04-01 -0.110502611 0.3302127675
>17 1981-05-01 -1.272021820 -0.1894645290
>18 1981-06-01 0.394292656 -0.3736021538
>19 1981-07-01 1.452892441 -0.4032687711
>20 1981-08-01 0.698150002 -0.4441882433
>21 1981-09-01 0.997106423 -0.1720737534
>22 1981-10-01 0.247264908 -0.2436828296
>23 1981-11-01 0.771663876 -0.3909929295
>24 1981-12-01 -0.316341458 -0.4943145967
>
>Regards,
>?Kwesi?
>
>--
>Try not to become a man of success but rather a man of value-Albert
>Einstein
>
>University of Cape Coast|College of Agriculture and Natural
>Sciences|Department
>of Physics|
>Team Leader|Recycle Up! Ghana|Technology Without Borders|
>Other emails: kwesi.quagraine at ucc.edu.gh|kwesi.quagraine at teog.de|
>Mobile: +233266173582
>Skype: quagraine_cwasi
>Twitter: @Pkdilly
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.
Hi
Probably just a small correction.
d3 <- embed( dta$MEI, 3)
Cheers
Petr
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Jeff
Newmiller
Sent: Monday, January 30, 2017 4:19 PM
To: r-help at r-project.org; Kwesi Quagraine <starskykwesi at gmail.com>
Subject: Re: [R] (no subject)
How you proceed depends on how consistent the data are and on what you
want to do with those sets of three months after you have identified them.
One approach is to create a matrix where each row contains the values
corresponding to the "second previous", "previous", and "current" months
data, respectively using the embed() function. The first two rows would be
incomplete because the earlier data are missing there:
d3 <- embed( dta$MEI )
with which you could compute whatever metric you wanted. For example
you could compute rolling means:
dta$MEImeans <- rowMeans( d3 )
If your data have missing rows you might need to use the aggregate or
merge functions instead.
For specific layouts of data or metrics you can find specialized functions in
various packages. You might want to search using the R "sos" package or
Google for your analysis method of choice.
--
Sent from my phone. Please excuse my brevity.
On January 30, 2017 6:11:48 AM PST, Kwesi Quagraine
<starskykwesi at gmail.com> wrote:
Hello, I have a data with two variables nodes and index, I want to
extract
3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA etc
to OND. Was wondering how to go about it. Kindly find data sample
below, data is in csv format.
Any help will be appreciated.
My data sample;
era...1. Node_freq MEI
1 1980-01-01 -0.389855332 0.3394196488
2 1980-02-01 -0.728019153 0.2483738232
3 1980-03-01 -1.992457784 0.3516954904
4 1980-04-01 0.222760284 0.5736836269
5 1980-05-01 0.972601798 0.6289249144
6 1980-06-01 0.570725954 0.5736836269
7 1980-07-01 -0.977966324 0.4120517119
8 1980-08-01 0.056128836 -0.0104418383
9 1980-09-01 0.987304573 -0.0687520861
10 1980-10-01 1.188242495 -0.1403611624
11 1980-11-01 1.693037763 -0.0963727298
12 1980-12-01 1.173539720 -0.2539126977
13 1981-01-01 0.423698206 -0.6140040528
14 1981-02-01 -2.208098481 -0.5209122536
15 1981-03-01 -0.786830252 0.1133395650
16 1981-04-01 -0.110502611 0.3302127675
17 1981-05-01 -1.272021820 -0.1894645290
18 1981-06-01 0.394292656 -0.3736021538
19 1981-07-01 1.452892441 -0.4032687711
20 1981-08-01 0.698150002 -0.4441882433
21 1981-09-01 0.997106423 -0.1720737534
22 1981-10-01 0.247264908 -0.2436828296
23 1981-11-01 0.771663876 -0.3909929295
24 1981-12-01 -0.316341458 -0.4943145967
Regards,
?Kwesi?
--
Try not to become a man of success but rather a man of value-Albert
Einstein
University of Cape Coast|College of Agriculture and Natural
Sciences|Department
of Physics|
Team Leader|Recycle Up! Ghana|Technology Without Borders| Other
emails:
kwesi.quagraine at ucc.edu.gh|kwesi.quagraine at teog.de|
Mobile: +233266173582
Skype: quagraine_cwasi
Twitter: @Pkdilly
[[alternative HTML version deleted]]
________________________________
Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny pouze jeho adres?t?m.
Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho syst?mu.
Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat.
Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i zpo?d?n?m p?enosu e-mailu.
V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?:
- vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu.
- a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout; Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce s dodatkem ?i odchylkou.
- trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech.
- odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi ?i osob? j?m zastoupen? zn?m?.
This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.
In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.
Hello Eric, thanks for the code, it seems to do something closer to what I
want. I generate JFM, FMA and so on, but it does not create the DJF at the
beginning. Any thoughts on that?
Kwesi
On Mon, Jan 30, 2017 at 6:01 PM, Erich Subscriptions <
Try not to become a man of success but rather a man of value-Albert Einstein
University of Cape Coast|College of Agriculture and Natural Sciences|Department
of Physics|
Team Leader|Recycle Up! Ghana|Technology Without Borders|
Other emails: kwesi.quagraine at ucc.edu.gh|kwesi.quagraine at teog.de|
Mobile: +233266173582
Skype: quagraine_cwasi
Twitter: @Pkdilly
[[alternative HTML version deleted]]
Upon trying this method, I get an error ;
Error in `$<-.data.frame`(`*tmp*`, "MEImeans", value =
c(0.313162987462034, :
replacement has 442 rows, data has 444
Any thoughts?
Kwesi
On Mon, Jan 30, 2017 at 5:37 PM, PIKAL Petr <petr.pikal at precheza.cz> wrote:
Hi
Probably just a small correction.
d3 <- embed( dta$MEI, 3)
Cheers
Petr
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Jeff
Newmiller
Sent: Monday, January 30, 2017 4:19 PM
To: r-help at r-project.org; Kwesi Quagraine <starskykwesi at gmail.com>
Subject: Re: [R] (no subject)
How you proceed depends on how consistent the data are and on what you
want to do with those sets of three months after you have identified
them.
One approach is to create a matrix where each row contains the values
corresponding to the "second previous", "previous", and "current" months
data, respectively using the embed() function. The first two rows would
be
incomplete because the earlier data are missing there:
d3 <- embed( dta$MEI )
with which you could compute whatever metric you wanted. For example
you could compute rolling means:
dta$MEImeans <- rowMeans( d3 )
If your data have missing rows you might need to use the aggregate or
merge functions instead.
For specific layouts of data or metrics you can find specialized
functions in
various packages. You might want to search using the R "sos" package or
Google for your analysis method of choice.
--
Sent from my phone. Please excuse my brevity.
On January 30, 2017 6:11:48 AM PST, Kwesi Quagraine
<starskykwesi at gmail.com> wrote:
Hello, I have a data with two variables nodes and index, I want to
extract
3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA etc
to OND. Was wondering how to go about it. Kindly find data sample
below, data is in csv format.
Any help will be appreciated.
My data sample;
era...1. Node_freq MEI
1 1980-01-01 -0.389855332 0.3394196488
2 1980-02-01 -0.728019153 0.2483738232
3 1980-03-01 -1.992457784 0.3516954904
4 1980-04-01 0.222760284 0.5736836269
5 1980-05-01 0.972601798 0.6289249144
6 1980-06-01 0.570725954 0.5736836269
7 1980-07-01 -0.977966324 0.4120517119
8 1980-08-01 0.056128836 -0.0104418383
9 1980-09-01 0.987304573 -0.0687520861
10 1980-10-01 1.188242495 -0.1403611624
11 1980-11-01 1.693037763 -0.0963727298
12 1980-12-01 1.173539720 -0.2539126977
13 1981-01-01 0.423698206 -0.6140040528
14 1981-02-01 -2.208098481 -0.5209122536
15 1981-03-01 -0.786830252 0.1133395650
16 1981-04-01 -0.110502611 0.3302127675
17 1981-05-01 -1.272021820 -0.1894645290
18 1981-06-01 0.394292656 -0.3736021538
19 1981-07-01 1.452892441 -0.4032687711
20 1981-08-01 0.698150002 -0.4441882433
21 1981-09-01 0.997106423 -0.1720737534
22 1981-10-01 0.247264908 -0.2436828296
23 1981-11-01 0.771663876 -0.3909929295
24 1981-12-01 -0.316341458 -0.4943145967
Regards,
?Kwesi?
--
Try not to become a man of success but rather a man of value-Albert
Einstein
University of Cape Coast|College of Agriculture and Natural
Sciences|Department
of Physics|
Team Leader|Recycle Up! Ghana|Technology Without Borders| Other
emails:
kwesi.quagraine at ucc.edu.gh|kwesi.quagraine at teog.de|
Mobile: +233266173582
Skype: quagraine_cwasi
Twitter: @Pkdilly
[[alternative HTML version deleted]]
________________________________
Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou
ur?eny pouze jeho adres?t?m.
Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav?
neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie
vyma?te ze sv?ho syst?mu.
Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email
jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat.
Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi
?i zpo?d?n?m p?enosu e-mailu.
V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?:
- vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en?
smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu.
- a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout;
Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany
p??jemce s dodatkem ?i odchylkou.
- trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve
v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech.
- odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za
spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n
nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto
emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich
existence je adres?tovi ?i osob? j?m zastoupen? zn?m?.
This e-mail and any documents attached to it may be confidential and are
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its
sender. Delete the contents of this e-mail with all attachments and its
copies from your system.
If you are not the intended recipient of this e-mail, you are not
authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage
caused by modifications of the e-mail or by delay with transfer of the
email.
In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to
immediately accept such offer; The sender of this e-mail (offer) excludes
any acceptance of the offer on the part of the recipient containing any
amendment or variation.
- the sender insists on that the respective contract is concluded only
upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter
into any contracts on behalf of the company except for cases in which
he/she is expressly authorized to do so in writing, and such authorization
or power of attorney is submitted to the recipient or the person
represented by the recipient, or the existence of such authorization is
known to the recipient of the person represented by the recipient.
Try not to become a man of success but rather a man of value-Albert Einstein
University of Cape Coast|College of Agriculture and Natural Sciences|Department
of Physics|
Team Leader|Recycle Up! Ghana|Technology Without Borders|
Other emails: kwesi.quagraine at ucc.edu.gh|kwesi.quagraine at teog.de|
Mobile: +233266173582
Skype: quagraine_cwasi
Twitter: @Pkdilly
[[alternative HTML version deleted]]
Thanks for your suggestion. I am much grateful.
Kwesi
On Mon, Jan 30, 2017 at 4:23 PM, Robert Sherry <rsherry8 at comcast.net> wrote:
Here is one thought. Assign each month a value of 0, 1 or 2. Then do a
simple linear regression analysis where the value of the month
is the independent variable. You can also do multiple linear regression
with the value you assigned to the month plus the other factors that
you believe are causing a change to your data. Time is the one that comes
to my mind. You can do this with the standard R function lm.
I hope this helps.
Bob
On 1/30/2017 9:11 AM, Kwesi Quagraine wrote:
Hello, I have a data with two variables nodes and index, I want to extract
3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA etc to
OND. Was wondering how to go about it. Kindly find data sample below, data
is in csv format.
Any help will be appreciated.
My data sample;
era...1. Node_freq MEI
1 1980-01-01 -0.389855332 0.3394196488
2 1980-02-01 -0.728019153 0.2483738232
3 1980-03-01 -1.992457784 0.3516954904
4 1980-04-01 0.222760284 0.5736836269
5 1980-05-01 0.972601798 0.6289249144
6 1980-06-01 0.570725954 0.5736836269
7 1980-07-01 -0.977966324 0.4120517119
8 1980-08-01 0.056128836 -0.0104418383
9 1980-09-01 0.987304573 -0.0687520861
10 1980-10-01 1.188242495 -0.1403611624
11 1980-11-01 1.693037763 -0.0963727298
12 1980-12-01 1.173539720 -0.2539126977
13 1981-01-01 0.423698206 -0.6140040528
14 1981-02-01 -2.208098481 -0.5209122536
15 1981-03-01 -0.786830252 0.1133395650
16 1981-04-01 -0.110502611 0.3302127675
17 1981-05-01 -1.272021820 -0.1894645290
18 1981-06-01 0.394292656 -0.3736021538
19 1981-07-01 1.452892441 -0.4032687711
20 1981-08-01 0.698150002 -0.4441882433
21 1981-09-01 0.997106423 -0.1720737534
22 1981-10-01 0.247264908 -0.2436828296
23 1981-11-01 0.771663876 -0.3909929295
24 1981-12-01 -0.316341458 -0.4943145967
Regards,
?Kwesi?
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posti
ng-guide.html
and provide commented, minimal, self-contained, reproducible code.
Try not to become a man of success but rather a man of value-Albert Einstein
University of Cape Coast|College of Agriculture and Natural Sciences|Department
of Physics|
Team Leader|Recycle Up! Ghana|Technology Without Borders|
Other emails: kwesi.quagraine at ucc.edu.gh|kwesi.quagraine at teog.de|
Mobile: +233266173582
Skype: quagraine_cwasi
Twitter: @Pkdilly
[[alternative HTML version deleted]]
Sent from my phone. Please excuse my brevity.
On January 30, 2017 9:28:52 AM PST, Kwesi Quagraine <starskykwesi at gmail.com> wrote:
>Upon trying this method, I get an error ;
>
>Error in `$<-.data.frame`(`*tmp*`, "MEImeans", value =
>c(0.313162987462034, :
> replacement has 442 rows, data has 444
>
>Any thoughts?
>
>Kwesi
>
>On Mon, Jan 30, 2017 at 5:37 PM, PIKAL Petr <petr.pikal at precheza.cz>
>wrote:
>
>> Hi
>>
>> Probably just a small correction.
>>
>> d3 <- embed( dta$MEI, 3)
>>
>> Cheers
>> Petr
>>
>> > -----Original Message-----
>> > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of
>Jeff
>> > Newmiller
>> > Sent: Monday, January 30, 2017 4:19 PM
>> > To: r-help at r-project.org; Kwesi Quagraine <starskykwesi at gmail.com>
>> > Subject: Re: [R] (no subject)
>> >
>> > How you proceed depends on how consistent the data are and on what
>you
>> > want to do with those sets of three months after you have
>identified
>> them.
>> >
>> > One approach is to create a matrix where each row contains the
>values
>> > corresponding to the "second previous", "previous", and "current"
>months
>> > data, respectively using the embed() function. The first two rows
>would
>> be
>> > incomplete because the earlier data are missing there:
>> >
>> > d3 <- embed( dta$MEI )
>> >
>> > with which you could compute whatever metric you wanted. For
>example
>> > you could compute rolling means:
>> >
>> > dta$MEImeans <- rowMeans( d3 )
>> >
>> > If your data have missing rows you might need to use the aggregate
>or
>> > merge functions instead.
>> >
>> > For specific layouts of data or metrics you can find specialized
>> functions in
>> > various packages. You might want to search using the R "sos"
>package or
>> > Google for your analysis method of choice.
>> > --
>> > Sent from my phone. Please excuse my brevity.
>> >
>> > On January 30, 2017 6:11:48 AM PST, Kwesi Quagraine
>> > <starskykwesi at gmail.com> wrote:
>> > >Hello, I have a data with two variables nodes and index, I want to
>> > >extract
>> > >3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA
>etc
>> > >to OND. Was wondering how to go about it. Kindly find data sample
>> > >below, data is in csv format.
>> > >Any help will be appreciated.
>> > >
>> > >My data sample;
>> > >
>> > > era...1. Node_freq MEI
>> > >1 1980-01-01 -0.389855332 0.3394196488
>> > >2 1980-02-01 -0.728019153 0.2483738232
>> > >3 1980-03-01 -1.992457784 0.3516954904
>> > >4 1980-04-01 0.222760284 0.5736836269
>> > >5 1980-05-01 0.972601798 0.6289249144
>> > >6 1980-06-01 0.570725954 0.5736836269
>> > >7 1980-07-01 -0.977966324 0.4120517119
>> > >8 1980-08-01 0.056128836 -0.0104418383
>> > >9 1980-09-01 0.987304573 -0.0687520861
>> > >10 1980-10-01 1.188242495 -0.1403611624
>> > >11 1980-11-01 1.693037763 -0.0963727298
>> > >12 1980-12-01 1.173539720 -0.2539126977
>> > >13 1981-01-01 0.423698206 -0.6140040528
>> > >14 1981-02-01 -2.208098481 -0.5209122536
>> > >15 1981-03-01 -0.786830252 0.1133395650
>> > >16 1981-04-01 -0.110502611 0.3302127675
>> > >17 1981-05-01 -1.272021820 -0.1894645290
>> > >18 1981-06-01 0.394292656 -0.3736021538
>> > >19 1981-07-01 1.452892441 -0.4032687711
>> > >20 1981-08-01 0.698150002 -0.4441882433
>> > >21 1981-09-01 0.997106423 -0.1720737534
>> > >22 1981-10-01 0.247264908 -0.2436828296
>> > >23 1981-11-01 0.771663876 -0.3909929295
>> > >24 1981-12-01 -0.316341458 -0.4943145967
>> > >
>> > >Regards,
>> > >?Kwesi?
>> > >
>> > >--
>> > >Try not to become a man of success but rather a man of
>value-Albert
>> > >Einstein
>> > >
>> > >University of Cape Coast|College of Agriculture and Natural
>> > >Sciences|Department
>> > >of Physics|
>> > >Team Leader|Recycle Up! Ghana|Technology Without Borders| Other
>> > emails:
>> > >kwesi.quagraine at ucc.edu.gh|kwesi.quagraine at teog.de|
>> > >Mobile: +233266173582
>> > >Skype: quagraine_cwasi
>> > >Twitter: @Pkdilly
>> > >
>> > > [[alternative HTML version deleted]]
>> > >
>> > >______________________________________________
>> > >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > >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 at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > 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.
>>
>> ________________________________
>> Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a
>jsou
>> ur?eny pouze jeho adres?t?m.
>> Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav?
>> neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho
>kopie
>> vyma?te ze sv?ho syst?mu.
>> Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento
>email
>> jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat.
>> Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou
>modifikacemi
>> ?i zpo?d?n?m p?enosu e-mailu.
>>
>> V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?:
>> - vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en?
>> smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu.
>> - a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn?
>p?ijmout;
>> Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze
>strany
>> p??jemce s dodatkem ?i odchylkou.
>> - trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve
>> v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech.
>> - odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za
>> spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn?
>zmocn?n
>> nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi
>tohoto
>> emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo
>jejich
>> existence je adres?tovi ?i osob? j?m zastoupen? zn?m?.
>>
>> This e-mail and any documents attached to it may be confidential and
>are
>> intended only for its intended recipients.
>> If you received this e-mail by mistake, please immediately inform its
>> sender. Delete the contents of this e-mail with all attachments and
>its
>> copies from your system.
>> If you are not the intended recipient of this e-mail, you are not
>> authorized to use, disseminate, copy or disclose this e-mail in any
>manner.
>> The sender of this e-mail shall not be liable for any possible damage
>> caused by modifications of the e-mail or by delay with transfer of
>the
>> email.
>>
>> In case that this e-mail forms part of business dealings:
>> - the sender reserves the right to end negotiations about entering
>into a
>> contract in any time, for any reason, and without stating any
>reasoning.
>> - if the e-mail contains an offer, the recipient is entitled to
>> immediately accept such offer; The sender of this e-mail (offer)
>excludes
>> any acceptance of the offer on the part of the recipient containing
>any
>> amendment or variation.
>> - the sender insists on that the respective contract is concluded
>only
>> upon an express mutual agreement on all its aspects.
>> - the sender of this e-mail informs that he/she is not authorized to
>enter
>> into any contracts on behalf of the company except for cases in which
>> he/she is expressly authorized to do so in writing, and such
>authorization
>> or power of attorney is submitted to the recipient or the person
>> represented by the recipient, or the existence of such authorization
>is
>> known to the recipient of the person represented by the recipient.
>>
Hi
Of course you have fewer values than in original data.
x<-1:21
length(rowSums(embed(x,3)))
[1] 19
length(x)
[1] 21
embed(x,3)
[,1] [,2] [,3]
[1,] 3 2 1
[2,] 4 3 2
[3,] 5 4 3
[4,] 6 5 4
[5,] 7 6 5
[6,] 8 7 6
[7,] 9 8 7
[8,] 10 9 8
[9,] 11 10 9
[10,] 12 11 10
[11,] 13 12 11
[12,] 14 13 12
[13,] 15 14 13
[14,] 16 15 14
[15,] 17 16 15
[16,] 18 17 16
[17,] 19 18 17
[18,] 20 19 18
[19,] 21 20 19
You need to prepend or append 2 NA values if you want to add newly computed values to old data.
or extend your original vector by 2 values
length(rowSums(embed(c(NA, NA, x),3), na.rm=T))
[1] 21
Cheers
Petr
From: Kwesi Quagraine [mailto:starskykwesi at gmail.com]
Sent: Monday, January 30, 2017 6:29 PM
To: PIKAL Petr <petr.pikal at precheza.cz>
Cc: Jeff Newmiller <jdnewmil at dcn.davis.ca.us>; r-help at r-project.org
Subject: Re: [R] (no subject)
Upon trying this method, I get an error ;
Error in `$<-.data.frame`(`*tmp*`, "MEImeans", value = c(0.313162987462034, :
replacement has 442 rows, data has 444
Any thoughts?
Kwesi
On Mon, Jan 30, 2017 at 5:37 PM, PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>> wrote:
Hi
Probably just a small correction.
d3 <- embed( dta$MEI, 3)
Cheers
Petr
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org<mailto:r-help-bounces at r-project.org>] On Behalf Of Jeff
Newmiller
Sent: Monday, January 30, 2017 4:19 PM
To: r-help at r-project.org<mailto:r-help at r-project.org>; Kwesi Quagraine <starskykwesi at gmail.com<mailto:starskykwesi at gmail.com>>
Subject: Re: [R] (no subject)
How you proceed depends on how consistent the data are and on what you
want to do with those sets of three months after you have identified them.
One approach is to create a matrix where each row contains the values
corresponding to the "second previous", "previous", and "current" months
data, respectively using the embed() function. The first two rows would be
incomplete because the earlier data are missing there:
d3 <- embed( dta$MEI )
with which you could compute whatever metric you wanted. For example
you could compute rolling means:
dta$MEImeans <- rowMeans( d3 )
If your data have missing rows you might need to use the aggregate or
merge functions instead.
For specific layouts of data or metrics you can find specialized functions in
various packages. You might want to search using the R "sos" package or
Google for your analysis method of choice.
--
Sent from my phone. Please excuse my brevity.
On January 30, 2017 6:11:48 AM PST, Kwesi Quagraine
<starskykwesi at gmail.com<mailto:starskykwesi at gmail.com>> wrote:
Hello, I have a data with two variables nodes and index, I want to
extract
3 months seasons, with a shift of 1 month, that is, DJF, JFM, FMA etc
to OND. Was wondering how to go about it. Kindly find data sample
below, data is in csv format.
Any help will be appreciated.
My data sample;
era...1. Node_freq MEI
1 1980-01-01 -0.389855332 0.3394196488<tel:3394196488>
2 1980-02-01 -0<tel:2%20%20%201980-02-01%20-0>.728019153 0.2483738232<tel:2483738232>
3 1980-03-01 -1.992457784 0.3516954904
4 1980-04-01 0.222760284 0.5736836269
5 1980-05-01 0.972601798 0.6289249144
6 1980-06-01 0.570725954 0.5736836269
7 1980-07-01 -0.977966324 0.4120517119
8 1980-08-01 0.056128836 -0.0104418383
9 1980-09-01 0.987304573 -0.0687520861
10 1980-10-01 1.188242495 -0.1403611624
11 1980-11-01 1.693037763 -0.0963727298
12 1980-12-01 1.173539720 -0.2539126977
13 1981-01-01 0.423698206 -0.6140040528
14 1981-02-01 -2.208098481 -0.5209122536
15 1981-03-01 -0.786830252 0.1133395650
16 1981-04-01 -0.110502611 0.3302127675
17 1981-05-01 -1.272021820 -0.1894645290
18 1981-06-01 0.394292656 -0.3736021538
19 1981-07-01 1.452892441 -0.4032687711
20 1981-08-01 0.698150002 -0.4441882433
21 1981-09-01 0.997106423 -0.1720737534
22 1981-10-01 0.247264908 -0.2436828296
23 1981-11-01 0.771663876 -0.3909929295
24 1981-12-01 -0.316341458 -0.4943145967
Regards,
?Kwesi?
--
Try not to become a man of success but rather a man of value-Albert
Einstein
University of Cape Coast|College of Agriculture and Natural
Sciences|Department
of Physics|
Team Leader|Recycle Up! Ghana|Technology Without Borders| Other
emails:
kwesi.quagraine at ucc.edu.gh<mailto:kwesi.quagraine at ucc.edu.gh>|kwesi.quagraine at teog.de<mailto:kwesi.quagraine at teog.de>|
Mobile: +233266173582<tel:%2B233266173582>
Skype: quagraine_cwasi
Twitter: @Pkdilly
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
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.
________________________________
Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny pouze jeho adres?t?m.
Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho syst?mu.
Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat.
Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i zpo?d?n?m p?enosu e-mailu.
V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?:
- vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu.
- a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout; Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce s dodatkem ?i odchylkou.
- trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech.
- odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi ?i osob? j?m zastoupen? zn?m?.
This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.
In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.
--
Try not to become a man of success but rather a man of value-Albert Einstein
University of Cape Coast|College of Agriculture and Natural Sciences|Department of Physics|
Team Leader|Recycle Up! Ghana|Technology Without Borders|
Other emails: kwesi.quagraine at ucc.edu.gh<mailto:kwesi.quagraine at ucc.edu.gh>|kwesi.quagraine at teog.de<mailto:kwesi.quagraine at teog.de>|
Mobile: +233266173582
Skype: quagraine_cwasi
Twitter: @Pkdilly
________________________________
Tento e-mail a jak?koliv k n?mu p?ipojen? dokumenty jsou d?v?rn? a jsou ur?eny pouze jeho adres?t?m.
Jestli?e jste obdr?el(a) tento e-mail omylem, informujte laskav? neprodlen? jeho odes?latele. Obsah tohoto emailu i s p??lohami a jeho kopie vyma?te ze sv?ho syst?mu.
Nejste-li zam??len?m adres?tem tohoto emailu, nejste opr?vn?ni tento email jakkoliv u??vat, roz?i?ovat, kop?rovat ?i zve?ej?ovat.
Odes?latel e-mailu neodpov?d? za eventu?ln? ?kodu zp?sobenou modifikacemi ?i zpo?d?n?m p?enosu e-mailu.
V p??pad?, ?e je tento e-mail sou??st? obchodn?ho jedn?n?:
- vyhrazuje si odes?latel pr?vo ukon?it kdykoliv jedn?n? o uzav?en? smlouvy, a to z jak?hokoliv d?vodu i bez uveden? d?vodu.
- a obsahuje-li nab?dku, je adres?t opr?vn?n nab?dku bezodkladn? p?ijmout; Odes?latel tohoto e-mailu (nab?dky) vylu?uje p?ijet? nab?dky ze strany p??jemce s dodatkem ?i odchylkou.
- trv? odes?latel na tom, ?e p??slu?n? smlouva je uzav?ena teprve v?slovn?m dosa?en?m shody na v?ech jej?ch n?le?itostech.
- odes?latel tohoto emailu informuje, ?e nen? opr?vn?n uzav?rat za spole?nost ??dn? smlouvy s v?jimkou p??pad?, kdy k tomu byl p?semn? zmocn?n nebo p?semn? pov??en a takov? pov??en? nebo pln? moc byly adres?tovi tohoto emailu p??padn? osob?, kterou adres?t zastupuje, p?edlo?eny nebo jejich existence je adres?tovi ?i osob? j?m zastoupen? zn?m?.
This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.
In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.