Why is the moon phase not in sync with the moon's illuminated fraction? I am using the following R script to plot the moon phase and the moon's illuminated fraction:

library(oce)

X11()

t_start &lt;- as.POSIXct("2017-02-23", tz='UTC')
t_end   &lt;- t_start + 75 * 24 * 3600  # 35 days

tm &lt;- seq(from = t_start,
           to  = t_end,
           by  = 10000
        )

moon     &lt;- moonAngle(t=tm, longitude=-8, latitude=47)
fraction &lt;- moon$illuminatedFraction
phase    &lt;- moon$phase - floor(moon$phase)

plot (tm, fraction, type="l", col='blue')
lines(tm, phase   , type="l", col='red' )

grid()

# wait for mouse click or enter pressed
locator(1)


This is plotted:


The red lines indicate the phase (0 = new moon, 1/4 = first quarter, 1/2 = full moon etc.), the blue curve indicates the how much of the moon is illuminated.

I have expected the illuminated fraction to be zero exactly then when also the phase is zero. However, this is not the case.

So, is there something I am missing, am I doing something wrong in my script or is the implementation of oce inaccurate?
This is a partial answer since your question is still unclear.  I would recommmend finding an astronomy package for tools like this rather than using what's basically a "bonus feature" from an oceanographic package. 

From the help pages for package oce,


  illuminatedFraction
   fraction of moon’s visible disk that is
   illuminated
  phase
   phase of the moon, defined in equation 32.3 of Meeus
   [1982]. The fractional part of which is 0 for new moon, 1/4 for first
   quarter, 1/2 for full moon, and 3/4 for last quarter.


Perhaps you are missing the fact that marginally more than 50% of the moon is illuminated, and thus at first/last quarter marginally more than 50% of the visible disk is illuminated?  I would also recommend looking up the referenced "equation 32.3" to see what the definition is and how it applies to a zero-altitude viewer.