Dear list, I'm trying to run the following for loop:
I have two list, the first one is
$'5684'
CFISCALE "5684"
RAGSOCB "Brembo"
$'4532'
CFISCALE "4532"
RAGSOCB "Stella"
which is this one in terms of dput:
dput(kk)
structure(list(`5684` = structure(c("5684", "Brembo",
"5684", "Brembo", "5684", "Brembo"),
.Dim = 2:3, .Dimnames = list(
c("CFISCALE", "RAGSOCB"), c("1",
"3", "2"))), `4532` = structure(c("450155",
"Stella"), .Names = c("CFISCALE", "RAGSOCB"
))), .Names = c("5684", "4532"))
The second one is:
$'5684'
ANNO 1986 1987 1988
var1 45 23 87
$'4532'
ANNO 1986
var1 35
In terms of dput:
dput(kk1)
structure(list(`5684` = structure(c("1986", "45",
"1987",
" 23", "1988", "87"), .Dim = 2:3, .Dimnames =
list(c("ANNO",
"var1"), c("1", "3", "2"))), `4532` =
structure(c("1986", "35"
), .Names = c("ANNO", "var1"))), .Names =
c("5684", "4532"
))
This is my loop:
mate: function(x,y){
for (i in x){
for (i in y){
ifelse(names(x)==names(y),print(xtable(i)) & print(xtable(l)),NULL)}}}
This is the error message I get:
Errore in print(xtable(i)) & print(xtable(l)) :
operations are possible only for numeric, logical or complex types
Anyone KNows How to solve it???
Moreover there is a way to use the structure of the first list object for the
second one?
I mean:
turn
$'4532'
ANNO 1986
var1 35
into:
$'4532'
ANNO 1986 1987 1988
var1 35 NA NA
Thanks a lot for your attention!
[[alternative HTML version deleted]]
I have some code that is working. The code calculates the error from the real vale when it does a run. The error in metres in called errorxy I want to do 10 runs of the code and everytime it does a run I want to an output of the errorxy, so that it can form an array. I am guessing I should use a for loop around the entire set of code? Any help? -- View this message in context: http://r.789695.n4.nabble.com/For-Loop-tp2314593p2314593.html Sent from the R help mailing list archive at Nabble.com.
Hello, Please read the posting guide found at the bottom of every post to this list. We need to be able to see a small, reproducible example of code that illustrates your question. It sounds like you might be looking for ?replicate. On 08/05/2010 03:47 AM, Turn & Fall wrote:> > I have some code that is working. > > The code calculates the error from the real vale when it does a run. > > The error in metres in called > > errorxy > > > I want to do 10 runs of the code and everytime it does a run I want to an > output of the errorxy, so that it can form an array. > > I am guessing I should use a for loop around the entire set of code? > > Any help?
Hi r-help-bounces at r-project.org napsal dne 05.08.2010 10:47:03:> > I have some code that is working. > > The code calculates the error from the real vale when it does a run. > > The error in metres in called > > errorxy > > > I want to do 10 runs of the code and everytime it does a run I want toan> output of the errorxy, so that it can form an array. > > I am guessing I should use a for loop around the entire set of code?Perhaps. Perhaps not. Regards Petr> > Any help? > -- > View this message in context: http://r.789695.n4.nabble.com/For-Loop- > tp2314593p2314593.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.