See the help for read.csv ?read.csv . Here is the relevant section:
colClasses: character. A vector of classes to be assumed for the columns. Recycled as necessary, or if the character vector is named, unspecified values are taken to be 'NA'. Possible values are 'NA' (the default, when 'type.convert' is used), '"NULL"' (when the column is skipped), one of the atomic vector classes (logical, integer, numeric, complex, character, raw), or '"factor"', '"Date"' or '"POSIXct"'. Otherwise there needs to be an 'as' method (from package 'methods') for conversion from '"character"' to the specified formal class. Note that 'colClasses' is specified per column (not per variable) and so includes the column of row names (if any).
Good luck with your quest to learn R. It's hard, but so much fun after you go through the first few steps (which, I admit, will take some time).
try this and fix the rest accordingly:
ex <- read.csv("exampleshort.csv",header=TRUE,colClasses=c("integer","integer","factor","integer","numeric","factor","factor","integer","numeric","numeric","numeric","numeric"), na.strings=c("."))
As BenBolker points out, the colClasses argument is probably not needed. However, note that using the colClasses argument can speed colClasses up, especially with a large dataset.
na.strings . See the next section in ?read.csv :
na.strings: a character vector of strings which are to be interpreted as 'NA' values. Blank fields are also considered to be missing values in logical, integer, numeric and complex fields.
For reference purposes (this should not be used as a solution because the best solution is to import the data correctly in one step): RET not imported as an integer. It was imported as factor . For future reference, if you want to convert factor to numeric , use
new_RET <-as.numeric(as.character(ex$RET))