[R] Visualize Sparse Matrix.

Jim Lemon drjimlemon at gmail.com
Fri Jun 10 11:39:08 CEST 2016


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