[R] Visualize Sparse Matrix.

FRANCISCO XAVIER SUMBA TORAL xavier.sumba93 at ucuenca.ec
Fri Jun 10 19:29:24 CEST 2016


Hi Jim,

Thanks for your answer. 

I try your code example, but it is basically the same that I had it. I want to visualise my matrix something like this image: 




With the graphics that I already have is difficult to visualise my data. I am getting this results:

1) With my first code, I got this:



2) With Jim’s code. I got this: 



Ho can I make my graphs more observable as in the first figure? My graphs shows points as if my screen was dirty. 

Cheers.



> On Jun 10, 2016, at 04:39, Jim Lemon <drjimlemon at gmail.com> wrote:
> 
> Hi Francisco,
> I tried this just to see if it would work. It did, after a while.
> 
> wtmat<-matrix(rnorm(4602*1817),nrow=4602)
> library(plotrix)
> x11(width=5,height=13)
> color2D.matplot(wtmat,c(1,1,0),c(0,1,0),0,border=FALSE)
> 
> Jim
> 
> On Fri, Jun 10, 2016 at 8:27 AM, FRANCISCO XAVIER SUMBA TORAL
> <xavier.sumba93 at ucuenca.ec> wrote:
>> Hi,
>> 
>> First of all, sorry for my question it could be so basic for a common user in R, but I am starting with this new environment.
>> 
>> I have done a clustering job and I would like to visualize my vectors. I have a matrix of TF-IDF weights of 4602 x 1817. I store the values in a CSV file. How can I visualize my vectors in a 2D-space?
>> 
>> After that, I execute a clustering algorithm and I got a label for each cluster. How can I visualize my vectors resulting base on a color or figure for each cluster?
>> 
>> This is the code that I am having trying to accomplish my graphs:
>> 
>> data <- read.csv(pathFile,header = FALSE, sep = ",”)
>> dMatrix <- matrix(unlist(data), ncol = 4602, byrow = TRUE) # Use a matrix to use melt.
>> # Graph my data
>> ggplot(melt(dMatrix), aes(Var1,Var2, fill=value)) + geom_raster() + scale_fill_gradient2(low='red', high=‘black', mid=‘white') + theme_bw() + xlab("x1") + ylab("x2")
>> 
>> 
>> Cheers.
>>        [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> 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