[R] Problems with Cosine Similarity using library(lsa)

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu Feb 23 13:15:16 CET 2012



On 23.02.2012 13:07, A J wrote:
>
> Thanks Uwe, you vere right. Now the library is working but I have next problem as well.
>
> I have loaded a matrix (named matrix_v3) from a TXT file. This matrix was previously reached using xtabs function. Now I have used this formula to obtain cosine similarities from my data matrix (following instructions of lsa package instructions):
>
>> cosine(matrix_v3, y = NULL)
>
> Finally R returns this message:
>
> Error en cosine(matrix_v3, y = NULL) :   argument mismatch. Either one matrix or two vectors needed as input.
>
> I understand that R don't contemplate matrix_v3 like a real matrix. If this is like this, how can I do? I have tried "as.matrix" but it does not work. Sorry if my questions are not very fine, but I am newbie in using R.


We do not know what you object matrix_v3 is, so how could we help? 
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


> Thanks again.
>
>
>> Date: Thu, 23 Feb 2012 11:35:04 +0100
>> From: ligges at statistik.tu-dortmund.de
>> To: anxusgo at hotmail.com
>> CC: r-help at r-project.org
>> Subject: Re: [R] Problems with Cosine Similarity using library(lsa)
>>
>> The error message suggests that you do not have Java installed. And
>> since you said it works in 32-bit: You only have a 32-bit Java but no
>> 64-bit Java installed in your machine.
>>
>> Uwe Ligges
>>
>>
>> On 23.02.2012 11:08, A J wrote:
>>>
>>> Hi everybody!
>>>
>>> I have intended to use library(lsa) on R 64-bits for Windows but it was not possible. Every time I try to launch library(lsa) function R give me back next message:
>>>
>>> Loading required package: SnowballError : .onLoad failed in loadNamespace() for 'Snowball', details:  call: NULL  error: .onLoad failed in loadNamespace() for 'rJava', details:  call: stop("No CurrentVersion entry in '", key, "'! Try re-installing Java and make sure R and Java have matching architectures.")  error: objeto 'key' no encontradoError: package ‘Snowball’ could not be loaded
>>>
>>> Of course, I have loaded all necessary packages, but the only way to library(lsa) works it is on R 32-bits release. The problem here is that R don't leave me to load all data from my matrix and tell me that it is not able to load big vectors (may be due to limitations on memory of 32-bit release).
>>>
>>> The issue is that I need to calculate cosine similarities on my matrix data. Has somebody any suggestion or idea about how to do it (a different library or a formula to get it)?
>>>
>>> Thanks in advance.
>>>
>>> Best,
>>>
>>> AJ 		 	   		
>>> 	[[alternative HTML version deleted]]
>>>
>>>
>>>
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list