Re: [R] why data.frame, mutate package and not lists

2016-09-15 Thread Rolf Turner
On 15/09/16 14:04, S Ellison wrote: If you want to add variable to data.frame you have to use attach, detach. Right? I'd have said "not at all", not "not quite". attach and detach have almost exactly nothing to do with adding to a data frame. You can add to a data frame using dfrm$newvar <-

Re: [R] why data.frame, mutate package and not lists

2016-09-15 Thread S Ellison
>If you want > to add variable to data.frame you have to use attach, detach. Right? I'd have said "not at all", not "not quite". attach and detach have almost exactly nothing to do with adding to a data frame. You can add to a data frame using dfrm$newvar <- dfrm['newvar'] <- cbind(dfrm,

Re: [R] why data.frame, mutate package and not lists

2016-09-14 Thread Duncan Murdoch
On 14/09/2016 2:40 PM, jeremiah rounds wrote: "If you want to add variable to data.frame you have to use attach, detach. Right?" Not quite. Use it like a list to add a variable to a data.frame e.g. df = list() df$var1 = 1:10 df = as.data.frame(df) df$var2 = 1:10 df[["var3"]] = 1:10 df df =

Re: [R] why data.frame, mutate package and not lists

2016-09-14 Thread jeremiah rounds
There is also this syntax for adding variables df[, "var5"] = 1:10 and the syntax sugar for row-oriented storage: df[1:5,] On Wed, Sep 14, 2016 at 11:40 AM, jeremiah rounds wrote: > "If you want to add variable to data.frame you have to use attach, detach. > Right?" >

Re: [R] why data.frame, mutate package and not lists

2016-09-14 Thread jeremiah rounds
"If you want to add variable to data.frame you have to use attach, detach. Right?" Not quite. Use it like a list to add a variable to a data.frame e.g. df = list() df$var1 = 1:10 df = as.data.frame(df) df$var2 = 1:10 df[["var3"]] = 1:10 df df = as.list(df) df$var4 = 1:10 as.data.frame(df)

Re: [R] why data.frame, mutate package and not lists

2016-09-14 Thread Alaios via R-help
thanks for all the answers. I think also ggplot2 requires data.frames.If you want to add variable to data.frame you have to use attach, detach. Right?Any more links that discuss thoe two different approaches?Alex On Wednesday, September 14, 2016 5:34 PM, Bert Gunter

Re: [R] why data.frame, mutate package and not lists

2016-09-14 Thread Bert Gunter
This is partially a matter of subjectve opinion, and so pointless; but I would point out that data frames are the canonical structure for a great many of R's modeling and graphics functions, e.g. lm, xyplot, etc. As for mutate() etc., that's about UI's and user friendliness, and imho my ho is

Re: [R] why data.frame, mutate package and not lists

2016-09-14 Thread Marc Schwartz
> On Sep 14, 2016, at 8:01 AM, Alaios via R-help wrote: > > Hi all,I have seen data.frames and operations from the mutate package getting > really popular. In the last years I have been using extensively lists, is > there any reason to not use lists and use other data

[R] why data.frame, mutate package and not lists

2016-09-14 Thread Alaios via R-help
Hi all,I have seen data.frames and operations from the mutate package getting really popular. In the last years I have been using extensively lists, is there any reason to not use lists and use other data types for data manipulation and storage? Any article that describe their differences? I