What criteria does one use to decide whether to write a common sequence of code as a source(procedure) or as a function? As I understand it, both are maintained as source code and interpreted, so is there any performance advantage either way? Thank you for your help. graham lawrence _________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Perhaps some kind person might show me the way to extract the first element of a list. The example is tmp <- c("A", "B C","BC D") I want the first "word" from each of these elements, i.e. "A" ,"B" ,"BC" strsplit(tmp," ") returns [[1]] [1] "A" [[2]] [1] "B" "C" [[3]] [1] "BC" "D" I have had no success in trying to extract the first element. Of course there may be another way to get the same result. Thanks Ross Darnell -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Ross Darnell wrote:> > Perhaps some kind person might show me the way to extract the first element of a list. > > The example is > > tmp <- c("A", "B C","BC D") > > I want the first "word" from each of these elements, i.e. "A" ,"B" ,"BC" > > strsplit(tmp," ") returns > > [[1]] > [1] "A" > > [[2]] > [1] "B" "C" > > [[3]] > [1] "BC" "D" > > I have had no success in trying to extract the first element. > > Of course there may be another way to get the same result.For the first element of a list L: L[[1]] For the first elements of all elements (vector) of the list: lapply(L, function(x) x[1]) Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._