Skip to content
Prev 305808 / 398506 Next

[newbie] aggregating table() results and simplifying code with loop

Hi dear R-helpers,

I really appreciate your "coding the answers" to (my) questions.
I am now in the situation to get results in a very shorter time and
with a proper code.

+++++ the study (summary) +++++++++++++++++++++

In (short) response to the question by John, the global target of the
analysis is to identify the dynamics of crop sequences in a given
region. The spatial grain is the elementary watershed (as defined by
the local water agency). The temporal grain is a 5 year period (it
allows, according to previous analyses, to grasp the major crop
sequences for the study area). The input data is a grid of points
where the land cover has been monitored since the 80's up to now (with
a couple of interruptions). The first part of the analysis was aimed
at characterizing crop sequences and their occurrences in the
different watersheds.
The step of the analysis for what I'm asking your help is aimed at
calculating the return time of the most relevant crops (from an
agronomic point of view), on which operate then a clustering. Raw
attempts I've tried so far with other methods appeared to give
promising results, so I've decided to improve the approach using R.
Here is where you come in.
+++++++++++++++++++++++++++++++++++++++++++

++++++ (unsolved) questions +++++++++++++++++++

The proposal by John is clear to me, probably because his way of
coding is closer to my capability to understand. The solution by Rui
looks interesting, complete and effective (few elementary functions
and reduced time to have the results to be used in the other steps of
the analysis).

Nevertheless I'm still in trouble because I'm not used with function
(that's one of the reasons I'm here).
The following questions will sound naive to you, but I'm not able to
decrypt Rui's code without asking again your help. Basic manuals (like
"R Language Definition" ch. 4, or "The R Inferno" ch. 5) were not
sufficient for me to understand how "w", "DF", "Mat", "WS" and
"currcols" are defined.
In other words, I see that the five embedded functions Rui has
proposed call for the above mentioned arguments, but I'm not able to
understand at which moment these arguments are defined.
+++++++++++++++++++++++++++++++++++++++++++

Everything flows without warnings, so I have the bad feeling to find
myself less smart than R...
That not a big problem, but having not understood the arguments, I do
not understand the functions (so, the results).
Thanks in advance for meeting this call for some extra-help...

Take care,
Dd

***********************************************************
Davide Rizzo
website :: http://sites.google.com/site/ridavide/
On Tue, Sep 18, 2012 at 5:08 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote: