Pregunta

For weekly reports I generate, I create a .csv file for my outputs which has 9 columns and 7 rows.

I use this command to create my file:

write.csv(table, paste('home/weekly_',start.date,'.csv',sep=''), row.names=F)

Note: 'table' is a matrix (I believe that's the right R terminology)

I would like to add a footnote/note under the table in this file, would this be possible?

For example, if I were to create a text file instead of a .csv file, I would use the following commands:

cat("Number of participants not eligible:")
cat(length(which((tbl[,'Reg_age_dob']<=18) & as.Date(tbl[,'DateWithdrew'])>='2013-01-01'& as.Date(tbl[,'DateWithdrew'])<'2013-04-01' & as.Date(tbl[,'QuestionnaireEndDate'])<'2013-01-01' )))
cat("\n")

How would I do this to appear under the table in a .csv output file?

¿Fue útil?

Solución

After writing the CSV part, just append the rest as new lines using

write("Footer",file="myfile",append=TRUE)

Solution from here: Add lines to a file

But be aware of the fact, that a CSV parser will be a upset, if you do not use comment tags correctly.

It might be better to use a second file for your purpose.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top