rhcaeb / QFC-course

Programming Fundamentals Using R
0 stars 0 forks source link

Complete application 2-6 #18

Closed rhcaeb closed 4 years ago

rhcaeb commented 4 years ago

Application 2-6

Notes

Pending review @belinskyc

rhcaeb commented 4 years ago

Question: In the application, the function write.csv() includes an additional column to the newly saved .csv file;

Is there a workaround for this? or does it include the row names (e.g., 1,2,3,4,5...etc.)? See 'Files Changed' for working example, there is a "" column before date.

belinskyc commented 4 years ago

Question: In the application, the function write.csv() includes an additional column to the newly saved .csv file;

Is there a workaround for this? or does it include the row names (e.g., 1,2,3,4,5...etc.)? See 'Files Changed' for working example, there is a "" column before date.

Try adding row.names = FALSE to write.csv()

belinskyc commented 4 years ago

row.names = FALSE works... sort of weird default behavior for R to assume the row number are row names. This is something I need to look more into...

In other news, you can also add quote = FALSE to write.csv() if you do not want to have strings quoted in the CSV file. I do not have an opinion on which way is better. I know you need quotes if the value separating your data (comma -- hence CSV) is being used in your data. Those commas need to be inside quotes or your data table is going to be a mess!