title: conversion of dataframe into Matrix in R
body: <p>I was trying to convert a dataframe into a realRatingMatrix. But for that, I'm first converting the dataframe to a matrix and a matrix to a realRatingMatrix.
  The dataframe <em>df</em> contains <code>475984 rows</code> and <code>3 columns</code>.<br>
  <code>Column1</code> is the <code>productID</code>, <code>column2</code> is the <code>customer names</code> and <code>column3</code> contains <code>rating of the product</code> given by the respective user
  Steps followed:<br>
  1. Removal of missing values<br>
  2. Deduplication of data<br>
  3. Conversion of dataframe into a matrix
  4. Testing the matrix</p>
  
  <pre><code>library(recommenderlab)
  sapply(df, function(x) sum(is.na(x)))
  # 100 missing values in column2
  df &lt;- df[-which(is.na(df$col2) == TRUE), ]
  sum(duplicated(df))
  # 580 duplicates
  df &lt;- df[-which(duplicated(df) == TRUE), ]
  
  # Converting the dataframe into realratingMatrix
  df_matrix &lt;- data.matrix(df)
  
  # Testing matrix
  str(df_matrix)
  df1 &lt;- as.data.frame(df_matrix)
  </code></pre>
  
  <p>While converting the dataframe into a matrix I'm getting the following warning message:<br>
      <strong>Warning message:
      In data.matrix(beer_data) : NAs introduced by coercion</strong>
  Now when I convert the created matrix to dataframe my customer names column (column2) has just 38 entries rest all are NAs.</p>
  
  <p>Can someone please suggest some way to correct my code and get the desired output.</p>