0

I'd like to plot a bar graph showing frequency of a string in ggplot. The input file (t1. txt) looks like:

do  4
re  2
mi  5

and my current r script is:

library("ggplot2")
t1<-read.table("t1.txt",header=FALSE,sep='\t')
ggplot(t1,aes(V1))+geom_bar()

However this isn't what I'd like - it has a correct x axis, but the y axis should show the variable from the second column (V2). Can anyone help? Thanks.

1 Answer 1

2

All you need to do is put the actual V2 in the command then. The default first two items to aes are x and y. You've only given x.

ggplot(t1,aes(V1,V2))+geom_bar()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.