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

2010-03-23 Thread Corrado

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_2dbl_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: ct...@york.ac.uk

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2010-03-23 Thread Bernardo Rangel Tura
On Tue, 2010-03-23 at 09:37 +, Corrado wrote:
 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_2dbl_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


Hi Corrado!

First: tolower(pcs$str_1) change to lower case
Second: try merge (East,pcs,by.x=str_1,by.y=str_1) to fusion data frames
Third: I don't recreate your database East in my computer do you give a
small part to I try solve your problem?

-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.