Skip to content

Lab 06 #18

Description

@katiegentry07

I'm struggling with labeling the clusters in Part 2, Step 2. I know the code needs to be changed to reflect the variables, but I'm unsure of where to go next.

stats <- 
  Census2010 %>% 
  group_by( cluster ) %>% 
  select(keep.these2010)%>% 
  summarise_each( funs(mean) )

t <- data.frame( t(stats), stringsAsFactors=F )
names(t) <- paste0( "GROUP.", 1:4 )
t <- t[-1,]

for( i in 1:4 )
{
  z <- t[,i]
  plot( rep(1,8), 1:8, bty="n", xlim=c(-1,1), 
        type="n", xaxt="n", yaxt="n",
        xlab="Score", ylab="",
        main=paste("GROUP",i) )
  abline( v=seq(0,.5,.1), lty=3, lwd=1.5, col="gray90" )
  segments( y0=1:8, x0=0, x1=100, col="gray70", lwd=2 )
  text( -0, 1:8, keep.these, cex=0.85, pos=2 )
  points( z, 1:8, pch=19, col="firebrick", cex=1.5 )
  axis( side=1, at=c(0,.3,.6), col.axis="gray", col="gray" )
}

The error states: Error in xy.coords(x, y) : 'x' and 'y' lengths differ

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions