【发布时间】:2015-07-22 19:39:17
【问题描述】:
我有一个可以读作的文本文件:
file=read.table("C:\\data.txt", sep="")
> class(file)
[1] "data.frame"
> head(file)
name bat cat co ro
1 face 2 16 25 96
我在一个目录中有许多文本文件,可以列为:
dir<- list.files("C:\\datasets", "*.txt", full.names = TRUE)
文件命名如下:
ds_ds_df_2011_ 25_96.txt
this corresponds to:
ds_ds_df_2011_ co_ro.txt # co ro change while the rest is the same in all files.
其中co 是file$co,ro 是file$ro。
我需要的是将file$name中的相应name添加到文件名中,以成为:
ds_ds_df_2011_ co_ro_name.txt
这可能吗?
【问题讨论】:
-
一点也不。它与那个无关。
-
哇,真的吗?您不是要重命名文件吗?
-
只是将从文本文件中提取的名称添加到它们?
-
我的理解是你想将
ds_ds_df_2011_ 25_96.txt重命名为ds_ds_df_2011_ 25_96_face.txt。
标签: r