creating correct output to viz with R