Thank you for your reply. This solves the problem I was having.
I noticed some things after having played around a little bit more. I am just mentioning them in case somebody is interested.
If the line
capSensor.capacitiveSensor(1); // allow one calibration
is present, then both
float sensor = capSensor.capacitiveSensorRaw(20);
and
float sensor = capSensor.capacitiveSensor(20);
work. However, if capSensor.capacitiveSensorRaw is used, then this line can also be left out.
Also something to note is that if my laptop is connected to the power, then the value of the capacitor shoots up and down at somewhat irregular intervals.