[R] 7 days confusion over lists

Wageningen-eR igor.milosavljevic at wur.nl
Thu Jul 5 16:44:46 CEST 2012


I am a Masters student and I am working on my thesis modelling smallholder
farms using a program in R.  I have modified the original code and I am
having some issues with lists that I cannot figure out.

Originally, I had list file defining lists such as: Param, Crop1, Crop1,
Soil, etc.  (ex. Param <- list() ).  Their subsets were listed as
Crop1$CContent for example and there was quite a few of them.  There is a
run file that gets the list file going in the following code:

#--Initialising the lists to store variable values
tmp <- init_lists()
Param       <- tmp[[1]]
Crop1       <- tmp[[2]]
Fert        <- tmp[[3]]
Meteo       <- tmp[[4]]
Soil        <- tmp[[5]]
RainPattern <- tmp[[6]]
Crop2       <- tmp[[7]]
Cropres     <- tmp[[8]]

The problem here is that the lists get confused with each other; that is
elements of Soil appear in Crop2.  In the run file, I changed the order of
the lists (for example Fert <- tmp[[5]] and Crop2 <-tmp[[3]]) and it changes
which ones are confused with what; with some lists not being confused at
all.  I cannot find why this is a problem as the tmps are removed at the end
of the command list shown below and each element is clearly defined as a
part of its given list with (list name)$(Sublist maybe)$(specific element

Either way, I changed the original lists to be more specific, for example:

Crop$ <- list(
CContent <- NA,
NContent <- NA,
PContent <- NA,
KContent <- NA,
K <- list(

The issue then became that it stops at a certain point accepting the
assigned values and keeps them as null.  That is, the list contains an
element that states Crop2$minYieldN <- NA but the value becomes NULL when it
is run.   Also, the list, say Param, contains both:

[1] NA

[1] NA

[1] NA

[1] NA
and some of the value names (up to a point)

[1] 0.001

[1] 0.25

[1] 0.2

[1] 0.6

Is it perhaps that the list is too long?  Please let me know if anything
comes to mind, it would be great help.

Thank you!


-Igor Milosavljevic
Wageningen University and Research Center

View this message in context: http://r.789695.n4.nabble.com/7-days-confusion-over-lists-tp4635489.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list