An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110607/0c7db0aa/attachment.pl>
Adding values to the end of a data frame
3 messages · Abraham Mathew, Dennis Murphy
Alas, you don't have a suffix2 object defined, but try this: d1 <- one(prefix, roots) d2 <- one(roots, suffix) rbind(d1, d2) To see a potential flaw in your function (as least as far as console output is concerned), try rbind(d1, one(roots, suffix)) HTH, Dennis
On Tue, Jun 7, 2011 at 3:30 PM, Abraham Mathew <abraham at thisorthat.com> wrote:
Let's say that I'm trying to write a functions that will allow me to
automate a process
where I examine all possible combinations of various string groupings. Each
time I run
the one function, I want to include the new values to the end of a data
frame. The data
frame will basically be one column with a lot of rows.
roots <- c("car insurance", "auto insurance")
prefix <- c("cheap", "budget")
suffix <- c("rate", "rates")
one <- function(x, y, z=0) {
? ? ?nu <- do.call(paste, expand.grid(x, y, z))
? ? ?mydf <- data.frame(nu)
? ? ?print(mydf)
}
one(roots, suffix2)
one(prefix, roots)
one(prefix, roots, suffix2)
The code above just replaces each value in the data frame each time I run
the one function.
How can I add the new values to the end of the data frame?
Help!
I'm running R 2.13 on Ubuntu 10.10
WebRep
Overall rating
? ? ? ?[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110608/fcb08175/attachment.pl>