2013-02-27 630 views

回答

1

d[,i]<-d[,i]*5。有關提取對象部分的更多信息,請參閱?Extract

4

假設您的數據幀d有一個名爲「number」的列(您可以使用str(d)查看數據框中列的實際名稱)。要乘以5列「數量」,使用:

# You are referring to the column "number" within the dataframe "d" 
d$number * 5 

# The last command only shoes the multiplication. 

# If you want to replace the original values, use 
d$number <- d$number * 5 

# If you want to save the new values in a new column, use 
d$numberX5 <- d$number * 5 

另外,儘量參照標準的R文檔,你可以在official page找到。

相關問題