[R] short question about data frame manipulation

arnaud Gaboury arnaud.gaboury at gmail.com
Fri Apr 30 15:08:21 CEST 2010


Dear group,

I am losing my mind with a simple question. Sorry if obvious, but I maybe
start to be confused after days and days of reading documentations.

Df :


df <-
structure(list(a = 1:3, b = 4:6, c = structure(c(1L, 1L, 1L), class =
"factor", .Label = "w")), .Names = c("a", 
"b", "c"), row.names = c(NA, -3L), class = "data.frame")

I want to multiply first and second by -1.

> x$a<-x$a*-1
> x$b<-x$b*-1

This returns what I want, but there must be an one line command to do it,
right?

TY for help



More information about the R-help mailing list