HMRC says billions have been lost through tax schemes designed to encourage research and development.