I have a .txt data file and I want to perform a very simple operation, namely creating a vector/column with values that are created by dividing a column of the .txt by another column of the .txt.
It seems very trivial but I haven't found out how to do this. First I encountered problems with the type
of entries. Being non-numeric I created a for-loop making them all numeric but even after that I didn't succeed. Therefore I now ask the question from stratch.
My text file looks like this:
state drivers cars pop
AK 360 5.1 5877
AL 498 34.4 3942
AR 219 19.2 3585
AZ 728 31.3 7116
CA 6539 336.2 6518
Now I just want to make a column (does not have to be included in the already existing table, can be just a new variable) with the values of column 2 divided by the values of column 3 divided by 10.
So far I just read the table as:
crimedata <- read.table("drivers.txt",stringsAsFactors=FALSE)
How to do this simple operation?