可能重複:
Replace contents of factor column in R dataframe替換R中數據幀列中的數字?
我有data.frame
df1<-data.frame("Sp1"=1:6,"Sp2"=7:12,"Sp3"=13:18)
rownames(df1)=c("A","B","C","D","E","F")
df1
Sp1 Sp2 Sp3
A 1 7 13
B 2 8 14
C 3 9 15
D 4 10 16
E 5 11 17
F 6 12 18
我要替換DF1 $ SP2中列有數字8的每個條目數量800.我曾嘗試過:
test<-replace(df1$Sp2,df1[800,"Sp2"],5)
爲了更好地理解如何使用'replace'看到:http://stackoverflow.com/questions/11811027/replace-function-examples – 2012-08-05 14:56:30