Skip to content
Back to formatted view

Raw Message

Message-ID: <5734BD8B.60906@binghamton.edu>
Date: 2016-05-12T17:29:47Z
From: Christopher W. Ryan
Subject: What is the easiest way to turn a dataframe into a barplot?
In-Reply-To: <056474CC-7FCD-48FF-8D21-CDE4A83F66A5@gmail.com>

Here is one way:

dd <- data.frame(var1=c("string1", "string2", "string3"), var2=c(3,7,4))
dd
with(dd, barplot(var2, names.arg=var1))

--Chris Ryan
Binghamton, NY

yoursurrogategod at gmail.com wrote:
> Hello, I can't post my code since it's on a work computer.
> 
> But basically, I have a dataframe that has two columns, one is a string and the other is an integer.  I want to turn this into a vertival barplot where on the x-axis I have the string in the first columb and then the plot will display the integer count.
> 
> I have found many examples online and most of those matched either odd edge cases or putting the data into a format that strips out some of the data and I can't use it later.
> 
> This should be a breeze, what am I missing?
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>