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-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jenny Jiang Sent: Monday, July 28, 2014 8:48 PM To: r-help@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 ______________________________________________ R-help@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.