function ET.PenmanMonteith

Hi, I am having a problem using the function ET.PenmanMonteith from the package "Evapotranspiration". I keep getting the error "$ operator is invalid for atomic vectors". Does anyone know the solution?

The code I am using is:

install.packages("readxl")
library("readxl")
install.packages("data.table")
library ("data.table")

2. Daten in R einlesen und anpassen, sodass mit ihnen gearbeitet werden kann

path<-"D:/Documents/TU/Hiwi-LWI/Hannes/01_Verdunstung"
setwd(path)

rohdaten<-read.table("Daten.txt",header=TRUE) #Einlesen der Daten aus Textformat

x<-dim(rohdaten) #Angabe der Dimensionen der Tabelle
data<-as.data.table(rohdaten) # 4 Header Zeilen sind schon entfernt worden

Überschriften für die einzelnen Spalten erstellen, damit damit diese

zugeordnet werden können.

ueberschriften<-c("doy", "rH","TLuft", "u", "P", "Rg", "Rn","H", "e", "e*", "e*-e")
names(data)<-ueberschriften

3. Erstellung von Abbildungen des Temperatur- und Feuchtigkeitsverlaufs

plot(data$TLuft, type="l", ylab="Lufttemperatur [°C]", xlab="Tag", col="red")
plot(data$rH, type="l", ylab="Relative Feuchte [%]", xlab="Tag", col="blue")

pdf("Klimadiagramm.pdf")
par(mar = c(5, 4, 4, 4) + 0.3)
plot(data$P, col="blue", xlab="Tag", ylab="Niederschlag [mm]") # Create first plot
par(new = TRUE) # Add new plot
plot(data$TLuft, type="l" ,col="red", # Create second plot without axes
axes = FALSE, xlab = "", ylab = "")
axis(side = 4, at = pretty(range(data$TLuft))) # Add second axis
mtext("Temperatur [°C]", side = 4, line = 3)
dev.off()

4. Berechnung der Grasreferenzverdunstung mit R-Paket

#install.packages("Evapotranspiration")
library("Evapotranspiration")

#data1<-cbind(data$TLuft, data$TLuft, data$rH, data$rH, data$Rn, data$u)
data1<-cbind(data[,3], data[,3], data[,2], data[,2], data[,7], data[,4])

#datatest <- as.numeric(data1)
#data1<-datatest
data2 <-as.data.frame(data1)

ueberschriften<-c('Tmax', 'Tmin', 'RHmax', 'RHmin', 'n', 'u2')
colnames(data1)<- ueberschriften
colnames(data2)<- ueberschriften
constants<- c(72, 2.45, 0.91280719879303, 0.0820, 2, 4.903*10^-9, 0)

ergebnis<- ET.PenmanMonteith(data2, constants, ts="daily", solar="sunshine hours",wind="yes", crop="short", message="yes")

Fehler: $ operator is invalid for atomic vectors

Perhaps constants needs to be a named list. See the documentation of the ET.PenmanMonteith function for the names to use.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.