Config Router

  • Google Sheets
  • CCNA Online training
    • CCNA
  • CISCO Lab Guides
    • CCNA Security Lab Manual With Solutions
    • CCNP Route Lab Manual with Solutions
    • CCNP Switch Lab Manual with Solutions
  • Juniper
  • Linux
  • DevOps Tutorials
  • Python Array
You are here: Home / ‘height’ must be a vector or a matrix. barplot error

‘height’ must be a vector or a matrix. barplot error

August 20, 2021 by James Palmer

You can specify the two variables you want to plot rather than passing the whole data frame, like so:
data <- structure(list(V1 = c(34.88372093, 35.07751938, 35.27131783, 35.46511628, 35.65891473, 35.85271318), V2 = c(0.00029997, 0.00019998, 0.00029997, 0.00029997, 0.00069993, 0.00069993)), .Names = c("V1", "V2"), row.names = c(NA, 6L), class = "data.frame") barplot(data$V2, data$V1, xlab="Percentage", ylab="Proportion") Alternatively, you can use ggplot to do this: library(ggplot2) ggplot(data, aes(x=V1, y=V2)) + geom_bar(stat="identity") + labs(x="Percentage", y="Proportion") Probably the entire dataframe format is wrong, The same thing happened to me since I added the columns individually and made the dataframe together. table.values = c(value1, value2,.......) table = matrix(table.values,nrow=number of rows ,byrow = T) colnames(table) = c("column1","column2",........) row.names(table) = c("row1", "row2",............) barplot(table, beside = T, xlab= "X-axis",ylab= "Y-axis")

Related

Filed Under: Uncategorized

Recent Posts

  • How do I give user access to Jenkins?
  • What is docker volume command?
  • What is the date format in Unix?
  • What is the difference between ARG and ENV Docker?
  • What is rsync command Linux?
  • How to Add Music to Snapchat 2021 Android? | How to Search, Add, Share Songs on Snapchat Story?
  • How to Enable Snapchat Notifications for Android & iPhone? | Steps to Turn on Snapchat Bitmoji Notification
  • Easy Methods to Fix Snapchat Camera Not Working Black Screen Issue | Reasons & Troubleshooting Tips to Solve Snapchat Camera Problems
  • Detailed Procedure for How to Update Snapchat on iOS 14 for Free
  • What is Snapchat Spotlight Feature? How to Make a Spotlight on Snapchat?
  • Snapchat Hack Tutorial 2021: Can I hack a Snapchat Account without them knowing?

Copyright © 2025 · News Pro Theme on Genesis Framework · WordPress · Log in