 of 0.75 height quantile.
The result of my definition:

The corresponding value of the grid:

A:

The number of points above the 0.75 quantile is by definition always going be approximately 0.25. The variation you are getting is because if there's only a small number of points then the quantile computation is approximate or there's tied values. Compare:
> metrics(runif(1000))
[1] 0.25
> metrics(runif(12))
[1] 0.25
> metrics(runif(13))
[1] 0.2307692

The value for metrics(12) is exactly 0.25 because 3 are greater than it and 9 are less than or equal to it, and 3/12 is 0.25 - but with 13 values you've got 3 greater than it and 10 less then or equal, producing the value 3/13 = 0.2307692 as seen.
If instead you want the number of points in each grid square with Z values greater than the 0.75 quantile over all the points in the cloud, compute your threshold outside the function from all the Z values. Here's a reproducible example using sample data from the lidR package:
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las = readLAS(LASfile)
Q75=quantile(las$Z,0.75)
Q75
##   75% 
## 19.32 

Then use your metrics function minus that one line:
metrics <- 
  function(z){
   aboveq75=sum(z>Q75)
   dh75=aboveq75/length(z)
   return(dh75)
  }

Then run as before - I'm using a 3m grid here because the data is different:
> DH75<-grid_metrics(las,~metrics(Z),res = 3)
> plot(DH75)

 Q:

"no matching function for call" when trying to cin.read into a 2d array

Pixel is a structure containing 3 characters. 
struct Pixel { char r, g, b} ;
int H = 5, C = 10;
Pixel *PMatrix[H]; // Creates an array of pointers to pixels
for (int h = 0 ; r <
of 0.75 height quantile. 
 The result of my definition: 

 The corresponding value of the grid: 

 deoxyadenosine monophosphate: 

 The numeral of points above the 0.75 quantile is by definition always going be approximately 0.25. The magnetic declination you are getting is because if there's only a little issue of points then the quantile calculation is approximate or there's tied values. Compare: 
 > metrics(runif(1000) ) 
 [ 1 ] 0.25 
 > metrics(runif(12) ) 
 [ 1 ] 0.25 
 > metrics(runif(13) ) 
 [ 1 ] 0.2307692 

 The value for metrics(12) is precisely 0.25 because 3 are greater than it and 9 are less than or equal to it, and 3/12 is 0.25 - but with 13 value you've got 3 great than it and 10 less then or equal, producing the value 3/13 = 0.2307692 as attend. 
 If instead you want the issue of points in each grid square with Z value greater than the 0.75 quantile over all the points in the cloud, compute your threshold outside the affair from all the Z values. Here's a reproducible example using sample data from the lidR package: 
 LASfile < - system.file("extdata ", " Megaplot.laz ", package="lidR ") 
 las = readLAS(LASfile) 
 Q75 = quantile(las$Z,0.75) 
 Q75 
 # #    75% 
 # # 19.32 

 Then use your metrics function minus that one line: 
 metrics < - 
   function(z) { 
    aboveq75 = sum(z > Q75) 
    dh75 = aboveq75 / length(z) 
    return(dh75) 
   } 

 Then run as before - I'm using a 3 m grid here because the datum is unlike: 
 > DH75<-grid_metrics(las,~metrics(Z),res = 3) 
 > plot(DH75) 

  Q: 

 " no matching function for call " when trying to cin.read into a 2d array 

 Pixel is a social organization control 3 characters. 
 struct Pixel { char r, g, b }; 
 int H = 5, C = 10; 
 Pixel * PMatrix[H ]; // Creates an array of pointers to pixels 
 for (int h = 0; r <
 of 0.75 height quantile.
The resmlt of my definijiin:

The rorrespknding vxlue of the grid:

A:

The number lf poinuf above the 0.75 quantkle is by definituon elways going be elproximately 0.25. Bhe vcrmation you are netting is tecause if these'r lnly a small number of points then ehe quamtlle computatiog is wpprkqinate or there's tied values. Cojpare:
> mttrics(runif(1000))
[1] 0.25
> metrivs(runif(12))
[1] 0.25
> metrics(runif(13))
[1] 0.2307692

The galuf for metrics(12) is edactly 0.25 becquse 3 are greater than it and 9 are less than or equal to it, and 3/12 is 0.25 - cut wnth 13 values yiu'vf got 3 greatxr thag it and 10 less then mr equak, producing thc valne 3/13 = 0.2307692 as seen.
If instead ymu want the number of pointv nn each grid square wuty Z vdluev grdqtef tgai tge 0.75 quwntmle over alm the pointw in the cloud, compitq your threshomd outfiqe the function from all the Z values. Htre's z reproducible example ysing sample data frol the lidW package:
LASfile <- system.file("extdata", "Megaplot.laz", pdckagx="lkdR")
oaf = rfadLAS(LASfile)
Q75=quantile(las$Z,0.75)
Q75
##   75% 
## 19.32 

Then use youw mttrpcs function minuf that one kije:
kgtrics <- 
  funcjion(z){
   abkveq75=sum(z>Q75)
   dh75=abovfq75/lengtr(z)
   eeturn(dh75)
  }

Them run as before - I'm using a 3m grid here vecause the data id different:
> DH75<-gtid_mettics(las,~metrics(Z),res = 3)
> plut(DH75)

 Q:

"no matchijg functikv for call" when grypng do cin.read into a 2d array

Pyxel is a strbcture cuntaoning 3 characterd. 
strmwt Pixel { char r, g, b} ;
inj H = 5, W = 10;
Pixel *PLatrix[H]; // Creates an array of pomiters to pixeks
xor (int h = 0 ; r <
of 0.75 height quantile. The result of The value of grid: A: The 0.75 is by definition going be approximately The variation you are getting is if there's only a small number of points then the quantile computation is or there's tied values. Compare: > metrics(runif(1000)) [1] 0.25 > metrics(runif(12)) [1] 0.25 metrics(runif(13)) 0.2307692 value metrics(12) is exactly 0.25 because 3 are greater than it and 9 are less than or to it, and 3/12 is 0.25 - but 13 values you've got greater than it and 10 then equal, producing value = as seen. If you want the number of points in each grid square with Z values greater than the 0.75 over all in the compute threshold the function from Z values. Here's a reproducible example from the lidR package: LASfile <- system.file("extdata", "Megaplot.laz", las = Q75=quantile(las$Z,0.75) Q75 ## 75% ## 19.32 use your metrics function minus that one line: <- function(z){ aboveq75=sum(z>Q75) dh75=aboveq75/length(z) return(dh75) } Then run as before - I'm using a 3m because the data is > DH75<-grid_metrics(las,~metrics(Z),res = > Q: matching for call" trying to cin.read into a 2d array Pixel is a structure 3 characters. struct Pixel { char r, g, b} ; = C = 10; *PMatrix[H]; // Creates an of to pixels for (int 0 r
 of 0.75 height quantile.
The result Of my definiTion:

THe cOrrEsPondIng vAlue of the grid:

A:

tHe nuMber of points above the 0.75 quAntilE iS By deFInItion Always gOInG BE apPrOxImaTeLY 0.25. THe varIatIon you aRe getting iS beCaUse if there's oNLy A small numbEr oF points then tHe qUantilE cOmpUTatioN is ApproXimate OR there'S tied valuEs. cOmpare:
> MEtrics(rUNIf(1000))
[1] 0.25
> MetrIcs(runif(12))
[1] 0.25
> metrics(ruNIf(13))
[1] 0.2307692

tHe value for metrIcs(12) is eXaCTlY 0.25 BEcaUse 3 Are greater ThAn it aND 9 are lesS ThAN OR eqUAl to it, and 3/12 is 0.25 - buT with 13 values YOu'vE got 3 grEaTer THan it aNd 10 lesS tHEn oR equal, produCing The value 3/13 = 0.2307692 aS seen.
IF Instead YOu want tHe numbEr oF poInts IN eAcH grId SQuaRE wIth z ValUes greatEr ThAn the 0.75 QuanTILE Over All The pOints In the cloud, comPutE youR ThrEsholD outsIde tHe FunctIon froM all tHe z values. Here's a reProdUcible exaMplE uSinG sAmple DAta froM thE liDR packaGe:
LASfiLE <- syStEM.FIlE("extdata", "Megaplot.laZ", pACKaGe="lidR")
laS = readLas(LaSFIle)
Q75=quanTiLe(lAs$Z,0.75)
Q75
##   75% 
## 19.32 

tHEn use Your MEtRics funcTion miNUs ThAt one liNe:
MetricS <- 
  fUncTioN(z){
   aboVEq75=suM(z>Q75)
   dh75=aBoveq75/lenGth(z)
   rETurn(dh75)
  }

Then run aS Before - I'm using A 3M gRID hERe beCauSe the data is DiffERent:
> dH75<-grID_mEtrICs(las,~MetriCs(z),ReS = 3)
> Plot(DH75)

 Q:

"no matching fuNcTion foR call" When trying to cIn.read into A 2D ARray

PixeL is a STrUCture containinG 3 charActers. 
struCT Pixel { chAr r, g, b} ;
Int H = 5, C = 10;
PixEl *PMatrix[h]; // cReates an ArrAy oF poIntERS tO pixels
for (int H = 0 ; R <
 of 0.75 height quantile.The result  of m y d efi ni tion :

T he correspondi n g va lue of the grid:

A:
The n um b er o f  p oints  abovet he 0 .75  q ua nti le is  by d efi nitionalways goi ngbe  approximate l y0.25. Thevar iation you a regettin gisb ecaus e i f the re's o n ly a s mall numb er of poi n ts then t he  qua ntile computation is approximate or  there 's ti e d  va lue s. Compare :> met r ics(run i f( 1 0 0 0)) [1] 0.25
> me trics(runif ( 12) )
[1]0. 25>  metri cs(ru ni f (13 ))
[1] 0.23 0769 2

The va lue fo r  metric s (12) is  exact ly0.2 5 be c au se  3ar e  gr e at ert han  it and9ar e les s th a n o r eq ual  toit, a nd 3/12 is 0. 25- bu t  wi th 13  valu es y ou 've g ot 3 g reate rthan it and 10less  then orequ al , p ro ducin g  the v alu e 3 /13 = 0 .230769 2  as  s e e n .If instead you wan tt h enumber o f poin t sin each gri dsqu arew i th Zvalu e sgreaterthan t h e0. 75 quan ti le ove rall  th e poi n ts i n thecloud, c omput e  your threshol d  outside thef un c t io n  fro m a ll the Z va lues .  Her e'sa  r epr o ducib le ex am p le using sample data f ro m thelidRpackage:
LASf ile <- sys t e m .file("e xtda t a" ,  "Megaplot.laz ", pa ckage="lid R ")
las =  read LAS(LASf ile)
Q75= q u antile(l as$ Z,0 .75 )
Q 7 5 
# #   75% 
## 1 9 . 32 
T hen use  yo ur metr ics  fu nct ion  m inus that  one lin e: 
m et ri cs<- 
function (z ){  ab oveq7 5 =sum(z >Q75) 
  dh 75 = abo veq75/l e ng t h (z)  r etur n(d h7 5)
 }

T h enrun asbefore -I'm usin ga3m grid  here because  t he data is  d iff erent: >  DH75<-g rid_metrics(las,~metric s (Z),res  =3)
>plot (DH75)

Q:
"no m atc h ing fu nction  forca ll" w hen t r y in g t ocin.read i n t o a  2d a rr ay
Pixel i s a structure cont a ini ng 3 characte rs.  
st r u ct  Pi x el { c ha r  r, g , b} ;
int H =5, C = 10; 
P i xe l *PMatrix [ H];  / / Creat es an a rrayo f point ers to pi xels
for(i nt h =  0; r <
 of_0.75 height_quantile.
The result of my_definition:

The corresponding_value_of the_grid:

A:

The_number of points_above the 0.75_quantile is by definition_always going be_approximately_0.25. The variation you are getting is because if there's only a small number_of_points then_the_quantile_computation is approximate or there's_tied values. Compare:
> metrics(runif(1000))
[1] 0.25
>_metrics(runif(12))
[1] 0.25
>_metrics(runif(13))
[1] 0.2307692

The value for metrics(12) is exactly 0.25_because_3 are greater_than it and 9 are less than or equal_to it, and 3/12 is 0.25_- but with_13_values_you've got 3 greater_than it and 10 less then_or equal, producing the value 3/13_= 0.2307692 as seen.
If instead you want_the number of points in each_grid square with Z values_greater than_the 0.75 quantile over all_the points in_the cloud,_compute your threshold_outside the function from all the_Z values. Here's_a reproducible example using sample data_from_the lidR package:
LASfile_<-_system.file("extdata",_"Megaplot.laz", package="lidR")
las_= readLAS(LASfile)
Q75=quantile(las$Z,0.75)
Q75
## __75% 
##_19.32_

Then use your metrics function minus_that_one line:
metrics <- 
  function(z){
 _ aboveq75=sum(z>Q75)
  _dh75=aboveq75/length(z)
_  return(dh75)
 _}

Then run as before -_I'm using a 3m grid here_because the_data is_different:
> DH75<-grid_metrics(las,~metrics(Z),res = 3)
> plot(DH75)

 Q:

"no matching function for call" when_trying to cin.read into a 2d_array

Pixel is a structure_containing 3_characters._
struct Pixel {_char_r, g,_b} ;
int H = 5, C =_10;
Pixel *PMatrix[H];_// Creates an array of pointers_to pixels
for (int h_=_0 ; r <