R--安装reshape 报错:Package which is only available in source form, and may need compilation of CC++Fo

    xiaoxiao2021-12-14  21

    对变量进行重命名(比如data.frame的列名称),有如下几种方法。 假设data.frame 的数据mydata如下:

    有4列,想把后两列名称修改为weight1,weight2。

    方法1:调用交互式编辑器,手动修改。 fix(mydata) 然后弹出数据框

    然后将鼠标移动到列名称上,就弹出 修改变量名就可以了。

    方法2:编程的方式修改,代码如下:

    library(reshape) mydata<-rename(mydata,c(x1=’weight1’,x2=’weight2’)) 主要:若reshape包没有安装,那么需要先安装,然后调用它下面的rename函数。

    *在用install.packages(‘reshape’)时出现了问题: Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘reshape’ These will not be installed*** 因为没有填写镜像网站。

    解决方法:联网调用reshape包的镜像网站。 如下是选择厦门大学的镜像网站, 执行命令: install.packages(‘reshape’,repo=’http://mirrors.xmu.edu.cn/CRAN/‘) 这样,通过联网,Rstidio搜索镜像网站的reshape包进行安装。然后再执行: library(reshape) mydata<-rename(mydata,c(x1=’weight1’,x2=’weight2’))

    转载请注明原文地址: https://ju.6miu.com/read-971164.html

    最新回复(0)