[R] scatter plot
Ana Marija
@okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Mon Feb 10 21:18:01 CET 2020
Hi,
Thanks for getting back to me. I need to have there two groups:
"nPDR.rg and "PDR.rg"
can you please let me know how my loop would look like just with those
two groups?
Thanks
Ana
On Mon, Feb 10, 2020 at 2:03 PM John Kane <jrkrideau using gmail.com> wrote:
>
> I must admit that I do not understand what you are doing but can you notm just subset the data?
> Note I am using a data.frame not a tibble. It would be helpful if you could supply sample data in dput() forest.
>
> library("ggpubr")
> mds <- structure(list(Dim.1 = c(0.41, 0.184, 0.394, -0.49, 0.635, -0.723,
> 0.76, -0.0918, -0.336, -0.439, -1.9, 0.631), Dim.2 = c(-0.984,
> 1.11, -0.159, -0.326, -0.112, 0.153, -0.732, 0.645, 0.756, -0.557,
> -0.858, -0.093), Dim.3 = c(-0.87, 0.101, 0.0272, 0.535, -0.0503,
> -0.245, 0.568, -0.189, 0.12, 0.556, -0.949, 1.43), cols = c("nPDR.rg",
> "nPDR.rg", "nPDR.rg", "nPDR.rg", "nPDR.rg", "nPDR.rg", "NoD.rg",
> "NoD.rg", "NoD.rg", "NoD.rg", "NoD.rg", "NoD.rg")), class = "data.frame", row.names = c(NA,
> -12L))
>
> mm1 <- subset(mds, cols =="nPDR.rg")
> ggscatter(mds, x = d1, y = d2, size=3, color = "red")
>
> On Mon, 10 Feb 2020 at 14:04, Ana Marija <sokovic.anamarija using gmail.com> wrote:
>>
>> Hello,
>>
>> I have a code like this:
>>
>> mds <- (ar_diff) %>% dist() %>% cmdscale(k=3) %>% as_tibble()
>> mds$cols <- as.factor(c(rep("nPDR.rg",7), rep("PDR.rg",8), rep("NoD.rg",7)))
>>
>> pdf(file = "RG.pdf")
>>
>>
>> for (dim1 in 1:2){
>> for (dim2 in (dim1+1):3){
>> d1 = paste0("Dim.",dim1); d2 = paste0("Dim.",dim2)
>> colnames(mds)[c(dim1,dim2)] <- c(d1,d2)
>> print(colnames(mds))
>> print(ggscatter(mds, x = d1, y = d2, color ="cols" ,size=3
>> ,palette=c("blue","red","green")))
>> }
>> }
>> dev.off()
>>
>> How do I run the same plot but excluding NoD.rg? What do I need to
>> change in this for loop?
>>
>> > head(mds)
>> # A tibble: 6 x 4
>> Dim.1 Dim.2 Dim.3 cols
>> <dbl> <dbl> <dbl> <fct>
>> 1 1.41 -0.984 -0.870 nPDR.rg
>> 2 0.184 1.11 0.101 nPDR.rg
>> 3 0.394 -0.159 0.0272 nPDR.rg
>> 4 -0.490 -0.326 0.535 nPDR.rg
>> 5 0.635 -0.112 -0.0503 nPDR.rg
>> 6 -0.723 0.153 -0.245 nPDR.rg
>>
>> > tail(mds)
>> # A tibble: 6 x 4
>> Dim.1 Dim.2 Dim.3 cols
>> <dbl> <dbl> <dbl> <fct>
>> 1 0.760 -0.732 0.568 NoD.rg
>> 2 -0.0918 0.645 -0.189 NoD.rg
>> 3 -0.336 0.756 0.120 NoD.rg
>> 4 -0.439 -0.557 0.556 NoD.rg
>> 5 -1.90 -0.858 -0.949 NoD.rg
>> 6 0.631 -0.0930 1.43 NoD.rg
>>
>> Thanks
>> Ana
>>
>> ______________________________________________
>> R-help using 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.
>
>
>
> --
> John Kane
> Kingston ON Canada
More information about the R-help
mailing list