【发布时间】:2021-09-13 20:51:08
【问题描述】:
我需要在超过 300 个不同长度的年轮宽度数据集(.rwl 文件)上使用 dplR 包中的函数 detrend() 和 chron()。我不想为每个对象复制和粘贴代码,而是同时执行此操作。经过一番谷歌搜索,看起来我需要开发一个 for 循环,但经过一些故障排除后我没有太多运气。有人可以帮助我朝着正确的方向前进吗?以下是我当前的代码。
##read data files in
or001 <- read.rwl("or001.rwl", format = "tucson")
or002 <- read.rwl("or002.rwl", format = "tucson")
or004 <- read.rwl("or004.rwl", format = "tucson")
#detrend - negex method
or001.negex <- detrend(or001, nyrs = NULL, method = "ModNegExp", f = 0.5,
pos.slope = FALSE)
or002.negex <- detrend(or002, nyrs = NULL, method = "ModNegExp", f = 0.5,
pos.slope = FALSE)
or004.negex <- detrend(or004, nyrs = NULL, method = "ModNegExp", f = 0.5,
pos.slope = FALSE)
#build final chronology
or001.negex.crn <- chron(or001.negex, prefix = 'OR')
or002.negex.crn <- chron(or002.negex, prefix = 'OR')
or004.negex.crn <- chron(or004.negex, prefix = 'OR')
#export final chronologies
write_excel_csv(or001.negex.crn, path = "or001.negex.crn.csv")
write_excel_csv(or002.negex.crn, path = "or002.negex.crn.csv")
write_excel_csv(or004.negex.crn, path = "or004.negex.crn.csv")
【问题讨论】:
-
stackoverflow.com/a/24376207/3358227 是一个很好的起点,将链接中的“数据框”翻译成
read.rwl(.)的输出。 -
请修剪您的代码,以便更容易找到您的问题。请按照以下指南创建minimal reproducible example。