Skip to content
Prev 75453 / 398502 Next

coercing created variables into a new data frame using na.omit()

Prof Brian Ripley wrote:

            
That cannot possible work, as assignment within with is local to
with's environment. I have used superassigmnent for this (<<-), but that 
cannot possible
be a good style?

Look at the following:

 > test <- data.frame( a=1:5, b=1:5)
 > test
  a b
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
 > with(test, test$c <- 1:5)
 > test
  a b
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
 > with(test, test$c <<- 1:5)
 > test
  a b c
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5

So what is the best style her?

Kjetil
-- 

Kjetil Halvorsen.

Peace is the most effective weapon of mass construction.
               --  Mahdi Elmandjra