Dear Jim Holtman,
Thank you very much for your help.
Theproblem I'm trying to solve is ?To determine weather the evolutionof ENSO
can influence rainfall over Tanzania?. In this study I havetwo types of data, ie
Rainfall data (for 23 stations) and Ninoindices data, both spanning a period of
31 years (1982-2012).
CASEI:1.In ?Nino.indices.txt? data for all columns of the ninoregions (both for
anomalies and SST), to calculate the Season means"January & February
(JF)", ?March, April and may(MAM)", "June, July & August
(JJA)" and "October,November and December (OND" for each year.
and have the outputin table form as;
Ninoindices Mean
| Years | JF SST Mean NINO1+2 | JF ANOM Mean NINO1+2 | MAM SST Mean NINO3
| MAM ANOM Mean NINO3 | JJA SST Mean NINO4 | JJA ANOM Mean NINO4 | OND
SST Mean NINO3.4 | OND SST Mean NINO3.4 |
| 1982 |
|
|
|
|
|
|
|
|
| 1983 |
|
|
|
|
|
|
|
|
| - - - - |
|
|
|
|
|
|
|
|
| - - - - |
|
|
|
|
|
|
|
|
| 2012 |
|
|
|
|
|
|
|
|
2.To use the Yearly anomalies for each column in nino regions toclassify the
events as;(i). IfANOM Mean>1, then I assign itto ?SE? (Being as Strong
El-nino)(ii). If0<ANOMMean<=1 , then Iassign it to ?ME? (Being as Moderate
El-nino)(iii). IfANOM==0,then I assign it to ?NT? (Being as
NeutralCondition)(iv). If ANOMMean< (-1),then I assign it to ?SL? (Being as
Strong La-nina)(v). If-1<=ANOMMean< 0, then I assign it to ?ML? (Being as
Moderate La-nina)Theoutput have to be in table form as;
FORNINO1+2
| Years | JF ANOM Mean NINO1+2 | MAM ANOM Mean NINO1+2 | JJA ANOM Mean
NINO1+2 | OND SST Mean NINO1+2 |
| 1982 | SE |
|
|
|
| 1983 |
|
| SL |
|
| - - - - |
|
|
| ML |
| - - - - |
| ME |
|
|
| 2012 |
|
|
| SL |
FORNINO3
| Years | JF ANOM Mean NINO3 | MAM ANOM Mean NINO3 | JJA ANOM Mean NINO3
| OND SST Mean NINO3 |
| 1982 | SE |
|
|
|
| 1983 |
|
|
|
|
| - - - - |
|
|
|
|
| - - - - |
| ME |
|
|
| 2012 |
|
|
| SL |
FORNINO4
| Years | JF ANOM Mean NINO4 | MAM ANOM Mean NINO4 | JJA ANOM Mean NINO4
| OND SST Mean NINO4 |
| 1982 | SE |
|
|
|
| 1983 |
|
|
|
|
| - - - - | ML |
|
| SL |
| - - - - |
| ME |
|
|
| 2012 |
|
|
| SL |
FORNINO3.4
| Years | JF ANOM Mean NINO3.4 | MAM ANOM Mean NINO3.4 | JJA ANOM Mean
NINO3.4 | OND SST Mean NINO3.4 |
| 1982 | SE | SL |
|
|
| 1983 |
|
|
|
|
| - - - - |
|
| ML |
|
| - - - - |
| ME |
|
|
| 2012 |
|
|
| SL |
3.To plot the time series graph for each nino regions using the YearlyAnomalies.
CASEII:Consider the Rainfall station data;1. In some files containing the data
there are missing data labeledby variable ?m?. I want to substitute these
missing data withlong term mean.2. Find the rowSum and anomalies of each file
containing the data.3. To find the cumsum of the rowSum of each file containing
the data.4. Plot the single mass curves ie. Plot(Year, cumsum) for each fileand
name its title as the name of the corresponding file name.5. Plot the time
series graphs for seasons JF, MAM, JJA and OND foreach file and name give its
name as ?Time series graph for ?nameof the file??6. To find the seasonal
correlations for JF, MAM, JJA and OND usingthe anomalies of the rainfall station
data and that of each ninoregion indices, and have the results in table form as;
CORRELATIONSOF RAINFALL AND NINO1+2 ANOMALIES
| Years | JF | MAM | JJA | OND |
| 1982 |
|
|
|
|
| 1983 |
|
|
|
|
| - - - - |
|
|
|
|
| - - - - |
|
|
|
|
| 2012 |
|
|
|
|
CORRELATIONSOF RAINFALL AND NINO3ANOMALIES
| Years | JF | MAM | JJA | OND |
| 1982 |
|
|
|
|
| 1983 |
|
|
|
|
| - - - - |
|
|
|
|
| - - - - |
|
|
|
|
| 2012 |
|
|
|
|
CORRELATIONSOF RAINFALL AND NINO4ANOMALIES
| Years | JF | MAM | JJA | OND |
| 1982 |
|
|
|
|
| 1983 |
|
|
|
|
| - - - - |
|
|
|
|
| - - - - |
|
|
|
|
| 2012 |
|
|
|
|
CORRELATIONSOF RAINFALL AND NINO3.4ANOMALIES
| Years | JF | MAM | JJA | OND |
| 1982 |
|
|
|
|
| 1983 |
|
|
|
|
| - - - - |
|
|
|
|
| - - - - |
|
|
|
|
| 2012 |
|
|
|
|
?Please find attached the data to be used in this analysis. Hopefully you will
help.
_____________
Peter? E. Tuju
Dar es Salaam
T A N Z A N I A
----------------------
From: jim holtman <jholtman at gmail.com>
To: Peter Tuju <peterenos at ymail.com>
Cc: "r-help at r-project.org" <r-help at r-project.org>
Sent: Thursday, June 25, 2015 10:12 PM
Subject: Re: [R] Extracting data from a file containing data
try this:> input <-
read.table("C:\\Users\\jh52822\\Downloads\\Nino_indices.txt" ??+ ? ? ?
? ? ? ? ? ? ? , header = TRUE+ ? ? ? ? ? ? ? ? ? ? , as.is = TRUE+ ? ? ? ? ? ? ?
? ? ? )> # create factors> input$season <- factor(c(rep("JF",
2), rep("MAM", 3), rep("JJA", 3)+ ? ? ? ? , NA,
rep("OND", 3)+ ? ? ? ? )[input$MON], levels = c("JF",
"MAM", "JJA", "OND"))> ? ? ? ??> # leave off
the MON (-2) column from the data ? ? ? ? ? ?> res <- aggregate(. ~ season
+ YR, data = input[, -2], FUN = 'mean')> head(res,10)? ?season ? YR
?NINO1.2 ? ? ? ANOM ? ?NINO3 ? ? ANOM.1 ? ?NINO4 ? ? ANOM.2 ?NINO3.4 ? ? ANOM.31
? ? ?JF 1982 24.89000 -0.3750000 26.12500 ?0.1250000 28.25500 ?0.0550000
26.71000 ?0.06500002 ? ? MAM 1982 24.56000 -0.8366667 27.48333 ?0.2433333
28.94000 ?0.4466667 27.92000 ?0.30333333 ? ? JJA 1982 22.37000 ?0.6800000
26.68333 ?1.0033333 29.39333 ?0.6200000 28.26000 ?1.03000004 ? ? OND 1982
24.55333 ?2.8200000 27.70667 ?2.6933333 29.25333 ?0.6600000 28.88667 ?2.25000005
? ? ?JF 1983 27.75500 ?2.4900000 28.92000 ?2.9200000 28.89500 ?0.6950000
29.24500 ?2.60000006 ? ? MAM 1983 28.47667 ?3.0800000 29.06333 ?1.8233333
28.89667 ?0.4033333 28.94333 ?1.32666677 ? ? JJA 1983 25.72333 ?4.0333333
26.88000 ?1.2000000 28.63667 -0.1366667 27.28000 ?0.05000008 ? ? OND 1983
22.25667 ?0.5233333 24.40667 -0.6066667 27.77667 -0.8166667 25.68000 -0.95666679
? ? ?JF 1984 24.68000 -0.5850000 25.52000 -0.4800000 27.44500 -0.7550000
26.01500 -0.630000010 ? ?MAM 1984 24.79667 -0.6000000 26.97333 -0.2666667
27.62000 -0.8733333 27.21333 -0.4033333>?
Jim Holtman
Data Munger Guru
?
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Thu, Jun 25, 2015 at 11:40 AM, Peter Tuju <peterenos at ymail.com>
wrote:
I have the data as attached. For each nino region, I want to get the mean of the
seasons January and February (JF), March, April and may (MAM), June, July and
August (JJA), and October, November and December (OND) as columns of each nino
regions. and have my result as;For example;
For NINO1.2Years???? JF????? MAMA???? JJA????? OND?1982?1983??? .??? .???? .2012
Any guide please!
_____________
Peter? E. Tuju
Dar es Salaam
T A N Z A N I A
----------------------
______________________________________________
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.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Nino_indices.txt
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20150626/975d53c4/attachment.txt>