Result of row binding in R while maintaining column labels

I have a technical question in R: how can I cast the following results (results1 and result2) into a data frame and save the column labels for both:

result1:

meanAUC.SIM meanCmax.SIM meanTmax.SIM  AUC.OBS Cmax.OBS Tmax.OBS   PE.AUC  PE.Cmax  PE.Tmax
777.4444     74.64377     4.551254 820.7667 73.46508 3.089009 5.278274 1.604416 47.33703

result2:

 medianAUC.SIM medianCmax.SIM medianTmax.SIM AUC.OBS Cmax.OBS Tmax.OBS   PE.AUC  PE.Cmax PE.Tmax
764.6611        72.4534            4.5 795.765     68.2        3 3.908683 6.236657      50

The reason for this is because I want to write them to a file in an *.csvorganized way with the correct labeling.

+4
source share
1 answer

If the only reason you want to merge the data is to write it to a csv file, then you can simply write each data frame separately to the same csv file. For instance:

write.table(result1, "myfile.csv", row.names=FALSE, sep=",")

# If you want a blank row between them
cat("\n", file = "myfile.csv", append = TRUE)

write.table(result2, "myfile.csv", row.names=FALSE, sep=",", append=TRUE)

This is what the file looks like:

enter image description here

+4
source

All Articles