I am to extract data from netCDF file using R for specific loaction the code i've written as showen and I have an error at the end of the code

I need some help with extracting date from NetCDF files using R , I downloaded them from cordex (The Coordinated Regional climate Downscaling Experiment). In total I have some files. This files have dimensions of (longitude, latitude, time) and the variable is maximum temperature (tasmax). At specific location, I need to extract data of tasmax at different time. In total I have some files. This files have dimensions of (longitude, latitude, time) and variable maximum temperature (tasmax). At specific location, I need to extract data of tasmax at different time.I wrote the code using R but at the end of code, an error appeared. Error ( location subscript out of bounds)

getwd() setwd("C:/Users/20120/climate change/rcp4.5/tasmax")

dir()
library ("ncdf4")
libra,-ry(ncdf4.helpers)
library ("chron")
ncin <- nc_open("tasmax_AFR-44_ICHEC-EC-EARTH_rcp45_r1i1p1_KNMI-RACMO22T_v1_mon_200601-201012.nc")

lat <- ncvar_get(ncin, "lat")

lon <- ncvar_get(ncin, "lon")

tori <- ncvar_get(ncin, "time")
title <- ncatt_get(ncin,0,"title")
institution <- ncatt_get(ncin,0,"institution") 
datasource <- ncatt_get(ncin,0,"source") 
references <- ncatt_get(ncin,0,"references")
history <- ncatt_get(ncin,0,"history") 
Conventions <- ncatt_get(ncin,0,"Conventions") 
tustr <- strsplit(tunits$value,"")
ncin$dim$time$units
ncin$dim$time$calendar
tas_time <- nc.get.time.series(ncin, v = "tasmax",
                           time.dim.name = "time")
tas_time[c(1:3, length(tas_time) - 2:0)]
tmp.array <- ncvar_get(ncin,"tasmax")
dunits <- ncatt_get(ncin,"tasmax","units")
tmp.array <- tmp.array-273.15
tunits <- ncatt_get(ncin,"time","units")
nc_close(ncin)
which.min(abs(lat-28.9))
which.min(abs(lon-30.2))
tmp.slice <- tmp.array[126,32981,]
tmp.slice

Error in tmp.array[126, 32981, ] : subscript out of bounds

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum