[R] bootstrapping for maxium data

2014-05-20 Thread
Dear friends,


I  have a numeric vector composed of 320 numbers.


Now, I want to do resample for 1 times. I want to get maxium number for 
every trial and get a 1 maxium numbers.


I have tried to use boot package such as follows.


results-boot(data=nearshore1,statistic=max,R=1,stype=w)


But, surprising, the results shows that I got 1 A (A is the maxium number 
in nearshore1)


It's a puzzle to me. I do not know how to do that. Thank you.


Yichun







[[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] figure margins too large

2014-04-03 Thread
Dear Jim,


Yes, what you said is right. I have resolved this question by your method. 
Thank you very much.


Best,
Yichun



 -原始邮件-
 发件人: Jim Lemon j...@bitwrit.com.au
 发送时间: 2014年4月3日 星期四
 收件人: 张以春 yczh...@nigpas.ac.cn
 抄送: r-help@r-project.org
 主题: Re: [R] figure margins too large
 
 On 04/03/2014 04:32 PM, 张以春 wrote:
  Dear R experts,
 
 
  I tried to plot some figures in R using postscript(), but it always shows 
  that the fugures margin is too large. I don't know how to change it. The 
  following is my example:
 
 
  postscript(All.eps,width=3.27,height=1.416,pointsize=12,family=Arial)
  par(mar=c(5.1,4.5,4.1,2.1));boxplot(All~Nameall,ylab= expression(Size~ 
  (log [10]~mm ^2)), boxwex=0.3, main=All 
  species,col=c(red,yellow,blue),ylim=c(0,4.0))
  Error: plot.new() : figure margins too large
 
 
  When I run the boxplot in R, it shows well, but once I run it in the 
  postscript, it fails. Can someone help me on it?
  Note: my operational system is windows 7.
 
 
 Hi Yichun,
 It is probably because you are trying to set up a very small postscript 
 device, and after the margins have been allocated, there is no room for 
 the plot. Try doing the plot with a larger size (e.g. width=8, height=4) 
 and see if you can scale it down afterward.
 
 Jim



--
Dr Yichun Zhang
State Key Laboratory of Palaeobiology and Stratigraphy, Nanjing Institute of 
Geology and Palaeontology
39 East Beijing Road, Nanjing, China, 210008




[[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] figure margins too large

2014-04-02 Thread
Dear R experts,


I tried to plot some figures in R using postscript(), but it always shows that 
the fugures margin is too large. I don't know how to change it. The following 
is my example:


 postscript(All.eps,width=3.27,height=1.416,pointsize=12,family=Arial)
par(mar=c(5.1,4.5,4.1,2.1));boxplot(All~Nameall,ylab= expression(Size~ (log 
[10]~mm ^2)), boxwex=0.3, main=All 
species,col=c(red,yellow,blue),ylim=c(0,4.0))
Error: plot.new() : figure margins too large


When I run the boxplot in R, it shows well, but once I run it in the 
postscript, it fails. Can someone help me on it?
Note: my operational system is windows 7.


Many thanks in advance
Yichun







[[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] How to set up the plot size and fonts in ggplot2

2014-03-11 Thread
Dear R experts,


I am trying to plot some figures using ggplot2. But, I do not know how to set 
up the plot size. (par(fig=)) seems not work in ggplot2 environment. Also, I do 
not know how to use Arial fonts in the plot. I have tried to load the package 
extrafont, but I can not install this package. I don't know the reason. Can 
you help me to resolve these questions? thank you very much.


Yichun



[[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] How to set up the plot region

2014-03-04 Thread
Hi, Jim


Thank you very much for your suggestion. But, x11() seems to be invalid for my 
computer. I have tried to use mar() to resolve this question. Thanks a lot.


Best,
Yichun


 -原始邮件-
 发件人: Jim Lemon j...@bitwrit.com.au
 发送时间: 2014年3月4日 星期二
 收件人: 张以春 yczh...@nigpas.ac.cn
 抄送: r-help@r-project.org
 主题: Re: [R] How to set up the plot region
 
 On 03/04/2014 12:40 AM, 张以春 wrote:
  Dear friends,
 
 
  I have a question don't know how to do. I want to plot two graphs in one 
  column of one plot. Also, I want to make every graph to be a square with 
  width to be 8cm, and their gap is 2cm. How do I set up in par()? Thank you 
  very much.
 
 
  Yichun
 
 Hi Yichun,
 Your question is not entirely clear, but I'll try to make some 
 suggestions. If what you mean is the figure region (that's the plot 
 and the margins around it), you want something like this:
 
 x11(width=3.15,height=7.09)
 layout(matrix(c(1,3,2),ncol=1),heights=c(1,0.25,1))
 plot(1:5)
 plot(1:5)
 
 If you just want plots with nothing around them, maybe this:
 
 x11(width=3.15,height=7.09)
 layout(matrix(c(1,3,2),ncol=1),heights=c(1,0.25,1))
 par(mar=c(0,0,0,0))
 plot(1:5,axes=FALSE)
 box()
 plot(1:5,axes=FALSE)
 box()
 
 Jim



--
Dr Yichun Zhang
State Key Laboratory of Palaeobiology and Stratigraphy, Nanjing Institute of 
Geology and Palaeontology
39 East Beijing Road, Nanjing, China, 210008




[[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] How to set up the plot region

2014-03-03 Thread
Dear friends,


I have a question don't know how to do. I want to plot two graphs in one column 
of one plot. Also, I want to make every graph to be a square with width to be 
8cm, and their gap is 2cm. How do I set up in par()? Thank you very much.


Yichun








[[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] how to get the numbers of factors in a matrix

2014-01-21 Thread
Dear friends,


I have a question do not know how to resolve.


I have a big matrix composed of different columns (I use N here). A column is 
species and another one is latitudes. Now, I want to know how I can get the 
number of different latitudes for every species. I have tried to split the 
matrix according to species (X-split(N, N$species) and then use sapply(X, 
function(m){nlevels(m$latitudes)}) to get that. But the result shows the total 
factor numbers of latitudes but not the factor numbers of every species I 
splitted. Also, I have tried to use tapply(N$latitudes, N$species, nlevels) to 
do this. The result is the same. I am confused about this. Can someone help me 
with that? Thank you very much!


Best regards,
Yichun






[[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] how to get the numbers of factors in a matrix

2014-01-21 Thread
Dear Pikal,


Thank you very much for your answer. 


I think your example is just the problem I have. 


In the following example you gave to me, 


  ff-factor(letters[1:5])
  levels(ff[1:2])
 [1] a b c d e
  fff-ff[1:2]
  nlevels(fff)
 [1] 5
 
  fff
 [1] a b
 Levels: a b c d e

In my understanding, fff is a subset of ff. Why fff's levels is not a, b but 
a,b,c,d,e.


My problem is quite similar to the example. I just want to split the matrix 
into many subsets and calculate the levels of every subset. Can you tell me how 
to do? Thank you very much!


Best regards,
Yichun

 -原始邮件-
 发件人: PIKAL Petr petr.pi...@precheza.cz
 发送时间: 2014年1月21日 星期二
 收件人: 张以春 yczh...@nigpas.ac.cn, r-help@r-project.org 
 r-help@r-project.org
 抄送: 
 主题: RE: [R] how to get the numbers of factors in a matrix
 
 Hi
 
 It is rather difficult to understand what problem you have.
 
 post some data e.g. by
 
 dput(head(bigmatrix))
 
 Maybe your problem is in a factor feature that it preserves also empty levels 
 until you specifically drop them.
 
  ff-factor(letters[1:5])
  levels(ff[1:2])
 [1] a b c d e
  fff-ff[1:2]
  nlevels(fff)
 [1] 5
 
  fff
 [1] a b
 Levels: a b c d e
 
 Regards
 Petr
 
  -Original Message-
  From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
  project.org] On Behalf Of ???
  Sent: Tuesday, January 21, 2014 7:36 AM
  To: r-help@r-project.org
  Subject: [R] how to get the numbers of factors in a matrix
 
  Dear friends,
 
 
  I have a question do not know how to resolve.
 
 
  I have a big matrix composed of different columns (I use N here). A
  column is species and another one is latitudes. Now, I want to know
  how I can get the number of different latitudes for every species.
  I have tried to split the matrix according to species (X-split(N,
  N$species) and then use sapply(X, function(m){nlevels(m$latitudes)}) to
  get that. But the result shows the total factor numbers of latitudes
  but not the factor numbers of every species I splitted. Also, I have
  tried to use tapply(N$latitudes, N$species, nlevels) to do this. The
  result is the same. I am confused about this. Can someone help me with
  that? Thank you very much!
 
 
  Best regards,
  Yichun
 
 
 
 
 
 
[[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.
 
 
 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, 

Re: [R] how to get the numbers of factors in a matrix

2014-01-21 Thread
Dear Jun Yi,


Thank you very much for your help. But, the link you attached can not resolve 
my question.


What I want is to get the numbers of factor levels for every subsets of a 
vector. When I do this, it always gives me the total numbers of levels for the 
whole vector. It really makes me confused. 


Best,
Yichun



 -原始邮件-
 发件人: Liu, Jun Yi 7yu...@gmail.com
 发送时间: 2014年1月21日 星期二
 收件人: 张以春 yczh...@nigpas.ac.cn, r-help@r-project.org
 抄送: 
 主题: Re: [R] how to get the numbers of factors in a matrix
 
 
 Dear YZ,
 
 I guess this is what you want:
 
 1. 
 http://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-an-integer-numeric-without-a-loss-of-information
 2. 
 http://stackoverflow.com/questions/6979625/arithmetic-operations-on-r-factors/6980780#6980780
 3. 
 http://toddjobe.blogspot.jp/2010/08/converting-r-contingency-tables-to-data.html
 
 but beware of that “If you really want the levels of the factor to be used, 
 you're either doing something very wrong or too clever for its own good.
 
 All the best 
 JY
 
 --
 From: 张以春 yczh...@nigpas.ac.cn
 Reply: 张以春 yczh...@nigpas.ac.cn
 Date: 21 January 2014 at 16:57:38
 To: r-help@r-project.org r-help@r-project.org
 Subject:  [R] how to get the numbers of factors in a matrix
 
   
  Dear friends,
   
   
  I have a question do not know how to resolve.
   
   
  I have a big matrix composed of different columns (I use N here).  
  A column is species and another one is latitudes. Now, I want  
  to know how I can get the number of different latitudes for every  
  species. I have tried to split the matrix according to species  
  (X-split(N, N$species) and then use sapply(X, 
  function(m){nlevels(m$latitudes)})  
  to get that. But the result shows the total factor numbers of latitudes  
  but not the factor numbers of every species I splitted. Also,  
  I have tried to use tapply(N$latitudes, N$species, nlevels)  
  to do this. The result is the same. I am confused about this. Can  
  someone help me with that? Thank you very much!
   
   
  Best regards,
  Yichun
   
   
   
   
   
   
  [[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.
   
 



--
Dr Yichun Zhang
State Key Laboratory of Palaeobiology and Stratigraphy, Nanjing Institute of 
Geology and Palaeontology
39 East Beijing Road, Nanjing, China, 210008




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