1
votes

I'm using RStudio to create glm's of a csv dataset and I'm really new to R (Using it for a Uni assignment). Quick summary, it's looking at some motor claim data. I've read.csv the dataset into R;

Motor <- read.csv("motor.csv", quote="", header=TRUE)

then am trying to run

(ClaimsTab <- table(Claims))

to create a table to see the frequency of different claim amounts.

'Claims' is a header in my CSV file and there's no spelling mistakes but am returned with

Error in table(Claims) : object 'Claims' not found

I've attempted to attach a picture of my dataset.

motor dataset picture

What am I doing wrong? I imported a different file earlier and the table() function was working fine.

1
Hard to know without dput(head(Motor, 10)), however you can always hash an specific column by using $ , I suggest you can try : ClaimsTab <- table(Motor$Claims)AlvaroMartinez

1 Answers

1
votes

The name of your dataframe object is Motor. To access a column in a dataframe in base R you do: Motor$Claims This should work: ClaimsTab <- table(Motor$Claims)