[英]making table in loop R
請幫忙,
我寫循環。 但是,data1 結果不是我想要的數據框。 data1 應該是這樣的:
newcol_0.000001 newcol_0.00001 newcol_0.0001 newcol_0.001 newcol_0.01 newcol_0.1 newcol_01
2.50E-07 2.50E-06 2.50E-05 0.0025 0.025 0.25 1
2.53E-07 2.53E-06 2.53E-05 0.002531969 0.025319693 0.253196931 1
2.56E-07 2.56E-06 2.56E-05 0.002564767 0.025647668 0.256476684 1
2.60E-07 2.60E-06 2.60E-05 0.002598425 0.025984252 0.25984252 1
2.63E-07 2.63E-06 2.63E-05 0.002632979 0.026329787 0.263297872 1
2.67E-07 2.67E-06 2.67E-05 0.002668464 0.026684636 0.266846361 1
2.70E-07 2.70E-06 2.70E-05 0.002704918 0.02704918 0.270491803 1
2.74E-07 2.74E-06 2.74E-05 0.002742382 0.027423823 0.274238227 1
2.78E-07 2.78E-06 2.78E-05 0.002780899 0.027808989 0.278089888 1
2.82E-07 2.82E-06 2.82E-05 0.002820513 0.028205128 0.282051282 1
se=seq(-0.4,0.1,length.out=100)
t=100
gamma=c(0.0000001,0.000001,0.00001,0.001,0.01,0.1,1)
for (i in 1:length(gamma)) {
newcol <- ((gamma[i]*(2.718^((se+gamma[i])*t)))-gamma[i])/((gamma[i]*(2.718^((se+gamma[i])*t)))+se)
data1 <- rbind(data1, newcol)
}
嘗試這個
se=seq(-0.4,0.1,length.out=100)
t=100
data1 <- data.frame(matrix(NA , nrow = 100))
gamma=c(0.0000001,0.000001,0.00001,0.001,0.01,0.1,1)
for (i in 1:length(gamma)) {
newcol <- ((gamma[i]*(2.718^((se+gamma[i])*t)))-gamma[i])/((gamma[i]*(2.718^((se+gamma[i])*t)))+se)
data1[[i]] <- newcol
}
colnames(data1) <- paste0("newcol_" ,gamma)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.