变量为Vector和grafics软件R

时间:2015-11-16 21:10:50

标签: r

如何将其传递给矢量并与卡方函数进行比较。现在我做到了:

x1<-rnorm(20000,3,2)
x2<-rnorm(20000,3,2)
x3<-rnorm(20000,3,2)
x4<-rnorm(20000,3,2)
x5<-rnorm(20000,3,2)
x6<-rnorm(20000,3,2)
x7<-rnorm(20000,3,2)
x8<-rnorm(20000,3,2)
x9<-rnorm(20000,3,2)
x10<-rnorm(20000,3,2)`

`y1<-((var(x1)*9)/(2^2))
y2<-((var(x2)*9)/(2^2))
y3<-((var(x3)*9)/(2^2))
y4<-((var(x4)*9)/(2^2))
y5<-((var(x5)*9)/(2^2))
y6<-((var(x6)*9)/(2^2))
y7<-((var(x7)*9)/(2^2))
y8<-((var(x8)*9)/(2^2))
y9<-((var(x9)*9)/(2^2))
y10<-((var(x10)*9)/(2^2))

谢谢

1 个答案:

答案 0 :(得分:0)

你可以这样做:

x1<-rnorm(20000,3,2)
x2<-rnorm(20000,3,2)
x3<-rnorm(20000,3,2)
x4<-rnorm(20000,3,2)
x5<-rnorm(20000,3,2)
x6<-rnorm(20000,3,2)
x7<-rnorm(20000,3,2)
x8<-rnorm(20000,3,2)
x9<-rnorm(20000,3,2)
x10<-rnorm(20000,3,2)

y1<-((var(x1)*9)/(2^2))
y2<-((var(x2)*9)/(2^2))
y3<-((var(x3)*9)/(2^2))
y4<-((var(x4)*9)/(2^2))
y5<-((var(x5)*9)/(2^2))
y6<-((var(x6)*9)/(2^2))
y7<-((var(x7)*9)/(2^2))
y8<-((var(x8)*9)/(2^2))
y9<-((var(x9)*9)/(2^2))
y10<-((var(x10)*9)/(2^2))

 y <- c(y1,y2,y3,y4,y5,y6,y7,y8,y9,y10)
 x <- c(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10)

但可能有更好的选择,可能有一个循环或其他东西。也许其他人可以帮助你