Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
r-使用paste0为read_excel定义路径_R_Path - Fatal编程技术网

r-使用paste0为read_excel定义路径

r-使用paste0为read_excel定义路径,r,path,R,Path,我正在编写一个R脚本,该脚本应该使用readxl库中的read\u excel从当前用户计算机的文件夹中打开一个excel文件 路径将有一个个人文件夹(C:/Users/Username…) 我正试图实现以下目标: string <- getwd() name <- strsplit(strsplit(x = string, split = "C:/Users/")[[1]][2], split = "/")[[1]][1] path_crivo <- paste0("C:/U

我正在编写一个R脚本,该脚本应该使用
readxl
库中的
read\u excel
从当前用户计算机的文件夹中打开一个excel文件

路径将有一个个人文件夹(C:/Users/Username…)

我正试图实现以下目标:

string <- getwd()
name <- strsplit(strsplit(x = string, split = "C:/Users/")[[1]][2], split = "/")[[1]][1]
path_crivo <- paste0("C:/Users/", name, "/some_folders/excel_file.xlsx")
如果我直接设置路径_crivo,如下所示:

string <- getwd()
name <- strsplit(strsplit(x = string, split = "C:/Users/")[[1]][2], split = "/")[[1]][1]
path_crivo <- paste0("C:/Users/", name, "/some_folders/excel_file.xlsx")
path\u crivo试试看


Encoding(path\u crivo)编码(name)
给你什么?
path\u crivo
属于类
character
Encoding(name)给我“UTF-8”为什么要拆分任何东西?如果您使用
setwd()
设置工作目录,您可以相对地引用Excel文件:
read\u Excel('some\u folders/Excel\u file.xlsx')
。如果我在其他函数中将
编码(path\u crivo)设置为
load
read.csv
我对路径名没有问题,只有
read\u excel
返回此消息如果有任何安慰,这似乎是一个已知的错误。。。
Encoding(path_crivo)<-"latin1"