[R] Adding a column into the file

David Winsemius dwinsemius at comcast.net
Sun Jun 3 18:41:05 CEST 2012


On Jun 1, 2012, at 4:08 PM, David Winsemius wrote:

>
> On Jun 1, 2012, at 12:27 PM, pigpigmeow wrote:
>
>> Dear all,
>> I have a lot of problems on R-programming.
>> for example my csv. file is ..
>
> That certainly does not look like any csv file I have ever seen.
>
>> Date                  wrfRH wrfsolar wrfwindspeed wrfrain wrftd wrfta
>> 21/10/2010 92.97 22.11 53.27 0 1546.337861 61.00852664
>>

>> i calculate the ratio of wrfRH/wrfsolar for each day.
>>
>
> If you are confused in your terminology, and you really have a  
> data.frame created by read.table, then adding a column to an  
> existing data.frame , say the ratio of wrftd divided by wrfta,  is  
> really simple:
>
> dfrm$ratio <- with dfrm, wrftd/wrfta)

And that of course should have been :

dfrm$ratio <- with( dfrm, wrftd/wrfta)

--

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list