是否可以在R程序中调用R程序?
比如说,我正在寻找这样的东西:
If condition == X{
CALL "Pgm A"
} else {
CALL "Pgm B"
}
Run Code Online (Sandbox Code Playgroud)
我在C中使用的这种语法.在R中有类似的方法吗?
谢谢.
我有这样一张桌子:
A B C D E
7 1 6 8 7
9 3 9 5 9
4 6 2 1 10
10 5 3 4 1
1 3 5 9 3
6 4 8 7 6
Run Code Online (Sandbox Code Playgroud)
我正在查找每个变量与表中每个其他变量的相关性.这是我使用的R代码:
test <- read.csv("D:/AB/test.csv")
iterations <- ncol(test)
correlation <- matrix(ncol = 3 , nrow = iterations * iterations)
for (k in 1:iterations) {
for (l in 1:iterations){
corr <- cor(test[,k], test[,l])
corr_string_A <- names(test[k])
corr_string_B <- names(test[l])
correlation[l + ((k-1) * iterations),] <- rbind(corr_string_A, …Run Code Online (Sandbox Code Playgroud) 我正在做一个chisq.test并尝试将输出分配给变量.
> Output <- chisq.test(test[,k], test[,l])
> Output
Pearson's Chi-squared test
data: test[, k] and test[, l]
X-squared = 7128, df = 36, p-value < 2.2e-16
Run Code Online (Sandbox Code Playgroud)
我想从输出中单独访问p值或仅将p值分配给ouptut.
有没有这样的方式:
Output$p-value
Run Code Online (Sandbox Code Playgroud)
使用哪个我可以单独访问p值?我不想要其他信息,如输出中的df,X平方值.
r ×3