[R] outputting R loop to a csv file
David L Carlson
dcarlson at tamu.edu
Tue Jul 29 05:25:08 CEST 2014
It will be difficult to help since all of the attached files were stripped out of your message. R-help accepts very few formats as attached files and they do not include .R or .csv or .xlsx, but they do include .txt (so you could rename your R and csv files). It will be easier to help if we have enough data to test alternate approaches. The function dput() will convert a sample of your data to text format so that you can paste it into your email or provide it as a .txt file.
David L. Carlson
Department of Anthropology
Texas A&M University
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Jenny Jiang
Sent: Monday, July 28, 2014 8:48 PM
To: r-help at R-project.org
Subject: [R] outputting R loop to a csv file
Hello,
My name is Jenny Jiang and I am a Finance Honours research student from the University of New South Wales. Currently my research project involves the calculating of some network centrality measures in R by using a loop, however I am having some trouble outputting my loop results to a desired CSV format.
Basically what I am doing is that for each firm year, I will need to calculate four different measures based on director id and connected director id and output these to the CSV file. I have provided in the attachment the code that I used for the R loop and CSV outputting (main-6.R). Using an example CSV file (data example 2), the output result I get is as shown in measure1.csv. As shown in the output file, the results are really messy, where for each firm year, all director ids and each type of measure for all directors are displayed in one cell. However, the desired format of output that I would like is as shown in output data template.xlsx.
As a result, I was just wondering if you could be able to help me to get the desired format that I would like, which would be much easier to enable me to do further research on this.
I cannot be more than appreciated.
Best regards
Jenny
More information about the R-help
mailing list