[R] apply

Roger Mason rmason at esd.mun.ca
Wed Sep 19 15:03:25 CEST 2007


Hello,

I have a list of filenames extracted from a data-frame thus:

files <- main$file

e.g. file[[1]] returns 

[1] Ca00Mn48_0.gout
4702 Levels: Ca00Mn48_0.gout Ca01Mn47_0.gout Ca01Mn47_1.gout
... Ca48Mn00_0.gout

I want to extract the substring that contains the two digits after
"Ca".  This works on individual entries, e.g. substr(files[[1]],3,4)
returns "00".

I wish to apply substr() to all the entries in files.  All my efforts
fail.  Could some kind soul explain how to do what I want?

Thanks,

Roger Mason



More information about the R-help mailing list