Reputation: 53786
limbs <- c(4, 3)
names(limbs) <- c('One-Eye', 'Peg-Leg')
To apply a barplot to above I use :
barplot(limbs)
How can I apply the same functionality to a .csv file ? Is there a command I can use to set the limbs & names(limbs) to the limbs,names columns ?
I've read the csv file into memory using : result <- read.csv(result.csv")
The format of the csv is :
names limbs
'One-Eye' , 4
'Peg-Leg' , 3
Upvotes: 0
Views: 110
Reputation: 193507
Why not just use the same approach that you use with a normal vector?
> limbs <- result$limbs
> names(limbs) <- result$names
> barplot(limbs)
Or, more directly:
> barplot(result$limbs, names.arg = result$names)
Upvotes: 1