[R] removing a specific number of digist from a character string
Kim Milferstedt
milferst at uiuc.edu
Mon Sep 17 17:21:04 CEST 2007
Hello,
I would like to remove the last 8 digists of character strings in a
vector. Below I added a couple of elements from that vector.
I have a problem defining a pattern to replace the digits using for
example "sub". Removing the ".tif" part works fine using
sub('.tif',"",x), but how do I get rid of the four preceding digits?
Thanks for your help,
Kim
Input:
[3988]
"060907_17_3_5_1_1_2909.tif" "060907_17_3_5_2_1_2910.tif"
"060907_17_3_5_3_1_2911.tif"
[3991]
"060907_17_3_5_4_1_2912.tif" "060907_17_3_5_5_1_2913.tif"
"060907_17_3_5_6_1_2914.tif"
Desired output:
[3988] "060907_17_3_5_1_1_" "060907_17_3_5_2_1_" "060907_17_3_5_3_1_"
[3991] "060907_17_3_5_4_1_" "060907_17_3_5_5_1_" "060907_17_3_5_6_1_"
__________________________________________
Kim Milferstedt
University of Illinois at Urbana-Champaign
Department of Civil and Environmental Engineering
4125 Newmark Civil Engineering Laboratory
205 North Mathews Avenue MC-250
Urbana, IL 61801
USA
phone: (001) 217 333-9663
fax: (001) 217 333-6968
email: milferst at uiuc.edu
http://cee.uiuc.edu/research/morgenroth
More information about the R-help
mailing list