starting from bed in r analysis