Re: [R] inplace assignment

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 16 Jun 2006 - 20:15:35 EST

"David Hugh-Jones" <davidhughjones@gmail.com> writes:

> I get tired of writing, e.g.
>
>
> data.frame[some.condition & another.condition, big.list.of.columns] <-
> paste(data.frame[some.condition & another.condition,
> big.list.of.columns], "foobar")
>
>
> I would a function like:
>
> inplace(paste(data.frame[some.condition & another.condition,
> big.list.of.columns], "foobar"))
>
> which would take the first argument of the inner function and assign
> the function's result to it.
>
> Has anyone done something like this? Are there simple alternative
> solutions that I'm missing?

Well, I'd consider

cc <- some.condition & another.condition l <- big.list.of.columns
mydf[cc,l] <- paste(mydf[cc,l], "foobar)

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Jun 16 20:23:25 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 16 Jun 2006 - 22:12:37 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.