Re: [R] help with the plot overlay

2018-02-14 Thread Fix Ace via R-help
Hi, JIm,
Thank you so much! Such a convenient tool!
A. 

On Sunday, February 4, 2018 9:59 PM, Jim Lemon  wrote:
 

 Hi Ace,
You can do it with plotrix:

library(plotrix)
barpos<-barp(c(1,5,38),width=0.5,col=c("white","lightgray","darkgray"),ylim=c(0,70))
ehplot(c(1,0.8,0.9,0.8,1.1,1,4,3,5,14,3,2,32,27,33,30,50,61),
 c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3),median=FALSE,add=TRUE,cex=2,
 pch=21,bg="white")
dispersion(barpos$x,barpos$y,c(0.1,1,5),lwd=2,arrow.cap=0.03)
lines(c(barpos$x[2],barpos$x[2],barpos$x[3],barpos$x[3]),c(18,63,63,62))
lines(c(barpos$x[1],barpos$x[1],barpos$x[3],barpos$x[3]),c(4,66,66,65))
text(2,68,"**",cex=2)
text(2.5,64.5,"**",cex=2)

Jim


On Mon, Feb 5, 2018 at 8:56 AM, Fix Ace via R-help  wrote:
> Dear R Community,
> I recently read an article and found a plot as attached. It has scatterplot, 
> barplot, and error bar. Could anyone help me to figure out what package I can 
> use in R to generate such plot?
> Thank you very much for any inputs!
> Kind regards,
> Ace
>
> __
> 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.


[R] help with the plot overlay

2018-02-04 Thread Fix Ace via R-help
Dear R Community,
I recently read an article and found a plot as attached. It has scatterplot, 
barplot, and error bar. Could anyone help me to figure out what package I can 
use in R to generate such plot?
Thank you very much for any inputs!
Kind regards,
Ace
__
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] error message for function: lmer (from lme4 package)

2017-11-16 Thread Fix Ace via R-help
Hi, Bert,
Thank you very much for the comments and suggestions!
Ace 

On Wednesday, November 15, 2017 10:44 AM, Bert Gunter 
 wrote:
 

 Always cc the list, which I have done here. I am not a (free) private 
consultant, nor do I have all the answers.

Based on what you sent me, which is not what you have previously posted, you 
failed to load the lme3 package. See ?library.

As for the appropriateness of your modeling, you should do what David already 
suggested and post to the r-sig-mixed-models list instead.

-- 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 Wed, Nov 15, 2017 at 5:09 AM, Fix Ace  wrote:

Hi, Bert,
Sorry about that! David seemed to be able to read the post since he replied. 
Here I just email you the sample code and error message:
> example.3=data.frame(levels= as.numeric(XXX[,c(4)]), 
> replicate=rep(c("0","1","2"," 3","4","5"),3),conditions=c( 
> rep("11",6),rep("12",6),rep(> example.3    levels replicate conditions1  
> 43.         0         112  42.0942         1         113  57.8131         
> 2         114  57.1726         3         115  77.8678         4         116  
> 44.7578         5         117  69.5078         0         128  52.0581         
> 1         129  40.0602         2         1210 45.5487         3         1211 
> 43.6201         4         1212 60.4939         5         1213 64.1932         
> 0         1314 53.4055         1         1315 59.6701         2         1316 
> 52.6922         3         1317 53.8712         4         1318 60.2770         
> 5         13> m.example.3=lmer(as.numeric( levels)~conditions+( 
> conditions|replicate),data= example.3)Error in lmer(as.numeric(levels) ~ 
> conditions + (conditions | replicate),  :   could not find function "lmer"> 
Hopefully you could read it and provide some comments!
Thank you very much for your time.
Kind regards,
Ace

 

On Tuesday, November 14, 2017 6:12 PM, Bert Gunter  
wrote:
 

 Still a complete mess!

Post in **plain text**. This should be an option in your email software. Please 
seek local help if you cannot figure out how to do this.

-- 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 Tue, Nov 14, 2017 at 12:49 PM, Fix Ace via R-help  
wrote:

Hi, David,
Thank you very much for getting back to me! Sorry about the messy code example. 
I am re-posting here (including the error message):
> example.3=data.frame(levels= as.numeric(XXX[,c(4)]), 
> replicate=rep(c("0","1","2"," 3","4","5"),3),conditions=c( 
> rep("11",6),rep("12",6),rep(" 13",6)))> example.3    levels replicate 
> conditions1  43.         0         112  42.0942         1         113  
> 57.8131         2         114  57.1726         3         115  77.8678         
> 4         116  44.7578         5         117  69.5078         0         128  
> 52.0581         1         129  40.0602         2         1210 45.5487         
> 3         1211 43.6201         4         1212 60.4939         5         1213 
> 64.1932         0         1314 53.4055         1         1315 59.6701         
> 2         1316 52.6922         3         1317 53.8712         4         1318 
> 60.2770         5         13> m.example.3=lmer(as.numeric( 
> levels)~conditions+( conditions|replicate),data= example.3)Error: number of 
> observations (=18) <= number of random effects (=18) for term (conditions | 
> replicate); the random-effects parameters and the residual variance (or scale 
> parameter) are probably unidentifiable> 
Please let me know if it is readable this time. 
Again, many thanks for your time and please help me fix the issue.
Kind regards,
Ace

    On Tuesday, November 14, 2017 12:19 PM, David Winsemius 
 wrote:



> On Nov 14, 2017, at 5:13 AM, Fix Ace via R-help  wrote:
>
> Dear R Community,
> My data have 3 conditions and each condition has 6 replicates. I am trying to 
> fit my data for a linear mixed model using the lmer function from lme4 
> package to find the random effects of the replicates;

Better venue for this question might be SIG-mixed-models. See the link 
avaialble at the bottom of every posting from rhelp:

https://stat.ethz.ch/mailman/ listinfo/r-help:



> however, I got the error message. Here are the example codes:
>> example.3=data.frame(levels= as.numeric(XXX[,c(4)]), 
>> replicate=rep(c("0","1","2"," 3","4","5"),3),

Re: [R] error message for function: lmer (from lme4 package)

2017-11-14 Thread Fix Ace via R-help
Hi, David,
Thank you very much for getting back to me! Sorry about the messy code example. 
I am re-posting here (including the error message):
> example.3=data.frame(levels=as.numeric(XXX[,c(4)]),replicate=rep(c("0","1","2","3","4","5"),3),conditions=c(rep("11",6),rep("12",6),rep("13",6)))>
>  example.3    levels replicate conditions1  43.         0         112  
> 42.0942         1         113  57.8131         2         114  57.1726         
> 3         115  77.8678         4         116  44.7578         5         117  
> 69.5078         0         128  52.0581         1         129  40.0602         
> 2         1210 45.5487         3         1211 43.6201         4         1212 
> 60.4939         5         1213 64.1932         0         1314 53.4055         
> 1         1315 59.6701         2         1316 52.6922         3         1317 
> 53.8712         4         1318 60.2770         5         13> 
> m.example.3=lmer(as.numeric(levels)~conditions+(conditions|replicate),data=example.3)Error:
>  number of observations (=18) <= number of random effects (=18) for term 
> (conditions | replicate); the random-effects parameters and the residual 
> variance (or scale parameter) are probably unidentifiable> 
Please let me know if it is readable this time. 
Again, many thanks for your time and please help me fix the issue.
Kind regards,
Ace 

On Tuesday, November 14, 2017 12:19 PM, David Winsemius 
 wrote:
 

 
> On Nov 14, 2017, at 5:13 AM, Fix Ace via R-help  wrote:
> 
> Dear R Community,
> My data have 3 conditions and each condition has 6 replicates. I am trying to 
> fit my data for a linear mixed model using the lmer function from lme4 
> package to find the random effects of the replicates;

Better venue for this question might be SIG-mixed-models. See the link 
avaialble at the bottom of every posting from rhelp:

https://stat.ethz.ch/mailman/listinfo/r-help:



> however, I got the error message. Here are the example codes:
>> example.3=data.frame(levels=as.numeric(XXX[,c(4)]),replicate=rep(c("0","1","2","3","4","5"),3),conditions=c(rep("11",6),rep("12",6),rep("13",6)))>
>>  example.3    levels replicate conditions1  43.        0        112  
>> 42.0942        1        113  57.8131        2        114  57.1726        3   
>>      115  77.8678        4        116  44.7578        5        117  69.5078  
>>       0        128  52.0581        1        129  40.0602        2        
>> 1210 45.5487        3        1211 43.6201        4        1212 60.4939       
>>  5        1213 64.1932        0        1314 53.4055        1        1315 
>> 59.6701        2        1316 52.6922        3        1317 53.8712        4   
>>      1318 60.2770        5        13> 
>> m.example.3=lmer(as.numeric(levels)~conditions+(conditions|replicate),data=example.3)Error:
>>  number of observations (=18) <= number of random effects (=18) for term 
>> (conditions | replicate); the random-effects parameters and the residual 
>> variance (or scale parameter) are probably unidentifiable> 
> Could anyone help me figure out how to fix the issue? 
> Thank you very much for any inputs!
> Ace
> 
>     [[alternative HTML version deleted]]

Complete mess. If you haven't yet been advised to posting in plain text, then 
this should be your wakeup call. If you have, then why are you ignoring 
sensible advice?


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

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'  
-Gehm's Corollary to Clarke's Third Law






   
[[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] error message for function: lmer (from lme4 package)

2017-11-14 Thread Fix Ace via R-help
Dear R Community,
My data have 3 conditions and each condition has 6 replicates. I am trying to 
fit my data for a linear mixed model using the lmer function from lme4 package 
to find the random effects of the replicates; however, I got the error message. 
Here are the example codes:
>example.3=data.frame(levels=as.numeric(XXX[,c(4)]),replicate=rep(c("0","1","2","3","4","5"),3),conditions=c(rep("11",6),rep("12",6),rep("13",6)))>
> example.3    levels replicate conditions1  43.         0         112  
>42.0942         1         113  57.8131         2         114  57.1726         
>3         115  77.8678         4         116  44.7578         5         117  
>69.5078         0         128  52.0581         1         129  40.0602         
>2         1210 45.5487         3         1211 43.6201         4         1212 
>60.4939         5         1213 64.1932         0         1314 53.4055         
>1         1315 59.6701         2         1316 52.6922         3         1317 
>53.8712         4         1318 60.2770         5         13> 
>m.example.3=lmer(as.numeric(levels)~conditions+(conditions|replicate),data=example.3)Error:
> number of observations (=18) <= number of random effects (=18) for term 
>(conditions | replicate); the random-effects parameters and the residual 
>variance (or scale parameter) are probably unidentifiable> 
Could anyone help me figure out how to fix the issue? 
Thank you very much for any inputs!
Ace

[[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] dendrogram adjustment in heatmap.2

2017-11-08 Thread Fix Ace via R-help
Dear R Community,
Is there a way to adjust the line width of the dendrogram in heat map.2 
function? I tried "lwd", but it didn't work...
Also, is there a way to adjust the general height/width/position of the 
dendrogram using heatmap.2 function? I feel the portion of the dendrogram is 
huge compared with the overall graph. I would like to squeeze them a bit.
Thank you very much for any inputs!
Kind regards,
Ace


[[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] pheatmap: incomplete figure

2017-09-20 Thread Fix Ace via R-help
Thank you so much for the reply! I thought the file would automatically adjust 
accordingly. But I just checked and found pheatmap does has width as parameter!
Ace 

On Monday, September 18, 2017 3:00 PM, David Winsemius 
 wrote:
 

 
> On Sep 18, 2017, at 9:26 AM, Fix Ace via R-help  wrote:
> 
> Dear R Community,
> I tried to generate heatmap for a matrix of 1500 columns by 106 rows using 
> the following R script:
>> pheatmap(tf.vs.DE.1.removeAllZeroCol, fontsize=3,border_color=NA)
> and got the graph (as attached Fig 1)
> 
> Since the column labels appear very crowded, I tried to increase the 
> cellwidth to stretch the graph horizontally. The idea was to show the graph 
> section by section, but with clear/readable column labels (not overlapped 
> labels).
> So I typed:
>> pheatmap(tf.vs.DE.1.removeAllZeroCol, 
>> fontsize=3,cellwidth=3,cellheight=3,border_color=NA)
> However, this time I only got middle part of the original heatmap (as 
> attached Fig 2)
> I wonder if there is way I could output the whole graph after such horizontal 
> stretch. If not, how do I get the left end of the graph.
> 

Why not define a graphics device that is wider?

-- 

David Winsemius
Alameda, CA, USA

'Any technology distinguishable from magic is insufficiently advanced.'  
-Gehm's Corollary to Clarke's Third Law






   
[[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] error with subtree()

2017-09-09 Thread Fix Ace via R-help
Dear R community,
I would like to plot a partial hclust output, so I am looking for a subtree 
function that would return an tree structure I can plot.
I ran the test code of subtree following the instruction on 
http://finzi.psych.upenn.edu/library/extracat/html/subtree.html
However, an error message popped up:
> library(extracat)
Attaching package: ‘extracat’
The following object is masked _by_ ‘.GlobalEnv’:
    subtreehc <- hclust(dist(USArrests), "ave")> > hcs <- subtree(hc, k = 
7)Error in subtree(hc, k = 7) : unused argument (k = 7)
===
Can anyone help me what happened here? And what should I do with it?
Thank you very much!
Ace

[[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] help with read.csv() for files with different number of columns

2017-08-29 Thread Fix Ace via R-help
Thank you very much! Looks like I have to know the length of each record ahead 
of time.
Ace
 

On Monday, August 28, 2017 12:56 AM, Jim Lemon  wrote:
 

 Hi Ace,
With tabs as separators:

testdf<-read.table("test.txt",header=FALSE,fill=TRUE,sep="\t",
col.names=paste("V",1:19,sep=""),stringsAsFactors=FALSE)

Also note that I got the number of columns wrong the first time.

Jim


On Mon, Aug 28, 2017 at 12:56 PM, Fix Ace  wrote:
> Hi, Jim,
>
> Thank you very much for pointing out the format issue. Here is the original
> text:
>
> ===
> I have a text file (test.txt) with different number of columns:
>
> 0610007P14Rik%%% Tcf19 Gtf2i
> 0610010O12Rik%%% Ivns1abp Etv6
> 111G20Rik%%% Nmi
> 1500015O10Rik%%% Foxi1 Ascl3 Sirt3
> 173E16Rik%%% Ascl2 Ifnar2
> 1700028J19Rik%%% Musk Nfe2l3
> 1810011O10Rik%%% Ppp1r13b Bpnt1 Cdkn2c Foxc1 Sox10 Smarca2
> 1810019D21Rik%%% Asb8
> 1810037I17Rik%%% Zfp612
> 1810055G02Rik%%% Nkx2-3 Maged1 Runx1 Ugp2 Elk4 Spdef Tcf19 Isl2 Gtf2i
> Ctnnbl1 Tcea3 Ank2 Zfp612 Creb3l1 Nupr1 3632451O06Rik Creb3l4 Lass6
>
> I wold like to read it into R using
>
>> test=read.csv("test.txt",sep="\t",header=FALSE)
>
> However, when I check the r object "test", I found that all the rows have 5
> columns:
>
>> test
>                  V1            V2      V3    V4      V5
> 1  0610007P14Rik%%%        Tcf19  Gtf2i
> 2  0610010O12Rik%%%      Ivns1abp    Etv6
> 3  111G20Rik%%%          Nmi
> 4  1500015O10Rik%%%        Foxi1  Ascl3  Sirt3
> 5  173E16Rik%%%        Ascl2  Ifnar2
> 6  1700028J19Rik%%%          Musk  Nfe2l3
> 7  1810011O10Rik%%%      Ppp1r13b  Bpnt1 Cdkn2c  Foxc1
> 8            Sox10      Smarca2
> 9  1810019D21Rik%%%          Asb8
> 10 1810037I17Rik%%%        Zfp612
> 11 1810055G02Rik%%%        Nkx2-3  Maged1  Runx1    Ugp2
> 12            Elk4        Spdef  Tcf19  Isl2  Gtf2i
> 13          Ctnnbl1        Tcea3    Ank2 Zfp612 Creb3l1
> 14            Nupr1 3632451O06Rik Creb3l4  Lass6
>
> Basically it breaks some rows into more than one rows. For example, row 7 in
> the original record becomes two rows. Looks like the "test" always has 5
> columns.
>
> How does this happen? How should I fix it to make one record into one two in
> R object?
>
> ==
>
> Please let me know if it is readable now. Thank you very much for your time!
>
> Kind regards,
>
> Ace
>
>
> On Sunday, August 27, 2017 7:25 PM, Jim Lemon  wrote:
>
>
> Hi Ace,
> As your example seems to have spaces as separators,
>
> testdf<-read.table("test.txt",header=FALSE,fill=TRUE,
> col.names=paste("V",1:14,sep=""),stringsAsFactors=FALSE)
>
> By specifying the number of columns with "col.names" and using
> "fill=TRUE" you can get a data frame with zero length strings where
> values are missing in the input file.
>
> Jim
>
> On Mon, Aug 28, 2017 at 6:25 AM, Fix Ace via R-help
>  wrote:
>> Dear R community,
>> I have a text file (test.txt) with different number of columns:
>> 0610007P14Rik%%% Tcf19 Gtf2i 0610010O12Rik%%% Ivns1abp Etv6
>> 111G20Rik%%% Nmi 1500015O10Rik%%% Foxi1 Ascl3 Sirt3 173E16Rik%%%
>> Ascl2 Ifnar2 1700028J19Rik%%% Musk Nfe2l3 1810011O10Rik%%% Ppp1r13b Bpnt1
>> Cdkn2c Foxc1 Sox10 Smarca2 1810019D21Rik%%% Asb8 1810037I17Rik%%% Zfp612
>> 1810055G02Rik%%% Nkx2-3 Maged1 Runx1 Ugp2 Elk4 Spdef Tcf19 Isl2 Gtf2i
>> Ctnnbl1 Tcea3 Ank2 Zfp612 Creb3l1 Nupr1 3632451O06Rik Creb3l4 Lass6
>> I wold like to read it into R using
>>  > test=read.csv("test.txt",sep="\t",header=FALSE)
>> However, when I check the r object "test", I found that all the rows have
>> 5 columns:
>>> test                V1            V2      V3    V4      V51
>>> 0610007P14Rik%%%        Tcf19  Gtf2i              2  0610010O12Rik%%%
>>> Ivns1abp    Etv6              3  111G20Rik%%%          Nmi
>>> 4  1500015O10Rik%%%        Foxi1  Ascl3  Sirt3        5  173E16Rik%%%
>>> Ascl2  Ifnar2              6  1700028J19Rik%%%          Musk  Nfe2l3
>>> 7  1810011O10Rik%%%      Ppp1r13b  Bpnt1 Cdkn2c  Foxc18            Sox10
>>> Smarca2                      9  1810019D21Rik%%%          Asb8
>>> 10 1810037I17Rik%%%        Zfp612                      11 1810055G02Rik%%%
>>> Nkx2-3  Maged1  Runx1    Ugp212            Elk4        Spdef  Tcf19  Isl2
>>> Gtf2i13          Ctnnbl1        Tcea3    Ank2 Zfp612 Creb3l114
>>> Nupr1 3632451O06Rik Creb3l4  Lass6
>> Basically it breaks some rows into more than one rows. For example, row 7
>> in the original r

Re: [R] help with read.csv() for files with different number of columns

2017-08-27 Thread Fix Ace via R-help
Hi, Jim,
Thank you very much for pointing out the format issue. Here is the original 
text:
===I have a text file (test.txt) with different number of columns:

0610007P14Rik%%% Tcf19 Gtf2i 0610010O12Rik%%% Ivns1abp Etv6 111G20Rik%%% 
Nmi 1500015O10Rik%%% Foxi1 Ascl3 Sirt3 173E16Rik%%% Ascl2 Ifnar2 
1700028J19Rik%%% Musk Nfe2l3 1810011O10Rik%%% Ppp1r13b Bpnt1 Cdkn2c Foxc1 Sox10 
Smarca2 1810019D21Rik%%% Asb8 1810037I17Rik%%% Zfp612 1810055G02Rik%%% Nkx2-3 
Maged1 Runx1 Ugp2 Elk4 Spdef Tcf19 Isl2 Gtf2i Ctnnbl1 Tcea3 Ank2 Zfp612 Creb3l1 
Nupr1 3632451O06Rik Creb3l4 Lass6 
I wold like to read it into R using
 > test=read.csv("test.txt",sep="\t",header=FALSE)
However, when I check the r object "test", I found that all the rows have 5 
columns:
> test                 V1            V2      V3     V4      V51  
> 0610007P14Rik%%%         Tcf19   Gtf2i               2  0610010O12Rik%%%      
> Ivns1abp    Etv6               3  111G20Rik%%%           Nmi              
>          4  1500015O10Rik%%%         Foxi1   Ascl3  Sirt3        5  
> 173E16Rik%%%         Ascl2  Ifnar2               6  1700028J19Rik%%%      
>     Musk  Nfe2l3               7  1810011O10Rik%%%      Ppp1r13b   Bpnt1 
> Cdkn2c   Foxc18             Sox10       Smarca2                       9  
> 1810019D21Rik%%%          Asb8                       10 1810037I17Rik%%%      
>   Zfp612                       11 1810055G02Rik%%%        Nkx2-3  Maged1  
> Runx1    Ugp212             Elk4         Spdef   Tcf19   Isl2   Gtf2i13       
>    Ctnnbl1         Tcea3    Ank2 Zfp612 Creb3l114            Nupr1 
> 3632451O06Rik Creb3l4  Lass6 
Basically it breaks some rows into more than one rows. For example, row 7 in 
the original record becomes two rows. Looks like the "test" always has 5 
columns. 
How does this happen? How should I fix it to make one record into one two in R 
object?
==
Please let me know if it is readable now. Thank you very much for your time!
Kind regards,
Ace 

On Sunday, August 27, 2017 7:25 PM, Jim Lemon  wrote:
 

 Hi Ace,
As your example seems to have spaces as separators,

testdf<-read.table("test.txt",header=FALSE,fill=TRUE,
col.names=paste("V",1:14,sep=""),stringsAsFactors=FALSE)

By specifying the number of columns with "col.names" and using
"fill=TRUE" you can get a data frame with zero length strings where
values are missing in the input file.

Jim

On Mon, Aug 28, 2017 at 6:25 AM, Fix Ace via R-help
 wrote:
> Dear R community,
> I have a text file (test.txt) with different number of columns:
> 0610007P14Rik%%% Tcf19 Gtf2i 0610010O12Rik%%% Ivns1abp Etv6 111G20Rik%%% 
> Nmi 1500015O10Rik%%% Foxi1 Ascl3 Sirt3 173E16Rik%%% Ascl2 Ifnar2 
> 1700028J19Rik%%% Musk Nfe2l3 1810011O10Rik%%% Ppp1r13b Bpnt1 Cdkn2c Foxc1 
> Sox10 Smarca2 1810019D21Rik%%% Asb8 1810037I17Rik%%% Zfp612 1810055G02Rik%%% 
> Nkx2-3 Maged1 Runx1 Ugp2 Elk4 Spdef Tcf19 Isl2 Gtf2i Ctnnbl1 Tcea3 Ank2 
> Zfp612 Creb3l1 Nupr1 3632451O06Rik Creb3l4 Lass6
> I wold like to read it into R using
>  > test=read.csv("test.txt",sep="\t",header=FALSE)
> However, when I check the r object "test", I found that all the rows have 5 
> columns:
>> test                V1            V2      V3    V4      V51  
>> 0610007P14Rik%%%        Tcf19  Gtf2i              2  0610010O12Rik%%%      
>> Ivns1abp    Etv6              3  111G20Rik%%%          Nmi               
>>        4  1500015O10Rik%%%        Foxi1  Ascl3  Sirt3        5  
>> 173E16Rik%%%        Ascl2  Ifnar2              6  1700028J19Rik%%%       
>>    Musk  Nfe2l3              7  1810011O10Rik%%%      Ppp1r13b  Bpnt1 Cdkn2c 
>>  Foxc18            Sox10      Smarca2                      9  
>> 1810019D21Rik%%%          Asb8                      10 1810037I17Rik%%%      
>>   Zfp612                      11 1810055G02Rik%%%        Nkx2-3  Maged1  
>> Runx1    Ugp212            Elk4        Spdef  Tcf19  Isl2  Gtf2i13          
>> Ctnnbl1        Tcea3    Ank2 Zfp612 Creb3l114            Nupr1 3632451O06Rik 
>> Creb3l4  Lass6
> Basically it breaks some rows into more than one rows. For example, row 7 in 
> the original record becomes two rows. Looks like the "test" always has 5 
> columns.
> How does this happen? How should I fix it to make one record into one two in 
> R object?
> Thank you very much!
> Ace
>
>
>
>
>
>
>
>
>        [[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-con

[R] help with read.csv() for files with different number of columns

2017-08-27 Thread Fix Ace via R-help
Dear R community,
I have a text file (test.txt) with different number of columns:
0610007P14Rik%%% Tcf19 Gtf2i 0610010O12Rik%%% Ivns1abp Etv6 111G20Rik%%% 
Nmi 1500015O10Rik%%% Foxi1 Ascl3 Sirt3 173E16Rik%%% Ascl2 Ifnar2 
1700028J19Rik%%% Musk Nfe2l3 1810011O10Rik%%% Ppp1r13b Bpnt1 Cdkn2c Foxc1 Sox10 
Smarca2 1810019D21Rik%%% Asb8 1810037I17Rik%%% Zfp612 1810055G02Rik%%% Nkx2-3 
Maged1 Runx1 Ugp2 Elk4 Spdef Tcf19 Isl2 Gtf2i Ctnnbl1 Tcea3 Ank2 Zfp612 Creb3l1 
Nupr1 3632451O06Rik Creb3l4 Lass6 
I wold like to read it into R using
 > test=read.csv("test.txt",sep="\t",header=FALSE)
However, when I check the r object "test", I found that all the rows have 5 
columns:
> test                 V1            V2      V3     V4      V51  
> 0610007P14Rik%%%         Tcf19   Gtf2i               2  0610010O12Rik%%%      
> Ivns1abp    Etv6               3  111G20Rik%%%           Nmi              
>          4  1500015O10Rik%%%         Foxi1   Ascl3  Sirt3        5  
> 173E16Rik%%%         Ascl2  Ifnar2               6  1700028J19Rik%%%      
>     Musk  Nfe2l3               7  1810011O10Rik%%%      Ppp1r13b   Bpnt1 
> Cdkn2c   Foxc18             Sox10       Smarca2                       9  
> 1810019D21Rik%%%          Asb8                       10 1810037I17Rik%%%      
>   Zfp612                       11 1810055G02Rik%%%        Nkx2-3  Maged1  
> Runx1    Ugp212             Elk4         Spdef   Tcf19   Isl2   Gtf2i13       
>    Ctnnbl1         Tcea3    Ank2 Zfp612 Creb3l114            Nupr1 
> 3632451O06Rik Creb3l4  Lass6 
Basically it breaks some rows into more than one rows. For example, row 7 in 
the original record becomes two rows. Looks like the "test" always has 5 
columns. 
How does this happen? How should I fix it to make one record into one two in R 
object?
Thank you very much!
Ace




 


   
[[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] prcomp: Error in La.svd(x, nu, nv): error code 1 from Lapack routine "dgesdd"

2017-05-23 Thread Fix Ace via R-help
Dear R community,
I have a data matrix (531X314), and would like to apply the prcomp. However, I 
got this error Lapack message. I am using R3.2.2.
I googled a bit and found that it might be related to converge issue.  Just 
wonder if there is a way to get around it?
Thank you very much!
Ace 

On Thursday, December 29, 2016 11:44 AM, Ista Zahn  
wrote:
 

 Use coord_fixed()

--Ista

On Thu, Dec 29, 2016 at 9:59 AM, Fix Ace via R-help
 wrote:
>
>
>
>  Hello, there,
> What exactly does "expand" do for this function?
> I followed the examples from the manual to get a plot:
>
> d <- ggplot(subset(diamonds, carat > 1), aes(cut, clarity)) +geom_jitter()
>
> I would like to have all the dots in a square instead of rectangular range. 
> When I applied d + scale_x_discrete(expand=c(1,1)) and d + 
> scale_x_discrete(expand=c(1,0)), I got the same plot (different from the 
> original one though).
> Could anyone help me to figure out how to use this argument?
> Thank you very much!
> Ace
>
>
>
>
>
>        [[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.


   
[[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] [FORGED] Re: get() return nothing

2017-02-18 Thread Fix Ace via R-help
Thank you very much for the information! I will try it!
Ace 

On Tuesday, February 14, 2017 8:48 AM, Ben Tupper  
wrote:
 

 Hi,

When you want to get 'something' out of a loop you need to assign that 
'something' to a variable that persists outside of the loop. I think it is a 
scoping thing. In your situation you could create a list with as many elements 
as there are objects with 'txt' in their names.  I can't quite follow what is 
is you are after, but perhaps something like this (untested and I'm still on my 
first cup of coffee) ...

obj_names <- ls(pattern="txt")
obj_dims <- vector(mode = 'list', length = length(obj_names))
names(obj_dims) <- obj_names
for (nm in obj_names)){
    obj_dims[[nm]] <- dim(get(nm)) 
}

Does that do what you want?  If so, you could probably use lapply() for the 
purpose instead of the for loop, but even better is to store each of your 
objects in a list as you create them rather than letting them get loose in the 
global environment.  That way you don't have to do this get-by-name rodeo to 
get info on them.

Cheers,
Ben



> On Feb 14, 2017, at 2:57 AM, Rolf Turner  wrote:
> 
> 
> On 14/02/17 05:50, Fix Ace via R-help wrote:
> 
>> Well, I am not trying to print anything. I just would like to get the 
>> dimension information for all the dataframes I created. Could you please 
>> help me to develop the script?
>> Thanks.
>> Ace
> 
> Yes you *are* trying to print something.  You are trying to print the 
> dimension information, i.e. dim(get(i))!!! For Pete's sake (a) *think* about 
> what you are doing and (b) *try* example that Duncan suggested to you.
> 
> cheers,
> 
> Rolf Turner
>> 
>>    On Saturday, February 11, 2017 7:53 PM, Duncan Murdoch 
>> wrote:
>> 
>> 
>> On 11/02/2017 1:33 PM, Fix Ace via R-help wrote:
>>> Hello, there,
>>> I wrote a loop to check the dimension of all the .txt dataframes:> ls()
>>>  [1] "actualpca.table" "b4galnt2"        "b4galnt2.txt"    "data"
>>>  [5] "galnt4"          "galnt4.txt"      "galnt5"          "galnt5.txt"
>>>  [9] "galnt6"          "galnt6.txt"      "glyco"          "glyco.txt"
>>> [13] "i"              "mtscaled"        "newsig.table"    "nicepca"
>>> [17] "pca"            "sig.txt"        "st3gal3"        "st3gal3.txt"
>>> [21] "st3gal5"        "st3gal5.txt"    "st6gal1"        "st6gal1.txt"
>>>> for(i in ls(pattern="txt")){dim(get(i))}
>>>> 
>>> If I check individual ones, they are ok:
>>>> dim(get("galnt4.txt"))
>>> [1] 8 3
>>>> 
>>> could anyone help me to figure out why it did not work with a loop?
>>> Thanks a lot!
>> 
>> It's the difference between
>> 
>> for (i in 1:10) i
>> 
>> (which prints nothing) and
>> 
>> for (i in 1:10) print(i)
>> 
>> Duncan Murdoch
>> 
>> 
>> 
>> 
>>     [[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.
>> 
> 
> 
> -- 
> Technical Editor ANZJS
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
> 
> __
> 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.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org




   
[[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] get() return nothing

2017-02-13 Thread Fix Ace via R-help
Well, I am not trying to print anything. I just would like to get the dimension 
information for all the dataframes I created. Could you please help me to 
develop the script?
Thanks.
Ace 

On Saturday, February 11, 2017 7:53 PM, Duncan Murdoch 
 wrote:
 

 On 11/02/2017 1:33 PM, Fix Ace via R-help wrote:
> Hello, there,
> I wrote a loop to check the dimension of all the .txt dataframes:> ls()
>  [1] "actualpca.table" "b4galnt2"        "b4galnt2.txt"    "data"
>  [5] "galnt4"          "galnt4.txt"      "galnt5"          "galnt5.txt"
>  [9] "galnt6"          "galnt6.txt"      "glyco"          "glyco.txt"
> [13] "i"              "mtscaled"        "newsig.table"    "nicepca"
> [17] "pca"            "sig.txt"        "st3gal3"        "st3gal3.txt"
> [21] "st3gal5"        "st3gal5.txt"    "st6gal1"        "st6gal1.txt"
>> for(i in ls(pattern="txt")){dim(get(i))}
>>
> If I check individual ones, they are ok:
>> dim(get("galnt4.txt"))
> [1] 8 3
>>
> could anyone help me to figure out why it did not work with a loop?
> Thanks a lot!

It's the difference between

for (i in 1:10) i

(which prints nothing) and

for (i in 1:10) print(i)

Duncan Murdoch



   
[[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] get() return nothing

2017-02-11 Thread Fix Ace via R-help
Hello, there,
I wrote a loop to check the dimension of all the .txt dataframes:> ls()
 [1] "actualpca.table" "b4galnt2"    "b4galnt2.txt"    "data"
 [5] "galnt4"  "galnt4.txt"  "galnt5"  "galnt5.txt"
 [9] "galnt6"  "galnt6.txt"  "glyco"   "glyco.txt"
[13] "i"   "mtscaled"    "newsig.table"    "nicepca"
[17] "pca" "sig.txt" "st3gal3" "st3gal3.txt"
[21] "st3gal5" "st3gal5.txt" "st6gal1" "st6gal1.txt"
> for(i in ls(pattern="txt")){dim(get(i))}
>
If I check individual ones, they are ok:
> dim(get("galnt4.txt"))
[1] 8 3
>
could anyone help me to figure out why it did not work with a loop?
Thanks a lot!

Ace






 

  
  
[[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] princomp() output loadings component missing

2017-02-02 Thread Fix Ace via R-help
Thank you very much!
Ace 

On Sunday, January 29, 2017 4:13 PM, Ben Tupper  wrote:
 

 Hi,

Check out the detailed explanation in the 'Value' section of ?princomp - in 
particular for 'loadings'.  It will send you to ?loadings where it explains why 
that one element appears to be missing.

If you really want to see the missing value try...

p3$loadings['Rape', 'Comp.4']

... or even ...

unclass(p3$loadings)

Don't forget that this email list works best when messages are send in plain 
text, and it works poorly for html or rich text.  Check the settings in your 
email client.  In case others are interested here is what the loadings print 
to...

Loadings:
        Comp.1 Comp.2 Comp.3 Comp.4
Murder  -0.536  0.418 -0.341  0.649
Assault  -0.583  0.188 -0.268 -0.743
UrbanPop -0.278 -0.873 -0.378  0.134
Rape    -0.543 -0.167  0.818      

              Comp.1 Comp.2 Comp.3 Comp.4
SS loadings      1.00  1.00  1.00  1.00
Proportion Var  0.25  0.25  0.25  0.25
Cumulative Var  0.25  0.50  0.75  1.00 

Cheers,
Ben

> On Jan 29, 2017, at 4:31 AM, Fix Ace via R-help  wrote:
> 
> Hello, there,
> I did a test run for this princomp() function using USArrests data. The R 
> document says that the output loadings contain the eigenvector matrix. When I 
> looked at this matrix, I found that a missing item for Comp.4 
> 
>> p3=princomp(USArrests, cor=TRUE )> p3$loadings
> Loadings:        Comp.1 Comp.2 Comp.3 Comp.4Murder  -0.536  0.418 -0.341  
> 0.649Assault  -0.583  0.188 -0.268 -0.743UrbanPop -0.278 -0.873 -0.378  
> 0.134Rape    -0.543 -0.167  0.818      
>                Comp.1 Comp.2 Comp.3 Comp.4SS loadings      1.00  1.00  1.00  
>1.00Proportion Var  0.25  0.25  0.25  0.25Cumulative Var  0.25  0.50  0.75  
>1.00
> How should I explain this?
> Thanks.
> Ace
> 
> 
>     [[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.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org




   
[[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] princomp() output loadings component missing

2017-01-29 Thread Fix Ace via R-help
Hello, there,
I did a test run for this princomp() function using USArrests data. The R 
document says that the output loadings contain the eigenvector matrix. When I 
looked at this matrix, I found that a missing item for Comp.4 

   > p3=princomp(USArrests, cor=TRUE )> p3$loadings
Loadings:         Comp.1 Comp.2 Comp.3 Comp.4Murder   -0.536  0.418 -0.341  
0.649Assault  -0.583  0.188 -0.268 -0.743UrbanPop -0.278 -0.873 -0.378  
0.134Rape     -0.543 -0.167  0.818       
               Comp.1 Comp.2 Comp.3 Comp.4SS loadings      1.00   1.00   1.00   
1.00Proportion Var   0.25   0.25   0.25   0.25Cumulative Var   0.25   0.50   
0.75   1.00
How should I explain this?
Thanks.
Ace

   
[[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] ggplot2 package: argument of expand with scale_x_discrete()

2016-12-29 Thread Fix Ace via R-help



 Hello, there,
What exactly does "expand" do for this function?
I followed the examples from the manual to get a plot: 

d <- ggplot(subset(diamonds, carat > 1), aes(cut, clarity)) +geom_jitter()

I would like to have all the dots in a square instead of rectangular range. 
When I applied d + scale_x_discrete(expand=c(1,1)) and d + 
scale_x_discrete(expand=c(1,0)), I got the same plot (different from the 
original one though).
Could anyone help me to figure out how to use this argument?
Thank you very much!
Ace
 



   
[[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] [FORGED] help with gradient boxplot

2016-12-12 Thread Fix Ace via R-help
Hi, Paul,
Thank you so much for this further clarification!
Ace 

On Sunday, December 11, 2016 2:09 PM, Paul Murrell 
 wrote:
 

 Hi

Great to hear you have it working.

Figuring out the names of grobs takes two things:

1. someone has to name the grobs
2. grid.ls()

The reason why I did my example using 'lattice' is because 'lattice' 
names all of its grobs.  There is a document ...

http://lattice.r-forge.r-project.org/Vignettes/src/naming-scheme/namingScheme.pdf

... that describes the 'lattice' naming scheme.

Paul

On 10/12/16 10:39, Fix Ace wrote:
> Hi, Paul,
>
> Thank you very much! It works this time with "strict=FALSE" option.
>
> Another relevant question:
>
> how did you figure out  that boxes in boxplot are called
> "bwplot.box.polygon". If I am trying to make a gradient filling for
> barplot of other plots, how would I define grobs?
>
> Thanks!!
>
> Ace
>
>
>
>
>
> On Thursday, December 8, 2016 5:24 PM, Paul Murrell
>  wrote:
>
>
> Hi
>
> You could try ...
>
> grid.export(..., strict=FALSE)
>
> ... and/or install the latest gridSVG version from R-Forge ...
>
> https://r-forge.r-project.org/R/?group_id=1025
>
> Paul
>
>

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/


   
[[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] [FORGED] help with gradient boxplot

2016-12-09 Thread Fix Ace via R-help
Hi, Paul,
Thank you very much! It works this time with "strict=FALSE" option.
Another relevant question:
how did you figure out  that boxes in boxplot are called "bwplot.box.polygon". 
If I am trying to make a gradient filling for barplot of other plots, how would 
I define grobs?
Thanks!!
Ace



 

On Thursday, December 8, 2016 5:24 PM, Paul Murrell 
 wrote:
 

 Hi

You could try ...

grid.export(..., strict=FALSE)

... and/or install the latest gridSVG version from R-Forge ...

https://r-forge.r-project.org/R/?group_id=1025

Paul


   
[[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] [FORGED] help with gradient boxplot

2016-12-08 Thread Fix Ace via R-help
Hi, Paul,
Thank you very much for your reply. I tried your sample code, but did not get 
gradient filling (still empty box). And many warnings:1: In checkAttrs(attrs, 
eltName) :
  Removing non-SVG attribute name(s): fill, fill-opacity
2: In checkAttrs(attrs, eltName) :
  Removing non-SVG attribute name(s): fill, fill-opacity
3: In checkAttrs(attrs, eltName) :
  Removing non-SVG attribute name(s): fill, fill-opacity
4: In checkAttrs(attrs, eltName) :
  Removing non-SVG attribute name(s): fill, fill-opacity
5: In checkAttrs(attrs, eltName) :
...

I saw the figure in an article, and so I don't have to script. I am actually 
trying to generate the similar figure for my own data. 

Any other thoughts?
Thanks.
Ace
 

On Tuesday, December 6, 2016 7:43 PM, Paul Murrell 
 wrote:
 

 Hi

'gridSVG' might be one way to get this.  For example ...

library(lattice)
# Draw boxplot (with a package that sits on top of 'grid')
bwplot(voice.part ~ height, data=singer, xlab="Height (inches)",
        horizontal=FALSE)

library(grid)
grid.ls()
# Looks like boxes are called bwplot.box.polygon

library(gridSVG)
# Define linear gradient
fill <- linearGradient(c("blue", "red"),
                        x0=.5, x1=.5,
                        gradientUnits="coords")
# Register gradient now so it applies to the whole page
registerGradientFill("br", fill)
# Fill each box with gradient
grid.gradientFill("bwplot.box.polygon", label=rep("br", 17), grep=TRUE,
                  group=FALSE)
# Generate SVG version "Rplots.svg"
# (where the gradient will actually be visible)
grid.export()

Does that help ?

Paul

On 07/12/16 09:14, Fix Ace wrote:
> Hello, there,
> I will like to fill the boxplot with gradient color, as exampled below:
>
> Can anyone help me figure out what package I should go with?
> Thank you very much for any inputs!
> Kind regards,
> Ace
>
>
>
> __
> 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.
>

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/


   
[[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] how to use vector of values to change row order of a heatmap

2016-11-21 Thread Fix Ace via R-help
Hello, there,
R document for heatmap says that Rowv could be a vector of values to specify 
the row order. However, I couldn't figure out how to apply it. A simple example 
here:> b=as.data.frame(matrix(c(3,4,5,8,9,10,13,14,15,27,19,20),3,4))
> b
  V1 V2 V3 V4
1  3  8 13 27
2  4  9 14 19
3  5 10 15 20
> row.names(b)=c("a","b","c")
> b
  V1 V2 V3 V4
a  3  8 13 27
b  4  9 14 19
c  5 10 15 20
> heatmap(as.matrix(b))
What I got: "a" stays at the bottom of the heatmap.
 Now I would like to put row "a" to the top row, how do I do that?I tried 
provide a vector of values (all the possible combination of 1,2,3) to Rowv,  
"a" is always stay at the bottom
Any input would be very helpful!
Thanks.
Ace

[[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] how to use vector of values to change row order of a heatmap

2016-11-21 Thread Fix Ace via R-help
Hello, there,
R document for heatmap says that Rowv could be a vector of values to specify 
the row order. However, I couldn't figure out how to apply it. A simple example 
here:> b=as.data.frame(matrix(c(3,4,5,8,9,10,13,14,15,27,19,20),3,4))
> b
  V1 V2 V3 V4
1  3  8 13 27
2  4  9 14 19
3  5 10 15 20
> row.names(b)=c("a","b","c")
> b
  V1 V2 V3 V4
a  3  8 13 27
b  4  9 14 19
c  5 10 15 20
> heatmap(as.matrix(b))
What I got:
 

Now I would like to put row "a" to the top row, how do I do that?I tried 
provide a vector of values (all the possible combination of 1,2,3) to Rowv,  
"a" is always stay at the bottom
Any input would be very helpful!
Ace
  

   __
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] how to pass multiple pattern varibles to grep()

2016-09-23 Thread Fix Ace via R-help
Hello, there,
My patterns are defined by variables, for example:z="h"v="x"
I have a vector: 
a=c("th","mx","t")
I would like to find elements in vector a that contain either "h", or "x"
grep("h|x", a) apparently works. However, when I tried: grep(z|v,a), it did not 
work. Can anyone help how to handle such situation?
Thanks.
Ace 

On Wednesday, March 18, 2015 5:52 PM, Fix Ace  wrote:
 

 Thank you very much!
I do need to learn more about R!! 


 On Tuesday, March 17, 2015 9:26 PM, William Dunlap  
wrote:
   

 Fix Ace wrote    What is the default "n"?
512:   > length(density(rnorm(10^6))$x)   [1] 512   > args(density.default)   
function (x, bw = "nrd0", adjust = 1, kernel = c("gaussian",        
"epanechnikov", "rectangular", "triangular", "biweight",        "cosine", 
"optcosine"), weights = NULL, window = kernel,        width, give.Rkern = 
FALSE, n = 512, from, to, cut = 3, na.rm = FALSE,        ...)   NULL   > 
?density # or ?density.default, should also tell you about its meaning

Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Mar 17, 2015 at 7:02 PM, Fix Ace  wrote:

Thank you for the email.
What is the default "n"?
Thanks! 


 On Tuesday, March 17, 2015 4:06 PM, William Dunlap  
wrote:
   

 Increasing the value of 'n' given to density will give an estimate at more 
points so it will look smoother.  Try n=2^18.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Mar 17, 2015 at 12:06 PM, Fix Ace  wrote:



 I have a dataset with 6187 elements, ranged from 3 to 104028. When I tried to 
examine only small range of data, I found that the plot was not smooth (as 
shown below):
plot(density(test$V2), xlim=c(0,1000))


 Is there away to make it smoother?
Thanks a lot!!

 


 



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