我是R的新手,我想用一个*apply函数改进下面的脚本(我已经读过apply,但我无法使用它).我想lm在多个独立变量(数据框中的列)上使用函数.我用了
for (i in (1:3) {
assign(paste0('lm.',names(data[i])), lm(formula=formula(i),data=data))
}
Run Code Online (Sandbox Code Playgroud)
Formula(i) 被定义为
formula=function(x)
{
as.formula ( paste(names(data[x]),'~', paste0(names(data[-1:-3]), collapse = '+')), env=parent.frame() )
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
请帮我在 R 中安装 Rmpfr 包。结果是:安装包 'Rmpfr' 的退出状态非零,我无法安装它。
R控制台的代码发布如下:
* installing *source* package ‘Rmpfr’ ...
** package ‘Rmpfr’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes …Run Code Online (Sandbox Code Playgroud)