#:::1.::: Replace precipitation with random number between 0 and 2.
# First find out how many records there are:
nrecords <- nrow(readmet("met.dat"))
# Make new rain
newrain <- runif(nrecords, 0, 2)
# And replace
replacemetvar("PPT",newrain,"met.dat", "newmet.dat")
#:::2.::: Replace multiple weather variables.
newtair <- runif(nrecords, 0, 35)
# Have to make a matrix of the variables to be replaced:
newmat <- matrix(cbind(newrain, newtair),ncol=2)
# And give a vector of variable names --in the same order as in the matrix!!--.
replacemetvar(c("PPT","TAIR"), newmat, "met.dat", "newmet.dat")
Run the code above in your browser using DataLab