[R] bootstrapping for maxium data
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
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
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
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
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
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
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
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
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.