error in scatterplot3js

This topic contains 1 reply, has 2 voices, and was last updated by  Merav Yuravlivker 1 year ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #27308

    Selina Carter
    Participant

    My code for scatterplot3js gives the following error:

    Error in scatterplot3js(subset(house_votes_color_Dem, select = c(“aye”, :
    (list) object cannot be coerced to type ‘double’

    How do I fix this?

    I ran exactly the same code as the slide:
    scatterplot3js(subset(house_votes_color_Dem,
    select = c(“aye”, “nay”, “other”)),
    renderer = “canvas”, #<- makes the points round
    color = house_votes_color_Dem$color,
    flip.y = FALSE, #<- makes the y-axis go from small to
    # large values starting from the x-axis
    labels = house_votes_color_Dem$Last.Name) #<- shows Rep’s last name
    # when you scroll over a point

    #27335

    Hi Selina,

    Thank you for your post – it looks like the scatterplot3js has been updated so that it only accepts matrices as the data input (you can view this documentation by entering ?scatterplot3js). This means that we need to put as.matrix in front of the subsetted data, and close it with an extra parenthesis:

    scatterplot3js(as.matrix(subset(house_votes_color_Dem, 
                                    select = c("aye", "nay", "other"))),
    #              renderer = "canvas",    # <- makes the points round
                   color = house_votes_color_Dem$color,
                   flip.y = FALSE,    # <- makes the y-axis go from small
                                      #    to large values starting from 
                                      #    the x-axis
                   labels = house_votes_color_Dem$Last.Name)  # <- shows the 
                                                              #    Rep's name 
                                                              #    when you 
                                                              #    scroll over 
    

    You’ll notice that I also commented out the ‘renderer’ argument, as it seems to have been temporarily disabled by the creator of this package. When you run this code, the chart should appear. Please let me know if that works!

    Best,

    Merav

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.