Skip to content
Prev 18275 / 398503 Next

Extracting the first element of a list

Ko-Kang Kevin Wang wrote:
Well, I meant *after* strsplit:

  temp <- strsplit(foo, "")
  L <- lapply(temp, function(x) x[1])
  as.numeric(unlist(L))
 
In this case you can also calculate it:

  floor(foo / (10^floor(log(foo, 10))))

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._