[R] Why do return or visible donīt return my objekt?

From: Christoph Heibl <christoph.heibl_at_gmx.net>
Date: Fri 26 Jan 2007 - 19:23:26 GMT


Dear RRRRRrrrrrrrrlist!

Iīve got two lists which contain sets of DNA-sequences. They look something like this:

	List of 33

$ Cunonia_atrorubens : chr [1:247] "t" "t" "n" "t" ...
$ Cunonia_balansae : chr [1:254] "t" "c" "c" "c" ...
$ Cunonia_capensis : chr [1:236] "v" "t" "c" "c" ...
$ Cunonia_macrophylla : chr [1:236] "t" "t" "a" "t" ...
$ Pancheria_engleriana : chr [1:315] "c" "t" "c" "c" ...
[....]
$ Brunellia_colombiana : chr [1:336] "t" "t" "c" "t" ...
$ Brunellia_oliveri : chr [1:368] "t" "a" "a" "t" ...
$ Bauera_rubioides : chr [1:276] "t" "c" "t" "c" ...
$ Bauera_sessiliflora : chr [1:332] "t" "c" "t" "c" ...
$ Davidsonia_pruriens_var._jeryseyana: chr [1:300] "t" "t" "c" "t" ...
$ Davidsonia_sp._'johnsonii' : chr [1:268] "c" "c" "c" "t" ...
- attr(*, "species")= chr [1:33] "Cunonia_atrorubens"
"Cunonia_balansae" "Cunonia_capensis" "Cunonia_macrophylla" ...

The names of each entry in first list match exactly the names of the entries in the second list and both list contain the same number of sequences (although not of the same length) I want to concatenate these sequences by the following function:

	interleave <- function(seq1, seq2)
	{
		#create a list to contain concatenated sequences
		sequence <- list()			
		for (name in names(seq1)) 	# get names as indices
			{
			# concatenate sequences
			sequence[[name]] <- c(seq1[[name]], seq2[[name]])
			}
	# return concatenated sequences
	invisible(sequence)	
	}

I guess the function works in principle, because they commands do so if I enter them step by step.
But when I call the function it does not return my object "sequence". But why?

(This happened to me with some functions that I wrote, but not all. The error seems quite erratic : ) to me and I canīt figure out what to change)

Thanks a lot in advance!

Christoph



R-help@stat.math.ethz.ch 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. Received on Sat Jan 27 06:30:48 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 26 Jan 2007 - 21:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.