[R] How insert data to a column in existing csv file?
jim holtman
jholtman at gmail.com
Thu Apr 12 17:45:54 CEST 2012
I would suggest using the XLConnect package so that you can read/write
the Excel files directly. You can read in the files to a dataframe,
make your transformations and then write the result back out to the
Excel file.
On Thu, Apr 12, 2012 at 11:29 AM, Nordlund, Dan (DSHS/RDA)
<NordlDJ at dshs.wa.gov> wrote:
>> -----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
>
>
>
> ______________________________________________
> 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.
--
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
More information about the R-help
mailing list