blue-sky
blue-sky

Reputation: 53786

How apply functions to csv files

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

Answers (1)

A5C1D2H2I1M1N2O1R2T1
A5C1D2H2I1M1N2O1R2T1

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

Related Questions