Às 06:29 de 06/11/2024, Sibylle Stöckli via R-help escreveu:
Dear community

To import multiple .dat  weather files I am using list.files().
I intend to use the R package “ClimInd” to calculate different agroclimatic 
indicators.

Question: Is there another solution to import multiple .dat files so that I can 
select elements from the list, e.g. one specific weather file (example 
AAR_DailyWeather)?
# Import multiple .dat files weather data
filelist <- list.files(path = "O:/Data-Work/……./Daten_RA-MeteoCH_1990-2021", 
pattern='*.dat', all.files= T, full.names= T)
W <- lapply(filelist, function(x) read.table(x, header = TRUE, sep = "", colClasses = 
"numeric", comment.char = ""))
W[[1]]
dd(data = W[[1]]$Precip, time.scale = W[[1]]$year)
Fehler in W[[1]]$year : $ operator is invalid for atomic vectors
Kind regards
Sibylle
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Hello,

I find it strange that the error is complaining about the 2nd argument, W[[1]]$year. It seems that column W[[1]]$Precip exists but not year.

What does

str(W[[1]])

return? A data.frame?

And why sep = "" when reading the files, aren't those files csv files?

Hope this helps,

Rui Barradas


--
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença 
de vírus.
www.avg.com

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to