[R] Script Taking Long to run

Frederic Ntirenganya ntfredo at gmail.com
Sun Mar 26 16:05:42 CEST 2017


Dear R users,

I do have a challenge in a srcipt of computing Sora Radiation. One line is
taking long time without giving the results. The line in which I have
problem is :
dat1$RS.daily<-ap(days=days,lat=lat,lon=lon,A=A,B=B,SSD=Sunshine,extraT=NULL)

Could you please assist me? Thanks

Here is the code:

library("sirad", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.0")
library("Evapotranspiration", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.0")
library("agridat", lib.loc="~/R/x86_64-pc-linux-gnu-library/3.0")
require(zoo)

dat1<-read.csv("/home/fredo/Documents/Meteo Data/Meteo Rwa
data.csv",header=T,na.string="9999")
dat1$u.daily<-dat1$Wind.Speed*0.514444
dat1$Date<-as.Date(paste(dat1$Year,dat1$Month,dat1$Day,sep="-"))
dat1$DOY<-dayOfYear(dat1$Date)
dat1$Longitude<-30.11
dat1$Latitude<--1.95
dat1$Elevation<-1490
A <- 0.21
B <- 0.57
dat1$RHmax.daily<-dat1$RHmax.daily
dat1$RHmin.daily<-dat1$RHmin.daily
dat1$Tmax.daily<-dat1$Tmax.daily
dat1$Tmin.daily<-dat1$Tmin.daily
dat1<-subset(select=-Wind.direction.measured.in.Degrees)
Sunshine<-dat1$n.daily
lat<-as.numeric(dat1$Latitude)
lon<-as.numeric(dat1$Longitude)
days<-dat1$Date

dat1$RS.daily<-ap(days=days,lat=lat,lon=lon,A=A,B=B,SSD=Sunshine,extraT=NULL)

#View(dat1)

DATA:

dput(head(dat1))
structure(list(Year = c(1984L, 1984L, 1984L, 1984L, 1984L, 1984L
), Month = c(1L, 1L, 1L, 1L, 1L, 1L), Day = 1:6, Wind.Speed = c(5L,
4L, 4L, 3L, 5L, 6L), n.daily = c(6.3, 4.8, 0.6, 8.2, 7.3, 1.7
), Tmax.daily = c(27.4, 26.3, 22.9, 27.7, 28.5, 25.5), Tmin.daily = c(14.5,
16, 14.4, 14.8, 16.6, 15.4), RHmax.daily = c(100L, 95L, 97L,
100L, 97L, 99L), RHmin.daily = c(45L, 62L, 72L, 55L, 54L, 63L
), Station.Name = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "KIGALI
AERO", class = "factor"),
    Elevation = c(1490, 1490, 1490, 1490, 1490, 1490), Longitude = c(30.11,
    30.11, 30.11, 30.11, 30.11, 30.11), Latitude = c(-1.95, -1.95,
    -1.95, -1.95, -1.95, -1.95), u.daily = c(2.57222, 2.057776,
    2.057776, 1.543332, 2.57222, 3.086664), Date = structure(c(5113,
    5114, 5115, 5116, 5117, 5118), class = "Date"), DOY = c(1,
    2, 3, 4, 5, 6)), .Names = c("Year", "Month", "Day", "Wind.Speed",
"n.daily", "Tmax.daily", "Tmin.daily", "RHmax.daily", "RHmin.daily",
"Station.Name", "Elevation", "Longitude", "Latitude", "u.daily",
"Date", "DOY"), row.names = c(NA, 6L), class = "data.frame")

Any help is appreciated!

Frederic Ntirenganya
Maseno University,
African Maths Initiative,
Kenya.
Mobile:(+254)718492836
Email: fredo at aims.ac.za
https://sites.google.com/a/aims.ac.za/fredo/

	[[alternative HTML version deleted]]



More information about the R-help mailing list