On 11/5/24 22:29, Sibylle Stöckli via R-help wrote:
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]]

`W[[1]]` should be a data.frame, but it will not have the name "AAR_DailyWeather" unless you assign names using the values in `filelist`.


dd(data = W[[1]]$Precip, time.scale = W[[1]]$year)
It is unclear what this code snippet is supposed to represent. There is no function named `dd` in the base packages. There is a `dd` function in package Hmisc but if you use it you need to assign the results to an object name. Just executing the call will do nothing except perhaps checking to see if there are errors.
Fehler in W[[1]]$year : $ operator is invalid for atomic vectors


Also unclear is how that error message came about. It seems to indicate that W[[1]] is not a dataframe. You can examine the `W` object with `str(W)`.

Looking at the help page for ClimInd::dd it appears that the 'time.scale' argument is supposed to signify what time scale to assume, namely one of {month, season, year}. Pretty crappy documentation since it is unstated what type the allowable values are and the usage example shows

|time.scale = YEAR|

And there does not appear to be any definition of what the value of `YEAR` is 
supposed to be.

It appears to me that you have been assigned a task in a poorly documented package.

Contact the package author.

--

David.

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.

______________________________________________
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