Re: [R] scatter plot

2020-02-10 Thread John Kane
In line

On Mon, 10 Feb 2020 at 15:12, Ana Marija 
wrote:

> Hi,
>
> Thanks for getting back to me. I need to have there two groups:
>
> "nPDR.rg  and "PDR.rg"
>

Your sample data only contains NoD.rg &  nPDR.rg.  To start with, I think
we need some representative data supplied in dput format just as I supplied
an "mds" dataset.  If I understand your mds$col statement correctly there
is only 22 rows of data. Just issue the command "dput(mds) and copy the
output into your e-mail. This will allow R-help readers to use the exact
same data set that you have on your computer.

>
> can you please let me know how my loop would look like just with those
> two groups
>

Well no I cannot  because I am still trying ta figure out where "d1 and d2
came from or why you need that loop. It looks like you are renaming the
columns in "mbs" three times but why? And why do it in a loop?

If all that you are doing is renaming the columns from the "ar_diff" data
set names just do it once,
colnames(mds)  <-  c("Dim.1", Dim.2, Dim.3) before you even create the
"cols" column.

We really need to see the data.

I have never used library("ggpubr") and I cannot see why cols is appearing
in the legend---well it does with my data set. Actually, given my version
of the data set I don't see why it it printing the graph.


Also do you really want all three grcaphs in one .pdf file?



> Thanks
> Ana
>
>










> On Mon, Feb 10, 2020 at 2:03 PM John Kane  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 
> 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
> >>  
> >> 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
> >>   
> >> 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@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
>


-- 
John Kane
Kingston ON Canada

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] scatter plot

2020-02-10 Thread Rui Barradas

Hello,

In the loop, try filtering out the values you do not want.

Any of

print(ggscatter(mds %>% dplyr::filter(cols != "NoD.rg"), etc))

print(ggscatter(subset(mds, cols != "NoD.rg"), etc))

tmp <- mds %>% filter(cols != "NoD.rg")
print(ggscatter(tmp, etc))


The first two will create a temporary df, the 3rd a permanent one. 
Remove it after the loop:


rm(tmp)


Hope this helps,

Rui Barradas


Às 19:09 de 10/02/20, Ana Marija escreveu:

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
  
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
   
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@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.



__
R-help@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.


Re: [R] scatter plot

2020-02-10 Thread Ana Marija
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  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  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
>>  
>> 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
>>   
>> 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@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

__
R-help@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.


Re: [R] scatter plot

2020-02-10 Thread John Kane
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 
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
>  
> 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
>   
> 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@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

[[alternative HTML version deleted]]

__
R-help@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.


[R] scatter plot

2020-02-10 Thread Ana Marija
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
 
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
  
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@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.


Re: [R] scatter plot coloring problem

2018-07-20 Thread PIKAL Petr
Hi

Values in conv_df are almost same for each Error level

> aggregate(conv_df$Intercept, list(conv_df$Error), mean)
 Group.1 x
1 High CML error -3.226313
2  Low CML error -3.226536
3  Med CML error -3.226422
> aggregate(conv_df$Slope, list(conv_df$Error), mean)
 Group.1x
1 High CML error 8.325558
2  Low CML error 8.324242
3  Med CML error 8.324721
> boxplot(split(conv_df$Slope, conv_df$Error))
> boxplot(split(conv_df$Intercept, conv_df$Error))
>

so points in ggplot are overplotted and only colour for last plotted level is 
visible.

Cheers
Petr

> On 07/20/2018 02:01 PM, Micha Silver wrote:
> >
> >
> > On 07/20/2018 01:28 PM, Bert Gunter wrote:
> >> Nothing attached. The mail server strips most attachments for security.
>
> Here is a (slightly shorter) repex.
> The fourth plot shows the problem. The first three are as expected.
>
> library(ggplot2)
>
> strat_df <- structure(list(Slope = c(1.15639473681994, 0.972278300619073,
>   1.14313365332712,
> 1.14399372216612, 1.22529134790727, 2.14326711679831,
>   0.54859156211142,
> 1.17046713623601, 1.17453878322687, 3.31323770780669,
>   0.966673750291528,
> 0.746319725592914, 1.02480114419885, 1.0229752524756,
>   1.00132723720128,
> 1.15639473681994, 0.972278300619073, 1.14313365332712,
>   1.14399372216612,
> 1.22529134790727, 2.14326711679831, 0.54859156211142,
>   1.17046713623601,
> 1.17453878322687, 3.31323770780669, 0.966673750291528,
>   0.746319725592914,
> 1.02480114419885, 1.0229752524756, 1.00132723720128,
>   1.15639473681994,
> 0.972278300619073, 1.14313365332712, 1.14399372216612,
>   1.22529134790727,
> 2.14326711679831, 0.54859156211142, 1.17046713623601,
>   1.17453878322687,
> 3.31323770780669, 0.966673750291528, 0.746319725592914,
>   1.02480114419885, 1.0229752524756,
> 1.00132723720128, 1.00564012971235,
>   0.781822304249351,
> 0.793232303666035, 0.798538338102623, 1.20657643535607,
>   2.16318241002351,
> 1.42268702026443, 0.812412401599228, 0.817089629984966,
>   3.27413789688355,
> 0.840735716836696, 0.629583577106973, 0.710708013029288,
>   0.714002133616219,
> 0.985501434987176, 1.03494070727933, 0.956962513783496,
>   0.793549829222589,
> 0.798851646709461, 1.20660885706037, 2.18674952848921,
>   1.5634217520085, 0.81273050967827,
> 0.817407079251797, 3.27417031858785,
>   0.877344267863596,
> 0.848664941338144, 0.710978765510023, 0.714268901361411,
>   0.985533856691474,
> 1.03983096388345, 0.985084623809766, 0.794138608594684,
>   0.79943259180892,
> 1.20665856218731, 2.21336885559571, 1.72189603514386,
>   0.813327118056704,
> 0.818002445250057, 3.27422002371479, 0.877473770321168,
>   0.848389484199237,
> 0.711483989718558, 0.714766443910276, 0.985583561818414
> ), Intercept = c(-1.0892464119326, 0.246565490954958, -1.1639008288321,
>   -1.17146025612969, -1.93566050996642,
> -3.96706179209372, 3.9202695728101,
>   -1.04771345550341, -1.07809518302298,
> -19.7820283549024, 0.36822137463493,
>   2.207658818211, -0.016876438597312,
> -0.00842619567899302, 0.0306144651329568,
>   -1.0892464119326, 0.246565490954958, -1.1639008288321,
> -1.17146025612969,
>   -1.93566050996642, -3.96706179209372, 3.9202695728101,
> -1.04771345550341,
>   -1.07809518302298, -19.7820283549024,
> 0.36822137463493, 2.207658818211,
>   -0.016876438597312, -0.00842619567899302,
> 0.0306144651329568,
>   -1.0892464119326, 0.246565490954958, -1.1639008288321,
> -1.17146025612969,
>   -1.93566050996642, -3.96706179209372, 3.9202695728101,
> -1.04771345550341,
>   -1.07809518302298, -19.7820283549024,
> 0.36822137463493, 2.207658818211,
>   -0.016876438597312, -0.00842619567899302,
> 0.0306144651329568,
>   -1.42588814587741, -0.0938807577163176,
> -0.760427987439108, -0.802681471353857,
>   -4.38731629113287, -4.7225823199,
> 1.08443985346667, -0.679055757307681,
>   -0.713928732007598, -22.2121480319997,
> -0.187477151457156, 1.28512191810652,
>   0.0386762170827232, 0.00928219285158222,
> 

Re: [R] scatter plot coloring problem

2018-07-20 Thread Micha Silver




On 07/20/2018 02:01 PM, Micha Silver wrote:



On 07/20/2018 01:28 PM, Bert Gunter wrote:

Nothing attached. The mail server strips most attachments for security.


Here is a (slightly shorter) repex.
The fourth plot shows the problem. The first three are as expected.

library(ggplot2)

strat_df <- structure(list(Slope = c(1.15639473681994, 0.972278300619073,
 1.14313365332712, 
1.14399372216612, 1.22529134790727, 2.14326711679831,
 0.54859156211142, 
1.17046713623601, 1.17453878322687, 3.31323770780669,
 0.966673750291528, 
0.746319725592914, 1.02480114419885, 1.0229752524756,
 1.00132723720128, 
1.15639473681994, 0.972278300619073, 1.14313365332712,
 1.14399372216612, 
1.22529134790727, 2.14326711679831, 0.54859156211142,
 1.17046713623601, 
1.17453878322687, 3.31323770780669, 0.966673750291528,
 0.746319725592914, 
1.02480114419885, 1.0229752524756, 1.00132723720128,
 1.15639473681994, 
0.972278300619073, 1.14313365332712, 1.14399372216612,
 1.22529134790727, 
2.14326711679831, 0.54859156211142, 1.17046713623601,
 1.17453878322687, 
3.31323770780669, 0.966673750291528, 0.746319725592914,
 1.02480114419885, 1.0229752524756, 
1.00132723720128, 1.00564012971235,
 0.781822304249351, 
0.793232303666035, 0.798538338102623, 1.20657643535607,
 2.16318241002351, 
1.42268702026443, 0.812412401599228, 0.817089629984966,
 3.27413789688355, 
0.840735716836696, 0.629583577106973, 0.710708013029288,
 0.714002133616219, 
0.985501434987176, 1.03494070727933, 0.956962513783496,
 0.793549829222589, 
0.798851646709461, 1.20660885706037, 2.18674952848921,
 1.5634217520085, 0.81273050967827, 
0.817407079251797, 3.27417031858785,
 0.877344267863596, 
0.848664941338144, 0.710978765510023, 0.714268901361411,
 0.985533856691474, 
1.03983096388345, 0.985084623809766, 0.794138608594684,
 0.79943259180892, 
1.20665856218731, 2.21336885559571, 1.72189603514386,
 0.813327118056704, 
0.818002445250057, 3.27422002371479, 0.877473770321168,
 0.848389484199237, 
0.711483989718558, 0.714766443910276, 0.985583561818414

), Intercept = c(-1.0892464119326, 0.246565490954958, -1.1639008288321,
 -1.17146025612969, -1.93566050996642, 
-3.96706179209372, 3.9202695728101,
 -1.04771345550341, -1.07809518302298, 
-19.7820283549024, 0.36822137463493,
 2.207658818211, -0.016876438597312, 
-0.00842619567899302, 0.0306144651329568,
 -1.0892464119326, 0.246565490954958, -1.1639008288321, 
-1.17146025612969,
 -1.93566050996642, -3.96706179209372, 3.9202695728101, 
-1.04771345550341,
 -1.07809518302298, -19.7820283549024, 
0.36822137463493, 2.207658818211,
 -0.016876438597312, -0.00842619567899302, 
0.0306144651329568,
 -1.0892464119326, 0.246565490954958, -1.1639008288321, 
-1.17146025612969,
 -1.93566050996642, -3.96706179209372, 3.9202695728101, 
-1.04771345550341,
 -1.07809518302298, -19.7820283549024, 
0.36822137463493, 2.207658818211,
 -0.016876438597312, -0.00842619567899302, 
0.0306144651329568,
 -1.42588814587741, -0.0938807577163176, 
-0.760427987439108, -0.802681471353857,
 -4.38731629113287, -4.7225823199, 
1.08443985346667, -0.679055757307681,
 -0.713928732007598, -22.2121480319997, 
-0.187477151457156, 1.28512191810652,
 0.0386762170827232, 0.00928219285158222, 
-2.45430083552569, -1.5052623193495,
 -0.571094020563348, -0.760898951384971, 
-0.80312079180565, -4.38543778472072,
 -4.74043340113669, 0.976337655364814, 
-0.679498378418568, -0.714366826235178,
 -22.2102695255875, -0.264069816907669, 
0.823783304969757, 0.0386132206604378,
 0.00924930329540931, -2.45242232911355, 
-1.5204762452006, -0.664489263100851,
 -0.761704010560802, -0.803866601426402, 
-4.38177522849324, -4.78366916314869,
 0.714779631860822, -0.68026224065537, 
-0.715122068793879, -22.20660696936,
 -0.262931522643713, 0.827039881514761, 
0.0385397097353969, 0.00923344703169212,
 -2.44875977288606), Struct = c("Bias only", 

Re: [R] scatter plot coloring problem

2018-07-20 Thread Micha Silver




On 07/20/2018 01:28 PM, Bert Gunter wrote:

Nothing attached. The mail server strips most attachments for security.


Here is my repex, inline:

library(ggplot2)

conv_df <- structure(list(Adjustment = structure(c(1L, 2L, 3L, 4L, 5L, 1L,
    2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 
5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L,
    3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 
1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L,
    4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 
2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L,
    5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L, 
3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L,
    1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L, 
4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L,
    2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L, 
5L, 1L, 2L, 3L, 4L, 5L, 1L, 2L,
    3L, 4L, 5L, 1L, 2L, 3L, 4L, 5L, 
1L, 2L, 3L, 4L, 5L, 1L, 2L, 3L,
    4L, 5L, 1L, 2L, 3L, 4L, 5L, 1L, 
2L, 3L, 4L, 5L, 1L, 2L, 3L, 4L,
    5L), .Label = c("Radar", 
"MeanFieldBias", "Multiplicative", "Mixed",

"ConditionalMerge"), class = "factor"), Struct = c("Bias only",
"Bias only", "Bias only", "Bias only", "Bias only", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"Bias only", "Bias only", "Bias only", "Bias only", "Bias only",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "Bias only", "Bias only", "Bias only", "Bias only",
"Bias only", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct.", "Bias only", "Bias only",
"Bias only", "Bias only", "Bias only", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"Bias only", "Bias only", "Bias only", "Bias only", "Bias only",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "Bias only", "Bias only", "Bias only", "Bias only",
"Bias only", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct.", "Bias only", "Bias only",
"Bias only", "Bias only", "Bias only", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"Bias only", "Bias only", "Bias only", "Bias only", "Bias only",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "Bias only", "Bias only", "Bias only", "Bias only",
"Bias only", "Lognormal error dist.", "Lognormal error dist.",
"Lognormal error dist.", "Lognormal error dist.", "Lognormal error dist.",
"FFT-based struct.", "FFT-based struct.", "FFT-based struct.",
"FFT-based struct.", "FFT-based struct."), Error = c("Low CML error",
"Low CML error", "Low CML error", "Low CML error", "Low CML error",
"Low CML error", "Low CML error", "Low CML error", "Low CML error",
"Low CML error", "Low CML error", "Low CML error", "Low CML error",
"Low CML error", "Low CML error", "Med CML error", "Med CML error",
"Med CML error", "Med CML error", "Med CML error", "Med CML error",
"Med CML error", "Med CML error", "Med CML error", "Med CML error",
"Med CML error", "Med CML error", "Med CML error", "Med CML error",
"Med CML error", "High CML error", "High CML error", "High CML error",
"High CML error", "High CML error", "High CML error", "High CML error",
"High CML error", "High CML error", "High CML error", "High CML error",
"High CML error", "High CML error", "High CML error", "High CML error",
"Low CML error", "Low CML error", "Low CML error", "Low CML error",
"Low CML error", "Low CML error", "Low CML error", "Low CML error",
"Low CML error", "Low CML error", "Low CML error", "Low CML error",
"Low CML error", "Low CML error", "Low CML error", "Med CML error",
"Med CML error", "Med CML error", 

Re: [R] scatter plot coloring problem

2018-07-20 Thread Bert Gunter
Nothing attached. The mail server strips most attachments for security.

See the posting guide below and ?dput for how to include data.
+ We need your faulty code also, of course.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Fri, Jul 20, 2018 at 3:15 AM, Micha Silver  wrote:

> Hello:
>
> I have two data frames (subsetted from a larger one). I am plotting
> scatterplots with ggplot2 and coloring by different variables. When using
> one of the variables "Error" with one of the dataframes "conv_df" only a
> single color is displayed. All the other variables show colors as expected,
> and when applying the same ggplot() functions to the second dataframe,
> colors are correctly applied for all variables.
>
> I'm scratching me head over this for some time. Maybe someone can see what
> I'm missing?
>
> My repex is attached
>
> Thanks
>
> --
> Micha Silver
> Ben Gurion Univ.
> Sde Boker, Remote Sensing Lab
> cell: +972-523-665918
>
> __
> R-help@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/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@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.


[R] scatter plot coloring problem

2018-07-20 Thread Micha Silver

Hello:

I have two data frames (subsetted from a larger one). I am plotting 
scatterplots with ggplot2 and coloring by different variables. When 
using one of the variables "Error" with one of the dataframes "conv_df" 
only a single color is displayed. All the other variables show colors as 
expected, and when applying the same ggplot() functions to the second 
dataframe, colors are correctly applied for all variables.


I'm scratching me head over this for some time. Maybe someone can see 
what I'm missing?


My repex is attached

Thanks

--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918

__
R-help@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.


Re: [R] scatter plot of numerical variables against different sample ids

2016-12-05 Thread Shawn Way
You can also try using ggplot2 to generate the plot:

> library(tidyr)
> library(ggplot2)
> data <- gather(mldf,Element,Value,2:4)
> p <- ggplot(data,aes(x=factor(Element),y=Value,group=Sample,color=Sample))
> p+geom_line()

Shawn Way, PE

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon
Sent: Monday, December 05, 2016 3:02 PM
To: Maria Lathouri <mlatho...@yahoo.gr>
Cc: R-help Mailing List <r-help@r-project.org>
Subject: Re: [R] scatter plot of numerical variables against different sample 
ids

Hi Maria,
Perhaps something like this:

 mldf<-read.table(text="Sample  Cu  Zn Mn
 M1 1  5  10
 M2  2.5  11   8
 M3 1.15  11  12
 M4  2  4  30
 M5  8  15 35",
 header=TRUE)
 matplot(mldf,type="b",pch=c("C","Z","M"))

Jim


On Mon, Dec 5, 2016 at 11:25 PM, Maria Lathouri via R-help 
<r-help@r-project.org> wrote:
> Dear all
> I know that my question is very simple but although I tried to find an answer 
> online, I couldn't and I am stuck.
> I have a dataset of three numerical variables measured in different samples 
> ID. Something like this:
> SampleCuZnMnM1   1  5  
> 10M2   2.5   11  8M3  1.15  11
>  12  M42 4  30M5815   
>   35
> I would like to plot these variables (Cu, Zn, Mn) (in y-axis) against the 
> Sample ID (in x-axis) in a scatter plot with lines as I want to see how they 
> change in the samples.
> I tried using the command>plot(Sample, Cu, type="l", lty=1, col="red") 
> but I wouldn't get a line. Actually, I would get some small horizontal lines 
> in each point. I tried to use type="p" but I would get the same thing.
> I would very much appreciate if you could help me on that. Apparently, I am 
> missing something.
> Thank you in advance.
> Kind regards,Maria
> [[alternative HTML version deleted]]
>
> __
> R-help@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.

__
R-help@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.

__
R-help@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.


Re: [R] scatter plot of numerical variables against different sample ids

2016-12-05 Thread Jim Lemon
Hi Maria,
Perhaps something like this:

 mldf<-read.table(text="Sample  Cu  Zn Mn
 M1 1  5  10
 M2  2.5  11   8
 M3 1.15  11  12
 M4  2  4  30
 M5  8  15 35",
 header=TRUE)
 matplot(mldf,type="b",pch=c("C","Z","M"))

Jim


On Mon, Dec 5, 2016 at 11:25 PM, Maria Lathouri via R-help
 wrote:
> Dear all
> I know that my question is very simple but although I tried to find an answer 
> online, I couldn't and I am stuck.
> I have a dataset of three numerical variables measured in different samples 
> ID. Something like this:
> SampleCuZnMnM1   1  5  
> 10M2   2.5   11  8M3  1.15  11
>  12  M42 4  30M5815   
>   35
> I would like to plot these variables (Cu, Zn, Mn) (in y-axis) against the 
> Sample ID (in x-axis) in a scatter plot with lines as I want to see how they 
> change in the samples.
> I tried using the command>plot(Sample, Cu, type="l", lty=1, col="red")
> but I wouldn't get a line. Actually, I would get some small horizontal lines 
> in each point. I tried to use type="p" but I would get the same thing.
> I would very much appreciate if you could help me on that. Apparently, I am 
> missing something.
> Thank you in advance.
> Kind regards,Maria
> [[alternative HTML version deleted]]
>
> __
> R-help@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.

__
R-help@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.


Re: [R] scatter plot of numerical variables against different sample ids

2016-12-05 Thread Ivan Calandra

Hi Maria,

What happens is that R plots with boxplots (explaining the horizontal 
lines, i.e. boxes with n=1) when the x-variable is a factor.
What you can do is transform your Sample column into numeric and then 
plot it, with some adjustment of axis labels.


For example:
datf <- data.frame(Sample=c("M1","M2","M3","M4","M5"), 
Cu=c(1,2.5,1.15,2,8), Zn=c(5,11,11,4,15), Mn=c(10,8,12,30,35))

datf$Sample2 <- as.numeric(datf$Sample)
with(datf, plot(Sample2, Cu, type="l", lty=1, col="red", xaxt="n"))
axis(1, at=datf$Sample2, labels=datf$Sample)

It might not be the easiest/best approach though... Someone here might 
have a better idea.


HTH,
Ivan

--
Ivan Calandra, PhD
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
calan...@rgzm.de
+49 (0) 2631 9772-287
--
https://www.researchgate.net/profile/Ivan_Calandra
https://publons.com/author/705639/

Le 05/12/2016 à 13:25, Maria Lathouri via R-help a écrit :

Dear all
I know that my question is very simple but although I tried to find an answer 
online, I couldn't and I am stuck.
I have a dataset of three numerical variables measured in different samples ID. 
Something like this:
SampleCuZnMnM1   1  5  10M2 
  2.5   11  8M3  1.15  11 12  
M42 4  30M5815 
35
I would like to plot these variables (Cu, Zn, Mn) (in y-axis) against the 
Sample ID (in x-axis) in a scatter plot with lines as I want to see how they 
change in the samples.
I tried using the command>plot(Sample, Cu, type="l", lty=1, col="red")
but I wouldn't get a line. Actually, I would get some small horizontal lines in each 
point. I tried to use type="p" but I would get the same thing.
I would very much appreciate if you could help me on that. Apparently, I am 
missing something.
Thank you in advance.
Kind regards,Maria
[[alternative HTML version deleted]]

__
R-help@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.


__
R-help@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.

[R] scatter plot of numerical variables against different sample ids

2016-12-05 Thread Maria Lathouri via R-help
Dear all
I know that my question is very simple but although I tried to find an answer 
online, I couldn't and I am stuck. 
I have a dataset of three numerical variables measured in different samples ID. 
Something like this:
Sample        Cu        Zn        MnM1               1          5          10M2 
              2.5       11          8M3              1.15      11         12  
M4                2         4          30M5                8        15         
35
I would like to plot these variables (Cu, Zn, Mn) (in y-axis) against the 
Sample ID (in x-axis) in a scatter plot with lines as I want to see how they 
change in the samples.
I tried using the command>plot(Sample, Cu, type="l", lty=1, col="red")
but I wouldn't get a line. Actually, I would get some small horizontal lines in 
each point. I tried to use type="p" but I would get the same thing. 
I would very much appreciate if you could help me on that. Apparently, I am 
missing something. 
Thank you in advance. 
Kind regards,Maria
[[alternative HTML version deleted]]

__
R-help@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.

[R] scatter plot matrix with multiple trend lines and p values

2015-02-28 Thread tianshu
I am trying to create a scatter plot matrix in which the lower panels
contain
scatter plots colored by group with trend lines by group, and the upper
panels contain r and p values. Using pairs() I was able to get close (ie,
scatter plot matrix on bottom with one trend line and correlation
coefficients and p values in the upper panel) but was unable to add two
lines. Using spm() I was able to get the multiple trend lines, but not the
upper
panel statistics. Does anyone know of a way to accomplish this?

My code using pairs:

pairs(~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width, data = iris,
bg=c(red,blue,green)[iris$Species],
pch = 22,
lower.panel  =my_line - function(x,y,...){
points(x,y,...)
abline(a = lm(y ~ x)$coefficients[1] , b = lm(y ~ x)$coefficients[2] ,
...)
},
upper.panel = panel.cor - function(x, y, digits = 2, cex.cor, ...)
{
  usr - par(usr); on.exit(par(usr))
  par(usr = c(0, 1, 0, 1))
  # correlation coefficient
  r - cor(x, y)
  txt - format(c(r, 0.123456789), digits = digits)[1]
  txt - paste(r= , txt, sep = )
  text(0.5, 0.6, txt)

  # p-value calculation
  p - cor.test(x, y)$p.value
  txt2 - format(c(p, 0.123456789), digits = digits)[1]
  txt2 - paste(p= , txt2, sep = )
  if(p0.01) txt2 - paste(p= , 0.01, sep = )
  text(0.5, 0.4, txt2)
})




--
View this message in context: 
http://r.789695.n4.nabble.com/scatter-plot-matrix-with-multiple-trend-lines-and-p-values-tp4703996.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot for repeated measures

2014-12-08 Thread farnoosh sheikhi
Thank you all. That was very helpful.  Farnoosh

 

 On Saturday, December 6, 2014 7:41 PM, Chel Hee Lee chl...@mail.usask.ca 
wrote:
   

 It seems that you would like to make a spaghetti plot (in a longitudinal 
data analysis).  You can use the function 'interaction.plot()'.

  with(my.df, interaction.plot(TIME, ID, X))

I hope this helps.

Chel Hee Lee

On 12/06/2014 02:24 AM, arun wrote:


 Not sure whether it is a scatterplot or just a plot with 3 lines.  If it is 
 the latter,

 library(reshape2)

 matplot(acast(my.df, TIME~ID, value.var='X'), type='l', col=1:3, ylab='X', 
 xlab='TIME')
 legend('bottomright', inset=.05, legend=LETTERS[1:3], pch=1, col=1:3)
 A.K.

 On Friday, December 5, 2014 5:45 PM, farnoosh sheikhi farnoosh...@yahoo.com 
 wrote:



 Hi Arun,

 I hope you are doing well.
 I have a data set as follow:
 my.df - data.frame(ID=rep(c(A,B,C), 5), TIME=rep(1:5, each=3), X=1:5)

 I would like to get a scatterplot where x axis is Time (1,2,3,4,5) and y axis 
 is X, but I want to have three lines separately for each ID.
  I basically want to tack each ID over time. Is this possible?


 Thanks a lot and Happy Holidays to you!

 __
 R-help@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.



   
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot for repeated measures

2014-12-06 Thread arun


Not sure whether it is a scatterplot or just a plot with 3 lines.  If it is the 
latter,

library(reshape2)

matplot(acast(my.df, TIME~ID, value.var='X'), type='l', col=1:3, ylab='X', 
xlab='TIME')
legend('bottomright', inset=.05, legend=LETTERS[1:3], pch=1, col=1:3)
A.K.

On Friday, December 5, 2014 5:45 PM, farnoosh sheikhi farnoosh...@yahoo.com 
wrote:



Hi Arun,

I hope you are doing well.
I have a data set as follow:
my.df - data.frame(ID=rep(c(A,B,C), 5), TIME=rep(1:5, each=3), X=1:5)

I would like to get a scatterplot where x axis is Time (1,2,3,4,5) and y axis 
is X, but I want to have three lines separately for each ID.
 I basically want to tack each ID over time. Is this possible?


Thanks a lot and Happy Holidays to you!

__
R-help@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.


Re: [R] Scatter plot for repeated measures

2014-12-06 Thread Chel Hee Lee
It seems that you would like to make a spaghetti plot (in a longitudinal 
data analysis).   You can use the function 'interaction.plot()'.


 with(my.df, interaction.plot(TIME, ID, X))

I hope this helps.

Chel Hee Lee

On 12/06/2014 02:24 AM, arun wrote:



Not sure whether it is a scatterplot or just a plot with 3 lines.  If it is the 
latter,

library(reshape2)

matplot(acast(my.df, TIME~ID, value.var='X'), type='l', col=1:3, ylab='X', 
xlab='TIME')
legend('bottomright', inset=.05, legend=LETTERS[1:3], pch=1, col=1:3)
A.K.

On Friday, December 5, 2014 5:45 PM, farnoosh sheikhi farnoosh...@yahoo.com 
wrote:



Hi Arun,

I hope you are doing well.
I have a data set as follow:
my.df - data.frame(ID=rep(c(A,B,C), 5), TIME=rep(1:5, each=3), X=1:5)

I would like to get a scatterplot where x axis is Time (1,2,3,4,5) and y axis 
is X, but I want to have three lines separately for each ID.
  I basically want to tack each ID over time. Is this possible?


Thanks a lot and Happy Holidays to you!

__
R-help@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.



__
R-help@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.


[R] Scatter plot selection points

2014-05-30 Thread Beatriz

Hi all,

I'd like to do a scatterplot where some of the values, out of a subset, 
are plotted differently in color and shape.

I've worked around the following code but I don't manage to make it right.
Any help greatly appreciated!

# My data
dd - iris
iris$Code - 1:150

# A selection of my data I'd like to plot differently
subset - subset(iris, iris$Sepal.Width5)
sel - as.character(subset$Code) # I think the problems start already 
here :)


# Plotting doesn't work
plot(iris$Sepal.Length ~ iris$Sepal.Widith,
 col=ifelse(iris$Code==sel, red, black)
 pch=ifelse(iris$Code==sel, 17, 1))

__
R-help@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.


Re: [R] Scatter plot selection points

2014-05-30 Thread PIKAL Petr
Hi

 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Beatriz
 Sent: Friday, May 30, 2014 9:37 AM
 To: R Help
 Subject: [R] Scatter plot selection points

 Hi all,

 I'd like to do a scatterplot where some of the values, out of a subset,
 are plotted differently in color and shape.
 I've worked around the following code but I don't manage to make it
 right.
 Any help greatly appreciated!

 # My data
 dd - iris
 iris$Code - 1:150

 # A selection of my data I'd like to plot differently
 subset - subset(iris, iris$Sepal.Width5)

 max(iris$Sepal.Width)
[1] 4.4

No values out of subset. So I changed threshold.

iris$code-iris$Sepal.Width3.5

 sel - as.character(subset$Code) # I think the problems start already
 here :)

 # Plotting doesn't work
 plot(iris$Sepal.Length ~ iris$Sepal.Widith,
   col=ifelse(iris$Code==sel, red, black)
   pch=ifelse(iris$Code==sel, 17, 1))

Overcomplicated

plot(iris$Sepal.Length ~ iris$Sepal.Width, col=c(red, black)[iris$code+1], 
pch=c(17, 1)[iris$code+1])

Regards
Petr


 __
 R-help@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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.
__
R-help@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.


Re: [R] Scatter plot selection points

2014-05-30 Thread Beatriz

Hi Ptr,

Thanks for your email however, I cannot make the code work.

Also, I quite like the ifelse approach. I find it very clean.

Cheers



On 30/05/2014 15:57, PIKAL Petr wrote:

Hi


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Beatriz
Sent: Friday, May 30, 2014 9:37 AM
To: R Help
Subject: [R] Scatter plot selection points

Hi all,

I'd like to do a scatterplot where some of the values, out of a subset,
are plotted differently in color and shape.
I've worked around the following code but I don't manage to make it
right.
Any help greatly appreciated!

# My data
dd - iris
iris$Code - 1:150

# A selection of my data I'd like to plot differently
subset - subset(iris, iris$Sepal.Width5)
max(iris$Sepal.Width)

[1] 4.4
No values out of subset. So I changed threshold.

iris$code-iris$Sepal.Width3.5


sel - as.character(subset$Code) # I think the problems start already
here :)

# Plotting doesn't work
plot(iris$Sepal.Length ~ iris$Sepal.Widith,
   col=ifelse(iris$Code==sel, red, black)
   pch=ifelse(iris$Code==sel, 17, 1))

Overcomplicated

plot(iris$Sepal.Length ~ iris$Sepal.Width, col=c(red, black)[iris$code+1], 
pch=c(17, 1)[iris$code+1])

Regards
Petr


__
R-help@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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny 
pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně 
jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze 
svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email 
jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či 
zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a 
to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; 
Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce 
s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným 
dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost 
žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně 
pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně 
osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi 
či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are 
intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. 
Delete the contents of this e-mail with all attachments and its copies from 
your system.
If you are not the intended recipient of this e-mail, you are not authorized to 
use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by 
modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a 
contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately 
accept such offer; The sender of this e-mail (offer) excludes any acceptance of 
the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an 
express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into 
any contracts on behalf of the company except for cases in which he/she is 
expressly authorized to do so in writing, and such authorization or power of 
attorney is submitted to the recipient or the person represented by the 
recipient, or the existence of such authorization is known to the recipient of 
the person represented by the recipient.


__
R-help@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.


Re: [R] Scatter plot selection points

2014-05-30 Thread PIKAL Petr
Hi


 -Original Message-
 From: Beatriz [mailto:aguitatie...@hotmail.com]
 Sent: Friday, May 30, 2014 10:08 AM
 To: PIKAL Petr; R Help
 Subject: Re: [R] Scatter plot selection points

 Hi Ptr,

 Thanks for your email however, I cannot make the code work.

Errors? What code you tried?

iris$code - iris$Sepal.Width3.5
plot(iris$Sepal.Length ~ iris$Sepal.Width, col=c(red,black)[iris$code+1], 
pch=c(17, 1)[iris$code+1])

works for me without any problem.


 Also, I quite like the ifelse approach. I find it very clean.

Yes. I mean complicated is your subset approach. You can use ifelse if you like.

plot(iris$Sepal.Length ~ iris$Sepal.Width, col=ifelse(iris$code, black, 
red), pch= ifelse(iris$code, 1,17))

Regards
Petr



 Cheers



 On 30/05/2014 15:57, PIKAL Petr wrote:
  Hi
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of Beatriz
  Sent: Friday, May 30, 2014 9:37 AM
  To: R Help
  Subject: [R] Scatter plot selection points
 
  Hi all,
 
  I'd like to do a scatterplot where some of the values, out of a
  subset, are plotted differently in color and shape.
  I've worked around the following code but I don't manage to make it
  right.
  Any help greatly appreciated!
 
  # My data
  dd - iris
  iris$Code - 1:150
 
  # A selection of my data I'd like to plot differently subset -
  subset(iris, iris$Sepal.Width5)
  max(iris$Sepal.Width)
  [1] 4.4
  No values out of subset. So I changed threshold.
 
  iris$code-iris$Sepal.Width3.5
 
  sel - as.character(subset$Code) # I think the problems start
 already
  here :)
 
  # Plotting doesn't work
  plot(iris$Sepal.Length ~ iris$Sepal.Widith,
 col=ifelse(iris$Code==sel, red, black)
 pch=ifelse(iris$Code==sel, 17, 1))
  Overcomplicated
 
  plot(iris$Sepal.Length ~ iris$Sepal.Width, col=c(red,
  black)[iris$code+1], pch=c(17, 1)[iris$code+1])
 
  Regards
  Petr
 
  __
  R-help@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.
  
  Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a
 jsou určeny pouze jeho adresátům.
  Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
 neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho
 kopie vymažte ze svého systému.
  Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento
 email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
  Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou
 modifikacemi či zpožděním přenosu e-mailu.
 
  V případě, že je tento e-mail součástí obchodního jednání:
  - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
 smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
  - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně
 přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky
 ze strany příjemce s dodatkem či odchylkou.
  - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
 výslovným dosažením shody na všech jejích náležitostech.
  - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
 společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně
 zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly
 adresátovi tohoto emailu případně osobě, kterou adresát zastupuje,
 předloženy nebo jejich existence je adresátovi či osobě jím zastoupené
 známá.
 
  This e-mail and any documents attached to it may be confidential and
 are intended only for its intended recipients.
  If you received this e-mail by mistake, please immediately inform its
 sender. Delete the contents of this e-mail with all attachments and its
 copies from your system.
  If you are not the intended recipient of this e-mail, you are not
 authorized to use, disseminate, copy or disclose this e-mail in any
 manner.
  The sender of this e-mail shall not be liable for any possible damage
 caused by modifications of the e-mail or by delay with transfer of the
 email.
 
  In case that this e-mail forms part of business dealings:
  - the sender reserves the right to end negotiations about entering
 into a contract in any time, for any reason, and without stating any
 reasoning.
  - if the e-mail contains an offer, the recipient is entitled to
 immediately accept such offer; The sender of this e-mail (offer)
 excludes any acceptance of the offer on the part of the recipient
 containing any amendment or variation.
  - the sender insists on that the respective contract is concluded
 only upon an express mutual agreement on all its aspects.
  - the sender of this e-mail informs that he/she is not authorized to
 enter into any contracts on behalf of the company except for cases in
 which he/she is expressly authorized to do so in writing

Re: [R] Scatter plot selection points

2014-05-30 Thread Beatriz

Hi Petr,

Initially your code didn´t work because 'Code' wasn't in uppercase. It 
works now! :) The only thing is that I wanted in red the codes  3.5.


Optional code:
sel - iris[iris$Sepal.Width3.5,Code]
plot(iris$Sepal.Length ~ iris$Sepal.Width,
col=ifelse(iris$Code %in% sel, red, black),
pch=ifelse(iris$Code %in% sel, 17, 1))

Cheers


On 30/05/2014 17:38, PIKAL Petr wrote:

Hi



-Original Message-
From: Beatriz [mailto:aguitatie...@hotmail.com]
Sent: Friday, May 30, 2014 10:08 AM
To: PIKAL Petr; R Help
Subject: Re: [R] Scatter plot selection points

Hi Ptr,

Thanks for your email however, I cannot make the code work.

Errors? What code you tried?

iris$code - iris$Sepal.Width3.5
plot(iris$Sepal.Length ~ iris$Sepal.Width, col=c(red,black)[iris$code+1], 
pch=c(17, 1)[iris$code+1])

works for me without any problem.


Also, I quite like the ifelse approach. I find it very clean.

Yes. I mean complicated is your subset approach. You can use ifelse if you like.

plot(iris$Sepal.Length ~ iris$Sepal.Width, col=ifelse(iris$code, black, 
red), pch= ifelse(iris$code, 1,17))

Regards
Petr



Cheers



On 30/05/2014 15:57, PIKAL Petr wrote:

Hi


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
project.org] On Behalf Of Beatriz
Sent: Friday, May 30, 2014 9:37 AM
To: R Help
Subject: [R] Scatter plot selection points

Hi all,

I'd like to do a scatterplot where some of the values, out of a
subset, are plotted differently in color and shape.
I've worked around the following code but I don't manage to make it
right.
Any help greatly appreciated!

# My data
dd - iris
iris$Code - 1:150

# A selection of my data I'd like to plot differently subset -
subset(iris, iris$Sepal.Width5)
max(iris$Sepal.Width)

[1] 4.4
No values out of subset. So I changed threshold.

iris$code-iris$Sepal.Width3.5


sel - as.character(subset$Code) # I think the problems start

already

here :)

# Plotting doesn't work
plot(iris$Sepal.Length ~ iris$Sepal.Widith,
col=ifelse(iris$Code==sel, red, black)
pch=ifelse(iris$Code==sel, 17, 1))

Overcomplicated

plot(iris$Sepal.Length ~ iris$Sepal.Width, col=c(red,
black)[iris$code+1], pch=c(17, 1)[iris$code+1])

Regards
Petr


__
R-help@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.


Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a

jsou určeny pouze jeho adresátům.

Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě

neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho
kopie vymažte ze svého systému.

Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento

email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.

Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou

modifikacemi či zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření

smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.

- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně

přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky
ze strany příjemce s dodatkem či odchylkou.

- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve

výslovným dosažením shody na všech jejích náležitostech.

- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za

společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně
zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly
adresátovi tohoto emailu případně osobě, kterou adresát zastupuje,
předloženy nebo jejich existence je adresátovi či osobě jím zastoupené
známá.

This e-mail and any documents attached to it may be confidential and

are intended only for its intended recipients.

If you received this e-mail by mistake, please immediately inform its

sender. Delete the contents of this e-mail with all attachments and its
copies from your system.

If you are not the intended recipient of this e-mail, you are not

authorized to use, disseminate, copy or disclose this e-mail in any
manner.

The sender of this e-mail shall not be liable for any possible damage

caused by modifications of the e-mail or by delay with transfer of the
email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering

into a contract in any time, for any reason, and without stating any
reasoning.

- if the e-mail contains an offer, the recipient is entitled to

immediately accept such offer; The sender of this e-mail (offer)
excludes any acceptance of the offer on the part of the recipient
containing any amendment or variation.

- the sender insists on that the respective contract is concluded

only upon an express

Re: [R] Scatter plot selection points

2014-05-30 Thread PIKAL Petr
Hi

My code worked. Your code did not work because you was not aware that R 
distinguish case of letters :)

 -Original Message-
 From: Beatriz [mailto:aguitatie...@hotmail.com]
 Sent: Friday, May 30, 2014 12:21 PM
 To: PIKAL Petr; R Help
 Subject: Re: [R] Scatter plot selection points

 Hi Petr,

 Initially your code didn´t work because 'Code' wasn't in uppercase. It
 works now! :) The only thing is that I wanted in red the codes  3.5.

If you insist on separate object for colouring purpose you can have it.

sel - iris$Sepal.Width3.5
plot(iris$Sepal.Length ~ iris$Sepal.Width, col=c(red,black)[sel+1], 
pch=c(17, 1)[sel+1])

I still consider my code simpler and easier to read and understand.

sel is logical TRUE/FALSE which can be used as 1/0 in calculations.

This
c(red,black)[sel+1]
selects red if sel is FALSE and and black if sel is TRUE
the same applies to selection of pch.

If you want to change colouring just swap the red/black
c(black, red)[sel+1]

Regards
Petr


 Optional code:
 sel - iris[iris$Sepal.Width3.5,Code]
 plot(iris$Sepal.Length ~ iris$Sepal.Width,
 col=ifelse(iris$Code %in% sel, red, black),
 pch=ifelse(iris$Code %in% sel, 17, 1))

 Cheers


 On 30/05/2014 17:38, PIKAL Petr wrote:
  Hi
 
 
  -Original Message-
  From: Beatriz [mailto:aguitatie...@hotmail.com]
  Sent: Friday, May 30, 2014 10:08 AM
  To: PIKAL Petr; R Help
  Subject: Re: [R] Scatter plot selection points
 
  Hi Ptr,
 
  Thanks for your email however, I cannot make the code work.
  Errors? What code you tried?
 
  iris$code - iris$Sepal.Width3.5
  plot(iris$Sepal.Length ~ iris$Sepal.Width,
 col=c(red,black)[iris$code+1], pch=c(17, 1)[iris$code+1])
 
  works for me without any problem.
 
  Also, I quite like the ifelse approach. I find it very clean.
  Yes. I mean complicated is your subset approach. You can use ifelse
 if you like.
 
  plot(iris$Sepal.Length ~ iris$Sepal.Width, col=ifelse(iris$code,
 black, red), pch= ifelse(iris$code, 1,17))
 
  Regards
  Petr
 
 
  Cheers
 
 
 
  On 30/05/2014 15:57, PIKAL Petr wrote:
  Hi
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of Beatriz
  Sent: Friday, May 30, 2014 9:37 AM
  To: R Help
  Subject: [R] Scatter plot selection points
 
  Hi all,
 
  I'd like to do a scatterplot where some of the values, out of a
  subset, are plotted differently in color and shape.
  I've worked around the following code but I don't manage to make
 it
  right.
  Any help greatly appreciated!
 
  # My data
  dd - iris
  iris$Code - 1:150
 
  # A selection of my data I'd like to plot differently subset -
  subset(iris, iris$Sepal.Width5)
  max(iris$Sepal.Width)
  [1] 4.4
  No values out of subset. So I changed threshold.
 
  iris$code-iris$Sepal.Width3.5
 
  sel - as.character(subset$Code) # I think the problems start
  already
  here :)
 
  # Plotting doesn't work
  plot(iris$Sepal.Length ~ iris$Sepal.Widith,
  col=ifelse(iris$Code==sel, red, black)
  pch=ifelse(iris$Code==sel, 17, 1))
  Overcomplicated
 
  plot(iris$Sepal.Length ~ iris$Sepal.Width, col=c(red,
  black)[iris$code+1], pch=c(17, 1)[iris$code+1])
 
  Regards
  Petr
 
  __
  R-help@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.
  
  Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a
  jsou určeny pouze jeho adresátům.
  Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě
  neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a
 jeho
  kopie vymažte ze svého systému.
  Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni
 tento
  email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
  Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou
  modifikacemi či zpožděním přenosu e-mailu.
  V případě, že je tento e-mail součástí obchodního jednání:
  - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření
  smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
  - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně
  přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí
 nabídky
  ze strany příjemce s dodatkem či odchylkou.
  - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve
  výslovným dosažením shody na všech jejích náležitostech.
  - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za
  společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně
  zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly
  adresátovi tohoto emailu případně osobě, kterou adresát zastupuje,
  předloženy nebo jejich existence je adresátovi či osobě jím
 zastoupené
  známá.
  This e-mail and any documents attached to it may be confidential
 and
  are intended only for its

[R] scatter plot to continuous plot

2014-02-24 Thread azam jaafari

Hello All

I want to convert a scatter plot to a continuous contour plot. I have x as a 
variable and y as another variable. 
is there any package for this?
can anybody halp me? 

Thanks



On Sun, 2/23/14, r-help-requ...@r-project.org r-help-requ...@r-project.org 
wrote:

 Subject: R-help Digest, Vol 132, Issue 23
 To: r-help@r-project.org
 Date: Sunday, February 23, 2014, 3:00 AM

 Send R-help mailing list submissions
 to
     r-help@r-project.org

 To subscribe or unsubscribe via the World Wide Web, visit
     https://stat.ethz.ch/mailman/listinfo/r-help
 or, via email, send a message with subject or body 'help'
 to
     r-help-requ...@r-project.org

 You can reach the person managing the list at
     r-help-ow...@r-project.org

 When replying, please edit your Subject line so it is more
 specific
 than Re: Contents of R-help digest...


 Today's Topics:

    1. Math symbols in ggplot facets (Lars
 Bishop)
    2. Re: dependent column(s) in data frame
 (PQuery)
    3. Exposures in bernoulli glm() (Marco
 Inacio)
    4. Learn R in a Day - new ebook (Steve
 Murray)
    5. Hi everybody, your help would be very
[[elided Yahoo spam]]
       (varin sacha)
    6. hist: argument '...' is not made use of
 (Jennifer Lyon)
    7. create video? (Spencer Graves)
    8. Re: how to plot a logarithmic
 regression line (arun)
    9. Re: dependent column(s) in data frame
 (David Winsemius)
   10. Re: how to plot a logarithmic regression line
 (David Winsemius)
   11. Re: Math symbols in ggplot facets (Dennis
 Murphy)
   12. equivalent of $\check Y$ in plotmath (Ranjan
 Maitra)
   13. seeking alternative method to copy a large
 section of my R
       program (Julie Royster)
   14. Re: seeking alternative method to copy a large
 section of my
       R    program (Jeff
 Newmiller)
   15. Re: seeking alternative method to copy a large
 section of my
       R    program (David
 Winsemius)


 --

 Message: 1
 Date: Sat, 22 Feb 2014 12:24:13 +0100
 From: Lars Bishop lars...@gmail.com
 To: r-help@r-project.org
 r-help@r-project.org
 Subject: [R] Math symbols in ggplot facets
 Message-ID:
     cao7omoila2obmgz3mtqcsgv8qzhghr52wkueqwq7qohnbp7...@mail.gmail.com
 Content-Type: text/plain

 Hello,

 I would like to show in my facet labels the equivalent in
 LaTex of
 $\sigma_{0}= \sqrt{2}$. I think I'm close below, but not yet
 as it shows
 $(\sigma_{0}, \sqrt{2})$

 m - mpg
 levels(m$drv) - c(sigma[0]=sqrt(2), sigma[0]=2 *
 sqrt(2), sigma[0]= 3
 * sqrt(2))

 ggplot(m, aes(x = displ, y = cty)) + geom_point() +
   facet_grid(. ~ drv, labeller = label_parsed)


 Thanks,
 Lars.

     [[alternative HTML version deleted]]



 --

 Message: 2
 Date: Sat, 22 Feb 2014 04:28:03 -0800 (PST)
 From: PQuery pierre.khoue...@embl.de
 To: r-help@r-project.org
 Subject: Re: [R] dependent column(s) in data frame
 Message-ID: 1393072083649-4685684.p...@n4.nabble.com
 Content-Type: text/plain; charset=us-ascii

 Many thanks David,

 I will have a look on logistic regression for my case.
 Do you know about a good example regarding logistic
 regression ?
 I was thinking also of using Multiple Factor Analysis too
 (MFA - like in
 FactoMineR). However I am not sure how successful this is
 going to be.

 Best,
 P.




 --
 View this message in context: 
http://r.789695.n4.nabble.com/dependent-column-s-in-data-frame-tp4685561p4685684.html
 Sent from the R help mailing list archive at Nabble.com.



 --

 Message: 3
 Date: Sat, 22 Feb 2014 11:29:56 -0300
 From: Marco Inacio marcoigarap...@gmail.com
 To: R help r-help@r-project.org
 Subject: [R] Exposures in bernoulli glm()
 Message-ID: 5308b464.7010...@gmail.com
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed

 Hi, is it possible to add exposures to a glm with
 family=binomial()?

 It's easy to do it for a Poisson/negative binomial: just
 multiply the 
 mean by the exposure, that is, offset(log(exposure)): but
 this obviously 
 wrong for a binomial/Bernoulli since the mean must be no
 bigger than 1.

 My goal was do it it with pscl::zeroinfl and pscl::hurdle,
 but answering 
 for binomial/Bernoulli would already help.



 --

 Message: 4
 Date: Sat, 22 Feb 2014 15:48:44 +
 From: Steve Murray smurray...@hotmail.com
 To: r-help@r-project.org
 r-help@r-project.org
 Subject: [R] Learn R in a Day - new ebook
 Message-ID: dub115-w46569916eec0d272530cbd88...@phx.gbl
 Content-Type: text/plain

 Dear all,
  
 I'd like to make you aware of my new ebook - Learn R in a
 Day - which
 provides the reader with key programming skills through an
 examples-oriented
 approach and is ideally suited for academics, scientists,
 mathematicians and
 engineers.
  
 Amazon.com: 
 
http://www.amazon.com/Learn-R-Day-Steven-Murray-ebook/dp/B00GC2LKOK/ref=sr_1_1?s=digital-textie=UTF8qid=1393005750sr=1-1keywords=learn+r+in+a+day
  

[R] scatter plot to contour plot

2014-02-24 Thread azam jaafari

Dear All

I want to convert a scatter plot to a continuous contour plot. I have x as a 
variable and y as another variable. 
is there any package for this?
can anybody halp me? 

Thanks
Azam 
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] scatter plot to contour plot

2014-02-24 Thread Duncan Murdoch

On 24/02/2014 12:45 PM, azam jaafari wrote:

Dear All

I want to convert a scatter plot to a continuous contour plot. I have x as a variable 
and y as another variable.
is there any package for this?
can anybody halp me?


A contour plot of values associated with the points, or a contour plot 
of the density of the points?  For the former, I think you want to use 
the akima package; for the density estimate, you could use kde2d from 
the MASS package.


In either case, you need to compute the values of the function on a 
grid, then the contour() function can plot it.


Duncan Murdoch

__
R-help@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.


Re: [R] scatter plot to contour plot

2014-02-24 Thread Clint Bowman

Azam,

If you also have z ~ f(x,y) you can produce contours.

Otherwise, you could look at package hexbin.

Clint

Clint BowmanINTERNET:   cl...@ecy.wa.gov
Air Quality Modeler INTERNET:   cl...@math.utah.edu
Department of Ecology   VOICE:  (360) 407-6815
PO Box 47600FAX:(360) 407-7534
Olympia, WA 98504-7600

USPS:   PO Box 47600, Olympia, WA 98504-7600
Parcels:300 Desmond Drive, Lacey, WA 98503-1274

On Mon, 24 Feb 2014, azam jaafari wrote:



Dear All

I want to convert a scatter plot to a continuous contour plot. I have x as a variable 
and y as another variable.
is there any package for this?
can anybody halp me?

Thanks
Azam
[[alternative HTML version deleted]]

__
R-help@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.



__
R-help@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.


Re: [R] scatter plot to contour plot

2014-02-24 Thread MacQueen, Don
In addition to the other responses, I'd like to suggest:

  help.search('contour', package='graphics')

Since the graphics package comes with R, you don't necessarily need any
additional package for contouring. But you will need the akima package for
interpolation. Assuming you're doing a contour plot of values associated
with the points, as Duncan put it.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 2/24/14 9:45 AM, azam jaafari azamjaaf...@yahoo.com wrote:


Dear All

I want to convert a scatter plot to a continuous contour plot. I have x
as a variable and y as another variable.
is there any package for this?
can anybody halp me?

Thanks
Azam 
   [[alternative HTML version deleted]]

__
R-help@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.

__
R-help@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.


Re: [R] Scatter plot with error bars

2013-06-28 Thread Blaser Nello
Are you sure, you want to calculate 68% confidence intervals? 

Use the add-argument in ?errorbar to add to the previous plot.
errbar(x2,y2,y2+1.96*SD2, y2-1.96*SD2, col=green,pch=19, add=TRUE)

Best, 
Nello

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of beginner
Sent: Freitag, 28. Juni 2013 02:24
To: r-help@r-project.org
Subject: [R] Scatter plot with error bars

Hi

I would like to plot multiple data sets on a scatter plot with error
bars.
To do this I write the following code:

install.packages(Hmisc)
library(Hmisc)

x1-data1[,1]
y1-data1[,2]
x2-data2[,1]
y2-data2[,2]
x3-data3[,1]
y3-data3[,2]

SD1-data1[,3]
SD2-data2[,3]
SD3-data3[,4]

delta-runif(5)
errbar(x1,y1,y1+SD1, y1-SD1, col=red,pch=19) lines(x1,y1,col=red,
pch=19, lty=3) errbar(x2,y2,y2+SD2, y2-SD2, col=green,pch=19)
lines(x2,y2,col=green, pch=19, lty=3) errbar(x3,y3,y3+SD3, y3-SD3,
col=blue,pch=19) lines(x3,y3,col=blue, pch=19, lty=3)

However, with this code I can obtain only the scatter plot for x1, y1,
but not for the other data sets. Could you please let me know how should
I modify the code presented above ?

In other situations, when I try to make a scatter plot of several data
sets without error bars, I usually use points () function. 
However it does not work in the presented case... 

I would be very grateful for your help. 



--
View this message in context:
http://r.789695.n4.nabble.com/Scatter-plot-with-error-bars-tp4670502.htm
l
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.

__
R-help@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.


Re: [R] Scatter plot with error bars

2013-06-28 Thread beginner
Thank you very much for your help !



--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-with-error-bars-tp4670502p4670530.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] Scatter plot with error bars

2013-06-27 Thread beginner
Hi

I would like to plot multiple data sets on a scatter plot with error bars.
To do this I write the following code:

install.packages(Hmisc)
library(Hmisc)

x1-data1[,1]
y1-data1[,2]
x2-data2[,1]
y2-data2[,2]
x3-data3[,1]
y3-data3[,2]

SD1-data1[,3]
SD2-data2[,3]
SD3-data3[,4]

delta-runif(5)
errbar(x1,y1,y1+SD1, y1-SD1, col=red,pch=19)
lines(x1,y1,col=red, pch=19, lty=3)
errbar(x2,y2,y2+SD2, y2-SD2, col=green,pch=19)
lines(x2,y2,col=green, pch=19, lty=3)
errbar(x3,y3,y3+SD3, y3-SD3, col=blue,pch=19)
lines(x3,y3,col=blue, pch=19, lty=3)

However, with this code I can obtain only the scatter plot for x1, y1, but
not for the other data sets. Could you please let me know how should I
modify the code presented above ?

In other situations, when I try to make a scatter plot of several data sets
without error bars, I usually use points () function. 
However it does not work in the presented case... 

I would be very grateful for your help. 



--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-with-error-bars-tp4670502.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] scatter plot matrix with different x-y variables

2013-05-13 Thread adel daoud
Greg, the pairs2 function was exactly what I wanted. Thanks for a very
useful function. May I ask a follow up question, is it possible to draw a
correlation line with R2 values for each graph – on each graph, or on the
side of the graph. I am sure this is possible somehow, but I am new to R
programming so please just direct me into the right direction.



John, the grid.arrange() function is useful too but not exactly what I
needed. Thanks any way.



Best



Adel


On Sat, May 11, 2013 at 4:52 PM, Greg Snow 538...@gmail.com wrote:

 The pairs2 function in the TeachingDemos package does what you describe.
  You give it 2 matricies instead of just one and it creates the plots.


 On Wed, May 8, 2013 at 10:49 AM, Adel adelda...@gmail.com wrote:

 Dear list-members,

 I wonder if there is a way of creating a scatter plot table/grid with
 different variables on the y-axis compared to the x-axis? Something like
 this:

  A***
 B***
 C***
 -XYZ


 I know that you can create scatter plot matrix with the same variables on
 the
 y-axis as on the x-axis, like this:



 A*
 *B
 **C***
 ***X**
 Y*
 *Z

 But this is not what I want. I basically want to get a visual
 representation of different dependent variables (y-axis) on various
 independent variables (x-axis). So I want it to look like a scatter plot
 matrix or grid, but with my own specified variables on each axis.

 Secondly, to add to this, can I add a correlation line (linear and
 quadratic)
 through all scatter plots with both correlation and R2 values?


 All help appreciated.

 Adel

 --
 Adel Daoud, PhD
 Department of Sociology,  University of Gothenburg
 Box 720
 405 30 Göteborg, SWEDEN
 Visiting address: Sprängkullsgatan 25, room F411
 +46 031-786 47 84
 adel.da...@sociology.gu.se




 --
 View this message in context:
 http://r.789695.n4.nabble.com/scatter-plot-matrix-with-different-x-y-variables-tp4666598.html
 Sent from the R help mailing list archive at Nabble.com.
 [[alternative HTML version deleted]]


 __
 R-help@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.




 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com




-- 
Adel Daoud, PhD
Department of Sociology,  University of Gothenburg
Box 720
405 30 Göteborg, SWEDEN
Visiting address: Sprängkullsgatan 25, room F411
+46 031-786 47 84
adel.da...@sociology.gu.se

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] scatter plot matrix with different x-y variables

2013-05-11 Thread Greg Snow
The pairs2 function in the TeachingDemos package does what you describe.
 You give it 2 matricies instead of just one and it creates the plots.


On Wed, May 8, 2013 at 10:49 AM, Adel adelda...@gmail.com wrote:

 Dear list-members,

 I wonder if there is a way of creating a scatter plot table/grid with
 different variables on the y-axis compared to the x-axis? Something like
 this:

  A***
 B***
 C***
 -XYZ


 I know that you can create scatter plot matrix with the same variables on
 the
 y-axis as on the x-axis, like this:



 A*
 *B
 **C***
 ***X**
 Y*
 *Z

 But this is not what I want. I basically want to get a visual
 representation of different dependent variables (y-axis) on various
 independent variables (x-axis). So I want it to look like a scatter plot
 matrix or grid, but with my own specified variables on each axis.

 Secondly, to add to this, can I add a correlation line (linear and
 quadratic)
 through all scatter plots with both correlation and R2 values?


 All help appreciated.

 Adel

 --
 Adel Daoud, PhD
 Department of Sociology,  University of Gothenburg
 Box 720
 405 30 Göteborg, SWEDEN
 Visiting address: Sprängkullsgatan 25, room F411
 +46 031-786 47 84
 adel.da...@sociology.gu.se




 --
 View this message in context:
 http://r.789695.n4.nabble.com/scatter-plot-matrix-with-different-x-y-variables-tp4666598.html
 Sent from the R help mailing list archive at Nabble.com.
 [[alternative HTML version deleted]]


 __
 R-help@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.




-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

__
R-help@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.


[R] scatter plot matrix with different x-y variables

2013-05-08 Thread Adel
Dear list-members,

I wonder if there is a way of creating a scatter plot table/grid with
different variables on the y-axis compared to the x-axis? Something like
this:

 A***
B***
C***
-XYZ


I know that you can create scatter plot matrix with the same variables on
the
y-axis as on the x-axis, like this:



A*
*B
**C***
***X**
Y*
*Z

But this is not what I want. I basically want to get a visual
representation of different dependent variables (y-axis) on various
independent variables (x-axis). So I want it to look like a scatter plot
matrix or grid, but with my own specified variables on each axis.

Secondly, to add to this, can I add a correlation line (linear and
quadratic)
through all scatter plots with both correlation and R2 values?


All help appreciated.

Adel

-- 
Adel Daoud, PhD
Department of Sociology,  University of Gothenburg
Box 720
405 30 Göteborg, SWEDEN
Visiting address: Sprängkullsgatan 25, room F411
+46 031-786 47 84
adel.da...@sociology.gu.se




--
View this message in context: 
http://r.789695.n4.nabble.com/scatter-plot-matrix-with-different-x-y-variables-tp4666598.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] scatter plot matrix with different x-y variables

2013-05-08 Thread John Kane
Several ways but I find that grid.arrange in the  gridExtra package combined 
with ggplot2 to draw the actual graphs works nicely.

You might also want to look mfcol or mfrow in ?par 

### quick and dirty example of ggplot2/gridExtra

library(ggplot2)
library(gridExtra)

mdat  -  data.frame(a= 1:5, b=1:5)
ndat  -  data.frame(x = rnorm(20), y =  rnorm(20))
p  -  ggplot(mdat  , aes(a,b, colour = 'red'   )) + geom_point() +
theme(legend.position=none)
  

p 
q  -  ggplot(ndat , aes( x, y  )) + geom_line() 
q

grid.arrange(p, q)
###  
I imagine that you will need to install the ggplot2 and gridExtra packages. See 
?install.packages for help
John Kane
Kingston ON Canada


 -Original Message-
 From: adelda...@gmail.com
 Sent: Wed, 8 May 2013 09:49:25 -0700 (PDT)
 To: r-help@r-project.org
 Subject: [R] scatter plot matrix with different x-y variables
 
 Dear list-members,
 
 I wonder if there is a way of creating a scatter plot table/grid with
 different variables on the y-axis compared to the x-axis? Something like
 this:
 
  A***
 B***
 C***
 -XYZ
 
 
 I know that you can create scatter plot matrix with the same variables on
 the
 y-axis as on the x-axis, like this:
 
 
 
 A*
 *B
 **C***
 ***X**
 Y*
 *Z
 
 But this is not what I want. I basically want to get a visual
 representation of different dependent variables (y-axis) on various
 independent variables (x-axis). So I want it to look like a scatter plot
 matrix or grid, but with my own specified variables on each axis.
 
 Secondly, to add to this, can I add a correlation line (linear and
 quadratic)
 through all scatter plots with both correlation and R2 values?
 
 
 All help appreciated.
 
 Adel
 
 --
 Adel Daoud, PhD
 Department of Sociology,  University of Gothenburg
 Box 720
 405 30 GC6teborg, SWEDEN
 Visiting address: SprC$ngkullsgatan 25, room F411
 +46 031-786 47 84
 adel.da...@sociology.gu.se
 
 
 
 
 --
 View this message in context:
 http://r.789695.n4.nabble.com/scatter-plot-matrix-with-different-x-y-variables-tp4666598.html
 Sent from the R help mailing list archive at Nabble.com.
   [[alternative HTML version deleted]]
 
 __
 R-help@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.


FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!

__
R-help@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.


Re: [R] Scatter plot from tapply output, labels of data

2012-09-04 Thread Jean V Adams
Try this:

# I created some example data
mydf - data.frame(
Species=sample(paste0(Species, 1:3), 50, TRUE), 
d13C=15+rnorm(50), 
d15N=15+rnorm(50), 
Year=sample(2009:2012, 50, TRUE))
attach(mydf)
Nmean - tapply(d15N, list(Year,Species), mean)
Cmean - tapply(d13C, list(Year,Species), mean)
detach(mydf)

# create an empty plot first with the correct x and y limits on the axes
plot(1, 1, xlim=range(Cmean), ylim=range(Nmean), type=n, 
xlab=Cmean, ylab=Nmean, 
main=Color indicates year, symbol indicates species)
# then add text for species, coloring by year
# convert the matrices to vectors before plotting
# use the col() and row() functions to get column (species)
#   and row (year) indicators
text(as.vector(Cmean), as.vector(Nmean), 
dimnames(Cmean)[[2]][col(Cmean)], 
col=c(green, black, red, blue)[row(Cmean)]) 

Jean


monaR mfu...@uit.no wrote on 09/03/2012 12:33:20 PM:
 
 Hei,
 i am trying to plot the means of two variables (d13C and d15N), by 2
 grouping factors (Species and Year) that i obtained by the function 
tapply.
 I would like to plot with different colours according to the Year and 
show
 the Species as data labels.
 My data looks like this:
 
 Species  d13Cd13NYear
 Species114,4   11.5 2009
 Species2   ......   
 
 Nmean-tapply(d15N,list(Year,Species),mean)
 Cmean-tapply(d13C,list(Year,Species),mean) 
 
 ##works fine, returns something like this
 
   Species1 Species2 Species3
 2009 20.3  13.4 13,5
 2011 NA 23.5 14.5
 2012 11.3   NA23.4
 
 plot(Cmean,Nmean,col=c(green,red,blue),)
 
 #works fine, gives a plot with data points coloured by Year
 
 text(Cmean,Nmean,labels=levels(Species),cex=.7,adj=c(-.1,-.6))
 
 #does not work, mixes up the labels, have tried 
Species-as.factor(Species)
 and switched tapply(d15N,list(Year,Species),mean)
 to--tapply(d15N,list(Species,Year),mean) which gives the Years as 
column
 names but does not produce a better plot. The
 
 I cannot find the error, any idea what i am doing wrong
 Thanks sooo much

[[alternative HTML version deleted]]

__
R-help@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.


[R] Scatter plot from tapply output, labels of data

2012-09-03 Thread monaR
Hei,
i am trying to plot the means of two variables (d13C and d15N), by 2
grouping factors (Species and Year) that i obtained by the function tapply.
I would like to plot with different colours according to the Year and show
the Species as data labels.
My data looks like this:

Species  d13Cd13NYear
Species114,4   11.5 2009
Species2   ......   

Nmean-tapply(d15N,list(Year,Species),mean)
Cmean-tapply(d13C,list(Year,Species),mean) 

##works fine, returns something like this

  Species1 Species2 Species3
2009 20.3  13.4 13,5
2011 NA 23.5 14.5
2012 11.3   NA23.4

plot(Cmean,Nmean,col=c(green,red,blue),)

#works fine, gives a plot with data points coloured by Year

text(Cmean,Nmean,labels=levels(Species),cex=.7,adj=c(-.1,-.6))

#does not work, mixes up the labels, have tried Species-as.factor(Species)
and switched tapply(d15N,list(Year,Species),mean)
to--tapply(d15N,list(Species,Year),mean) which gives the Years as column
names but does not produce a better plot. The

I cannot find the error, any idea what i am doing wrong
Thanks sooo much



--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-from-tapply-output-labels-of-data-tp4642077.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-30 Thread David Doyle
First let me say thank you for all the help everyone gave me.

Below is the code I came up with to look at Rainfall pH reading for
Kentucky and Tennessee.

Also there is a more *generic* ver of the code on my web page if anybody
ever needs it in the future.
http://sites.google.com/site/davidsstatistics/using-r/smoothing-curveshttps://sites.google.com/site/davidsstatistics/using-r/smoothing-curves

Thanks again
David
-


#Load your data.
data - read.csv(http://www.doylesdartden.com/R/2000-2011_ph_data.csv;,
sep=,)
attach(data)

#Plots the Y and X axis
plot( Year, MF,

#sets the range of the y axis
ylim=range(4.5,5.2),

#sets the symbol type, size, and color for the 1st series
pch=20,cex=0.0, col='black', xlab=Year , ylab=pH)

#Plots the second series
points( Year, HNWR,
#sets the symbol type, size, and color for the 2nd series
col='blue',pch=20, cex=0.0)

#Plots the 3rd series
points( Year, MCNP,
#sets the symbol type, size, and color for the 3rd series
col='red',pch=20, cex=0.0)

#Plots the 4th series
points( Year, Mackville,
#sets the symbol type, size, and color for the 4th series
col='forestgreen',pch=20, cex=0.0)

#Plots the 5th series
points( Year, GSM,
#sets the symbol type, size, and color for the 5th series
col='purple',pch=20, cex=0.0)



#draw the smooth lines.  NOTE-the span will adjust how much it is smooth
lines( loess.smooth(Year,MF, span = 0.6),col='black', lwd=4, lty=1)

lines( loess.smooth(Year,HNWR, span = 0.6),col='blue',lwd=4, lty=2)

lines( loess.smooth(Year,MCNP, span = 0.6),col='red',lwd=4, lty=3)

lines( loess.smooth(Year,Mackville, span = 0.6),col='forestgreen',lwd=3,
lty=4)

lines( loess.smooth(Year,GSM, span = 0.6),col='purple',lwd=3, lty=5)



#Add Legend to graph.  You can change the size of the box by changing cex =
0.75  Large # makes it larger.
legend(topleft,c(Mulberry Flat KY,Hatchie National Wildlife Refuge
TN, Mammoth Cave Nat Park, Mackville KY,  Great Smokies Mount Nat
Park),
col = c(black,blue, red, forestgreen,purple, orange,
limegreen, gray49, yellow),
cex = 0.9,text.col = black,lty = c(1,2,3,4,5),lwd=c(3),pch = c(-1),
merge = TRUE, bg = 'gray90')


#Add title
title(main=Rainfall pH
Locally Weighted Scatterplot Smoothing Curve)
#done

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-25 Thread Greg Snow
You can also use range( MC.pH, MV.pH, na.rm=TRUE).

On Tue, Apr 24, 2012 at 1:29 PM, David Doyle kydaviddo...@gmail.com wrote:
 Hi Greg,

 Sloved my own problem.

 I had some missing data NA in the datasets.  So I manually entered the
 ylim=range(4,6)
 and it worked!!!

 Thanks!!
 David


 On Tue, Apr 24, 2012 at 1:55 PM, David Doyle kydaviddo...@gmail.com wrote:

 Hi Greg,

 Thanks,

 I got the 1st example to work using the following code:


 data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;,
 sep=,)

 attach(data)

 par(mfrow=c(2,1))
 scatter.smooth( Year, MC.pH )
 scatter.smooth( Year, MV.pH )


 This is good but what I'm really looking for is to have them on the same
 graph.


 I tried your second example using the code below but got:

 Error in plot.window(...) : need finite 'ylim' values

 here is the code I used


 data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;,
 sep=,)

 attach(data)


 plot( Year, MC.pH, ylim=range(MC.pH,MV.pH) , col='blue')

 points( Year, MV.pH, col='green' )

 lines( loess.smooth(Year,MC.pH), col='blue')

 lines( loess.smooth(Year,MV.pH), col='green')


 Thanks again

 David



 On Tue, Apr 24, 2012 at 1:45 PM, Greg Snow 538...@gmail.com wrote:

 Assuming that you want event as the x-axis (horizontal) you can do
 something like (untested without reproducible data):

 par(mfrow=c(2,1))
 scatter.smooth( event, pH1 )
 scatter.smooth( event, pH2 )

 or

 plot( event, pH1, ylim=range(pH1,pH2) , col='blue')
 points( event, pH2, col='green' )
 lines( loess.smooth(event,pH1), col='blue')
 lines( loess.smooth(event,pH2), col='green')

 Only do the second one if pH1 and pH2 are measured on the same scale
 in a way that the comparison and any crossings are meaningful or if
 there is enough separation (but not too much) that there is no
 overlap, but still enough detail.



 On Mon, Apr 23, 2012 at 10:40 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
  The scatter plot is easy:
 
  plot(pH1 ~ pH2, data = OBJ)
 
  When you say a loess for each -- how do you break them up? Are there
  repeat values for pH1? If so, this might be hard to do in base
  graphics, but ggplot2 would make it easy:
 
  library(ggplot2)
  ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() + stat_smooth() +
  facet_wrap(~factor(pH1))
 
  or something similar.
 
  Michael
 
  On Mon, Apr 23, 2012 at 11:26 PM, David Doyle kydaviddo...@gmail.com
  wrote:
  Hi folks.
 
  If I have the following in my data
 
  event    pH1    pH2
  1            4.0     6.0
  2            4.3     5.9
  3            4.1     6.1
  4            4.0     5.9
  and on and on. for about 400 events
 
  Is there a way I can get R to plot event vs. pH1  and event vs. pH2
  and
  then do a loess or lowess line for each??
 
  Thanks in advance
  David
 
         [[alternative HTML version deleted]]
 
  __
  R-help@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.
 
  __
  R-help@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.



 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com






-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

__
R-help@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.


Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-24 Thread Greg Snow
Assuming that you want event as the x-axis (horizontal) you can do
something like (untested without reproducible data):

par(mfrow=c(2,1))
scatter.smooth( event, pH1 )
scatter.smooth( event, pH2 )

or

plot( event, pH1, ylim=range(pH1,pH2) , col='blue')
points( event, pH2, col='green' )
lines( loess.smooth(event,pH1), col='blue')
lines( loess.smooth(event,pH2), col='green')

Only do the second one if pH1 and pH2 are measured on the same scale
in a way that the comparison and any crossings are meaningful or if
there is enough separation (but not too much) that there is no
overlap, but still enough detail.



On Mon, Apr 23, 2012 at 10:40 PM, R. Michael Weylandt
michael.weyla...@gmail.com wrote:
 The scatter plot is easy:

 plot(pH1 ~ pH2, data = OBJ)

 When you say a loess for each -- how do you break them up? Are there
 repeat values for pH1? If so, this might be hard to do in base
 graphics, but ggplot2 would make it easy:

 library(ggplot2)
 ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() + stat_smooth() +
 facet_wrap(~factor(pH1))

 or something similar.

 Michael

 On Mon, Apr 23, 2012 at 11:26 PM, David Doyle kydaviddo...@gmail.com wrote:
 Hi folks.

 If I have the following in my data

 event    pH1    pH2
 1            4.0     6.0
 2            4.3     5.9
 3            4.1     6.1
 4            4.0     5.9
 and on and on. for about 400 events

 Is there a way I can get R to plot event vs. pH1  and event vs. pH2 and
 then do a loess or lowess line for each??

 Thanks in advance
 David

        [[alternative HTML version deleted]]

 __
 R-help@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.

 __
 R-help@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.



-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

__
R-help@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.


Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-24 Thread David Doyle
Hi Michael,

What I run into is that I have a lot of time-series data from groundwater
wells but when plot it..it becomes way to busy to see what is going on.

For example, here is the code to load and plot my Mammoth Cave rainfall pH
data

#Load data from web page
data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;, sep=,)
attach(data)

#Plot data
plot(Year,MC.pH,pch=*,col=blue)

# Apply loess smoothing
y.loess - loess(y ~ x, span=0.8, data.frame(x=Year, y=MC.pH))

# Compute loess smoothed values for all points along the curve
y.predict - predict(y.loess, data.frame(x=Year))

# Plots the curve.
lines(Year,y.predict,lwd=3,col=blue)

#Done

What I would like to do is to have it plot the MC.pH data vs. year and the
MV.pH vs. year data and then draw two different smoothed lines for the
data.  This way I could really just look at the two smoothed lines and see
how the data is trending in relationship to each other.

Thanks
David


On Mon, Apr 23, 2012 at 11:40 PM, R. Michael Weylandt 
michael.weyla...@gmail.com wrote:

 The scatter plot is easy:

 plot(pH1 ~ pH2, data = OBJ)

 When you say a loess for each -- how do you break them up? Are there
 repeat values for pH1? If so, this might be hard to do in base
 graphics, but ggplot2 would make it easy:

 library(ggplot2)
 ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() + stat_smooth() +
 facet_wrap(~factor(pH1))

 or something similar.

 Michael

 On Mon, Apr 23, 2012 at 11:26 PM, David Doyle kydaviddo...@gmail.com
 wrote:
  Hi folks.
 
  If I have the following in my data
 
  eventpH1pH2
  14.0 6.0
  24.3 5.9
  34.1 6.1
  44.0 5.9
  and on and on. for about 400 events
 
  Is there a way I can get R to plot event vs. pH1  and event vs. pH2 and
  then do a loess or lowess line for each??
 
  Thanks in advance
  David
 
 [[alternative HTML version deleted]]
 
  __
  R-help@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.


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-24 Thread David Doyle
Hi Greg,

Thanks,

I got the 1st example to work using the following code:


data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;, sep=,)

attach(data)

par(mfrow=c(2,1))
scatter.smooth( Year, MC.pH )
scatter.smooth( Year, MV.pH )


This is good but what I'm really looking for is to have them on the same
graph.


I tried your second example using the code below but got:

Error in plot.window(...) : need finite 'ylim' values

here is the code I used


data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;, sep=,)

attach(data)


plot( Year, MC.pH, ylim=range(MC.pH,MV.pH) , col='blue')

points( Year, MV.pH, col='green' )

lines( loess.smooth(Year,MC.pH), col='blue')

lines( loess.smooth(Year,MV.pH), col='green')


Thanks again

David


On Tue, Apr 24, 2012 at 1:45 PM, Greg Snow 538...@gmail.com wrote:

 Assuming that you want event as the x-axis (horizontal) you can do
 something like (untested without reproducible data):

 par(mfrow=c(2,1))
 scatter.smooth( event, pH1 )
 scatter.smooth( event, pH2 )

 or

 plot( event, pH1, ylim=range(pH1,pH2) , col='blue')
 points( event, pH2, col='green' )
 lines( loess.smooth(event,pH1), col='blue')
 lines( loess.smooth(event,pH2), col='green')

 Only do the second one if pH1 and pH2 are measured on the same scale
 in a way that the comparison and any crossings are meaningful or if
 there is enough separation (but not too much) that there is no
 overlap, but still enough detail.



 On Mon, Apr 23, 2012 at 10:40 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
  The scatter plot is easy:
 
  plot(pH1 ~ pH2, data = OBJ)
 
  When you say a loess for each -- how do you break them up? Are there
  repeat values for pH1? If so, this might be hard to do in base
  graphics, but ggplot2 would make it easy:
 
  library(ggplot2)
  ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() + stat_smooth() +
  facet_wrap(~factor(pH1))
 
  or something similar.
 
  Michael
 
  On Mon, Apr 23, 2012 at 11:26 PM, David Doyle kydaviddo...@gmail.com
 wrote:
  Hi folks.
 
  If I have the following in my data
 
  eventpH1pH2
  14.0 6.0
  24.3 5.9
  34.1 6.1
  44.0 5.9
  and on and on. for about 400 events
 
  Is there a way I can get R to plot event vs. pH1  and event vs. pH2 and
  then do a loess or lowess line for each??
 
  Thanks in advance
  David
 
 [[alternative HTML version deleted]]
 
  __
  R-help@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.
 
  __
  R-help@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.



 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-24 Thread David Doyle
Hi Greg,

Sloved my own problem.

I had some missing data NA in the datasets.  So I manually entered the
ylim=range(4,6)
and it worked!!!

Thanks!!
David

On Tue, Apr 24, 2012 at 1:55 PM, David Doyle kydaviddo...@gmail.com wrote:

 Hi Greg,

 Thanks,

 I got the 1st example to work using the following code:


 data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;,
 sep=,)

 attach(data)

 par(mfrow=c(2,1))
 scatter.smooth( Year, MC.pH )
 scatter.smooth( Year, MV.pH )


 This is good but what I'm really looking for is to have them on the same
 graph.


 I tried your second example using the code below but got:

 Error in plot.window(...) : need finite 'ylim' values

 here is the code I used


 data - read.csv(http://doylesdartden.com/Monthly-pH-example.csv;,
 sep=,)

 attach(data)


 plot( Year, MC.pH, ylim=range(MC.pH,MV.pH) , col='blue')

 points( Year, MV.pH, col='green' )

 lines( loess.smooth(Year,MC.pH), col='blue')

 lines( loess.smooth(Year,MV.pH), col='green')


 Thanks again

 David


 On Tue, Apr 24, 2012 at 1:45 PM, Greg Snow 538...@gmail.com wrote:

 Assuming that you want event as the x-axis (horizontal) you can do
 something like (untested without reproducible data):

 par(mfrow=c(2,1))
 scatter.smooth( event, pH1 )
 scatter.smooth( event, pH2 )

 or

 plot( event, pH1, ylim=range(pH1,pH2) , col='blue')
 points( event, pH2, col='green' )
 lines( loess.smooth(event,pH1), col='blue')
 lines( loess.smooth(event,pH2), col='green')

 Only do the second one if pH1 and pH2 are measured on the same scale
 in a way that the comparison and any crossings are meaningful or if
 there is enough separation (but not too much) that there is no
 overlap, but still enough detail.



 On Mon, Apr 23, 2012 at 10:40 PM, R. Michael Weylandt
 michael.weyla...@gmail.com wrote:
  The scatter plot is easy:
 
  plot(pH1 ~ pH2, data = OBJ)
 
  When you say a loess for each -- how do you break them up? Are there
  repeat values for pH1? If so, this might be hard to do in base
  graphics, but ggplot2 would make it easy:
 
  library(ggplot2)
  ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() + stat_smooth() +
  facet_wrap(~factor(pH1))
 
  or something similar.
 
  Michael
 
  On Mon, Apr 23, 2012 at 11:26 PM, David Doyle kydaviddo...@gmail.com
 wrote:
  Hi folks.
 
  If I have the following in my data
 
  eventpH1pH2
  14.0 6.0
  24.3 5.9
  34.1 6.1
  44.0 5.9
  and on and on. for about 400 events
 
  Is there a way I can get R to plot event vs. pH1  and event vs. pH2 and
  then do a loess or lowess line for each??
 
  Thanks in advance
  David
 
 [[alternative HTML version deleted]]
 
  __
  R-help@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.
 
  __
  R-help@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.



 --
 Gregory (Greg) L. Snow Ph.D.
 538...@gmail.com




[[alternative HTML version deleted]]

__
R-help@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.


[R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-23 Thread David Doyle
Hi folks.

If I have the following in my data

eventpH1pH2
14.0 6.0
24.3 5.9
34.1 6.1
44.0 5.9
and on and on. for about 400 events

Is there a way I can get R to plot event vs. pH1  and event vs. pH2 and
then do a loess or lowess line for each??

Thanks in advance
David

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot / LOESS, or LOWESS for more than one parameter

2012-04-23 Thread R. Michael Weylandt
The scatter plot is easy:

plot(pH1 ~ pH2, data = OBJ)

When you say a loess for each -- how do you break them up? Are there
repeat values for pH1? If so, this might be hard to do in base
graphics, but ggplot2 would make it easy:

library(ggplot2)
ggplot(OBJ, aes(x = pH1, y = pH2)) + geom_point() + stat_smooth() +
facet_wrap(~factor(pH1))

or something similar.

Michael

On Mon, Apr 23, 2012 at 11:26 PM, David Doyle kydaviddo...@gmail.com wrote:
 Hi folks.

 If I have the following in my data

 event    pH1    pH2
 1            4.0     6.0
 2            4.3     5.9
 3            4.1     6.1
 4            4.0     5.9
 and on and on. for about 400 events

 Is there a way I can get R to plot event vs. pH1  and event vs. pH2 and
 then do a loess or lowess line for each??

 Thanks in advance
 David

        [[alternative HTML version deleted]]

 __
 R-help@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.

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-23 Thread Ian Robertson

Hello all,

Yesterday I wrote Michael Weylandt to ask for some help in understanding 
a line of code he used responding to SarahH's query about controlling 
colours in scatter plots. He wrote an excellent explanation that 
deserves to be shared here. Below I include the code I wrote while 
experimenting with the problem (indicating the specific line of code I 
asked him about) followed by Michael's thoughtful reply.


Saludos - Ian

--
Ian G. Robertson
Department of Anthropology
Building 50, 450 Serra Mall
Stanford University, CA 94305-2034
e:i...@stanford.edu

#the code:
##
x1 - rnorm(13)
y1 - rnorm(13)

#these two lines from R. Michael Weylandt
X = letters[c(1,2,3,3,1,2,1,3,3,1,2,2,1)]
colX = c(red,green,blue)[as.factor(X)] #?? How does this work? Ask RMW

table(colX)
plot(x1, y1, col=colX, pch=20, cex=2)
##
#Michael Weylandt's explanation:

In short, there are two key bits to follow:

1) What happens when you factorize something -- R stores factors
internally as integers with special labels and a few special behaviors
for some calculations that won't come up here: the labels aren't so
important for our purpose, but the key is that each unique value of X
gets assigned to its own factor. The order that they appear in X
corresponds to the integers they get, not their real values (if they
were already integers or doubles). As a side point this means that
floating point trouble can sometimes show up so if you want to bin
real numbers, it's safer to use cut() for the factoring step.

2) What happens when you use a factor to subset -- R simply tosses out
the factor-ness and only uses the internal integer representation.
If we wanted to be more explicit, we'd write
colVec[as.integer(as.factor(X))] but the as.integer happens
automatically.

So the whole path is: assign integers to each unique value of X and
subset by those integers: if there are as many unique values as there
are elements of the color vector, the end result is a direct matching:
if there are too many, it throws and error: too few and some colors go
unused:

something like:

col(red,green,blue)[as.factor(letters[1:4])] ## ERROR

col(red,green,blue)[as.factor(letters[1:2])] ## blue not used.

Hope this helps,

Michael

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-22 Thread SarahH
Thanks all for suggestions. 

I now have a nice plot showing the temperature of 6 different sites, each
site distinguished by different coloured points, using nested ifelse. My
apologies I thought I could change the type to l and the same arguments
would be applied to line graph, with 6 different lines for each site...? 
I wanted to try lines as I think they might show the trends more clearly.  
I have just found the plottrix package manual and will try that to achieve
this, and look at ggplot too.


--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4095079.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-22 Thread R. Michael Weylandt michael.weyla...@gmail.com
There's also the lines() command which takes a col argument if you want to do 
multiple lines (I usually wind up wrapping it in a for loop though there might 
be something smarter)

ggplot2 is great, though the learning curve is a little rough: you can get good 
help here but if you go down that path, there's also a dedicated ggplot2 list 
that's worth checking out. 

Glad to have you as a new useR!

Michael

On Nov 22, 2011, at 5:13 AM, SarahH sarah@hotmail.co.uk wrote:

 Thanks all for suggestions. 
 
 I now have a nice plot showing the temperature of 6 different sites, each
 site distinguished by different coloured points, using nested ifelse. My
 apologies I thought I could change the type to l and the same arguments
 would be applied to line graph, with 6 different lines for each site...? 
 I wanted to try lines as I think they might show the trends more clearly.  
 I have just found the plottrix package manual and will try that to achieve
 this, and look at ggplot too.
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4095079.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@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.

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-22 Thread SarahH
Success with the lines command and col argument! I have some nice point and
line plots.
Thanks so much for you help. Ongoing project - I will probably be back!

Sarah 

--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4097625.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] Scatter plot - using colour to group points?

2011-11-21 Thread SarahH
Dear All, 

I am very new to R - trying to teach myself it for some MSc coursework. 

I am plotting temperature data for two different sites over the same time
period which I have downloaded from a university weather station data
archive. 

I am using the following code to create the plot

plot ( x = TEMP3[,TIME], y = TEMP3[,TEMP], type = p, col =
TEMP3[,SITE], pch = 3, main = Temperature changes, xlab = Date, ylab =
Temberature[C])

I managed to use col = TEMP3[SITE] to plot the two different sites( BG1
and EA7) in different colours, but I am struggling to change the colours. 

I wanted to up a colour scheme to match the site, so tried 

BG1 - blue
EA7 - green

before the plot function, but the graphic just came out with red and black
as before. 

There are other datasets in which there are more than two sites so I would
really like to learn how to use colour to distinguish between them on a
plot. 

Any direction would be very greatly received!

Thank you very much

Sarah





--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4092794.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread David Winsemius


On Nov 21, 2011, at 2:17 PM, SarahH wrote:


Dear All,

I am very new to R - trying to teach myself it for some MSc  
coursework.


I am plotting temperature data for two different sites over the same  
time

period which I have downloaded from a university weather station data
archive.

I am using the following code to create the plot

plot ( x = TEMP3[,TIME], y = TEMP3[,TEMP], type = p, col =
TEMP3[,SITE], pch = 3, main = Temperature changes, xlab =  
Date, ylab =

Temberature[C])

I managed to use col = TEMP3[SITE] to plot the two different  
sites( BG1
and EA7) in different colours, but I am struggling to change the  
colours.




I wanted to up a colour scheme to match the site, so tried


Instead try

num.site - as.numeric(TEMP3[,SITE])
plot ( x = TEMP3[,TIME], y = TEMP3[,TEMP], type = p, col =
num.site, pch = 3, main = Temperature changes, xlab = Date, ylab =
Temberature[C])

Would create a vector of integer values that are specific to the sites  
and then offere that as argument to col=





BG1 - blue
EA7 - green


That would only have created two new objects by that name (unless of  
course you were following someone's misguided directions to use  
attach().)


before the plot function, but the graphic just came out with red and  
black

as before.

There are other datasets in which there are more than two sites so I  
would
really like to learn how to use colour to distinguish between them  
on a

plot.

Any direction would be very greatly received!

Thank you very much

Sarah





--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4092794.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


David Winsemius, MD
West Hartford, CT

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread R. Michael Weylandt
I think the easiest way to do this is to set up a color vector with
ifelse and hand that off to the plot command: something like

col = ifelse(TEMP3[,SITE] == BG1, blue, green) # Syntax is
ifelse(TEST, OUT_IF_TRUE, OUT_IF_FALSE)

For more complicated schemes, a set of nested ifelse()'s can get you
what you need. There are some other tricks with factors as well, but
they require a little more advanced use of R. Just for the record,
they'd look something like this:

X = letters[c(1,2,3,3,1,2,1,3,3,1,2,2,1)]

colX = c(red,green,blue)[as.factor(X)]

Hope this helps,
Michael

On Mon, Nov 21, 2011 at 2:17 PM, SarahH sarah@hotmail.co.uk wrote:
 Dear All,

 I am very new to R - trying to teach myself it for some MSc coursework.

 I am plotting temperature data for two different sites over the same time
 period which I have downloaded from a university weather station data
 archive.

 I am using the following code to create the plot

 plot ( x = TEMP3[,TIME], y = TEMP3[,TEMP], type = p, col =
 TEMP3[,SITE], pch = 3, main = Temperature changes, xlab = Date, ylab =
 Temberature[C])

 I managed to use col = TEMP3[SITE] to plot the two different sites( BG1
 and EA7) in different colours, but I am struggling to change the colours.

 I wanted to up a colour scheme to match the site, so tried

 BG1 - blue
 EA7 - green

 before the plot function, but the graphic just came out with red and black
 as before.

 There are other datasets in which there are more than two sites so I would
 really like to learn how to use colour to distinguish between them on a
 plot.

 Any direction would be very greatly received!

 Thank you very much

 Sarah





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4092794.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@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.

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread SarahH
I got the colour vector with ifelse to work, great! Thank you. 

Is it possible to use the ifelse colour vector with other plot types? For
example with type=l ? I tried but the graphic came back with blue lines for
both sites and also a straight line connecting the start and end point of
the data? 

Thanks
Sarah






Michael Weylandt wrote
 
 I think the easiest way to do this is to set up a color vector with
 ifelse and hand that off to the plot command: something like
 
 col = ifelse(TEMP3[,SITE] == BG1, blue, green) # Syntax is
 ifelse(TEST, OUT_IF_TRUE, OUT_IF_FALSE)
 
 For more complicated schemes, a set of nested ifelse()'s can get you
 what you need. There are some other tricks with factors as well, but
 they require a little more advanced use of R. Just for the record,
 they'd look something like this:
 
 X = letters[c(1,2,3,3,1,2,1,3,3,1,2,2,1)]
 
 colX = c(red,green,blue)[as.factor(X)]
 
 Hope this helps,
 Michael
 
 On Mon, Nov 21, 2011 at 2:17 PM, SarahH lt;sarah.g10@.cogt; wrote:
 Dear All,

 I am very new to R - trying to teach myself it for some MSc coursework.

 I am plotting temperature data for two different sites over the same time
 period which I have downloaded from a university weather station data
 archive.

 I am using the following code to create the plot

 plot ( x = TEMP3[,TIME], y = TEMP3[,TEMP], type = p, col =
 TEMP3[,SITE], pch = 3, main = Temperature changes, xlab = Date,
 ylab =
 Temberature[C])

 I managed to use col = TEMP3[SITE] to plot the two different sites( BG1
 and EA7) in different colours, but I am struggling to change the colours.

 I wanted to up a colour scheme to match the site, so tried

 BG1 - blue
 EA7 - green

 before the plot function, but the graphic just came out with red and
 black
 as before.

 There are other datasets in which there are more than two sites so I
 would
 really like to learn how to use colour to distinguish between them on a
 plot.

 Any direction would be very greatly received!

 Thank you very much

 Sarah





 --
 View this message in context:
 http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4092794.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@ 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.
 
 __
 R-help@ 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.
 


--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4093337.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread John Kane
Another approach would be to use ggplot2.  
Code can look a bit daunting to begin with but ggplot2 is a 
very versitile graphing package and well worth learning.

Simple example
=
library(ggplot2)
mydata - data.frame(site=c(A,A,A, B,B,B), time1 = 1:6, 
t1=c(23,24,13,7,19,12),
t2=c(7, 4,6,8,5,9))
   
p - ggplot(mydata, aes(x=time1)) +
geom_point(aes(y= t1, colour= site)) +
 geom_point(aes(y = t2, colour=site))

p   - ggplot(mydata, aes(x=time1)) +
geom_point(aes(y= t1, colour= site)) +
 geom_point(aes(y = t2, colour=site))
 
p - p + scale_x_continuous('Time')+
  scale_y_continuous('Temperature')

p
=

--- On Mon, 11/21/11, SarahH sarah@hotmail.co.uk wrote:

 From: SarahH sarah@hotmail.co.uk
 Subject: [R] Scatter plot - using colour to group points?
 To: r-help@r-project.org
 Received: Monday, November 21, 2011, 2:17 PM
 Dear All, 
 
 I am very new to R - trying to teach myself it for some MSc
 coursework. 
 
 I am plotting temperature data for two different sites over
 the same time
 period which I have downloaded from a university weather
 station data
 archive. 
 
 I am using the following code to create the plot
 
 plot ( x = TEMP3[,TIME], y = TEMP3[,TEMP], type = p,
 col =
 TEMP3[,SITE], pch = 3, main = Temperature changes, xlab
 = Date, ylab =
 Temberature[C])
 
 I managed to use col = TEMP3[SITE] to plot the two
 different sites( BG1
 and EA7) in different colours, but I am struggling to
 change the colours. 
 
 I wanted to up a colour scheme to match the site, so tried
 
 
 BG1 - blue
 EA7 - green
 
 before the plot function, but the graphic just came out
 with red and black
 as before. 
 
 There are other datasets in which there are more than two
 sites so I would
 really like to learn how to use colour to distinguish
 between them on a
 plot. 
 
 Any direction would be very greatly received!
 
 Thank you very much
 
 Sarah
 
 
 
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4092794.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@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.
 


__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread R. Michael Weylandt
I don't think you can do different colors for a single line (not an
ifelse thing, just a what would that mean sort of thing), but a plot
type like b o or h will work the same way.

Michael

On Mon, Nov 21, 2011 at 4:23 PM, SarahH sarah@hotmail.co.uk wrote:
 I got the colour vector with ifelse to work, great! Thank you.

 Is it possible to use the ifelse colour vector with other plot types? For
 example with type=l ? I tried but the graphic came back with blue lines for
 both sites and also a straight line connecting the start and end point of
 the data?

 Thanks
 Sarah






 Michael Weylandt wrote

 I think the easiest way to do this is to set up a color vector with
 ifelse and hand that off to the plot command: something like

 col = ifelse(TEMP3[,SITE] == BG1, blue, green) # Syntax is
 ifelse(TEST, OUT_IF_TRUE, OUT_IF_FALSE)

 For more complicated schemes, a set of nested ifelse()'s can get you
 what you need. There are some other tricks with factors as well, but
 they require a little more advanced use of R. Just for the record,
 they'd look something like this:

 X = letters[c(1,2,3,3,1,2,1,3,3,1,2,2,1)]

 colX = c(red,green,blue)[as.factor(X)]

 Hope this helps,
 Michael

 On Mon, Nov 21, 2011 at 2:17 PM, SarahH sarah.g10@.co wrote:
 Dear All,

 I am very new to R - trying to teach myself it for some MSc coursework.

 I am plotting temperature data for two different sites over the same time
 period which I have downloaded from a university weather station data
 archive.

 I am using the following code to create the plot

 plot ( x = TEMP3[,TIME], y = TEMP3[,TEMP], type = p, col =
 TEMP3[,SITE], pch = 3, main = Temperature changes, xlab = Date,
 ylab =
 Temberature[C])

 I managed to use col = TEMP3[SITE] to plot the two different sites( BG1
 and EA7) in different colours, but I am struggling to change the colours.

 I wanted to up a colour scheme to match the site, so tried

 BG1 - blue
 EA7 - green

 before the plot function, but the graphic just came out with red and
 black
 as before.

 There are other datasets in which there are more than two sites so I
 would
 really like to learn how to use colour to distinguish between them on a
 plot.

 Any direction would be very greatly received!

 Thank you very much

 Sarah





 --
 View this message in context:
 http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4092794.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@ 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.

 __
 R-help@ 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.



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4093337.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@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.

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread David Winsemius


On Nov 21, 2011, at 10:18 PM, R. Michael Weylandt wrote:


I don't think you can do different colors for a single line (not an
ifelse thing, just a what would that mean sort of thing), but a plot
type like b o or h will work the same way.


I think Jim Lemon has a multicolored line function in package:plotrix.

--  
David.


Michael

On Mon, Nov 21, 2011 at 4:23 PM, SarahH sarah@hotmail.co.uk  
wrote:

I got the colour vector with ifelse to work, great! Thank you.

Is it possible to use the ifelse colour vector with other plot  
types? For
example with type=l ? I tried but the graphic came back with blue  
lines for
both sites and also a straight line connecting the start and end  
point of

the data?

Thanks
Sarah






Michael Weylandt wrote


I think the easiest way to do this is to set up a color vector with
ifelse and hand that off to the plot command: something like

col = ifelse(TEMP3[,SITE] == BG1, blue, green) # Syntax is
ifelse(TEST, OUT_IF_TRUE, OUT_IF_FALSE)

For more complicated schemes, a set of nested ifelse()'s can get you
what you need. There are some other tricks with factors as well, but
they require a little more advanced use of R. Just for the record,
they'd look something like this:

X = letters[c(1,2,3,3,1,2,1,3,3,1,2,2,1)]

colX = c(red,green,blue)[as.factor(X)]

Hope this helps,
Michael

On Mon, Nov 21, 2011 at 2:17 PM, SarahH sarah.g10@.co wrote:

Dear All,

I am very new to R - trying to teach myself it for some MSc  
coursework.


I am plotting temperature data for two different sites over the  
same time
period which I have downloaded from a university weather station  
data

archive.

I am using the following code to create the plot

plot ( x = TEMP3[,TIME], y = TEMP3[,TEMP], type = p, col =
TEMP3[,SITE], pch = 3, main = Temperature changes, xlab =  
Date,

ylab =
Temberature[C])

I managed to use col = TEMP3[SITE] to plot the two different  
sites( BG1
and EA7) in different colours, but I am struggling to change the  
colours.


I wanted to up a colour scheme to match the site, so tried

BG1 - blue
EA7 - green

before the plot function, but the graphic just came out with red  
and

black
as before.

There are other datasets in which there are more than two sites  
so I

would
really like to learn how to use colour to distinguish between  
them on a

plot.

Any direction would be very greatly received!

Thank you very much

Sarah





--
View this message in context:
http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4092794.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@ 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.


__
R-help@ 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.




--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-using-colour-to-group-points-tp4092794p4093337.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


__
R-help@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.


David Winsemius, MD
West Hartford, CT

__
R-help@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.


Re: [R] Scatter plot - using colour to group points?

2011-11-21 Thread Jim Lemon

On 11/22/2011 05:00 PM, David Winsemius wrote:


On Nov 21, 2011, at 10:18 PM, R. Michael Weylandt wrote:


I don't think you can do different colors for a single line (not an
ifelse thing, just a what would that mean sort of thing), but a plot
type like b o or h will work the same way.


I think Jim Lemon has a multicolored line function in package:plotrix.


Hi David (and everybody else),
The color.scale.lines function will display multicolored lines, just 
force the colors to what you want using the col argument.


Jim

__
R-help@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.


[R] Scatter Plot Command Syntax Using Data.Frame Source

2011-08-31 Thread Rich Shepard

  I've tried various commands. ?plot, Teetor's book, R Cookbook, and
Mittal's book, R Graphs Cookbook without seeing how to write the command
to create scatterplots from my data.frame. The structure is:


str(chemdata)

'data.frame':   14886 obs. of  4 variables:
 $ site: Factor w/ 148 levels BC-0.5,BC-1,..: 104 145 126 115 114
128 124 2 3 3 ...
 $ sampdate: Date, format: 1996-12-27 1996-08-22 ...
 $ param   : Factor w/ 8 levels As,Ca,Cl,..: 1 1 1 1 1 1 1 1 1 1 ...
 $ quant   : num  0.06 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 ...

  and what I'd like to do is create scatter plots of quant (y-axis) against
the factor site (x-axis) for specified param factors. Teetor has an example
for a data set with two numeric variables and a single factor. I have a
single numeric veriable, two factors, and a date.

  I'll also want to create time series line plots of values as a function of
date for specified params.

  If the data.frame had only two columns all the examples work. But, using
two columns (the number per site factor for only a specified param factor)
is not covered in what I've read so far.

  Other graphing resources about which I should know?

Rich

__
R-help@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.


Re: [R] Scatter Plot Command Syntax Using Data.Frame Source

2011-08-31 Thread baptiste auguie
Hi,

Below are a couple of options using a standard dataset,

str(iris)

## using base graphics
d - split(iris, iris$Species)
str(d) # list of 3 data.frames

par(mfrow=n2mfrow(length(d))) # split the device in 3 plotting regions
b.quiet - lapply(names(d), function(x) { # loop over the list names
  with(d[[x]], plot(Sepal.Length, Petal.Length))
  title(x)
})

library(ggplot2)
# using facetting
ggplot(iris) + facet_wrap(~Species) +
  geom_point(aes(Sepal.Length, Petal.Length))

library(lattice)
# using facetting
xyplot(Petal.Length ~ Sepal.Length | Species, data=iris )

HTH,

baptiste

On 1 September 2011 08:50, Rich Shepard rshep...@appl-ecosys.com wrote:
  I've tried various commands. ?plot, Teetor's book, R Cookbook, and
 Mittal's book, R Graphs Cookbook without seeing how to write the command
 to create scatterplots from my data.frame. The structure is:

 str(chemdata)

 'data.frame':   14886 obs. of  4 variables:
  $ site    : Factor w/ 148 levels BC-0.5,BC-1,..: 104 145 126 115 114
 128 124 2 3 3 ...
  $ sampdate: Date, format: 1996-12-27 1996-08-22 ...
  $ param   : Factor w/ 8 levels As,Ca,Cl,..: 1 1 1 1 1 1 1 1 1 1 ...
  $ quant   : num  0.06 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 ...

  and what I'd like to do is create scatter plots of quant (y-axis) against
 the factor site (x-axis) for specified param factors. Teetor has an example
 for a data set with two numeric variables and a single factor. I have a
 single numeric veriable, two factors, and a date.

  I'll also want to create time series line plots of values as a function of
 date for specified params.

  If the data.frame had only two columns all the examples work. But, using
 two columns (the number per site factor for only a specified param factor)
 is not covered in what I've read so far.

  Other graphing resources about which I should know?

 Rich

 __
 R-help@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.


__
R-help@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.


Re: [R] Scatter Plot Command Syntax Using Data.Frame Source

2011-08-31 Thread Rich Shepard

On Thu, 1 Sep 2011, baptiste auguie wrote:


Below are a couple of options using a standard dataset,


  Thanks, Baptiste. These point me in the right direction.

Rich

__
R-help@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.


Re: [R] Scatter Plot Command Syntax Using Data.Frame Source

2011-08-31 Thread Jorge I Velez
Hi Rich,

Using the data set iris as an example, you might also try

require(car)
scatterplot(Petal.Length ~ Sepal.Length | Species, data = iris)

HTH,
Jorge


On Wed, Aug 31, 2011 at 4:50 PM, Rich Shepard  wrote:

  I've tried various commands. ?plot, Teetor's book, R Cookbook, and
 Mittal's book, R Graphs Cookbook without seeing how to write the command
 to create scatterplots from my data.frame. The structure is:

  str(chemdata)

 'data.frame':   14886 obs. of  4 variables:
  $ site: Factor w/ 148 levels BC-0.5,BC-1,..: 104 145 126 115 114
 128 124 2 3 3 ...
  $ sampdate: Date, format: 1996-12-27 1996-08-22 ...
  $ param   : Factor w/ 8 levels As,Ca,Cl,..: 1 1 1 1 1 1 1 1 1 1 ...
  $ quant   : num  0.06 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 0.01 ...

  and what I'd like to do is create scatter plots of quant (y-axis) against
 the factor site (x-axis) for specified param factors. Teetor has an example
 for a data set with two numeric variables and a single factor. I have a
 single numeric veriable, two factors, and a date.

  I'll also want to create time series line plots of values as a function of
 date for specified params.

  If the data.frame had only two columns all the examples work. But, using
 two columns (the number per site factor for only a specified param factor)
 is not covered in what I've read so far.

  Other graphing resources about which I should know?

 Rich

 __**
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/**
 posting-guide.html http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@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.


[R] Scatter plot in R

2011-08-05 Thread Abder-Rahman Ali
Hi,

I have 334 records, with two columns:

Column (1): Resolution Column (2): Number of images with a specific
resolution

How can I make a scatter plot in R with this data? Is there a way to *import
* the records, since it will be time consuming to enter 334 records?

Thanks.

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot in R

2011-08-05 Thread Jannis
This is a really basic question that is answered in many R tutorials. 
Why dont you just google:


R import csv

And the first hit will tell you straight away what to do?


Jannis

P.S. I just guessed from your not very specific post that you may want 
to import from csv ...


On 08/05/2011 12:45 PM, Abder-Rahman Ali wrote:

Hi,

I have 334 records, with two columns:

Column (1): Resolution Column (2): Number of images with a specific
resolution

How can I make a scatter plot in R with this data? Is there a way to *import
* the records, since it will be time consuming to enter 334 records?

Thanks.

[[alternative HTML version deleted]]

__
R-help@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.



__
R-help@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.


Re: [R] Scatter plot produces 'x' and 'y' lengths differ

2011-06-17 Thread Daniel Malter
It likely means that your x and y are differently long. That is, affect1 and
adh1scr do not contain the same number of values in that instance. That
precludes them from being plotted against each other. abline and lowess
would fail for the same reason.

x-c(1,2,3)
y-c(2,4)
plot(y~x)
complete.cases(x,y)

However, what is peculiar about this is that if x and y indeed have
different length, the complete.cases() function should fail (unless
specified with some override argument).

The problem is definitely NOT one with XLIM or YLIM.

HTH,
Daniel






Alspach, Steven E. wrote:
 
 Hello,
 
  
 
 I am working on a project to create some scatter plots.  I have syntax
 for 26 plots, and 22 of them display as they should.  But here, for
 example, is a sample of the command syntax I am using:
 
  
 
 good - complete.cases(affect1,adh1scr)
 
 plot
 (jitter(affect1,2.0),jitter(adh1scr,1.0),xlim=c(1,35),ylim=c(1,35),pch=1
 6,
 
 main='Adherence Score by Affectiveness Level - Visit 1',
 
 ylab='Adherence score',xlab='Affect Scale - Patient
 Survey',abline(lsfit(affect1,adh1scr)),col=red)
 
 lines(lowess(affect1[good], adh1scr[good]), col=blue)
 
  
 
 I run this and get:
 
  
 
 good - complete.cases(affect1,adh1scr)
 
 plot
 (jitter(affect1,2.0),jitter(adh1scr,1.0),xlim=c(1,35),ylim=c(1,35),pch=1
 6,
 
 +  main='Adherence Score by Affectiveness Level - Visit 1',
 
 + ylab='Adherence score',xlab='Affect Scale - Patient
 Survey',abline(lsfit(affect1,adh1scr)),col=red)
 
 Error in xy.coords(x, y, xlabel, ylabel, log) : 
 
   'x' and 'y' lengths differ
 
 lines(lowess(affect1[good], adh1scr[good]), col=blue)
 
 Error in xy.coords(x, y) : 'x' and 'y' lengths differ
 
  
 
 The data is a bit skewed towards the high end, but I found other
 variables that skew even more and they produce graphs.  I've taken out
 the ABLINE and LINES options and the problem persists.  I tried changing
 the name of the AFFECT1 variable, the problem exists.  I tried changing
 the values of XLIM and YLIM (the range for the X and Y variables are
 both 1 and 35); I still get the same error.  There are enough valid
 cases to create a scatter plot (two of the plots will have 211 valid
 cases, the other two will have 163 valid cases).
 
  
 
 This occurs in the middle of my command file.  So - I know that the
 variables are being read into R correctly (no error messages from R when
 I define the variables), and similar syntax for other variables works -
 it's just these 4 variables (AFFECT1, AFFECT2, INFOSC1, INFOSC2) that
 produce the Error in xy.coords message.
 
  
 
 Any help that anyone can give regarding this would be helpful.  
 
  
 
 Sincerely,
 
  
 
 Steve Alspach 
 
 Jesse Brown Veterans' Administration Hospital
 
 steven.alsp...@va.gov
 
  
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@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.
 

--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-produces-x-and-y-lengths-differ-tp3604367p3604688.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] Scatter plot produces 'x' and 'y' lengths differ

2011-06-16 Thread Alspach, Steven E.
Hello,

 

I am working on a project to create some scatter plots.  I have syntax
for 26 plots, and 22 of them display as they should.  But here, for
example, is a sample of the command syntax I am using:

 

good - complete.cases(affect1,adh1scr)

plot
(jitter(affect1,2.0),jitter(adh1scr,1.0),xlim=c(1,35),ylim=c(1,35),pch=1
6,

main='Adherence Score by Affectiveness Level - Visit 1',

ylab='Adherence score',xlab='Affect Scale - Patient
Survey',abline(lsfit(affect1,adh1scr)),col=red)

lines(lowess(affect1[good], adh1scr[good]), col=blue)

 

I run this and get:

 

 good - complete.cases(affect1,adh1scr)

 plot
(jitter(affect1,2.0),jitter(adh1scr,1.0),xlim=c(1,35),ylim=c(1,35),pch=1
6,

+  main='Adherence Score by Affectiveness Level - Visit 1',

+ ylab='Adherence score',xlab='Affect Scale - Patient
Survey',abline(lsfit(affect1,adh1scr)),col=red)

Error in xy.coords(x, y, xlabel, ylabel, log) : 

  'x' and 'y' lengths differ

 lines(lowess(affect1[good], adh1scr[good]), col=blue)

Error in xy.coords(x, y) : 'x' and 'y' lengths differ

 

The data is a bit skewed towards the high end, but I found other
variables that skew even more and they produce graphs.  I've taken out
the ABLINE and LINES options and the problem persists.  I tried changing
the name of the AFFECT1 variable, the problem exists.  I tried changing
the values of XLIM and YLIM (the range for the X and Y variables are
both 1 and 35); I still get the same error.  There are enough valid
cases to create a scatter plot (two of the plots will have 211 valid
cases, the other two will have 163 valid cases).

 

This occurs in the middle of my command file.  So - I know that the
variables are being read into R correctly (no error messages from R when
I define the variables), and similar syntax for other variables works -
it's just these 4 variables (AFFECT1, AFFECT2, INFOSC1, INFOSC2) that
produce the Error in xy.coords message.

 

Any help that anyone can give regarding this would be helpful.  

 

Sincerely,

 

Steve Alspach 

Jesse Brown Veterans' Administration Hospital

steven.alsp...@va.gov

 


[[alternative HTML version deleted]]

__
R-help@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.


[R] scatter plot: multiple Y variables and error bars

2011-05-18 Thread B77S
#Hi all, 
#Using the example data that follows, can someone please show me how to get
a scatterplot of points with #error bars in the Y direction. something like
this works for one Y:

xYplot(Cbind(y1, l1, u1) ~x1,  data=y)

#but  this:

xYplot(Cbind(y1, l1, u1) + Cbind(y2, l2, u2)~x1,  data=y)

# doesn't give me what I would have expected, which is both sets of points
to have their respective error # bars.  Any examples would be greatly
appreciated, and I am not partial to xYplot, so please share #anything you
like. 

y1 - c(1, 1.2, 0.9, 1, 1.2)
u1 - c(1.3, 1.4, 1.3, 1.2, 1.4)
l1 - c(0.8, 0.9, 0.85, 0.8, 0.9)
x1 -  c(1:5)
y2 - c(1.2, 1.4, 1.2, 1.4, 1.5)
u2 - c(1.5, 1.8, 1.6, 1.6, 1.7)
l2 - c(1.1, 1.3, 1.0, 1.2, 1.4)
y - data.frame(y1,u1,l1,x1)


## thanks ahead of time!

--
View this message in context: 
http://r.789695.n4.nabble.com/scatter-plot-multiple-Y-variables-and-error-bars-tp3531563p3531563.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


[R] scatter plot with Z value

2011-05-04 Thread Matevž Pavlič
Hi all, 

 

I would like to create a scatter plot of two variables (y, x)  whith third 
value (z) written on the plot? After that i would like to add a line 
(Y=0.7*(x-20)) to the graph. 

 

I tried 

plot(x~y)

 

but there is no command for the third vairable to be shown on the graph

also i can't find a way to add a Y=x*(0.7-20) to the chart.

 

Thanks, m


[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] scatter plot with Z value

2011-05-04 Thread Jannis
I am sure you would have found answers to your questions if you would have 
searched the mailing list archive  
(http://r.789695.n4.nabble.com/R-help-f789696.html)!

To get you started, have a look at:

?text   (for the z values)
?abline (for the line)


Jannis

--- Matevž Pavlič matevz.pav...@gi-zrmk.si schrieb am Mi, 4.5.2011:

 Von: Matevž Pavlič matevz.pav...@gi-zrmk.si
 Betreff: [R] scatter plot with Z value
 An: r-help@r-project.org
 Datum: Mittwoch, 4. Mai, 2011 12:55 Uhr
 Hi all, 
 
  
 
 I would like to create a scatter plot of two variables (y,
 x)  whith third value (z) written on the plot? After
 that i would like to add a line (Y=0.7*(x-20)) to the graph.
 
 
  
 
 I tried 
 
 plot(x~y)
 
  
 
 but there is no command for the third vairable to be shown
 on the graph
 
 also i can't find a way to add a Y=x*(0.7-20) to the
 chart.
 
  
 
 Thanks, m
 
 
     [[alternative HTML version deleted]]
 
 __
 R-help@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.


__
R-help@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.


[R] Scatter plot with multiple data sets

2011-03-03 Thread Jorseff
Hi, I have multiple (6) data sets which I would like to plot together on one
scatter graph. The reason they are all separate is that I require a
different symbol to be plotted for each set. Could somebody advise on how to
do this?

Many thanks,

Joe

--
View this message in context: 
http://r.789695.n4.nabble.com/Scatter-plot-with-multiple-data-sets-tp3334096p3334096.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.


Re: [R] Scatter plot with multiple data sets

2011-03-03 Thread Joshua Wiley
Hi Joe,

The easiest option will be to combine all 6 datasets (at least the
variables you want to use in your scatter plot), and then create
another variable that indicates to which group the observations
belong.  Here is a small example of what you might do once your data
are all together (obviously replace mtcars with your dataset name
and the variables with your variables):

with(mtcars, plot(x = hp, y = mpg, pch = carb))

I am also fond using the ggplot2 package for graphs.

require(ggplot2)
ggplot(mtcars, aes(x = hp, y = mpg, shape = factor(carb))) + geom_point()

Cheers,

Josh

On Thu, Mar 3, 2011 at 12:03 PM, Jorseff jcp...@york.ac.uk wrote:
 Hi, I have multiple (6) data sets which I would like to plot together on one
 scatter graph. The reason they are all separate is that I require a
 different symbol to be plotted for each set. Could somebody advise on how to
 do this?

 Many thanks,

 Joe

 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Scatter-plot-with-multiple-data-sets-tp3334096p3334096.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@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.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

__
R-help@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.


Re: [R] Scatter plot with margin distributions

2009-11-25 Thread Jose Narillos de Santos
Finally I get a plot manual...so I got the solution

Sorry about inconveniences


2009/11/24, Jose Narillos de Santos narillosdesan...@gmail.com:

 Hi All,

 My doub I think is very simple. I hope it is. So you can again help, guide
 me.

 I´m trying to make a graph (scatter graph) about two variables, imagine I
 have a watter.txt file with two variables watter and hardness:

 This code extracted from:
 http://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_simple_inference.pdf
 would make a plot similar I want I mean to make an scatterplot with
 marginal ditribution up and left...(in this case a boxplot on the left and
 also I omitt the location).


 layout(matrix(c(2, 0, 1, 3), 2, 2, byrow = TRUE),
 2 + c(2, 1), c(1, 2), TRUE)

 plot(mortality ~ hardness, data = water, pch = psymb)

 abline(lm(mortality ~ hardness, data = water))

 legend(topright, legend = levels(water$location), 7 + pch = c(1,2), bty
 = n)

 hist(water$hardness)

 boxplot(water$mortality)



 Can anyone explain what is the values in layout the inputs I mean, I have
 read the help but because I´m a begginer I ´m not able to comprehed why they
 put matrix c(2,0,1,3) and the other inputs?



 I need if someone can help me an easy example



 Thanks a lot.






[[alternative HTML version deleted]]

__
R-help@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.


[R] Scatter plot with margin distributions

2009-11-24 Thread Jose Narillos de Santos
Hi All,

My doub I think is very simple. I hope it is. So you can again help, guide
me.

I´m trying to make a graph (scatter graph) about two variables, imagine I
have a watter.txt file with two variables watter and hardness:

This code extracted from:
http://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_simple_inference.pdf
would make a plot similar I want I mean to make an scatterplot with marginal
ditribution up and left...(in this case a boxplot on the left and also I
omitt the location).


layout(matrix(c(2, 0, 1, 3), 2, 2, byrow = TRUE),2 + c(2, 1), c(1, 2), TRUE)

plot(mortality ~ hardness, data = water, pch = psymb)

abline(lm(mortality ~ hardness, data = water))

legend(topright, legend = levels(water$location), 7 + pch = c(1,2), bty =
n)

hist(water$hardness)

boxplot(water$mortality)



Can anyone explain what is the values in layout the inputs I mean, I have
read the help but because I´m a begginer I ´m not able to comprehed why they
put matrix c(2,0,1,3) and the other inputs?



I need if someone can help me an easy example



Thanks a lot.

[[alternative HTML version deleted]]

__
R-help@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.


[R] scatter plot equation

2009-11-22 Thread Rofizah Mohammad
Hi,

If I have 2D data set say (x,y) and I can do scatter plot by using plot(x,y)
command.
How can I add in this scatter plot the equations curve say

2X2 + 3Y2 – 6X – 7Y + 9 = 0.

Regards

Rofizah

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] scatter plot equation

2009-11-22 Thread Duncan Murdoch

On 22/11/2009 11:27 AM, Rofizah Mohammad wrote:

Hi,

If I have 2D data set say (x,y) and I can do scatter plot by using plot(x,y)
command.
How can I add in this scatter plot the equations curve say

2X2 + 3Y2 – 6X – 7Y + 9 = 0.


You could do it using contour(), but you should use an equation that has 
some real solutions.  For example, using a different equation than yours:


x - rnorm(100, sd=1)
y - rnorm(100, sd=1)
xgrid - seq(min(x), max(x), len=100)
ygrid - seq(min(y), max(y), len=120)
grid - expand.grid(x=xgrid, y=ygrid)
LHS - function(x, y) x^2 + y^2 - x - y  - 1
z - apply(grid, 1, function(x) LHS(x[1], x[2]) )
z - matrix(z, 100, 120)
plot(x,y)
contour(xgrid, ygrid, z, levels=0, add=TRUE)

__
R-help@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.


Re: [R] scatter plot equation

2009-11-22 Thread David Winsemius


On Nov 22, 2009, at 11:27 AM, Rofizah Mohammad wrote:


Hi,

If I have 2D data set say (x,y) and I can do scatter plot by using  
plot(x,y)

command.
How can I add in this scatter plot the equations curve say

2X2 + 3Y2 – 6X – 7Y + 9 = 0.



No executable example... so if you are too lazy to construct one, then  
I would suggest looking for worked examples at one of the graphics  
galleries.


Perhaps:

http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=44




Regards

Rofizah

[[alternative HTML version deleted]]

__
R-help@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.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@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.


Re: [R] scatter plot equation

2009-11-22 Thread Rofizah Mohammad
Many thanks Duncan. I got the plot even I don't really understand the whole
command..
I will study that later..

:-)

Regards



On Sun, Nov 22, 2009 at 4:44 PM, Duncan Murdoch murd...@stats.uwo.cawrote:

  On 22/11/2009 11:27 AM, Rofizah Mohammad wrote:

 Hi,

 If I have 2D data set say (x,y) and I can do scatter plot by using
 plot(x,y)
 command.
 How can I add in this scatter plot the equations curve say

 2X2 + 3Y2 – 6X – 7Y + 9 = 0.


 You could do it using contour(), but you should use an equation that has
 some real solutions.  For example, using a different equation than yours:

 x - rnorm(100, sd=1)
 y - rnorm(100, sd=1)
 xgrid - seq(min(x), max(x), len=100)
 ygrid - seq(min(y), max(y), len=120)
 grid - expand.grid(x=xgrid, y=ygrid)
 LHS - function(x, y) x^2 + y^2 - x - y  - 1
 z - apply(grid, 1, function(x) LHS(x[1], x[2]) )
 z - matrix(z, 100, 120)
 plot(x,y)
 contour(xgrid, ygrid, z, levels=0, add=TRUE)


[[alternative HTML version deleted]]

__
R-help@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.


[R] Scatter plot using icons (from a gif) instaed of points - is it possible ?

2009-10-14 Thread Tal Galili
Hello dear R-help group.

I wish to plot a scatter plot using icons (or images) instead of points.
Is it possible? and how so?

Thanks,
Tal






--


My contact information:
Tal Galili
E-mail: tal.gal...@gmail.com
Phone number: 972-52-7275845
FaceBook: Tal Galili
My Blogs:
http://www.talgalili.com (Web and general, Hebrew)
http://www.biostatistics.co.il (Statistics, Hebrew)
http://www.r-statistics.com/ (Statistics,R, English)

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot using icons (from a gif) instaed of points - is it possible ?

2009-10-14 Thread baptiste auguie
Hi,

You'll probably find that there are two parts to your query:

1- import a bitmap into R, for this I'd suggest the wiki page,
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-misc:display-images

2- place the image (now some sort of matrix of colour points) at
different locations on a graph. I don't know any function to do this
(*) (but there may be some listed in the above webpage).

Another option is to convert the bitmap to vector graphics using an
external tool, then use the grImport package to create a grob
(graphical object) that you can then place in any Grid-based plot
(there is an example with lattice).


HTH,

baptiste

(*) this may look like a starting point:
http://wiki.r-project.org/rwiki/doku.php?id=tips:graphics-grid:displaybitmap





2009/10/14 Tal Galili tal.gal...@gmail.com:
 Hello dear R-help group.

 I wish to plot a scatter plot using icons (or images) instead of points.
 Is it possible? and how so?

 Thanks,
 Tal






 --


 My contact information:
 Tal Galili
 E-mail: tal.gal...@gmail.com
 Phone number: 972-52-7275845
 FaceBook: Tal Galili
 My Blogs:
 http://www.talgalili.com (Web and general, Hebrew)
 http://www.biostatistics.co.il (Statistics, Hebrew)
 http://www.r-statistics.com/ (Statistics,R, English)

        [[alternative HTML version deleted]]

 __
 R-help@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.


__
R-help@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.


Re: [R] Scatter plot using icons (from a gif) instaed of points - is it possible ?

2009-10-14 Thread Greg Snow
The help page for the subplot function in the TeachingDemos package shows an 
example of doing what you ask.  The my.symbols function in the same package may 
work better (depending on what exactly you want).

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
 project.org] On Behalf Of Tal Galili
 Sent: Wednesday, October 14, 2009 12:13 PM
 To: r-help@r-project.org
 Subject: [R] Scatter plot using icons (from a gif) instaed of points -
 is it possible ?
 
 Hello dear R-help group.
 
 I wish to plot a scatter plot using icons (or images) instead of
 points.
 Is it possible? and how so?
 
 Thanks,
 Tal
 
 
 
 
 
 
 --
 
 
 My contact information:
 Tal Galili
 E-mail: tal.gal...@gmail.com
 Phone number: 972-52-7275845
 FaceBook: Tal Galili
 My Blogs:
 http://www.talgalili.com (Web and general, Hebrew)
 http://www.biostatistics.co.il (Statistics, Hebrew)
 http://www.r-statistics.com/ (Statistics,R, English)
 
   [[alternative HTML version deleted]]
 
 __
 R-help@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.

__
R-help@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.


Re: [R] Scatter Plot

2009-07-31 Thread baptiste auguie
please Cc. the list next time

Two suggestions,

1) read the help page, e.g. ?points would have told you why pch=10
produces 1.

2) Try the following and see which you prefer,

x = y = labels = 1:20

?text
plot(x, y, type='n') # empty plot
text(x, y, paste(labels))

library(ggplot2)
?qplot
qplot(x, y, geom=text, label=labels)

library(lattice)
?xyplot
xyplot(y~x, t=n,
   panel = function(...) { panel.text(..., label= labels) } )


HTH,

baptiste

2009/7/31 amna khan amnakhan...@gmail.com:
 Hi Sir
 Your suggested code worked only for numbers 1 to 9 remaining points were
 marked by 1. I want to have numbers 1 to 22 instead of points on scatter
 plot.
 Suggest more.
 Kind Regards

 On Thu, Jul 30, 2009 at 11:57 PM, baptiste auguie
 baptiste.aug...@googlemail.com wrote:

 Hi,

 Try this,

 plot(1:5,1:5, t='p', pch=paste(1:5))

 baptiste


 2009/7/30 amna khan amnakhan...@gmail.com:
  Dear Sir
 
  I want to write the numbers 1,2,3,on a scatter plot instead of
  points,
  like 1 corresponding to first point on plot, 2 corresponding second
  point
  etc.
  Help in this regard.
 
  Regards
 
  --
  AMINA SHAHZADI
  Department of Statistics
  GC University Lahore, Pakistan.
 
         [[alternative HTML version deleted]]
 
  __
  R-help@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.
 



 --
 AMINA SHAHZADI
 Department of Statistics
 GC University Lahore, Pakistan.




-- 
_

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

http://newton.ex.ac.uk/research/emag

__
R-help@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.


[R] Scatter Plot

2009-07-30 Thread amna khan
Dear Sir

I want to write the numbers 1,2,3,on a scatter plot instead of points,
like 1 corresponding to first point on plot, 2 corresponding second point
etc.
Help in this regard.

Regards

-- 
AMINA SHAHZADI
Department of Statistics
GC University Lahore, Pakistan.

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter Plot

2009-07-30 Thread baptiste auguie
Hi,

Try this,

plot(1:5,1:5, t='p', pch=paste(1:5))

baptiste


2009/7/30 amna khan amnakhan...@gmail.com:
 Dear Sir

 I want to write the numbers 1,2,3,on a scatter plot instead of points,
 like 1 corresponding to first point on plot, 2 corresponding second point
 etc.
 Help in this regard.

 Regards

 --
 AMINA SHAHZADI
 Department of Statistics
 GC University Lahore, Pakistan.

        [[alternative HTML version deleted]]

 __
 R-help@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.


__
R-help@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.


Re: [R] Scatter Plot

2009-07-30 Thread Felipe Carrillo

Tri this for both, points and text..
library(ggplot2)
qplot(x=1:5,y=1:5) + geom_text(label=1:5)


Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish  Wildlife Service  
California, USA


--- On Thu, 7/30/09, amna khan amnakhan...@gmail.com wrote:

 From: amna khan amnakhan...@gmail.com
 Subject: [R] Scatter Plot
 To: r-help@r-project.org
 Date: Thursday, July 30, 2009, 9:14 AM
 Dear Sir
 
 I want to write the numbers 1,2,3,on a scatter plot
 instead of points,
 like 1 corresponding to first point on plot, 2
 corresponding second point
 etc.
 Help in this regard.
 
 Regards
 
 -- 
 AMINA SHAHZADI
 Department of Statistics
 GC University Lahore, Pakistan.
 
     [[alternative HTML version deleted]]
 
 __
 R-help@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.
 




__
R-help@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.


Re: [R] Scatter Plot

2009-07-30 Thread John Kane

x - 1:10
y - 1:10
plot(, xlim=c(1,10),ylim=c(0,10)
text(x,y, labels=x)

--- On Thu, 7/30/09, amna khan amnakhan...@gmail.com wrote:

 From: amna khan amnakhan...@gmail.com
 Subject: [R] Scatter Plot
 To: r-help@r-project.org
 Received: Thursday, July 30, 2009, 12:14 PM
 Dear Sir
 
 I want to write the numbers 1,2,3,on a scatter plot
 instead of points,
 like 1 corresponding to first point on plot, 2
 corresponding second point
 etc.
 Help in this regard.
 
 Regards
 
 -- 
 AMINA SHAHZADI
 Department of Statistics
 GC University Lahore, Pakistan.
 
     [[alternative HTML version deleted]]
 
 __
 R-help@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.
 


  __
Be smarter than spam. See how smart Sp
ck on Options in Mail and switch to New Mail today or register for free at 
__
R-help@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.


[R] Scatter plot

2009-04-01 Thread Sueli Rodrigues

Hi. How do I plot the straight line and r² in a scatter plot using a
simple file x~y?

Sueli Rodrigues

Eng. Agrônoma - UNESP
Mestranda - USP/ESALQ
PPG-Solos e Nutrição de Plantas
Fones (19)93442981
  (19)33719762

__
R-help@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.


Re: [R] Scatter plot

2009-04-01 Thread Peter Alspach
Tena koe Sueli

?abline
?text

HTH ...

Peter Alspach 

 -Original Message-
 From: r-help-boun...@r-project.org 
 [mailto:r-help-boun...@r-project.org] On Behalf Of Sueli Rodrigues
 Sent: Thursday, 2 April 2009 2:35 p.m.
 To: r-help@r-project.org
 Subject: [R] Scatter plot
 
 
 Hi. How do I plot the straight line and r² in a scatter plot 
 using a simple file x~y?
 
 Sueli Rodrigues
 
 Eng. Agrônoma - UNESP
 Mestranda - USP/ESALQ
 PPG-Solos e Nutrição de Plantas
 Fones (19)93442981
   (19)33719762
 
 __
 R-help@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.
 

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

__
R-help@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.


Re: [R] Scatter plot

2009-04-01 Thread stephen sefick
#excel like regression line but better
reg.line - function(y,x, data)
{plot(data[,y]~data[,x], main=paste(x,vs.,y, sep= ), xlab=x, ylab=y, pch=20)
line - lm(data[,y]~data[,x])
d - summary(line)
mtext(3, line=1, adj=0.25 ,text=bquote(bold(R^2== ~ .(d$r.squared))), bty=n)
abline(line)}

x  - 1:100+rnorm(100)
y - 1:100
z - data.frame(x,y)
reg.line(y=y,x=x,data=z)

try this - as an aside does anyone know how to take the x and y out of
quotes.  What can I do differently

hope this helps

Stephen Sefick


On Wed, Apr 1, 2009 at 9:41 PM, Peter Alspach
palsp...@hortresearch.co.nz wrote:
 Tena koe Sueli

 ?abline
 ?text

 HTH ...

 Peter Alspach

 -Original Message-
 From: r-help-boun...@r-project.org
 [mailto:r-help-boun...@r-project.org] On Behalf Of Sueli Rodrigues
 Sent: Thursday, 2 April 2009 2:35 p.m.
 To: r-help@r-project.org
 Subject: [R] Scatter plot


 Hi. How do I plot the straight line and r² in a scatter plot
 using a simple file x~y?

 Sueli Rodrigues

 Eng. Agrônoma - UNESP
 Mestranda - USP/ESALQ
 PPG-Solos e Nutrição de Plantas
 Fones (19)93442981
       (19)33719762

 __
 R-help@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.


 The contents of this e-mail are confidential and may be subject to legal 
 privilege.
  If you are not the intended recipient you must not use, disseminate, 
 distribute or
  reproduce all or any part of this e-mail or attachments.  If you have 
 received this
  e-mail in error, please notify the sender and delete all material pertaining 
 to this
  e-mail.  Any opinion or views expressed in this e-mail are those of the 
 individual
  sender and may not represent those of The New Zealand Institute for Plant and
  Food Research Limited.

 __
 R-help@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.




-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

-K. Mullis

__
R-help@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.


Re: [R] Scatter plot

2009-04-01 Thread markleeds

   Hi Stephen: If you want to take tem out of quotes, you can use deparse
   substitute as in below. Maybe there are other ways
   also  but  that's  the  one I  often see used. I hope this email ends
   up looking okay because my mailer has been acting strangely lately.
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  Mark
   reg.line - function(yin,xin, data) {

   Â Â Â Â  yval - deparse(substitute(yin))
   Â Â Â Â  xval - deparse(substitute(xin))
   Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
   Â Â Â Â  plot(data[,yval]~data[,xval], main=paste(xval,vs.,yval, sep= ),
   xlab=xval, ylab=yval, pch=20)
   Â Â Â Â  line - lm(data[,yval]~data[,xval])
   Â Â Â Â  d - summary(line)
   Â Â Â Âmtext(3,   line=1,   adj=0.25   ,text=bquote(bold(R^2==   ~
   .(d$r.squared))), bty=n)
   Â Â Â Â  abline(line)

   }

   Â Â Â Â
   x - 1:100+rnorm(100)
   y - 1:100
   z - data.frame(x,y)
   reg.line(y,x,data=z)

   On Apr 1, 2009, stephen sefick ssef...@gmail.com wrote:

 #excel like regression line but better
 reg.line - function(y,x, data)
 {plot(data[,y]~data[,x], main=paste(x,vs.,y, sep= ), xlab=x, ylab=y,
 pch=20)
 line - lm(data[,y]~data[,x])
 d - summary(line)
 mtext(3, line=1, adj=0.25 ,text=bquote(bold(R^2== ~ .(d$r.squared))),
 bty=n)
 abline(line)}
 x - 1:100+rnorm(100)
 y - 1:100
 z - data.frame(x,y)
 reg.line(y=y,x=x,data=z)
 try this - as an aside does anyone know how to take the x and y out of
 quotes. What can I do differently
 hope this helps
 Stephen Sefick
 On Wed, Apr 1, 2009 at 9:41 PM, Peter Alspach
 [1]palsp...@hortresearch.co.nz wrote:
  Tena koe Sueli
 
  ?abline
  ?text
 
  HTH ...
 
  Peter Alspach
 
  -Original Message-
  From: [2]r-help-boun...@r-project.org
  [mailto:[3]r-help-boun...@r-project.org] On Behalf Of Sueli Rodrigues
  Sent: Thursday, 2 April 2009 2:35 p.m.
  To: [4]r-h...@r-project.org
  Subject: [R] Scatter plot
 
 
  Hi. How do I plot the straight line and r² in a scatter plot
  using a simple file x~y?
 
  Sueli Rodrigues
 
  Eng. Agrônoma - UNESP
  Mestranda - USP/ESALQ
  PPG-Solos e Nutrição de Plantas
  Fones (19)93442981
  Â  Â  Â  (19)33719762
 
  __
  [5]r-h...@r-project.org mailing list
  [6]https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  [7]http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
  The contents of this e-mail are confidential and may be subject to legal
 privilege.
  Â If you are not the intended recipient you must not use, disseminate,
 distribute or
  Â reproduce all or any part of this e-mail or attachments. Â If you have
 received this
  Â e-mail in error, please notify the sender and delete all material
 pertaining to this
  Â e-mail. Â Any opinion or views expressed in this e-mail are those of
 the individual
  Â sender and may not represent those of The New Zealand Institute for
 Plant and
  Â Food Research Limited.
 
  __
  [8]r-h...@r-project.org mailing list
  [9]https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 [10]http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 --
 Stephen Sefick
 Let's not spend our time and resources thinking about things that are
 so little or so large that all they really do for us is puff us up and
 make us feel like gods. We are mammals, and have not exhausted the
 annoying little problems of being mammals.
 -K. Mullis
 __
 [11]r-h...@r-project.org mailing list
 [12]https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 [13]http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

References

   1. mailto:palsp...@hortresearch.co.nz
   2. mailto:r-help-boun...@r-project.org
   3. mailto:r-help-boun...@r-project.org
   4. mailto:r-help@r-project.org
   5. mailto:R-help@r-project.org
   6. https://stat.ethz.ch/mailman/listinfo/r-help
   7. http://www.R-project.org/posting-guide.html
   8. mailto:R-help@r-project.org
   9. https://stat.ethz.ch/mailman/listinfo/r-help
  10. http://www.R-project.org/posting-guide.html
  11. mailto:R-help@r-project.org
  12. https://stat.ethz.ch/mailman/listinfo/r-help
  13. http://www.R

Re: [R] scatter plot question

2009-03-04 Thread Marc Vinyes
plot(x,rho,pch=id)

-Mensaje original-
De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]en
nombre de Dipankar Basu
Enviado el: 03 March 2009 20:11
Para: r-help@r-project.org
Asunto: [R] scatter plot question


Hi R Users,

I have a dataframe like this:

id  x   rho
A  1   0.1
B  20  0.5
C  2   0.9
...

I want to do a scatter plot of x versus rho but for each point on the
scatter plot I want the corresponding entry for id instead of points. In
STATA I can do so by

twoway (scatter x rho, mlabel(id))

How can I do the same in R? I am sure there is some simple way to do this.

Dipankar

[[alternative HTML version deleted]]

__
R-help@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.

__
R-help@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.


Re: [R] scatter plot question

2009-03-04 Thread Tim Cavileer

At 12:19 AM 3/4/2009, you wrote:

plot(x,rho,pch=id)


Or this.
Tim

 dat
  id  x rho
1  A  1 0.1
2  B 20 0.5
3  C  2 0.9

 labels-dat$id
 labels
[1] A B C
 plot(dat$x,dat$rho,pch=labels)

__
R-help@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.


[R] scatter plot question

2009-03-03 Thread Dipankar Basu
Hi R Users,

I have a dataframe like this:

id  x   rho
A  1   0.1
B  20  0.5
C  2   0.9
...

I want to do a scatter plot of x versus rho but for each point on the
scatter plot I want the corresponding entry for id instead of points. In
STATA I can do so by

twoway (scatter x rho, mlabel(id))

How can I do the same in R? I am sure there is some simple way to do this.

Dipankar

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] scatter plot question

2009-03-03 Thread Mark Lyman
Dipankar Basu basu.15 at gmail.com writes:

 
 Hi R Users,
 
 I have a dataframe like this:
 
 id  x   rho
 A  1   0.1
 B  20  0.5
 C  2   0.9
 ...
 
 I want to do a scatter plot of x versus rho but for each point on the
 scatter plot I want the corresponding entry for id instead of points.

test - data.frame(id=c(A, B, C), x=c(1, 20, 2), rho=c(0.1, 0.5, 0.9))
plot(rho~x, test, pch=as.character(id))

Mark Lyman

__
R-help@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.


[R] scatter plot using ggplot

2008-07-22 Thread Megh Dal
I used ggplot to create a scatter plot :

library(ggplot)
library(mnormt)
Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2)
x = rmnorm(20, c(0,0), Sigma)
xx = x[order(x[,1]),]
y = xx[,1]
z = xx[,2]
qplot(z, y, type=point, main=x-y plot, xlab=x, col=blue)

However I want following:

1. Plot color must be Blue (where it is displaying as red)
2. There should not be any color platted
3. Plot size must be larger than what it is displacing

Can anyone please tell me how to do that?

Regards,

__
R-help@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.


Re: [R] scatter plot using ggplot

2008-07-22 Thread hadley wickham
On Tue, Jul 22, 2008 at 3:42 AM, Megh Dal [EMAIL PROTECTED] wrote:
 I used ggplot to create a scatter plot :

 library(ggplot)
 library(mnormt)
 Sigma = matrix(c(1, 0.6, 0.6, 1), 2, 2)
 x = rmnorm(20, c(0,0), Sigma)
 xx = x[order(x[,1]),]
 y = xx[,1]
 z = xx[,2]
 qplot(z, y, type=point, main=x-y plot, xlab=x, col=blue)

 However I want following:

 1. Plot color must be Blue (where it is displaying as red)
 2. There should not be any color platted

You can't currently do this with qplot (but will be able to in the
next version).  Use ggplot() instead:

ggplot(data.frame(y,z), aes(y, z)) +
geom_point(colour = blue) +
scale_x_continuous(x) +
opts(title = x-y plot)

 3. Plot size must be larger than what it is displacing

Make the window bigger?

Hadley

-- 
http://had.co.nz/

__
R-help@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.


Re: [R] Scatter plot transparency

2008-06-21 Thread Prof Brian Ripley
Please see the footer of this message.  What do you want to be 
transparent, and what did you use to try to get it (there are many 
possibilities)?  What OS and version of R is this?


Note that the default value of bg for the png() and tiff() devices is 
white, and the Windows version of the tiff() device does not support 
transparency.  But png(bg=transparent) does give a transparent 
background.


On Fri, 20 Jun 2008, Anh Tran wrote:


Hi all,
I'm putting a few plots together and wondering what format would be best to
export a few scatter plots to Illustrator to make a figure. I'm thinking
about overlaying some plot in Illustrator, so the export file type has to be
transparent for Illustrator (version 10).
I tried PNG and TIFF, but it does not seems to have transparency that is
recognized by Illustrator (or Photoshop for that matter).

EMF (meta data file) on the other hand is very good. The only problem is
that every dot on the plot becomes a vector, which slows the program down
considerably (I have about 200k dots on a graph).

So, is there a good way to import these plot in as picture so I can use them
as layer for Illustrator (Photoshop would be fine too).

Thank you all.

--
Regards,
Anh Tran

[[alternative HTML version deleted]]

__
R-help@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.



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@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.


Re: [R] Scatter plot transparency

2008-06-21 Thread Anh Tran
Thanks, I think I've got it on Mac. Will try with my windows station  
tomorrow.


Best,
Anh Tran



On Jun 21, 2008, at 12:05 AM, Prof Brian Ripley wrote:

Please see the footer of this message.  What do you want to be  
transparent, and what did you use to try to get it (there are many  
possibilities)?  What OS and version of R is this?


Note that the default value of bg for the png() and tiff() devices  
is white, and the Windows version of the tiff() device does not  
support transparency.  But png(bg=transparent) does give a  
transparent background.


On Fri, 20 Jun 2008, Anh Tran wrote:


Hi all,
I'm putting a few plots together and wondering what format would be  
best to
export a few scatter plots to Illustrator to make a figure. I'm  
thinking
about overlaying some plot in Illustrator, so the export file type  
has to be

transparent for Illustrator (version 10).
I tried PNG and TIFF, but it does not seems to have transparency  
that is

recognized by Illustrator (or Photoshop for that matter).

EMF (meta data file) on the other hand is very good. The only  
problem is
that every dot on the plot becomes a vector, which slows the  
program down

considerably (I have about 200k dots on a graph).

So, is there a good way to import these plot in as picture so I can  
use them

as layer for Illustrator (Photoshop would be fine too).

Thank you all.

--
Regards,
Anh Tran

[[alternative HTML version deleted]]

__
R-help@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.



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595


__
R-help@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.


[R] Scatter plot transparency

2008-06-20 Thread Anh Tran
Hi all,
I'm putting a few plots together and wondering what format would be best to
export a few scatter plots to Illustrator to make a figure. I'm thinking
about overlaying some plot in Illustrator, so the export file type has to be
transparent for Illustrator (version 10).
I tried PNG and TIFF, but it does not seems to have transparency that is
recognized by Illustrator (or Photoshop for that matter).

EMF (meta data file) on the other hand is very good. The only problem is
that every dot on the plot becomes a vector, which slows the program down
considerably (I have about 200k dots on a graph).

So, is there a good way to import these plot in as picture so I can use them
as layer for Illustrator (Photoshop would be fine too).

Thank you all.

-- 
Regards,
Anh Tran

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] Scatter plot transparency

2008-06-20 Thread milton ruser
Hi Anh,

I don´t know if I understood your point fine.
I generate a scatterplot, and open it on adobe photoshop 7.0 with tranparent
background.

setwd(c:\\temp)

x-runif(100)
y-rnorm(100)

png(transparent_scatterplot.png, 800, 600, bg=transparent)
plot(y~x)
dev.off()

I hope this help,

miltinho
Brazil

On 6/20/08, Anh Tran [EMAIL PROTECTED] wrote:

 Hi all,
 I'm putting a few plots together and wondering what format would be best to
 export a few scatter plots to Illustrator to make a figure. I'm thinking
 about overlaying some plot in Illustrator, so the export file type has to
 be
 transparent for Illustrator (version 10).
 I tried PNG and TIFF, but it does not seems to have transparency that is
 recognized by Illustrator (or Photoshop for that matter).

 EMF (meta data file) on the other hand is very good. The only problem is
 that every dot on the plot becomes a vector, which slows the program down
 considerably (I have about 200k dots on a graph).

 So, is there a good way to import these plot in as picture so I can use
 them
 as layer for Illustrator (Photoshop would be fine too).

 Thank you all.

 --
 Regards,
 Anh Tran

[[alternative HTML version deleted]]

 __
 R-help@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.


[[alternative HTML version deleted]]

__
R-help@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.


[R] Scatter Plot - 3 vectors side by side

2008-05-06 Thread A Ezhil
Hi,

I have 3 vectors, 
x=rnorm(10); y=rnorm(20); z=rnorm(30). 

I would like to plot 3 vectors side by side (like a
bar plot) with scatter plot something similar to the
following: 

..   ***  ;;;
..   **   ;;;
..   ***  ;;;
..   ***  ;;;
...  ***  ;;
x y   z

How can I do this with Plot()? 

Thanks in advance.
Best regards,
Ezhil





  


[[elided Yahoo spam]]

__
R-help@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.


  1   2   >