Electrochemical tuning of electronic states in single-wall carbon nanotubes studied by in situ absorption spectroscopy and ac resistance