[R] Changing content of column in data.frame + efficient join extraction between 2 data.frames

Corrado ct529 at york.ac.uk
Tue Mar 23 10:37:01 CET 2010


Dear R users,

I have 2 SpatialPointsDataFrame's, pcs and East.

The column str_1 in the first (pcs) is:

 > pcs[0:4,]
       coordinates cat   str_1  int_1  int_2    dbl_1     dbl_2
1 (101000, 263000)   1 "SM06B" 101000 263000 4.978915 -4.293668
2 (101000, 265000)   2 "SM06C" 101000 265000 4.960478 -4.266742
3 (101000, 267000)   3 "SM06D" 101000 267000 4.912984 -4.246849
4 (101000, 269000)   4 "SM06E" 101000 269000 4.613309 -4.185405
 >

The column str_1 in the second (East) is:

 > East[0:4,]
       coordinates str_1
1 (489000, 215000) sp81x
2 (489000, 217000) sp81y
3 (493000, 209000) sp90j
4 (495000, 209000) sp90p
 >

I would like to do 2 things:

1) I would like to change the format of the column str_1
in the first to be the same that it is in the second,
that is I need to remove the inverted commas " and I need to
make it lower case.

2) I would like to extract the rows from the first one (pcs) where 
pcs$str_1
is the same as East$str_1.

I have even tried regexp, but cannot modify
the content of pcs$str_1 to remove
the inveretd commas " and change the case to lowercase.

How do I do that?

Regards
-- 

Corrado Topi
PhD Researcher
Global Climate Change and Biodiversity
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct529 at york.ac.uk



More information about the R-help mailing list