[R] how to identify values from a column of a dataframe, and insert them in other data.frame with the corresponding id?

John Kane jrkrideau at inbox.com
Fri Aug 3 20:17:00 CEST 2012


Hi Nerea,

For some reason your post is badl garbled and close to imposible to read.  
Perhaps you need to check your text encoding?

Also to send sample data it is better to use the dput() command.
Do dput(myfile) and then paste the results into your email

Sorry not to be of more help.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: nlezama at azti.es
> Sent: Fri, 3 Aug 2012 12:34:07 +0200
> To: r-help at r-project.org
> Subject: [R] how to identify values from a column of a dataframe, and
> insert them in other data.frame with the corresponding id?
> 
> 
> 
> Hello,
> 
> Ib??d like to do next, see if you could help me please:
> I have a csv called b??datuakb?? with a id called b??calee_idb?? and a
> colunm called b??poidsb??.
> 
> I have another csv called b??datuak2b?? with the same id called
> b??calee_idb??, (although there are b??calee_idb?? that are in
> b??datuakb?? but not in b??datuak2b?? and inverse), and a column called
> b??kg_totalesb?? in which the values are repeteated for each calee_id
> because are the sum of the colum b??kgb?? for each row.
> 
> 
> 
> I show you the table b??datuakb?? and b??datuak2b??:
> 
> 
> 
> Datuak (in the example the calee_id is the same, but there are a lot):
> 
> 
> 
> 	poids
> 
> calee_id
> 
> maree_id
> 
> 	10
> 
> 1.27E+12
> 
> 0.3013157
> 
> 	20
> 
> 1.27E+12
> 
> 0.05726046
> 
> 	20
> 
> 1.27E+12
> 
> 0.73631699
> 
> 	25
> 
> 1.27E+12
> 
> 0.74492002
> 
> 	3
> 
> 1.27E+12
> 
> 0.74492002
> 
> 	27
> 
> 1.27E+12
> 
> 0.31776439
> 
> 	43
> 
> 1.27E+12
> 
> 0.31776439
> 
> 
> 
> 
> 
> Datuak2:
> 
> 
> 
>            calee_id          maree_id      kg_totales  effectif
> 
> 1     1.33959e+12 0.782835873      129.7             30
> 
> 2     1.33959e+12 0.782835873      129.7             40
> 
> 3     1.33959e+12 0.782835873      129.7             10
> 
> 4     1.33959e+12 0.782835873      129.7              5
> 
> 5     1.33959e+12 0.782835873      129.7            1.7
> 
> 6     1.33959e+12 0.782835873      129.7             20
> 
> 7     1.33959e+12 0.782835873      129.7             20
> 
> 8     1.33959e+12 0.782835873      129.7              1
> 
> 9     1.33959e+12 0.782835873      129.7              2
> 
> I would like to identify in the csv b??datuak2b?? the corresponding
> b??calee_idb?? that also are in b??datuakb??, and create a new column in
> b??datuakb?? with the values for each b??calee_idb?? from
> b??kg_totalesb??, and not repeat them.
> 
> So the final table would be b??datuakb??, with b??calee_idb??,
> b??poidsb??, and the new column b??kg_totalesb?? with its corresponding
> value for each row.
> 
> 
> 
> Thank you very much,
> 
> Nerea
> 
> 
> 
> 
> 
> 
> --
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list