简体   繁体   English

在 R 中的文件名中保存带有可变文本的文件

[英]Save file with variable text in file name in R

in R I'm trying to read in a file name where part of the file name references a string variable.在 R 中,我试图读入一个文件名,其中部分文件名引用了一个字符串变量。 I'm having issues with the paste function.我的粘贴功能有问题。

Without the variable reference I was reading the file as follows:在没有变量引用的情况下,我正在读取文件,如下所示:

adp <- readxl::read_xlsx('Data//2020-08-28 Hours.xlsx')

I also have the following variable:我还有以下变量:

pdate <- as.Date('2020-08-28')

I tried to incorporate the variable as follows, but something is wrong with my syntax:我尝试按如下方式合并变量,但我的语法有问题:

adp <- readxl::read_xlsx(paste(''Data//'. pdate, 'Hours.xlsx'')

这是正确的语法:

readxl::read_xlsx(paste0('Data//', pdate, ' Hours.xlsx'))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM