简体   繁体   English

在R中使用read.csv - 打开文件名包含单词/短语的数据集

[英]Using read.csv in R - Opening a dataset where the file name contains a word/phrase

#set working directory
setwd("C:/Bucky/Locations/London")

#open survey data
survey.data <- read.csv("01-London-Dataset.csv")

I am looking to analyse multiple datasets which contain the same information for different locations. 我期待分析多个数据集,这些数据集包含不同位置的相同信息。 Each dataset is saved in a folder alongside other files relating to that location. 每个数据集都与文件夹相关的其他文件一起保存在文件夹中。

The file names are all structured in the same format - (01-London-Dataset.csv) - and no other file name in the folder will contain the word Dataset. 文件名都采用相同的格式 - (01-London-Dataset.csv) - 文件夹中没有其他文件名包含数据集。

Is it possible to use read.csv to open the file that contains the word Dataset once the correct working directory is set? 一旦设置了正确的工作目录,是否可以使用read.csv打开包含单词Dataset的文件?

你可以在一行中做到这一点

read.csv(list.files(pattern = "Dataset"))

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

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