[R] data frame subscription
arnaud Gaboury
arnaud.gaboury at gmail.com
Wed May 12 14:50:39 CEST 2010
Dear group,
Here is my df :
pose16 <-
structure(list(DESCRIPTION = structure(c(1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 12L), .Label = c("COPPER May/10", "COTTON NO.2 Jul/10",
"CRUDE OIL miNY May/10", "GOLD Jun/10", "ROBUSTA COFFEE (10) Jul/10",
"SOYBEANS Jul/10", "SUGAR NO.11 Jul/10", "SUGAR NO.11 May/10",
"WHEAT Jul/10", "PRIMARY NICKEL USD", "PRM HGH GD ALUMINIUM USD",
"SPCL HIGH GRADE ZINC USD", "STANDARD LEAD USD"), class = "factor"),
POSITION = c(-2, 3, 2, 2, 18, 3, 5, -1, 5, -1), SETTLEMENT = c(351.45,
81.59, 83.24, 1136.9, 1382, 995, 16.18, 15.95, 502.5, 2423
)), .Names = c("DESCRIPTION", "POSITION", "SETTLEMENT"), row.names =
c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "51"), class = "data.frame")
Here is my code :
>pose16$prix<-pose16[,2]*pose16[,3]
>pose16<-pose16[,-3]
>pose16[,-1]<- -pose16[,-1]
It works fine, as the resulting df is what I want. I am just wandering if
these 3 command lines can be writen in only 1 or 2 lines??
TY for the help.
More information about the R-help
mailing list