what does 'str(vr)' show as the structure of the list you are creating? On Fri, Jun 27, 2008 at 3:19 AM, Muhammad Azam <[EMAIL PROTECTED]> wrote: > Dear R community > I have a problem to access particular list. I have a code given below where > there is recursive process. It is not possible to run it because there are > few other functions involved inside like sv, LN, RN etc. > > k=0; n=0; variable=c(); vr<-list() > func <- function(data,testdata) > { > . > . > if(......){ > n<<-n+1; vr[[n]] <<- variable; print(vr) > }else > { > k <<- k + 1; data1 = data; data2 = testdata; > s=sv(data1)[[1]]; s1=s[1]; s2=s[2]; variable[k] <<- s1 > data=LN(data1,s1,s2); testdata=LN(data2,s1,s2) > > func(data,testdata); > > data=RN(data1,s1,s2); testdata=RN(data2,s1,s2) > > func(data,testdata) > } > } > func(m,w) > > Actually i made an global array to store s1 named "variable". It contains "k" > values. When it enters into "if", i made a list of variable named "vr". So it > will make "n" lists. If i get the print out of "vr", i will get > [[1]] > [1] 4 > > [[1]] > [1] 4 > > [[2]] > [1] 4 4 3 > > [[1]] > [1] 4 > > [[2]] > [1] 4 4 3 > > [[3]] > [1] 4 4 3 > > [[1]] > [1] 4 > > [[2]] > [1] 4 4 3 > > [[3]] > [1] 4 4 3 > > [[4]] > [1] 4 4 3 > > But if i print(vr[[n]]), i get result like an array > [1] 4 > [1] 4 4 3 > [1] 4 4 3 > [1] 4 4 3 > I want to access a particular list vr[[n-1]], but it gives an error > "Error in print(vr[[n - 1]]) : attempt to select less than one element". > How can i tackle this problem to access vr[[n-1]]. Please give some suitable > suggestions. > > Thanks and best regards > > Muhammad Azam > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > 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. >
-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ R-help@r-project.org mailing list 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.