Importing R cosine similarity to UNIX? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Importing R cosine similarity to UNIX?

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-07-2013
A-V A-V is offline
Registered User
 
Join Date: May 2012
Last Activity: 9 April 2014, 8:55 AM EDT
Posts: 139
Thanks: 84
Thanked 2 Times in 2 Posts
Importing R cosine similarity to UNIX?

I really need help in this

I have a file and would like to calculate the cosine similarity of the values in it...

For now I do use R which has an easy function for doing so

Code:
test <- as.matrix(read.csv(file="file.csv", sep=",", header=FALSE)) 
result<- cosine(t(test))

I am using unix of cygwin, so usually have to call

Code:
dos2unix test.sh test.sh

before being able to run a bash file

now I need to combine my R and unix code together
1. either by writing it in unix -- which yet I have not found any way to do
2. Or to call R

1 option is preferable

can you please guide me on this?
thank you very much
Sponsored Links
    #2  
Old 02-07-2013
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
 
Join Date: Sep 2005
Last Activity: 20 July 2014, 2:59 PM EDT
Location: Switzerland - GE
Posts: 5,609
Thanks: 151
Thanked 387 Times in 364 Posts
I think you will have to give more details in order to get some help:
What OS are you on?
explain the R code, and what you want in unix
Where does cygwin intervene in the process
etc...
Sponsored Links
    #3  
Old 02-07-2013
A-V A-V is offline
Registered User
 
Join Date: May 2012
Last Activity: 9 April 2014, 8:55 AM EDT
Posts: 139
Thanks: 84
Thanked 2 Times in 2 Posts
I have two files each of 6 lines each representing the frequency of specific words
now I wanted to calculate the cosine similarity between these files

for R I simply combine both files and extracted the bits from overall matrix that I needed

Code:
test <- as.matrix(read.csv(file="file.csv", sep=",", header=FALSE)) 
result<- cosine(t(test))
result-files <- (result[7:12,1:6])

I know that is not the best solution but it was easier as I am new to both languages

I have tried to get R running in cygwin but didnt manage... so now I am wondering whether it is possible to do cosine similarity calculations in unix... is there any shortcuts on doing so?

I a working on windows Vista

Cheers
    #4  
Old 02-19-2013
A-V A-V is offline
Registered User
 
Join Date: May 2012
Last Activity: 9 April 2014, 8:55 AM EDT
Posts: 139
Thanks: 84
Thanked 2 Times in 2 Posts
Solved the problem by working on a Linux machine
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with merge data based on similarity patrick87 Shell Programming and Scripting 1 12-19-2011 06:33 AM
building flat files in unix and importing them from windows tunirayavarapu UNIX for Advanced & Expert Users 3 08-09-2004 09:54 AM
Importing a unix file dump into a PC capable database DaltonF UNIX for Dummies Questions & Answers 7 07-23-2002 05:06 PM
importing database from unix to winnt sadiecutie UNIX for Dummies Questions & Answers 4 08-16-2001 01:04 AM



All times are GMT -4. The time now is 07:20 AM.