loms
loms

Reputation: 11

How can I graph from the data set?

x <- del_time[,c('arrivaltime')][1:4]
x
y <- del_time[,c('prop_arrdelay')][1:4]
y

barplot(x,y)

Here are the results

[1] "Early"   "Evening" "Morning" "Night"  
> y <- del_time[,c('prop_arrdelay')][1:4]
> y
[1] 0.9083699 0.4830701 0.3752655 0.5393416
> barplot(x,y)
Error in -0.01 * height : non-numeric argument to binary operator

I am getting an error here, how can I fix it?

Upvotes: 0

Views: 30

Answers (1)

Rui Barradas
Rui Barradas

Reputation: 76651

The solution is to use the formula interface to barplot.

x <- c("Early",   "Evening", "Morning", "Night"  )
y <- c(0.9083699, 0.4830701, 0.3752655, 0.5393416)

barplot(y ~ x, ylim = c(0, 1), las = 2)

enter image description here

Upvotes: 1

Related Questions