Note that there are some explanatory texts on larger screens.

plurals
  1. POCSV of Distances to Dist Object R
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/11343637/convert-a-dataframe-to-an-object-of-class-dist-without-actually-calculating-di">Convert a dataframe to an object of class &ldquo;dist&rdquo; without actually calculating distances in R</a> </p> </blockquote> <p>I have a very large csv file (so a for loop takes too long in R) of similarities between keywords that when I read into a data.frame looks like:</p> <pre><code>&gt; df kwd1 kwd2 similarity a b 1 b a 1 c a 2 a c 2 </code></pre> <p>I would like to convert this to a dist object, like this:</p> <pre><code>&gt; dObject a b b 1 c 2 0 </code></pre> <p>I was unable to get this to work: <a href="https://stackoverflow.com/questions/11343637/convert-a-dataframe-to-an-object-of-class-dist-without-actually-calculating-di">Convert a dataframe to an object of class &quot;dist&quot; without actually calculating distances in R</a></p> <p>Another idea I had was to create a sparse matrix using Matrix(), but I am unsure how to populate the matrix efficiently because my csv is fairly large - maybe an apply function?</p> <p>Maybe reshape()?</p> <p>---- Update ---- This seems to work on the toy dataset above: <a href="https://stats.stackexchange.com/questions/6827/efficient-way-to-populate-matrix-in-r">https://stats.stackexchange.com/questions/6827/efficient-way-to-populate-matrix-in-r</a></p> <p>However, in this example, they use a matrix(), but I would like to use Matrix() that is sparse for memory reasons.</p> <p>--- Furthermore ---- There is a similar posting from before. However, I don't think that the advice from it works for this case in which their isn't a link between every element in the dataset - the csv doesn't contain the pairwise similarities between all keywords as in the previous post: <a href="https://stackoverflow.com/questions/11343637/convert-a-dataframe-to-an-object-of-class-dist-without-actually-calculating-di/12289896#12289896">Convert a dataframe to an object of class &quot;dist&quot; without actually calculating distances in R</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload