title: R: read_csv reads numeric entries as logical - parsing col_logical instead of col_double
body: <p>I am new to R.
  I wrote a code for an assignment which reads several csv files and binds it into a data frame and then according to the id, calculates the mean of either nitrate or sulfate.</p>
  <p>Data sample:</p>
  <pre><code>  Date       sulfate nitrate    ID
    &lt;date&gt;       &lt;dbl&gt;   &lt;dbl&gt; &lt;dbl&gt;
  1 2003-10-06    7.21   0.651     1
  2 2003-10-12    5.99   0.428     1
  3 2003-10-18    4.68   1.04      1
  4 2003-10-24    3.47   0.363     1
  5 2003-10-30    2.42   0.507     1
  6 2003-11-11    1.43   0.474     1
  ... 
  </code></pre>
  <p>To read the files and create a data.frame, I wrote this function:</p>
  <pre><code>pollutantmean &lt;- function (pollutant, id = 1:332) {
         #creating a data frame from several files
    file_m &lt;- list.files(path = &quot;specdata&quot;, pattern = &quot;*.csv&quot;, full.names = TRUE) 
    read_file_m &lt;- lapply(file_m, read_csv)
    df_1 &lt;- bind_rows(read_file_m)
  
          # delete NAs
    df_clean &lt;- df_1[complete.cases(df_1),] 
    
          #select rows according to id
    df_asid_clean &lt;- filter(df_clean, ID %in% id)
    
          #count the mean of the column
    mean_result &lt;- mean(df_asid_clean[, pollutant])
    mean_result
  </code></pre>
  <p>However, when the read_csv function is applied, certain entries in nitrate column are read as col_logical, although the whole class of the column remains numeric and the entries are numeric. It seems that the code &quot;expects&quot; to receive logical value, although the real value is not.
  Throughout the reading I get this message:</p>
  <pre><code>&lt;...&gt;
  Parsed with column specification:
  cols(
    Date = col_date(format = &quot;&quot;),
    sulfate = col_double(),
    nitrate = col_logical(),
    ID = col_double()
  )
  Warning: 41 parsing failures.
   row     col           expected actual               file
  2055 nitrate 1/0/T/F/TRUE/FALSE 0.383  'specdata/288.csv'
  2067 nitrate 1/0/T/F/TRUE/FALSE 0.355  'specdata/288.csv'
  2073 nitrate 1/0/T/F/TRUE/FALSE 0.469  'specdata/288.csv'
  2085 nitrate 1/0/T/F/TRUE/FALSE 0.144  'specdata/288.csv'
  2091 nitrate 1/0/T/F/TRUE/FALSE 0.0984 'specdata/288.csv'
  .... ....... .................. ...... ..................
  See problems(...) for more details. 
  </code></pre>
  <p>I tried to change the column class by writing
  <code>df_1[,nitrate] &lt;- as.numeric(as.character(df_1[, nitrate])</code>
  , after binding rows, but it only shows that NAs are again introduced in step which calculates the mean.</p>
  <p>What is wrong here, and how could I solve it?
  Would appreciate your help!</p>
  <p><strong>UPDATE:</strong> tried to insert read_csv(col_types = list...), but I get &quot;files&quot; argument is not defined. As I understand, the R reads inside read_csv first, <em>then</em> lapply and because there is not &quot;file&quot; given at the time, it shows error.</p>