since key in for-in r is a string, dot-notation cannot be used. Use bracket notation instead.