For anyone still struggling (like I was) with deleting folders in a synced SharePoint directory, add force=TRUE.
unlink("dir", recursive = TRUE, force = TRUE)