[R] outputting R loop to a csv file
yun.jiang at student.unsw.edu.au
Tue Jul 29 03:47:38 CEST 2014
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.
More information about the R-help