[R] How insert data to a column in existing csv file?

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Thu Apr 12 17:29:28 CEST 2012


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Yellow
> Sent: Thursday, April 12, 2012 2:18 AM
> To: r-help at r-project.org
> Subject: [R] How insert data to a column in existing csv file?
> 
> I was working with some excel files with a lot of data.
> And by hand it is impossible to handle them.
> So they are now converted to .csv.
> 
> With headers above the columns, like:
> Data1, Data2, Data3
> 
> But now I needed to calculate the log2 value of Data1 and place the
> result
> under Data2.
> I can't find how to do that.
> Does anyone else know?
> 
> I have the log2 values, but how do I get then inside the .csv file
> under
> Data2?
> 
> I already tried write.table(), buy that wasn't it.
> And I am kinda stuck on this now.....
> 
> 

In the absence of a reproducible example, we can only guess.  My guess is that you should read the csv file into a data frame, add or modify your variable(s), then write out a new csv file.


Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204





More information about the R-help mailing list