Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从向量中提取具有定义扩展名的文件名?
示例:如果我有向量:
c(“a.hdf”、“b.tif”、“c.jpg”、“b.hdf”、“t.tif”、“z.png”)
例如,我想要一个包含所有 .hdf 文件的向量。所以结果是:
c("a.hdf", "b.hdf")
如果x是你的向量:x[grepl(".hdf",x)].
x
x[grepl(".hdf",x)]