[R] I have a question

Jim Lemon jim at bitwrit.com.au
Sat Jun 14 07:13:05 CEST 2014


On Sat, 14 Jun 2014 10:59:07 AM 오건희 wrote:
> Hi
> 
> I got a wrong graph when I typed " 
qplot(names(termFrequency),termFrequency,
> geom="bar", xlab="Terms",stat="bin")+coord_flip() "
> 
> The frequency weren't displayed on the graph. what's the problem?
> 
> I attached the screen shot to this e-mail.
> 
Hi 오건희 ,
You seem to be supplying a character vector - names(termFrequency) - 
as the "x" argument to qplot. Making a wild guess that these names are 
actually numbers, perhaps:

as.numeric(names(termFrequency))

will work. If the wild guess was wrong, perhaps you want to specify 
termFrequency as the first argument. When something like this happens, 
it is often helpful to explicitly name your arguments:

qplot(x=names(termFrequency),y=termFrequency,
 geom="bar", xlab="Terms",stat="bin")+coord_flip()

This will sometimes give a meaningful error message that helps to 
identify what has gone wrong.

Jim



More information about the R-help mailing list