当前位置:网站首页>R 创建文件夹和子文件夹
R 创建文件夹和子文件夹
2022-06-10 09:21:00 【qq_45759229】
测试案例1
main_dir="./"
sub_dir="fassafsdfa"
## Provide the dir name(i.e sub dir) that you want to create under main dir:
output_dir <- file.path(main_dir, sub_dir)
if (!dir.exists(output_dir)){
dir.create(output_dir)
} else {
print("Dir already exists!")
}
可以得到的结果是在当前目录创建了一个sub_dir的文件夹
应用
我现在的目的是这样的,我需要在上层目录的evaluation文件夹创建一个数据集命名(取名为test)的子文件夹,然后子文件夹中又有很多的方法子文件夹,命名为A,B,C
实现如下
parent_dir="../evaluation/"
dataset="test"
output_dir <- file.path(parent_dir, dataset)
# print(output_dir)
if (!dir.exists(output_dir)){
dir.create(output_dir)
} else {
print("Dir already exists!")
}
#先创建test子文件夹,否则接下来的程序会报错
method=c("A","B","C")
for(sub_dir in method){
main_dir=paste(parent_dir,dataset,sep="")
output_dir=file.path(main_dir,sub_dir)
#print(output_dir)
if (!dir.exists(output_dir)){
dir.create(output_dir)
} else {
print("Dir already exists!")
}
}
# 必须创建test文件夹,然后程序自动创建A,B,C文件夹
#
边栏推荐
- BlockingQueue、SynchronousQueue、ArrayBlockingQueue、ReentrantLock、Semaphore、公平与非公平
- Data governance in industrial digital transformation
- LeetCode琅琊榜第二十一层-只出现一次的数字
- Win11 install texlive version 2021
- Redis的配置优化
- 案例分享 | 数智化升级:红蜻蜓的转型之路(下)
- Lexin ESP Rainmaker accelerates the transformation of enterprise intelligence, and private cloud solutions help customers build their own brands
- Latex基本语法备注
- Web free font library
- win11下配置vscode+cmake
猜你喜欢

Textstudio displays line numbers and does not check spelling settings

The 21st layer of leetcode Langya list - numbers that only appear once

The file is shown in the figure above. How to open a database file with Navicat

中断上下文中的preempt count

必应(Bing)的站内搜索 site:<域名> <搜索内容>

10 revelations from the success of digital transformation

在 Kubernetes 中基于 StatefulSet 部署 MySQL(上)

Win11 install texlive version 2021

谈谈2022年数字化转型的趋势

阿裏巴巴數字化轉型的啟示
随机推荐
Rendercylinder lights for VTK learning
36氪首发 | 新一代iPOCT产品持续发展,「伊鸿健康 」完成新一轮数千万元融资
RunLoop的实际使用
必应(Bing)的站内搜索 site:<域名> <搜索内容>
Deploy MySQL based on statefulset in kubernetes (Part 2)
接触式IC卡 - STM32(Smart Card)
Summary of cache usage
Exemple de référence AWS IOT de lexine pour esp32 - C3
阿裏巴巴數字化轉型的啟示
GNSS定位资料收集
技能树评测
Textstudio displays line numbers and does not check spelling settings
AWS IOT reference example of Lexin launching esp32-c3
Compiler-pl/0 language compiler function extension
BlockingQueue, synchronousqueue, arrayblockingqueue, reentrantlock, semaphore, fair and unfair
Web free font library
Understanding of pointer forced rotation in C language
Thinking about function declaration
对线HR_MySQL存储引擎,原来是这样啊
Compile-PL/0语言编译器功能扩充