Just replace the minus and everything after it with an empty string:
sub("-.*", "", Names)
On Nov 19, 2007 2:14 AM, Tom.O <[EMAIL PROTECTED]> wrote:
>
> Hi
> I wonder if there's a smarter way to do this procedure.
>
> I have a vector of filenames wher I only am interested in the first part of
On Mon, 19 Nov 2007, Benilton Carvalho wrote:
> I'd use:
>
> sapply(strsplit(Names, "-"), "[[", 1)
An alternative is
sub("([^-]*).*", "\\1", Names)
which for many Names would be considerably more efficient.
> On Nov 19, 2007, at 2:14 AM, Tom.O wrote:
>
>>
>> Hi
>> I wonder if there's a smarte
I'd use:
sapply(strsplit(Names, "-"), "[[", 1)
b
On Nov 19, 2007, at 2:14 AM, Tom.O wrote:
>
> Hi
> I wonder if there's a smarter way to do this procedure.
>
> I have a vector of filenames wher I only am interested in the first
> part of
> the filename.
> I would use the following method of
Hi
I wonder if there's a smarter way to do this procedure.
I have a vector of filenames wher I only am interested in the first part of
the filename.
I would use the following method of extracting the first part. But is there
a more simple way of doing this?
Names <-
c("A1-F1.txt","A2-F1.txt","A
4 matches
Mail list logo