ls is a list of character vectors created by strsplit()

I want to concatenate  the 1st 4 character elements of each list item as a new vector called file.  I admit to being confused about list syntax even after numerous readings.

Here's what I tried:

ls <- list(c("Focused", "10k", "A12", "t04.tif", "+", "痠"), c("Focused", 
"10k", "A12", "t08.tif", "+", "痠"), c("Focused", "10k", "A12", 
"t12.tif", "+", "痠"), c("Focused", "10k", "A12", "t16.tif", 
"+", "痠"), c("Focused", "10k", "A12", "t20.tif", "+", "痠"), 
    c("Focused", "10k", "A12", "t24.tif", "+", "痠"), c("Focused", 
    "10k", "A12", "t36.tif", "+", "痠"), c("Focused", "10k", 
    "A12", "t48.tif", "+", "痠"), c("Focused", "10k", "B12", 
    "t04.tif", "+", "痠"), c("Focused", "10k", "B12", "t08.tif", 
    "+", "痠"))

# Test the waters with one element
cat(unlist(ls[1])[1:4])      # WHY DOES THE COMMAND PROMPT NOT APPEAR ON NEXT LINE AS USUAL???

# Appears to work except for command prompt glitch

# Attempts to use tapply() don't get me anywhere
file <- tapply(unlist(ls), list(1:length(unlist(ls))), cat(unlist(ls[1])[1:4]))

I'm grateful for an approach to putting my vector together, but I'd also love to understand the headache I've apparently given the command parser.  I'm apparently doing some "no no".

Thanks,

Rob

> R.Version()
$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "12.1"

$year
[1] "2010"

$month
[1] "12"

$day
[1] "16"

$`svn rev`
[1] "53855"

$language
[1] "R"

$version.string
[1] "R version 2.12.1 (2010-12-16)"


	[[alternative HTML version deleted]]

