I am fairly new to R but trying to learn by doing
I am trying to plot a categorical (channel) against a continuous variable (sales).
Here is my data
print(columnValues)
channel_final tot_sales_year
1 Texas 5000.00
2 Mexico 8951.55
3 Mexico 0.23
4 Mexico 12.00
5 Mexico 250094.00
6 Texas 388859.38
Here is the code I am using to produce the graph
plot(columnValues[,1],columnValues[,2],xlab="independentColumnName",ylab="Test")
However I get an error
Error in plot.window(...) : need finite 'xlim' values
and some warnings
4: In min(x) : no non-missing arguments to min; returning Inf
5: In max(x) : no non-missing arguments to max; returning -Inf
What am I doing wrong? How do I fix this?
Thanks in advance for your help
Update #1 I have updated my plotting code to
boxplot(columnValues[,2]~columnValues[,1])
This works now.
With so many comments it's hard to know what's been covered, but here's a "scatterplot" by category using ggplot
. Is this what you had in mind?
library(ggplot2)
ggplot(columnValues)+
geom_point(aes(x=channel_final, y=tot_sales_year),size=3)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.