That seems to be a suitable situation for a loop although you might
wish to write it like this:
for ( nm in names(df) ) df[ v[[nm]], nm ] <- NA
Note that R does not require semicolons at the end of each statement.
On Sat, May 8, 2010 at 11:12 AM, wrote:
> Hello, after the creation of a data.f
Try this:
df <- as.data.frame(mapply(`[<-`, x = df, i = v, NA))
On Sat, May 8, 2010 at 12:12 PM, wrote:
> Hello, after the creation of a data.frame I like to add NAs as follows:
>
> n <- 743;
> x <- runif(n, 1, 7);
> Y <- runif(n, 1, 7);
> Ag6 <- runif(n, 1, 7);
> df <- data.frame(x, Y, Ag6);
2 matches
Mail list logo