These two methods for calculating the p-value should be equivalent:
The problem with the second method is that there is the risk of getting values bigger than $1$ (in fact up to $2$):
2*pt((1.5-1.2)*sqrt(100)/.5,df=100-1)  2
This can of course be remedied by
2*pt((1.5-1.2)*sqrt(100)/.5,df=100-1,lower=F)  3.245916e-08
Obviously the algorithm of the t-test function is intelligent enough to distinguish these two cases (whether the sample mean is bigger or smaller than the given mean). Is there an easy method to manually replicate the calculation of the p-value as it is done by the t-test function?
My solution at the moment is an if-statement which checks whether the resulting value is bigger than $1$ and in this case does the same calculation again with the lower=F option but perhaps there is a better way.