R language learning problem solving error in output $nodeid: $operator is invalid for atomic vectors

Problem: Error in output$nodeID: $operator is invalid for atomic Vectors when viewing variable columns using the “$” operator

output <- data$score
output <- cbind(nodeID=dat$nodeID,score=output)
head(output$nodeID)
 Error in output$nodeID : $ operator is invalid for atomic vectors
# Check the type of output and find out it's matrix.
class(output)
 [1] "matrix"
#"data.frame" can only be used with "$", just use [,] here.
head(output[,1])

 

 

Read More: