I think that what you are trying to do is to end up with a delimited text file with 24 blank columns between each adjacent variable. Here is a sort of roundabout and clunky solution. It will break if you have any strings with commas in any of your variables, has the annoying quality of having 24 commas written inside a string (you can count them with nchar()
), and commits the offense of saving data to disk and then reading them back in.
# Export your data.frame to a csv file
write.csv(YourDataFrame, file="Path/To/File.csv", row.names=FALSE)
# Read in the lines of the file
fileLinesTemp = readLines("Path/To/File.csv")
# Add a bunch of commas to add columns
fileLinesTemp = gsub(",", ",,,,,,,,,,,,,,,,,,,,,,,,", fileLinesTemp)
# Write the new lines back to the file
fileConn = file("Path/To/File.csv")
writeLines(fileLinesTemp, fileConn)
close(fileConn)