Finding the trees in the woods

This is my first post here. I learned most of how to put this post together using maharshi's post Learning CUDA by optimizing softmax: A worklog which is a nice graphic post format with prose, functions, images and code. Images are all from my Imgur.
Software is R (statistics) and QGIS to understand tree health on a steep hillside.
My site is in Southern New Zealand and has 2 hectares of trees (weeds and native) on an inaccessible steep broken hillside; higher up rough, boulder-strewn terraces with very steep land - about 22°. The forest is very dense, half hawthorn ( Crataegus monogyna), the remainder in NZ natives: tree fuchsia (Fuchsia excorticata), Pittosporum species, whiteywood - Alectryon excelsus and horopito - Pseudowintera colorata). Ultimately, I'll identify and segment the vegetation data to species level using R on the newly-available Sentinel2 L2A data. [url to Copernicus and requires making a login to obtain data - which is free] (Sentinel2 scans the planet weekly (at a minimum pixel size of 10metres) and the data enables identifying surface features and species) but first I need to locate the approximate tree positions which needs a filetype called a Canopy Height Model or CHM, and QGIS is most suited for making these.
First I want to determine tree cover and openings (and then verify on site), get an idea of tree canopy height, tree positions and number, and virtualise terrain variability. I also want to see how close my model matches reality using this data. Later I'll see if tree form and health vary with the rocky surface - and if that's a real effect, and that will help me manage the site better.

Visual outline of process, at left the elevation model, centre the canopy height model, and at right the red points in the image represent the centres of the tree canopies.
While there is a lot of information on R, the basics of command line operations and file paths are often left out - very confusing for us gui folk, so I cover these aspects. To simplify the process I work from a local folder on my desktop - nothing worse learning new software than being frustrated by network issues. Some content below includes code blocks that include comments and I use R's standard #Comment format to separate comments from R Code. > indicates the following is a menu item.
This post assumes a Windows system and that you have R and QGIS installed (although both also run on Mac and Linux).
Some very basic R basics
R only reads forward slashes (or double backslashes, but I will only use / here).
With errors, first look very, very closely at path and file name. Extra spaces, wrong slash types and errant punctuation characters are often the cause.
After loading R you see a blank interface, so first I ask R where it is working from, and change if I want it to work from my local folder.
First, create a folder in Windows to work to/from, and ask R in case it is already using it:
getwd()
#getwd means tell me what the working directory is
#R replies:
[1] "C:/Users/myname/Documents"
#R says it's working from myname. This is not where I want R to work from, so;
setwd(file.path("C:/Users/myname/Documents/RWorking"))
R will then save and read files in this folder.
The next post will cover building a canopy height model CHM from the data, and the processes involved.