Skip to content

position of the end of a text file

3 messages · Henri-Paul Indiogine, michael.weylandt at gmail.com (R. Michael Weylandt

#
Hi!

I need to find the position of the last character (could be empty
space) of a vector of text files (my.text.vector) that I have read
into R.  I tried Google, but all I have found needs a pattern.

I tried the following

as.integer(regexpr("??", my.text.vector)

but it returns 1 or even the correct number, but not consistently.   I
understand that ?? is an operator, thus should not be used but itself.

Any ideas?

Thanks,
Henri-Paul
#
I think I have it and my apologies for spamming the list.  I should
not work this late on Sunday :-)

I think that it should be

as.integer(regexpr("$$", my.text.vector)


2011/10/16 Henri-Paul Indiogine <hindiogine at gmail.com>:

  
    
Couldn't you also just count the number of characters with nchar()?

Michael Weylandt
On Oct 17, 2011, at 1:57 AM, Henri-Paul Indiogine <hindiogine at gmail.com> wrote: