Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

r - write.csv() a list of unequally sized data.frames

I would like to pump out a list of data.frame() objects to a csv file so I can work on it for presentation. I'm finding that it's replying with an error:

In write.csv(tmp[i], file = "Output.csv", append = T) :
  attempt to set 'append' ignored

I've saved the outputs to a list (all of which can be coerced to a df), here's an example:

outputs <- list() 
outputs$fivenum <- fivenum(rnorm(100))
outputs$summary <- as.data.frame(as.vector(summary(rnorm(100))))

tmp <- lapply(outputs, as.data.frame)

write.csv(tmp, file="Output.csv",append=T)

Does every append action have to have the same number of columns?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That's a warning, not an error. You can't change append=FALSE with write.csv. ?write.csv says:

Attempts to change ‘append’, ‘col.names’, ‘sep’, ‘dec’ or ‘qmethod’ are ignored, with a warning.

Use write.table with sep="," instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...