[R] boxplot
Hi, I try to boxplot following data on the subset of (V1,V3,V5,V7) and (V2,V4,V6,V8) V1 V2 V3 V4 V5 V6 V7 V8 24 6 712 33 43 53 how can I use boxplot function to plot it? thanks, William __ 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] sync+Rnw+TeXShop, again
Hi All -- I'm not sure this is the natural place for this question, but this list is the place with the best Sweave-TeXShop-sync discussion so far. My problem is that sync+Sweave+TeXShop works sometimes and not others, and it's not consistent. The failure, in which sync from PDF opens the .tex file instead of the .Rnw file, always comes after a code chunk. If I start from a simple example (below), sync works perfectly. But often when I change the R code (see example alternate code chunk below) , sync breaks after the code. In the example, if I click on Maecenas eget dolor enim in the pdf, TeXShop opens the tex file (minSyncWithTable_failsSync.tex). This outlasted restarting TeXShop and deleting all files except the .Rnw. Then I deleted a line within the code chunk and synced successfully. To confirm the importance of that particular line, I undid the deletion, but this did not break sync: I continued to sync successfully. Deleting all the files except the .Rnw didn't break sync again. Are there types of code in code chunks that break sync? Is there better way to troubleshoot sync failures? Am I missing a factor? Examples below. Thanks for your consideration. Following is my basic file that works - it always flips back to the .Rnw rather than opening the corresponding .tex file. MINIMAL EXAMPLE % !TEX TS-program = Sweave2 \documentclass{article} \usepackage{Sweave} \SweaveOpts{concordance=TRUE} \begin{document} Lorem ipsum dolor sit amet, consectetur adipiscing elit. \section{dolor} = n - 5 for(i in 1:n){ print(i) } @ Maecenas eget dolor enim. \end{document} END MINIMAL EXAMPLE Alternate code chunk: = library(xtable) read.txt-function (file=, sep=\t, header=TRUE,row.names=NULL, ...){ read.table(file, sep= sep, header= header, row.names= row.names, ...) } setwd(~/Documents/Dropbox/) ### Variable depth @ I use a Sweave engine called Sweave2.engine that contains the following: ### SWEAVE ENGINE FOLLOWS #!/bin/bash R CMD Sweave $1 latexmk -pdf -silent -pdflatex='pdflatex -shell-escape -synctex=1' ${1%.*} Rscript -e .libPaths('~/Rlibs'); library('patchDVI');patchSynctex('${1%.*}.synctex.gz') [[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] Error with epiR and sensitivity
Hi everyone, I emailed yesterday thinking I had a problem with reading matrix information as numerical output into epiR. After working on the data frame today, I realise it's a problem with the data itself rather than the syntax. An original data frame of min max T1 1.50e+01 3.54e+01 SE1 0.00e+00 1.00e+00 PRE 0.00e+00 1.00e+00 WET 0.00e+00 5.98e+00 BE1 4.664642e+00 5.866620e+00 Kappa1 5.50e+03 2.00e+04 Kappa3 1.00e+04 2.00e+04 produces a latin hypercube sampling set called samplevalues: T1 SE1 PRE WETBE1Kappa1 Kappa3 131.35590 0.7066388715 0.8665111432 4.965701530 5.783424 12240.019 12675.12 228.27640 0.5442730461 0.7000693454 3.181014435 5.183708 16626.566 10759.27 328.14695 0.6295741145 0.7818034368 2.262515130 4.670685 16930.360 13857.44 430.51873 0.3983581045 0.4026640041 2.730221171 5.058697 19546.625 14408.89 516.03162 0.0440886703 0.9954737808 1.002989298 5.310149 13188.279 19500.85 619.48413 0.4280443098 0.8500412067 1.668042962 5.068510 11742.748 18891.87 736.44783 0.5033961511 0.8249423312 5.582521574 4.722634 8738.121 16457.21 839.76318 0.8805976090 0.3430379347 4.876022801 4.787737 19873.134 18660.02 939.99782 0.4109272317 0.6606016486 0.191627831 5.625588 11086.803 13569.30 I have produced a column (r1) where each cell is a vector of the previous cells in that row. I tried binding them with zz-cbind(samplevalues, r1) and then running epi-epi.prcc(zz, sided.test=2) which is what produced the original error message of Error in solve.default(C) : Lapack routine dgesv: system is exactly singular I then tried 'sensitivity' with the syntax zz-pcc(samplevalues, r1). I didn't get any error messages, but print(zz) only reveals the Call value, and no information. Any advice on what could be the problem?? thank you, Aimee Kopolow __ 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] different color indicates difference magnitude
Many thanks At 2013-03-14 01:07:53,David L Carlson dcarl...@tamu.edu wrote: If you are just looking for a range of colors that communicate low to high values, try package RColorBrewer and look at the sequential palettes. -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of John Kane Sent: Wednesday, March 13, 2013 11:19 AM To: meng; Pascal Oettli Cc: R help Subject: Re: [R] different color indicates difference magnitude The R-help list strips most attachements other than text (and perhaps pngs? ) to deduce the risk of virus or malware being recieved. You could try parking the file on something like medifire and providing a link here. John Kane Kingston ON Canada -Original Message- From: laomen...@163.com Sent: Wed, 13 Mar 2013 16:13:33 +0800 (CST) To: kri...@ymail.com Subject: Re: [R] different color indicates difference magnitude So strange to find the attachment is disappear. Resent again. At 2013-03-13 13:01:01,Pascal Oettli kri...@ymail.com wrote: Hi, The attachment has been deleted. Please be more specific. Regards, Pascal On 13/03/13 10:20, meng wrote: Hi all: Is there a plot tool to use different color indicates difference magnitude of data? The plot is in the attachment. Many thanks. __ 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. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas 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. [[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] multi-comparison of means
Many thanks At 2013-03-14 00:23:43,Richard M. Heiberger r...@temple.edu wrote: Meng, What seems to be going on is that the covariates are handled very differently in TukeyHSD and in glht. Please see the interaction_average and covariate_average arguments to glht. I ran your example twice, first as you did, with the covariates after the factor. x2 is not significant if the factor comes first. The second time I placed the covariates before the factor. result_aov - aov(y ~ method + x1 + x2, data=meng) anova(result_aov) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F valuePr(F) method 2 4.4705 2.23525 41.3822 1.170e-08 *** x1 1 2.8352 2.83519 52.4892 1.363e-07 *** x2 1 0.0747 0.07469 1.38270.2507 Residuals 25 1.3504 0.05401 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 result2_aov - aov(y ~ x1 + x2 + method, data=meng) anova(result2_aov) Analysis of Variance Table Response: y Df Sum Sq Mean Sq F valuePr(F) x1 1 5.4399 5.4399 100.7113 2.985e-10 *** x2 1 0.3134 0.3134 5.8017 0.02371 * method 2 1.6271 0.8135 15.0616 5.100e-05 *** Residuals 25 1.3504 0.0540 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Looking at the plot of your data shows a very interesting pattern. xyplot(y ~ x1 + x2 | method, outer=TRUE, data=meng) b and c both give higher values of y than does a. You will also see that in the table of means. Although I leave the interpretation of x1 and x2 to you, my inclination is to drop x2 and look at the ancova of method and x1. ancova is in the HH package. ## install.packages(HH) ## if you don't have it yet. library(HH) result3_aov - ancova(y ~ method + x1, data=meng) result3_aov Analysis of Variance Table Response: y Df Sum Sq Mean Sq F valuePr(F) method 2 4.4705 2.23525 40.782 9.616e-09 *** x1 1 2.8352 2.83519 51.728 1.226e-07 *** Residuals 26 1.4251 0.05481 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 update(attr(result3_aov, trellis), ylim=c(3.5, 6.7)) Now it looks like conditional on x1, all three methods differ. Rich On Wed, Mar 13, 2013 at 7:15 AM, meng laomen...@163.com wrote: Hi all: I have a question about multi-comparison. The data is in the attachment. My purpose: Compare the predicted means of the 3 methods(a,b,c) pairwisely. I have 3 ideas: #idea1 result_aov-aov(y~ method + x1 + x2) TukeyHSD(result_aov) difflwr upr p adj b-a 0.845 0.5861098 1.1038902 0.001 c-a 0.790 0.5311098 1.0488902 0.002 c-b -0.055 -0.3138902 0.2038902 0.8578386 #idea2 library(multcomp) summary(glht(result_aov,linfct=mcp(method=Tukey))) Estimate Std. Error t value Pr(|t|) b - a == 0 0.3239 0.1402 2.309 0.0683 . c - a == 0 -0.3332 0.1937 -1.720 0.2069 c - b == 0 -0.6570 0.1325 -4.960 0.001 *** #idea3 #ref=a dat$method - relevel(dat$method, ref=a) lm_ref_a-lm(y~method + x1 + x2) summary(lm_ref_a) Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 0.922020.64418 1.431 0.1647 methodb 0.323890.14025 2.309 0.0295 * methodc -0.333160.19372 -1.720 0.0978 . x1 0.579350.09356 6.192 1.78e-06 *** x2 0.135960.11563 1.176 0.2507 #ref=b dat$method - relevel(dat$method, ref=b) lm_ref_b-lm(y~method + x1 + x2) summary(lm_ref_b) Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 1.245910.73770 1.689 0.1037 methoda -0.323890.14025 -2.309 0.0295 * methodc -0.657050.13248 -4.960 4.14e-05 *** In summary: idea1: a vs b:pvalue=0.001 a vs c:pvalue=0.002 b vs c:pvalue=0.8578386 idea2: a vs b:pvalue=0.0683 a vs c:pvalue=0.2069 b vs c:pvalue0.001 idea3: a vs b:pvalue=0.0295 a vs c:pvalue=0.0978 b vs c:pvalue=4.14e-05 So the result of 3 ideas are different,and I don't know which one is correct. Many thanks for your help. My best __ 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] different color indicates difference magnitude
Thanks for your notice. At 2013-03-14 00:18:48,John Kane jrkrid...@inbox.com wrote: The R-help list strips most attachements other than text (and perhaps pngs? ) to deduce the risk of virus or malware being recieved. You could try parking the file on something like medifire and providing a link here. John Kane Kingston ON Canada -Original Message- From: laomen...@163.com Sent: Wed, 13 Mar 2013 16:13:33 +0800 (CST) To: kri...@ymail.com Subject: Re: [R] different color indicates difference magnitude So strange to find the attachment is disappear. Resent again. At 2013-03-13 13:01:01,Pascal Oettli kri...@ymail.com wrote: Hi, The attachment has been deleted. Please be more specific. Regards, Pascal On 13/03/13 10:20, meng wrote: Hi all: Is there a plot tool to use different color indicates difference magnitude of data? The plot is in the attachment. Many thanks. __ 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. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! Check it out at http://www.inbox.com/marineaquarium [[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] Create patterns within a plot?
Dear All, As an attempt to highlight the overall pattern in a Forest plot, I would like to highlight the area around HR=1. I cannot find any simple tools for painting a grey ribbon between 0.9 and 1.1. Any suggestions? Thank you in advance! Cheers, Patrik [[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] boxplot
v - c(V1=2, V2=4 ,V3=6 ,V4=7 ,V5=12 ,V6=33 ,V7=43 ,V8=53) boxplot(v[seq(from=1, to=8, by=2)], v[seq(from=2, to=8, by=2)]) Sincerely Marc Le 13/03/13 23:14, wei wu a écrit : Hi, I try to boxplot following data on the subset of (V1,V3,V5,V7) and (V2,V4,V6,V8) V1 V2 V3 V4 V5 V6 V7 V8 24 6 712 33 43 53 how can I use boxplot function to plot it? thanks, William __ 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. -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ 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] Same eigenvalues but different eigenvectors using 'prcomp' and 'principal' commands
Dear all, I've used the 'prcomp' command to calculate the eigenvalues and eigenvectors of a matrix(gg). Using the command 'principal' from the 'psych' package I've performed the same exercise. I got the same eigenvalues but different eigenvectors. Is there any reason for that difference? Below are the steps I've followed: 1. PRCOMP #defining the matrix gg=matrix(byrow = TRUE, nrow = 3,data = c(1, 0, 1, 1, 4, 2)) gg [,1] [,2] [1,]10 [2,]11 [3,]42 pc=prcomp(gg,center=TRUE,scale=TRUE) # The eigenvectors pc$rotation PC1PC2 [1,] 0.7071068 0.7071068 [2,] 0.7071068 -0.7071068 # The eigenvalues: pc$sdev^2 [1] 1.8660254 0.1339746 2. PSYCH Package: pp=principal(gg,nfactors=2) # The eigenvectors pp$loadings Loadings: PC1PC2 [1,] 0.966 -0.259 [2,] 0.966 0.259 # The eigenvalues pp$values 1] 1.8660254 0.1339746 Sincerely, Arlindo [[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 change `Year_Month)201103` into Year_Month)201103 using R?
HI, I have the pattern like `Year_Month)201103` I want to delete single quotes within double quetes. I want to change it into Year_Month)201103 , how to do it in r? Thanks a lot. Tammy [[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:classification using association rules
Hi, I have used apriori method in arules package which has given out rules. But I could not understand how to classify the new data. Could you throw some light on it. Thanks, Satish [[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 change `Year_Month)201103` into Year_Month)201103 using R?
Le 14/03/13 09:23, Tammy Ma a écrit : HI, I have the pattern like `Year_Month)201103` I want to delete single quotes within double quetes. I want to change it into Year_Month)201103 , how to do it in r? Thanks a lot. Tammy x - \`Year_Month)201103`\ cat(x) `Year_Month)201103` cat(gsub(`, , x)) Year_Month)201103 Sincerely Marc -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ 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 import DNA sequences in R
Dear all, I was wondering how to read DNA sequences in R, is there a specific function and/or a specific package for that? Thank you very much in advance, Gian ** [[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] Viewing Compelete Decision Tree in R - R.2.15.2 - Wndows7 32bit
I tried drawing some decision trees. Since the number of levels are more in the tree, the plot result for the decision tree is not clear and conjusted. If i save it as pdf or png also, the image is same. So how can i view the complete clear plot of decision tree? Thanks in Advance, Manoj G [[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] column and line graphs in R
Hi all, I would love to plot my data with R. I have abundance and frequency of fungal taxonomic data that should be plotted in the same graph. In Microsoft Excel is that possible but the graphic result is, as always, very poor. Is there a function that may let me plot these data in R? I have a matrix made of two columns, on is the relative abundance and the other is the relative frequency for each of my sample. Thank you very much, -- Gian [[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 achieve big vector times big dataframe in R?
HI, I have the following question: Vector a with lenght 150 A B C D. dataframe b with dim 908X150 1 1 1 1. 2 2 2 2 3 3 3 3 4 4 4 4 final result I want is the vector with length 908: A*1+B*1+C*1+D*1+. A*2+B*2+C*2+D*2+. A*3+B*3+C*3+D*3+. A*4+B*4+C*4+D*4+. because of too large dimension, how can I achieve this in R? Thanks. Kind Regards, Tammy [[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] Create patterns within a plot?
Please note that I want to use log-scale on the x-axis which makes the polygon function sad. Cheers, Patrik -Ursprungligt meddelande- Från: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] För Öhagen Patrik Skickat: den 14 mars 2013 08:47 Till: R hELP Ämne: [R] Create patterns within a plot? Dear All, As an attempt to highlight the overall pattern in a Forest plot, I would like to highlight the area around HR=1. I cannot find any simple tools for painting a grey ribbon between 0.9 and 1.1. Any suggestions? Thank you in advance! Cheers, Patrik [[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] Bootstrap encounter histories data
Hi all, I am working with a capture-recapture analyses and my data set consists of a typical set of encounter histories. Thus, for each individual I have a string (same length for all the individuals) consisting of 0 (not seen) and other numbers (seen in state 1, seen in state 2, etc. where state may refer to breeding, nesting, feeding, etc.). At the end of each string I have a last value that refers to the group (according to sex, age, sex*age, whatever). State and group refer to different classifications. Hence my original data set would be (by the way I can modify it to make things easier): 0001002002 1; (individual of group 1, first captured in state 1! at occasion 4th, not captured at occasion 5th and 6th, captured at 7th in state 2...etc.) 1100222101 1; 020010 3; 0010101022 2; ... Suppose I have 5000 strings divided in x individuals of group 1, y individuals of group 2, ... z individuals of group n. I need to bootstrap this data set to get a new data set of the same length (resampling with replacement) and where the number of individuals of each group is maintained the same. Does anyone have an idea on how to do it? Thanks in advance for any help Simone -- View this message in context: http://r.789695.n4.nabble.com/Bootstrap-encounter-histories-data-tp4661300.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] HOw to achieve big vector times big dataframe in R?
apply((t(as.matrix(b)) * a), 2, sum) should do what you want. Why this works; see, http://cran.r-project.org/doc/manuals/r-release/R-intro.html#The-recycling-rule and the paragraph before that. Jan Tammy Ma metal_lical...@live.com schreef: HI, I have the following question: Vector a with lenght 150 A B C D. dataframe b with dim 908X150 1 1 1 1. 2 2 2 2 3 3 3 3 4 4 4 4 final result I want is the vector with length 908: A*1+B*1+C*1+D*1+. A*2+B*2+C*2+D*2+. A*3+B*3+C*3+D*3+. A*4+B*4+C*4+D*4+. because of too large dimension, how can I achieve this in R? Thanks. Kind Regards, Tammy [[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] holding argument(s) fixed within lapply
Thank you Blaser; this is helpful. On 03/13/2013 12:22 PM, Blaser Nello wrote: One way is to use the do.call function. For example: ret2 - lapply(X=mylist2, FUN=do.call, what=function(...) f2(y=Y, ...)) Best, Nello -Original Message- Date: Tue, 12 Mar 2013 22:37:52 -0400 From: Benjamin Tyner bty...@gmail.com To: r-help@r-project.org Subject: Re: [R] holding argument(s) fixed within lapply Message-ID: 513fe680.2070...@gmail.com Content-Type: text/plain; charset=iso-8859-1 Apologies; resending in plain text... Given a function with several arguments, I would like to perform an lapply (or equivalent) while holding one or more arguments fixed to some common value, and I would like to do it in as elegant a fashion as possible, without resorting to wrapping a separate wrapper for the function if possible. Moreover I would also like it to work in cases where one or more arguments to the original function has a default binding. # Here is an example; the original function f - function(w, y, z){ w + y + z } # common value I would like y to take Y - 5 # I have a list of arguments for the lapply() mylist - list(one = list(w = 1, z = 2), two = list(w = 3, z = 4) ) # one way to do it involves a custom wrapper; I do not like this method ret - lapply(FUN = function(x,...) f(w = x$w, z = x$z, ...), X = mylist, y = Y ) # another way ret - lapply(FUN = with.default, X= mylist, expr = f(w, y = Y, z) ) # yet another way ret - lapply(FUN = eval, X= mylist, expr = substitute(f(w, y = Y, z)) ) # now, the part I'm stuck on is for a version of f where z has a default binding f2 - function(w, y, z = 0){ w + y + z } # the same as mylist, but now z is optional mylist2 - list(one = list(w = 1), two = list(w = 3, z = 4) ) # undesired result (first element has length 0) ret2 - lapply(FUN = function(x,...) f2(w = x$w, z = x$z, ), X = mylist2, y = Y ) # errors out ('z' not found) ret2 - lapply(FUN = with.default, X= mylist2, expr = f2(w, y = Y, z) ) # errors out again ret2 - lapply(FUN = eval, X= mylist2, expr = substitute(f2(w, y = Y, z)) ) # not quite... ret2 - lapply(FUN = gtools::defmacro(y = Y, expr = f2(w, y = Y, z)), X = mylist2 ) It seems like there are many ways to skin this cat; open to any and all guidance others care to offer. Regards, Ben __ 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] Create patterns within a plot?
Providing s reproducible example would help a lot. Also, can you not just feed polygon() log-transformed coordinates? On Thursday, March 14, 2013, Öhagen Patrik wrote: Please note that I want to use log-scale on the x-axis which makes the polygon function sad. Cheers, Patrik -Ursprungligt meddelande- Från: r-help-boun...@r-project.org javascript:; [mailto: r-help-boun...@r-project.org javascript:;] För Öhagen Patrik Skickat: den 14 mars 2013 08:47 Till: R hELP Ämne: [R] Create patterns within a plot? Dear All, As an attempt to highlight the overall pattern in a Forest plot, I would like to highlight the area around HR=1. I cannot find any simple tools for painting a grey ribbon between 0.9 and 1.1. Any suggestions? Thank you in advance! Cheers, Patrik -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[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] Create patterns within a plot?
On 03/14/2013 09:19 PM, Öhagen Patrik wrote: Please note that I want to use log-scale on the x-axis which makes the polygon function sad. Cheers, Patrik -Ursprungligt meddelande- Från: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] För Öhagen Patrik Skickat: den 14 mars 2013 08:47 Till: R hELP Ämne: [R] Create patterns within a plot? Dear All, As an attempt to highlight the overall pattern in a Forest plot, I would like to highlight the area around HR=1. I cannot find any simple tools for painting a grey ribbon between 0.9 and 1.1. Any suggestions? Hi Patrik, This is a bit indirect, but it may do what you want. The example plot is from the metafor package (see forest.default): forest(dat$yi, dat$vi) library(plotrix) gradient.rect(0.9,-0.1,1.1,14, reds=c(1,0.5,1),greens=c(1,0.5,1), blues=c(1,0.5,1),gradient=x,border=NA) par(new=TRUE) forest(dat$yi, dat$vi) 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.
Re: [R] different color indicates difference magnitude
On 03/14/2013 12:10 PM, meng wrote: Thanks for your notice. At 2013-03-14 00:18:48,John Kanejrkrid...@inbox.com wrote: The R-help list strips most attachements other than text (and perhaps pngs? ) to deduce the risk of virus or malware being recieved. You could try parking the file on something like medifire and providing a link here. John Kane Kingston ON Canada -Original Message- From: laomen...@163.com Sent: Wed, 13 Mar 2013 16:13:33 +0800 (CST) To: kri...@ymail.com Subject: Re: [R] different color indicates difference magnitude So strange to find the attachment is disappear. Resent again. At 2013-03-13 13:01:01,Pascal Oettlikri...@ymail.com wrote: Hi, The attachment has been deleted. Please be more specific. Regards, Pascal On 13/03/13 10:20, meng wrote: Hi all: Is there a plot tool to use different color indicates difference magnitude of data? Hi meng, I think that the color.scale function (plotrix), which linearly transforms numeric values to colors, might be what you want. 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.
Re: [R] Bootstrap encounter histories data
Hello, It doesn't seem very complicated. First of all, for the function fun below to work, you need the data not as strings of staes followed by a space followed by a broup number, but in two columns vectors, a character vector of states and a vector of groups. The vector of groups can be of class character, factor or numeric. I've written a function to simulate such data. makeData - function(n, g = 3, size = 10){ res - matrix(0, nrow = n, ncol = size) gr - sample(g, n, replace = TRUE) for(i in seq_len(n)) res[i, ] - sample(0:2, 10, replace = TRUE, prob = c(0.5, 0.25, 0.25)) res - apply(res, 1, paste0, collapse = ) data.frame(states = res, group = gr, stringsAsFactors = FALSE) } dat - makeData(10) # Now to sample from 'dat', by group. fun - function(x){ f - function(y){ idx - sample(nrow(y), nrow(y), replace = TRUE) y[idx, ] } res - do.call(rbind, lapply(split(x, x[, 2]), f)) rownames(res) - seq_len(nrow(res)) res } fun(dat) Hope this helps, Rui Barradas Em 14-03-2013 10:25, Simone Santoro escreveu: Hi all, I am working with a capture-recapture analyses and my data set consists of a typical set of encounter histories. Thus, for each individual I have a string (same length for all the individuals) consisting of 0 (not seen) and other numbers (seen in state 1, seen in state 2, etc. where state may refer to breeding, nesting, feeding, etc.). At the end of each string I have a last value that refers to the group (according to sex, age, sex*age, whatever). State and group refer to different classifications. Hence my original data set would be (by the way I can modify it to make things easier): 0001002002 1; (individual of group 1, first captured in state 1! at occasion 4th, not captured at occasion 5th and 6th, captured at 7th in state 2...etc.) 1100222101 1; 020010 3; 0010101022 2; ... Suppose I have 5000 strings divided in x individuals of group 1, y individuals of group 2, ... z individuals of group n. I need to bootstrap this data set to get a new data set of the same length (resampling with replacement) and where the number of individuals of each group is maintained the same. Does anyone have an idea on how to do it? Thanks in advance for any help Simone -- View this message in context: http://r.789695.n4.nabble.com/Bootstrap-encounter-histories-data-tp4661300.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. __ 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 change `Year_Month)201103` into Year_Month)201103 using R?
On 14 March 2013 01:56, Marc Girondot marc_...@yahoo.fr wrote: cat(gsub(`, , x)) might want to add fixed=TRUE to the gsub line. -- Sent from my mobile device Envoyait de mon portable __ 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] Bootstrap encounter histories data
Hello, One more thing, if you have the data as strings of states/space/group, you can split it in vectors state/group with # This is your data example x - c( 1100222101 1, 020010 3, 0010101022 2 ) mat - do.call(rbind, strsplit(x, )) But this creates a matrix, so you'll need to revise the function as fun - function(x){ f - function(y){ idx - sample(NROW(y), NROW(y), replace = TRUE) y[idx, ] } sp - split(as.data.frame(x), x[, 2]) res - do.call(rbind, lapply(sp, f)) rownames(res) - seq_len(nrow(res)) res } fun(mat) Hope this helps, Rui Barradas Em 14-03-2013 11:34, Rui Barradas escreveu: Hello, It doesn't seem very complicated. First of all, for the function fun below to work, you need the data not as strings of staes followed by a space followed by a broup number, but in two columns vectors, a character vector of states and a vector of groups. The vector of groups can be of class character, factor or numeric. I've written a function to simulate such data. makeData - function(n, g = 3, size = 10){ res - matrix(0, nrow = n, ncol = size) gr - sample(g, n, replace = TRUE) for(i in seq_len(n)) res[i, ] - sample(0:2, 10, replace = TRUE, prob = c(0.5, 0.25, 0.25)) res - apply(res, 1, paste0, collapse = ) data.frame(states = res, group = gr, stringsAsFactors = FALSE) } dat - makeData(10) # Now to sample from 'dat', by group. fun - function(x){ f - function(y){ idx - sample(nrow(y), nrow(y), replace = TRUE) y[idx, ] } res - do.call(rbind, lapply(split(x, x[, 2]), f)) rownames(res) - seq_len(nrow(res)) res } fun(dat) Hope this helps, Rui Barradas Em 14-03-2013 10:25, Simone Santoro escreveu: Hi all, I am working with a capture-recapture analyses and my data set consists of a typical set of encounter histories. Thus, for each individual I have a string (same length for all the individuals) consisting of 0 (not seen) and other numbers (seen in state 1, seen in state 2, etc. where state may refer to breeding, nesting, feeding, etc.). At the end of each string I have a last value that refers to the group (according to sex, age, sex*age, whatever). State and group refer to different classifications. Hence my original data set would be (by the way I can modify it to make things easier): 0001002002 1; (individual of group 1, first captured in state 1! at occasion 4th, not captured at occasion 5th and 6th, captured at 7th in state 2...etc.) 1100222101 1; 020010 3; 0010101022 2; ... Suppose I have 5000 strings divided in x individuals of group 1, y individuals of group 2, ... z individuals of group n. I need to bootstrap this data set to get a new data set of the same length (resampling with replacement) and where the number of individuals of each group is maintained the same. Does anyone have an idea on how to do it? Thanks in advance for any help Simone -- View this message in context: http://r.789695.n4.nabble.com/Bootstrap-encounter-histories-data-tp4661300.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. __ 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] Viewing Compelete Decision Tree in R - R.2.15.2 - Wndows7 32bit
On 14.03.2013 10:49, Manoj G wrote: I tried drawing some decision trees. Since the number of levels are more in the tree, the plot result for the decision tree is not clear and conjusted. If i save it as pdf or png also, the image is same. So how can i view the complete clear plot of decision tree? FOr example pdf with a huge size should clear things up. Uwe Ligges Thanks in Advance, Manoj G [[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] HOw to achieve big vector times big dataframe in R?
On 14.03.2013 11:27, Jan van der Laan wrote: apply((t(as.matrix(b)) * a), 2, sum) ... where colSums(.) should be faster than apply(., 2, sum), Uwe Ligges should do what you want. Why this works; see, http://cran.r-project.org/doc/manuals/r-release/R-intro.html#The-recycling-rule and the paragraph before that. Jan Tammy Ma metal_lical...@live.com schreef: HI, I have the following question: Vector a with lenght 150 A B C D. dataframe b with dim 908X150 1 1 1 1. 2 2 2 2 3 3 3 3 4 4 4 4 final result I want is the vector with length 908: A*1+B*1+C*1+D*1+. A*2+B*2+C*2+D*2+. A*3+B*3+C*3+D*3+. A*4+B*4+C*4+D*4+. because of too large dimension, how can I achieve this in R? Thanks. Kind Regards, Tammy [[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-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] Modifying a data frame based on a vector that contains column numbers
Thank you so much, Bill and Arun! Dimitri On Wed, Mar 13, 2013 at 9:36 PM, arun smartpink...@yahoo.com wrote: HI, Try this: mydf1- mydf mydf1[]-lapply(1:3,function(i) {mydf[which(i== myindex),i]-1; mydf[,i]}) mydf1 # c1 c2 c3 #1 1 NA NA #2 NA 1 NA #3 NA NA 1 #4 NA 1 NA #5 1 NA NA identical(mydf1,mygoal) #[1] TRUE A.K. - Original Message - From: Dimitri Liakhovitski dimitri.liakhovit...@gmail.com To: r-help r-help@r-project.org Cc: Sent: Wednesday, March 13, 2013 8:10 PM Subject: [R] Modifying a data frame based on a vector that contains column numbers Hello! # I have a data frame: mydf-data.frame(c1=rep(NA,5),c2=rep(NA,5),c3=rep(NA,5)) # I have an index whose length is always the same as nrow(mydf): myindex-c(1,2,3,2,1) # I need c1 to have 1s in rows 1 and 5 (based on the information in myindex) # I need c2 to have 1s in rows 2 and 4 (also based on myindex) # I need c3 to have 1 in row 3 # In other words, I am trying to achieve this result: mygoal-data.frame(c1=c(1,NA,NA,NA,1),c2=c(NA,1,NA,1,NA),c3=c(NA,NA,1,NA,NA)) I know how to do it with a loop that runs through rows of mydf. However, in real life I have a huge data frame with tons of rows, dozens of columns (instead of 3 in this example) - I am afraid it'll take forever. Any hint on how to do it faster, maybe using subindexing somehow? Thank you very much! -- Dimitri Liakhovitski [[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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitri Liakhovitski [[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 import DNA sequences in R
Le 14/03/13 10:19, Gian Maria Niccolò Benucci a écrit : Dear all, I was wondering how to read DNA sequences in R, is there a specific function and/or a specific package for that? Thank you very much in advance, Gian ** Before to write on the list, a simple google search brings you a lot of information. For example: https://a-little-book-of-r-for-bioinformatics.readthedocs.org/en/latest/src/chapter1.html Sincerely Marc Girondot -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ 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 change `Year_Month)201103` into Year_Month)201103 using R?
x- `Year_Month)201103` gsub([`],,x) #[1] Year_Month)201103 A.K. - Original Message - From: Tammy Ma metal_lical...@live.com To: r-help@r-project.org r-help@r-project.org Cc: Sent: Thursday, March 14, 2013 4:23 AM Subject: [R] how to change `Year_Month)201103` into Year_Month)201103 using R? HI, I have the pattern like `Year_Month)201103` I want to delete single quotes within double quetes. I want to change it into Year_Month)201103 , how to do it in r? Thanks a lot. Tammy [[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] column and line graphs in R
Le 14/03/13 11:05, Gian Maria Niccolò Benucci a écrit : Hi all, I would love to plot my data with R. I have abundance and frequency of fungal taxonomic data that should be plotted in the same graph. In Microsoft Excel is that possible but the graphic result is, as always, very poor. Is there a function that may let me plot these data in R? I have a matrix made of two columns, on is the relative abundance and the other is the relative frequency for each of my sample. Thank you very much, You should be more precise about what sort of graph you want. A bivariate plot ? For example, here is a bivariate from a matrix object: fungal - matrix(c(12, 54, 65, 76, .2, .6, .1, .7), nrow=4) plot(fungal, xlab=Abondance, ylab=Frequency, bty=n, xlim=c(0,80)) (I don't understand the difference between relative abondance and frequency). Sincerely, Marc Girondot -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot __ 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] Same eigenvalues but different eigenvectors using 'prcomp' and 'principal' commands
Arlindo Meque mequitomz at yahoo.com.br writes: Dear all, I've used the 'prcomp' command to calculate the eigenvalues and eigenvectors of a matrix(gg). Using the command 'principal' from the 'psych' package I've performed the same exercise. I got the same eigenvalues but different eigenvectors. Is there any reason for that difference? [snip] eigenvectors are only defined up to a scale factor. prcomp is scaling them so that the sum of squares is 1; I haven't bothered to see how principal() is scaling them (maybe the documention says). (1,1) and (-1,1) , or (1,1) and (1,-1), would have been equally valid choices. Ben Bolker __ 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] Same eigenvalues but different eigenvectors using 'prcomp' and 'principal' commands
Dear Arlindo, When, as here, the eigenvalues are distinct, corresponding eigenvectors are defined only up to multiplication by a nonzero constant. As you can verify, the first set of eigevectors is normalized to length 1 while the second set is normalized to have length equal to the corresponding eigenvalues. I hope this helps, John John Fox Sen. William McMaster Prof. of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Thu, 14 Mar 2013 01:01:56 -0700 (PDT) Arlindo Meque mequit...@yahoo.com.br wrote: Dear all, I've used the 'prcomp' command to calculate the eigenvalues and eigenvectors of a matrix(gg). Using the command 'principal' from the 'psych' package I've performed the same exercise. I got the same eigenvalues but different eigenvectors. Is there any reason for that difference? Below are the steps I've followed: 1. PRCOMP #defining the matrix gg=matrix(byrow = TRUE, nrow = 3,data = c(1, 0, 1, 1, 4, 2)) gg [,1] [,2] [1,]10 [2,]11 [3,]42 pc=prcomp(gg,center=TRUE,scale=TRUE) # The eigenvectors pc$rotation PC1PC2 [1,] 0.7071068 0.7071068 [2,] 0.7071068 -0.7071068 # The eigenvalues: pc$sdev^2 [1] 1.8660254 0.1339746 2. PSYCH Package: pp=principal(gg,nfactors=2) # The eigenvectors pp$loadings Loadings: PC1PC2 [1,] 0.966 -0.259 [2,] 0.966 0.259 # The eigenvalues pp$values 1] 1.8660254 0.1339746 Sincerely, Arlindo [[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] why predict() gives zero length prediction?
If you look at the help for predict.naiveBayes, you can see that newdata is supposed to be a data.frame. However, you are providing newdata as a vector, titanic_small[,-1]. Try using titanic_small[,-1, drop=FALSE] instead. Jean On Tue, Mar 12, 2013 at 11:35 PM, S. Zhou myx...@yahoo.com wrote: titanic_small[,-1] [[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 import DNA sequences in R
On 03/14/2013 02:19 AM, Gian Maria Niccolò Benucci wrote: Dear all, I was wondering how to read DNA sequences in R, is there a specific function and/or a specific package for that? Thank you very much in advance, Bioconductor has many sequence-related packages; a basic starting point is http://bioconductor.org/packages/release/bioc/html/Biostrings.html Martin Gian ** [[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. -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ 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] Create patterns within a plot?
Same idea, but just using base graphics and using an x-axis with log units: library(metafor) data(dat.bcg) res - rma(measure=OR, ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, slab=paste(dat.bcg$author, dat.bcg$year, sep=, )) forest(res, cex=.9, at=log(c(.05, .25, 1, 4)), xlim=c(-10,7), atransf=exp) rect(log(0.5), 0.1, log(1.5), 13.9, col=gray90, border=NA) par(new=TRUE) forest(res, cex=.9, at=log(c(.05, .25, 1, 4)), xlim=c(-10,7), atransf=exp) Best, Wolfgang -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jim Lemon Sent: Thursday, March 14, 2013 12:19 To: Öhagen Patrik Cc: R hELP Subject: Re: [R] Create patterns within a plot? On 03/14/2013 09:19 PM, Öhagen Patrik wrote: Please note that I want to use log-scale on the x-axis which makes the polygon function sad. Cheers, Patrik -Ursprungligt meddelande- Från: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] För Öhagen Patrik Skickat: den 14 mars 2013 08:47 Till: R hELP Ämne: [R] Create patterns within a plot? Dear All, As an attempt to highlight the overall pattern in a Forest plot, I would like to highlight the area around HR=1. I cannot find any simple tools for painting a grey ribbon between 0.9 and 1.1. Any suggestions? Hi Patrik, This is a bit indirect, but it may do what you want. The example plot is from the metafor package (see forest.default): forest(dat$yi, dat$vi) library(plotrix) gradient.rect(0.9,-0.1,1.1,14, reds=c(1,0.5,1),greens=c(1,0.5,1), blues=c(1,0.5,1),gradient=x,border=NA) par(new=TRUE) forest(dat$yi, dat$vi) 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-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] Ignoring NA in matplot
Dear useRs,How to matplot a column of matrix while ignoring NA values in it. More precisely, If a column has 10values in it, and row 7 and 8 are NA, instead of reading 7 and 8 as zeros, it should link 6th row with 9th.I hope my question is understandable...Thanks in advanceElisa [[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] column and line graphs in R
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example You really need to read the posting guide and supply some sample data at the very least. Here is about as simple minded a plot as R will do as an example however dat1 - structure(list(abond = c(17L, 3L, 6L, 11L, 5L, 8L, 13L, 16L, 15L, 2L), freq = c(17L, 14L, 7L, 13L, 19L, 5L, 3L, 20L, 9L, 10L )), .Names = c(abond, freq), row.names = c(NA, -10L), class = data.frame) plot(dat1$abond, col = red) lines(dat1$freq, col= blue) John Kane Kingston ON Canada -Original Message- From: gian.benu...@gmail.com Sent: Thu, 14 Mar 2013 11:05:40 +0100 To: r-help@r-project.org Subject: [R] column and line graphs in R Hi all, I would love to plot my data with R. I have abundance and frequency of fungal taxonomic data that should be plotted in the same graph. In Microsoft Excel is that possible but the graphic result is, as always, very poor. Is there a function that may let me plot these data in R? I have a matrix made of two columns, on is the relative abundance and the other is the relative frequency for each of my sample. Thank you very much, -- Gian [[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] how to import DNA sequences in R
Thank you all guys, for the useful information. Gian On 14 March 2013 14:14, Martin Morgan mtmor...@fhcrc.org wrote: On 03/14/2013 02:19 AM, Gian Maria Niccolò Benucci wrote: Dear all, I was wondering how to read DNA sequences in R, is there a specific function and/or a specific package for that? Thank you very much in advance, Bioconductor has many sequence-related packages; a basic starting point is http://bioconductor.org/**packages/release/bioc/html/**Biostrings.htmlhttp://bioconductor.org/packages/release/bioc/html/Biostrings.html Martin Gian ** [[alternative HTML version deleted]] __** 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. -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 [[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] column and line graphs in R
Hi again, Thank you all for your support. I would love to have a graph in which two variables are contemporary showed. For example a histogram and a curve should be the perfect choice. I tried to use twoord.plot() but I am not sure I understand how to manage the the arguments lx, ly, rx, ry... Anyway these are my data: nat_af rel.abund rel.freq MOTU2 0.0030.083 MOTU4 0.0290.167 MOTU6 0.0330.167 MOTU7 0.0230.083 MOTU9 0.0090.083 MOTU11 0.0420.250 MOTU14 0.0690.083 MOTU16 0.0590.167 MOTU17 0.0340.083 MOTU18 0.0490.083 MOTU19 0.0840.333 MOTU20 0.0150.083 MOTU21 0.0590.083 MOTU22 0.0320.167 MOTU23 0.1420.250 MOTU24 0.0310.083 MOTU25 0.0340.083 MOTU29 0.0100.083 MOTU30 0.0110.083 MOTU33 0.0040.083 MOTU36 0.0340.333 MOTU34 0.1820.417 First column is the relative abundance of the given MOTU and second column is the relative frequency of the same MOTU. Thank you very much in advance, -- Gian On 14 March 2013 14:51, John Kane jrkrid...@inbox.com wrote: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example You really need to read the posting guide and supply some sample data at the very least. Here is about as simple minded a plot as R will do as an example however dat1 - structure(list(abond = c(17L, 3L, 6L, 11L, 5L, 8L, 13L, 16L, 15L, 2L), freq = c(17L, 14L, 7L, 13L, 19L, 5L, 3L, 20L, 9L, 10L )), .Names = c(abond, freq), row.names = c(NA, -10L), class = data.frame) plot(dat1$abond, col = red) lines(dat1$freq, col= blue) John Kane Kingston ON Canada -Original Message- From: gian.benu...@gmail.com Sent: Thu, 14 Mar 2013 11:05:40 +0100 To: r-help@r-project.org Subject: [R] column and line graphs in R Hi all, I would love to plot my data with R. I have abundance and frequency of fungal taxonomic data that should be plotted in the same graph. In Microsoft Excel is that possible but the graphic result is, as always, very poor. Is there a function that may let me plot these data in R? I have a matrix made of two columns, on is the relative abundance and the other is the relative frequency for each of my sample. Thank you very much, -- Gian [[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! Check it out at http://www.inbox.com/earth [[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] Working with string
Hello again, Let say I have following string: Vec - c(sada, asdsa, sa) Now I want to make each element of this vector with equal length. Basically I want following vector: c(sada , asdsa, sa ) Therefore we can get: nchar(c(sada , asdsa, sa )) [1] 5 5 5 Is there any possiblity that we can do it programetically? Because I need to handle a really big vector. Thanks for your help. __ 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] error: object of type 'closure' is not subsettable
Hi all, when i run this script: read.table(Angelika.txt,header=T,sep=\t) mytable=read.table(Angelika.txt,header=T,sep=\t) for ( dye in c(A,B,C,F,G,K,L,M)) + { + for (cond in 1:8) + { + measurement = table[mytable[,bed]==cond mytable[,dye]==dye,differenz] + print(median(measurement)) + wilcox.test(measurement,mu=0) + } + } I get the error massage: error in table[mytable[, bed] == cond mytable[, dye] == dye, differenz] : object of type 'closure' is not subsettable I am beginner with R, so I didn´t write this script myself. What is meant with 'closure' and how can I solve this? I started also another script (this time by myself) but for sure it is much more work to do this in comparison to the other script: # con (condition) #1: Standart-hoch #2: Standart-niedrig #3: Standart-mittel #4: Ringe-hoch #5: Ringe-niedrig #6: Ringe-mittel #7: Fitness-hoch #8: Fitness-niedrig # dye #A: Hoechst42 #B: Hoechst80 #C: Vio #D: Vibrant Orange gating 1 #E: Vibrant Orange gating 2 #F: NID APC #G: NID PerCP #H: DraQ #I: Syber Green 1000 #J: Syber Green 2000 #K: Syber Green 5000 #L: Acridin Orange FITC #M: Acridin Orange PerCP #Standart Hoch Hoechst42, Hoechst80, Vio, NID APC, NID PerCP, Syber Green 5000, Acridin Orange FITC, Acridin Orange PerCP aa=mytable[mytable[,con]==1 mytable[,dye]==A,differenz] ab=mytable[mytable[,con]==1 mytable[,dye]==B,differenz] ac=mytable[mytable[,con]==1 mytable[,dye]==C,differenz] ad=mytable[mytable[,con]==1 mytable[,dye]==F,differenz] ae=mytable[mytable[,con]==1 mytable[,dye]==G,differenz] af=mytable[mytable[,con]==1 mytable[,dye]==K,differenz] ag=mytable[mytable[,con]==1 mytable[,dye]==L,differenz] ah=mytable[mytable[,con]==1 mytable[,dye]==M,differenz] wilcox.test(aa,mu=0) wilcox.test(ab,mu=0)... but here I have to do a single test for each condition and dye...and thats is much (each condition has to be tested with these dyes) Table with data attached: Angelika.txt http://r.789695.n4.nabble.com/file/n4661305/Angelika.txt It would be great if someone could help me. Thanks and greetings Robert -- View this message in context: http://r.789695.n4.nabble.com/error-object-of-type-closure-is-not-subsettable-tp4661305.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] evtree
hi I got the following error in 'evtree'. could u help pl. Error in if (var(mf[, nVariables]) = 0) stop(variance of the denpendent variable is 0) : argument is of length zero [[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] NADA and cenmle
Hi, I am using the cenmle function from the NADA package and some of my data are negative values. As a result the cenmle function will not work and NaN's are produced. I try to change the distribution to Gaussian, but it still will not run. Could somebody please help me with this? Thanks -- Shane [[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] question about nls
Hi,all: I met a problem of nls. My data: xy 60 0.8 80 6.5 100 20.5 120 45.9 I want to fit exp curve of data. My code: nls(y ~ exp(a + b*x)+d,start=list(a=0,b=0,d=1)) Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates I can't find out the reason for the error. Any suggesions are welcome. Many 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] date time manipulation- R 2.15.1 windows 7
Hi, I wanted to learn how to solve a date and time manipulation where i can do the following two 1. difference of two dates eg (differnce between 5th jan 2013 and 1st jan 2013) 2.Suppose i have week number of the year, i want to know if i can find out the day it refers to eg( say week 2 of 2013 would be 6th jan 2013 and the day is sunday) i need my result to tell me that its the 6th of jan 2013 as well as the day (sunday) Can u please help me out? Thanks, Yashvardhan Kajaria [[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] Demean argument in ar function
Hello, I understand that the/ demean/ argument in the *ar()* function to fit an autoregressive model selects the best AR model fitted to the mean deleted observations. What is the purpose of using this demean procedure at all? Its seems silly as the post doesn't deal with R problems Thanks -- View this message in context: http://r.789695.n4.nabble.com/Demean-argument-in-ar-function-tp4661304.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] error: object of type 'closure' is not subsettable
Edit: OK I got it for ( dye in c(A,B,C,F,G,K,L,M)) + { + for (cond in 1:8) + { + measurement = *my*table[mytable[,bed]==cond mytable[,dye]==dye,differenz] + print(median(measurement)) + wilcox.test(measurement,mu=0) + } + } But now I get new error massages: Error in wilcox.test.default(measurement, mu = 0) : not enough (finite) 'x' observations In addition: There were 11 warnings (use warnings() to see them) warnings() Warning messages: 1: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 2: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with zeroes 3: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with zeroes 4: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 5: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 6: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 7: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with zeroes 8: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with zeroes 9: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 10: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 11: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties What does this mean? OK can´t compute with zeros, but why? The test should compare the mediandifference to 0 and if the values are 0 it should be 1, or not? And what means 'cannot compute exact p-value with ties'? Greetings Robert -- View this message in context: http://r.789695.n4.nabble.com/error-object-of-type-closure-is-not-subsettable-tp4661305p4661316.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] Working with string
?nchar will tell you how many characters are in each string (mod multibyte locales) and you can use this to extend any that are shorter than the max with blanks or whatever. -- Bert On Thu, Mar 14, 2013 at 7:42 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, Let say I have following string: Vec - c(sada, asdsa, sa) Now I want to make each element of this vector with equal length. Basically I want following vector: c(sada , asdsa, sa ) Therefore we can get: nchar(c(sada , asdsa, sa )) [1] 5 5 5 Is there any possiblity that we can do it programetically? Because I need to handle a really big vector. Thanks for your help. __ 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] NADA and cenmle
On Thu, 14 Mar 2013, Shane Carey wrote: I am using the cenmle function from the NADA package and some of my data are negative values. As a result the cenmle function will not work and NaN's are produced. I try to change the distribution to Gaussian, but it still will not run. Could somebody please help me with this? Possibly. What do your negative values represent? If they are 'less-thans', that is, censored as below the method detection limit or laboratory reporting limit, then you need to transform them to absolute values and set a flag indicating their status. For example, your data frame should have a column named 'flag' or (the lable I use) 'ceneq1' which contains a Boolean value: zero if the value is measured and one if it is censored. Then write the function call similar to this: cenmle(dataframe$value, dataframe$ceneq1, dist='lognormal') Works as advertised. 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] Working with string
library(stringr) str_pad(Vec,5,right) #[1] sada asdsa sa #or str_pad(Vec,max(nchar(Vec)),right) #[1] sada asdsa sa str_count(str_pad(Vec,5,right),) #[1] 5 5 5 A.K. - Original Message - From: Christofer Bogaso bogaso.christo...@gmail.com To: r-help r-help@r-project.org Cc: Sent: Thursday, March 14, 2013 10:42 AM Subject: [R] Working with string Hello again, Let say I have following string: Vec - c(sada, asdsa, sa) Now I want to make each element of this vector with equal length. Basically I want following vector: c(sada , asdsa, sa ) Therefore we can get: nchar(c(sada , asdsa, sa )) [1] 5 5 5 Is there any possiblity that we can do it programetically? Because I need to handle a really big vector. Thanks for your help. __ 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] Working with string
On Mar 14, 2013, at 9:42 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, Let say I have following string: Vec - c(sada, asdsa, sa) Now I want to make each element of this vector with equal length. Basically I want following vector: c(sada , asdsa, sa ) Therefore we can get: nchar(c(sada , asdsa, sa )) [1] 5 5 5 Is there any possiblity that we can do it programetically? Because I need to handle a really big vector. Thanks for your help. ?format will by default, left justify and pad with spaces to the longest length element in the character vector: Vec - c(sada, asdsa, sa) format(Vec) [1] sada asdsa sa Regards, Marc Schwartz __ 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] question about nls
On Thu, Mar 14, 2013 at 5:07 AM, meng laomen...@163.com wrote: Hi,all: I met a problem of nls. My data: xy 60 0.8 80 6.5 100 20.5 120 45.9 I want to fit exp curve of data. My code: nls(y ~ exp(a + b*x)+d,start=list(a=0,b=0,d=1)) Error in nlsModel(formula, mf, start, wts) : singular gradient matrix at initial parameter estimates I can't find out the reason for the error. Any suggesions are welcome. The gradient is singular at your starting value so you will have to use a better starting value. If d = 0 then its linear in log(y) so you can compute a starting value using lm like this: lm1 - lm(log(y) ~ x, DF) st - setNames(c(coef(lm1), 0), c(a, b, d)) Also note that you are trying to fit a model with 3 parameters to only 4 data points. -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at 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] Working with string
Duhhh... You already knew about nchar!! So (untested): nc - nchar(vec) mx - max(nc) blanks - rep( ,mx-nchar+1) ## +1 needed for rep paddedvec -substring(paste(vec,blanks,sep=),1,mx) You can also do this at one go with str_pad in the stringr package, found by searching on pad strings.' -- Bert On Thu, Mar 14, 2013 at 7:56 AM, Bert Gunter bgun...@gene.com wrote: ?nchar will tell you how many characters are in each string (mod multibyte locales) and you can use this to extend any that are shorter than the max with blanks or whatever. -- Bert On Thu, Mar 14, 2013 at 7:42 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, Let say I have following string: Vec - c(sada, asdsa, sa) Now I want to make each element of this vector with equal length. Basically I want following vector: c(sada , asdsa, sa ) Therefore we can get: nchar(c(sada , asdsa, sa )) [1] 5 5 5 Is there any possiblity that we can do it programetically? Because I need to handle a really big vector. Thanks for your help. __ 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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] NADA and cenmle
On Thu, 14 Mar 2013, Shane Carey wrote: Thanks for your reply. My data frame contains the value and a true/false to indicate whether they are censored or not. So I have something like: Data Censored -1.2 TRUE -5.5 TRUE 5 FALSE These negative values are actual values so do these have to be made absolute? Shane, If your data represent chemical concentrations of some sort then, yes, the data must all be positive. You cannot have a chemical concentration less than zero. If the negative values are actual, then what is the reporting level? And what do they measure that is really a censored value? The concept of censored data, whether right or left censored, is that there is no way of knowing the actual numeric value. In right-censored survival analyses (e.g., medical trials) the death of an individual is recorded. But, when the study ends for whatever reason, there are still subjects alive and there's no way of knowing how long after the end of the study they die. Ergo, their age at death is unknown or censored. With left censored data such as chemical constituent concentrations in air, water, or some other medium, there is a concentration below which the instruments cannot distinguish it from noise. All we know is that the constituent is present but its concentration is somewhere between zero and the detection/reporting limit. Therefore, having a number that is below this detection/reporting limit is meaningless, and it cannot be negative. That's why it is flagged as being censored. The cenmle() function assumes these conditions to be true. Please keep this thread on the mail list so others can participate and learn from the conversation. 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] column and line graphs in R
The easiest way to supply data is to use the dput() function. Example with your file named testfile: dput(testfile) Then copy the output and paste into your email. For large data sets, you can just supply a representative sample. Usually, dput(head(testfile, 100)) will be sufficient. Generally speaking two y-axis scales are to be avoided if at all possible. Faceting is likely to give you better results although I see that the scale differences are annoying large. It is possible to plot the two facets of the graph independently in order to have two independent y-axes but it takes more work and may or may not be needed Here is a possible approach based on ggplot2 . You will probably have to install ggplot2 and reshape2 using install.packages() Notice I've changed your variable names around and turned your data into a dataframe with the matrix row.names as another variable. ##===begin code==# library(reshape2) library(ggplot2) dat1-read.table(text= place abund freq MOTU2 0.0030.083 MOTU4 0.0290.167 MOTU6 0.0330.167 MOTU7 0.0230.083 MOTU9 0.0090.083 MOTU11 0.0420.250 MOTU14 0.0690.083 MOTU16 0.0590.167 MOTU17 0.0340.083 MOTU18 0.0490.083 MOTU19 0.0840.333 MOTU20 0.0150.083 MOTU21 0.0590.083 MOTU22 0.0320.167 MOTU23 0.1420.250 MOTU24 0.0310.083 MOTU25 0.0340.083 MOTU29 0.0100.083 MOTU30 0.0110.083 MOTU33 0.0040.083 MOTU36 0.0340.333 MOTU34 0.1820.417 ,sep=,header=TRUE,stringsAsFactors=FALSE) str(dat1) dm1 - melt(dat1, id = place, variable.name=type, value.name=freq) str(dm1) # plot first alternative ggplot(dm1, aes(place, freq, colour = type, group = type )) + geom_line(group = 1) + facet_grid(type ~ . ) # or plot second alternative. ggplot(dm1, aes(place, freq, colour = type, group = type )) + geom_line(group = 1) + facet_grid(. ~ type ) ##end code===# -Original Message- From: gian.benu...@gmail.com Sent: Thu, 14 Mar 2013 15:40:53 +0100 To: r-help@r-project.org Subject: Re: [R] column and line graphs in R Hi again, Thank you all for your support. I would love to have a graph in which two variables are contemporary showed. For example a histogram and a curve should be the perfect choice. I tried to use twoord.plot() but I am not sure I understand how to manage the the arguments lx, ly, rx, ry... Anyway these are my data: nat_af rel.abund rel.freq MOTU2 0.0030.083 MOTU4 0.0290.167 MOTU6 0.0330.167 MOTU7 0.0230.083 MOTU9 0.0090.083 MOTU11 0.0420.250 MOTU14 0.0690.083 MOTU16 0.0590.167 MOTU17 0.0340.083 MOTU18 0.0490.083 MOTU19 0.0840.333 MOTU20 0.0150.083 MOTU21 0.0590.083 MOTU22 0.0320.167 MOTU23 0.1420.250 MOTU24 0.0310.083 MOTU25 0.0340.083 MOTU29 0.0100.083 MOTU30 0.0110.083 MOTU33 0.0040.083 MOTU36 0.0340.333 MOTU34 0.1820.417 First column is the relative abundance of the given MOTU and second column is the relative frequency of the same MOTU. Thank you very much in advance, -- Gian On 14 March 2013 14:51, John Kane jrkrid...@inbox.com wrote: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example You really need to read the posting guide and supply some sample data at the very least. Here is about as simple minded a plot as R will do as an example however dat1 - structure(list(abond = c(17L, 3L, 6L, 11L, 5L, 8L, 13L, 16L, 15L, 2L), freq = c(17L, 14L, 7L, 13L, 19L, 5L, 3L, 20L, 9L, 10L )), .Names = c(abond, freq), row.names = c(NA, -10L), class = data.frame) plot(dat1$abond, col = red) lines(dat1$freq, col= blue) John Kane Kingston ON Canada -Original Message- From: gian.benu...@gmail.com Sent: Thu, 14 Mar 2013 11:05:40 +0100 To: r-help@r-project.org Subject: [R] column and line graphs in R Hi all, I would love to plot my data with R. I have abundance and frequency of fungal taxonomic data that should be plotted in the same graph. In Microsoft Excel is that possible but the graphic result is, as always, very poor. Is there a function that may let me plot these data in R? I have a matrix made of two columns, on is the relative abundance and the other is the relative frequency for each of my sample. Thank you very much, -- Gian [[alternative HTML version deleted]]
[R] R programmer
Quantide is looking for an junior R programmer for a three/six month contract in Milan (Italy). If interested please email your resume to me 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] date time manipulation- R 2.15.1 windows 7
A good place to start might be http://www.jstatsoft.org/v40/i03/paper for the lubridate package or have a look at the zoo package John Kane Kingston ON Canada -Original Message- From: yash.kaja...@gmail.com Sent: Thu, 14 Mar 2013 19:15:00 +0530 To: r-help@r-project.org Subject: [R] date time manipulation- R 2.15.1 windows 7 Hi, I wanted to learn how to solve a date and time manipulation where i can do the following two 1. difference of two dates eg (differnce between 5th jan 2013 and 1st jan 2013) 2.Suppose i have week number of the year, i want to know if i can find out the day it refers to eg( say week 2 of 2013 would be 6th jan 2013 and the day is sunday) i need my result to tell me that its the 6th of jan 2013 as well as the day (sunday) Can u please help me out? Thanks, Yashvardhan Kajaria [[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.
[R] plotting
Hi alL, I have a data frame with 4 columns: value, time, group and id. I would like to plot value vs. time with different colors for different levels of group and different symbols for different values of id. I think I could do this but I would like to see what is an easier way to plot the data this way. Thank you vey much. Hanna [[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] plotting
I think you'll find this easiest with ggplot2: library(ggplot2) ggplot(dat, aes(x = value, y = time, color = group, symbol = id)) + geom_point() # symbol = might not be the right argument -- I'm doing this from memory or similar MW On Thu, Mar 14, 2013 at 3:46 PM, li li hannah@gmail.com wrote: Hi alL, I have a data frame with 4 columns: value, time, group and id. I would like to plot value vs. time with different colors for different levels of group and different symbols for different values of id. I think I could do this but I would like to see what is an easier way to plot the data this way. Thank you vey much. Hanna [[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] NADA and cenmle
Shane: Just to add some practical advice on top of Rich's interpretation of the censoring process (which is correct), my recent experiences with analyzing below-detection limit chemical concentrations in water using left-censoring estimators indicates that historically people have not always indicated the below-detection limit data in a consistent fashion. So often people would include either a with the detection limit value (e.g, 5), possibly also negative values (e.g., -5, negatives could be used as a flag for censoring if the real measurement scale is strictly positive as it is for chemical concentrations, but it has risky potential side effects), and possibly a separate column variable like your Censored TRUE/FALSE. I'm wondering if it is possible that your data format has a mix of these approaches. It seems like most recent statistical software for censoring usually wants a column variable for the measured response (Y), where observations of Y that are below (or above) detection-limit (censored) have the detection limit (censoring) value; and then a second column like your Censored column (either with TRUE/FALSE or 0/1 indicators). Brian Brian S. Cade, PhD U. S. Geological Survey Fort Collins Science Center 2150 Centre Ave., Bldg. C Fort Collins, CO 80526-8818 email: ca...@usgs.gov brian_c...@usgs.gov tel: 970 226-9326 On Thu, Mar 14, 2013 at 9:20 AM, Rich Shepard rshep...@appl-ecosys.comwrote: On Thu, 14 Mar 2013, Shane Carey wrote: Thanks for your reply. My data frame contains the value and a true/false to indicate whether they are censored or not. So I have something like: Data Censored -1.2 TRUE -5.5 TRUE 5 FALSE These negative values are actual values so do these have to be made absolute? Shane, If your data represent chemical concentrations of some sort then, yes, the data must all be positive. You cannot have a chemical concentration less than zero. If the negative values are actual, then what is the reporting level? And what do they measure that is really a censored value? The concept of censored data, whether right or left censored, is that there is no way of knowing the actual numeric value. In right-censored survival analyses (e.g., medical trials) the death of an individual is recorded. But, when the study ends for whatever reason, there are still subjects alive and there's no way of knowing how long after the end of the study they die. Ergo, their age at death is unknown or censored. With left censored data such as chemical constituent concentrations in air, water, or some other medium, there is a concentration below which the instruments cannot distinguish it from noise. All we know is that the constituent is present but its concentration is somewhere between zero and the detection/reporting limit. Therefore, having a number that is below this detection/reporting limit is meaningless, and it cannot be negative. That's why it is flagged as being censored. The cenmle() function assumes these conditions to be true. Please keep this thread on the mail list so others can participate and learn from the conversation. 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.
Re: [R] NADA and cenmle
On Thu, 14 Mar 2013, Shane Carey wrote: Ah ok, thanks. I understand now. The data are chemical concentrations but are reported back as negative values. I have a Lower limit of detection (LLD) of 1 for one element but a value of -2.9 gets reported back to me. One last question, for a different element the LLD is reported as 10, anything = 10 is given a value of -10. So, I now have: Data Censored -10 TRUE -10 TRUE 20 FALSE In order for this to work in the NADA package, it must be transformed to: Data Censored 10 TRUE 10 TRUE 20 FALSE Yep. Your first example would be recorded as 1 TRUE and your second example as 10TRUE Now, if both limits reflect different times or analytical methods for the same chemical constituent, then you need two additional columns for the lowest value (0) and the LLD (1 or 10) and a different analytical approach for multiple reporting levels. Otherwise, you're on your way. Rich -- Richard B. Shepard, Ph.D. | Integrity - Credibility - Innovation Applied Ecosystem Services, Inc. | http://www.appl-ecosys.com Voice: 503-667-4517 Fax: 503-667-8863 __ 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] NADA and cenmle
Ah ok, thanks. I understand now. The data are chemical concentrations but are reported back as negative values. I have a Lower limit of detection (LLD) of 1 for one element but a value of -2.9 gets reported back to me. One last question, for a different element the LLD is reported as 10, anything = 10 is given a value of -10. So, I now have: Data Censored -10 TRUE -10 TRUE 20 FALSE In order for this to work in the NADA package, it must be transformed to: Data Censored 10 TRUE 10 TRUE 20 FALSE Thanks On Thu, Mar 14, 2013 at 3:20 PM, Rich Shepard rshep...@appl-ecosys.comwrote: On Thu, 14 Mar 2013, Shane Carey wrote: Thanks for your reply. My data frame contains the value and a true/false to indicate whether they are censored or not. So I have something like: Data Censored -1.2 TRUE -5.5 TRUE 5 FALSE These negative values are actual values so do these have to be made absolute? Shane, If your data represent chemical concentrations of some sort then, yes, the data must all be positive. You cannot have a chemical concentration less than zero. If the negative values are actual, then what is the reporting level? And what do they measure that is really a censored value? The concept of censored data, whether right or left censored, is that there is no way of knowing the actual numeric value. In right-censored survival analyses (e.g., medical trials) the death of an individual is recorded. But, when the study ends for whatever reason, there are still subjects alive and there's no way of knowing how long after the end of the study they die. Ergo, their age at death is unknown or censored. With left censored data such as chemical constituent concentrations in air, water, or some other medium, there is a concentration below which the instruments cannot distinguish it from noise. All we know is that the constituent is present but its concentration is somewhere between zero and the detection/reporting limit. Therefore, having a number that is below this detection/reporting limit is meaningless, and it cannot be negative. That's why it is flagged as being censored. The cenmle() function assumes these conditions to be true. Please keep this thread on the mail list so others can participate and learn from the conversation. 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. -- Shane [[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 copy current line in Tinn-R
Hello All, A very simple question about Tinn-R. I am able to use the send line shortcut, but I want to be able to just copy the current line to the clipboard and then paste in the current document or somewhere else. It's so tedious to select the whole line and then copy it. Thanks __ 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] merge function to combine two tables
Below , in line John Kane Kingston ON Canada -Original Message- From: michael.eisenr...@gmx.ch Sent: Thu, 14 Mar 2013 11:51:49 +0100 To: r-help@r-project.org Subject: [R] merge function to combine two tables Dear R-help members I would be grateful if anyone could help me with the following problem: I would like to combine two matrices (Schmitt_15 and Schmitt_16, they are attached) which have a species presence/absence x sampling plot structure. The aim would be to have in the end only one matrix which shows all existing species and their presence/absence on all the different plots. To do this I used the merge function in R. The problem is that my matrix in the end shows only 12 species (but there are in total about 100!). I don't know why. I used the following commands: Schmitt_15 Schmitt_16 output-merge(Schmitt_15,Schmitt_16,by=species) # you seem to be only picking out the common species in the two data.frames ncol(output) length(unique(output$species)) Schmitt_15$species %in% Schmitt_16$species # This may do what you want. It means that you are taking every speices name found in either file. Is that what you want newdat - merge(Schmitt_15,Schmitt_16, by=species, all = TRUE) This gives me a merged file with # You seem to have missed a step here since there is no ab object in your code. write.table(ab,file=output.txt,sep=,) Can anyone help me? Thank you very much! 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. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas 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.
[R] does R read commands from scripts instantanously or seuqently during processing
Dear R community, when I source a script into R via: R --slave scriptname.R is the whole script file read at once during startup or is each indivdual line of code read seqnetially during the execution (i.e. directly before r processes the respective command)? In other words, can I savely edit the scriptname.R file even when an active R process still runs the command above? Thanks for your help Jannis __ 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] merge function to combine two tables
Take a look at your data. When I loaded what you attached, there were only 9 species that were in common across the two files: dim(s16) [1] 226 83 dim(s15) [1] 96 41 sum(s15$species %in% s16$species) [1] 10 sum(s16$species %in% s15$species) [1] 10 length(intersect(s16$species, s15$species)) [1] 9 length(unique(s16$species)) [1] 173 length(unique(s15$species)) [1] 90 x - merge(s16, s15, by = 'species') dim(x) [1] 12 123 so it is not surprising you got the result that you did. On Thu, Mar 14, 2013 at 6:51 AM, Michael Eisenring michael.eisenr...@gmx.ch wrote: Dear R-help members I would be grateful if anyone could help me with the following problem: I would like to combine two matrices (Schmitt_15 and Schmitt_16, they are attached) which have a species presence/absence x sampling plot structure. The aim would be to have in the end only one matrix which shows all existing species and their presence/absence on all the different plots. To do this I used the merge function in R. The problem is that my matrix in the end shows only 12 species (but there are in total about 100!). I don't know why. I used the following commands: Schmitt_15 Schmitt_16 output-merge(Schmitt_15,Schmitt_16,by=species) write.table(ab,file=output.txt,sep=,) Can anyone help me? Thank you very much! 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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. [[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] plotting
It is easy to do in base graphics, but probably a bad idea just because it is very hard to decode the symbol/color combinations. I added a crude legend: # Provide reproducible data set.seed(42) value - round(rnorm(20), 2) time - round(runif(20)*10, 1) group - sample(1:4) id - sample(1:5) dta - data.frame(value, time, group, id) # Plot and legend plot(value~time, pch=id+20, col=group, bg=group, cex=1.25) legend(bottomright, as.character(1:4), pch=16, col=1:4, bty=n, inset=c(0, .045), title=Group) legend(bottomright, as.character(1:5), pch=21:25, col=gray, inset=c(.1, 0), bty=n, title=ID) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of R. Michael Weylandt Sent: Thursday, March 14, 2013 10:51 AM To: li li Cc: r-help Subject: Re: [R] plotting I think you'll find this easiest with ggplot2: library(ggplot2) ggplot(dat, aes(x = value, y = time, color = group, symbol = id)) + geom_point() # symbol = might not be the right argument -- I'm doing this from memory or similar MW On Thu, Mar 14, 2013 at 3:46 PM, li li hannah@gmail.com wrote: Hi alL, I have a data frame with 4 columns: value, time, group and id. I would like to plot value vs. time with different colors for different levels of group and different symbols for different values of id. I think I could do this but I would like to see what is an easier way to plot the data this way. Thank you vey much. Hanna [[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-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] plotting
Also going from memory Michael's ggplot should almost work but I think yo need to change symbol = id in the aes statement to geom_point(aes(shape = id)) although it may work in the first aes() statement. John Kane Kingston ON Canada -Original Message- From: michael.weyla...@gmail.com Sent: Thu, 14 Mar 2013 15:51:21 + To: hannah@gmail.com Subject: Re: [R] plotting I think you'll find this easiest with ggplot2: library(ggplot2) ggplot(dat, aes(x = value, y = time, color = group, symbol = id)) + geom_point() # symbol = might not be the right argument -- I'm doing this from memory or similar MW On Thu, Mar 14, 2013 at 3:46 PM, li li hannah@gmail.com wrote: Hi alL, I have a data frame with 4 columns: value, time, group and id. I would like to plot value vs. time with different colors for different levels of group and different symbols for different values of id. I think I could do this but I would like to see what is an easier way to plot the data this way. Thank you vey much. Hanna [[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. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas 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] Re move row.names column in dataframe
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of jeharmse Sent: Monday, March 11, 2013 5:28 PM To: r-help@r-project.org Subject: Re: [R] Re move row.names column in dataframe 1.If your data frame is numeric, change it to matrix. It isn't necessarily numeric. 2.Or make your own function I think that's the solution, but the function has to handle both NA and non-numeric. equal.NA - function(x,y) all(is.na(x)==is.na(y)) all(is.na(x) | x==y) I'm still worried that row names could bite me in some other way, and would prefer to be able to discard them. As you did not include my answer I can not be 100% sure but for comparison purpose matrix way behaves correctly Regards Petr -- View this message in context: http://r.789695.n4.nabble.com/Remove-row- names-column-in-dataframe-tp856647p4660956.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] NLS results different from Excel -- Tricky fortunes nomination
Following up on Bert's nomination, may I take one from a recent email I received? The second file is air concentrations against frequencies plotted by SAS; however we don't have the SAS statistical package... I thought the original name for SAS was Statistical Analysis System--am I missing something? 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 Wed, 20 Feb 2013, Bert Gunter wrote: Folks: I thought the following excerpt from Bruce McCullough's post would be a good candidate for the R fortunes package -- except that it's about Excel, not R! So I nominate it... but leave it to others to say whether it's really qualified to be nominated. The idea that the Excel solver has a good reputation for being fast and accurate does not withstand an examination of the Excel solver's ability to solve the StRD nls test problems. ... Excel solver does have the virtue that it will always produce an answer, albeit one with zero accurate digits. --- I also leave it to others to modify what is excerpted if appropriate. Cheers, Bert On Wed, Feb 20, 2013 at 7:58 AM, Bruce McCullough bdmccullo...@drexel.edu wrote: The idea that the Excel solver has a good reputation for being fast and accurate does not withstand an examination of the Excel solver's ability to solve the StRD nls test problems. Solver's ability is abysmal. 13 of 27 answers have zero accurate digits, and three more have fewer than two accurate digits -- and this is after tuning the solver to get a good answer. For details see B. D. McCullough and Berry Wilson On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and Excel XP, /Computational Statistics and Data Analysis/ *40*(4), 713-721, 2002 The situation is the same for Excel 2003 and Excel 2007. The alleged improvements for Excel 2010 have had not much practical effect. Excel solver does have the virture that it will always produce an answer, albeit one with zero accurate digits. To see an extended example of precisely how solver fails: B. D. McCullough Some Details of Nonlinear Estimation, Chapter Eight in /Numerical Methods in Statistical Computing for the Social Sciences, / Micah Altman, Jeff Gill and Michael P. McDonald, editors New York: Wiley, 2004 I am unaware of R being applied to the StRD, but I did apply S+ to the StRD and, with analytic derivatives, it performed flawlessly. On 02/19/2013 08:38 PM, r-help-requ...@r-project.org wrote: May I be allowed to say that the general comments on MS Excel may be alright, in this special case they are not. The Excel Solver -- which is made by an external company, not MS -- has a good reputation for being fast and accurate. And it indeed solves least-squares and nonlinear problems better than some of the solvers available in R. There is a professional version of this solver, not available from Microsoft, that could be called excellent. We, and this includes me, should not be too arrogant towards the outside, non-R world, the 'barbarians' as the ancient Greeks called it. Hans Werner -- B. D. McCullough, Professor Department of Decision Sciences LeBow College of Business So what's getting ubiquitous and cheap? Data. And what is complementary to data? Analysis. So my recommendation is to take lots of courses about how to manipulate and analyze data: databases, machine learning, econometrics, statistics, visualization, and so on. Google Chief Economist, Hal Varian, New York Times, 25 February 2008 [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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] map question
Dear All, wondering if anyone could help with a working code for the following: I would like to plot a map using R that includes New York City (with counties of Kings, Queens, Bronx, New York and Richmond), Westchester, Nassau, Suffolk and Rockland counties (any color would be ok per county as long as they are different), and place 4 visible red dots at the following zip codes: 11219, 10960, 10003, 10029. Can this be done in R? thank you, Andras [[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] saving vector output as numeric
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Aimee Kopolow Sent: Wednesday, March 13, 2013 5:39 AM To: r-help Subject: [R] saving vector output as numeric Hi everybody, I'm trying to create a numerical data frame on which to perform PRCC. So far I have created a data frame that consists of function/vector output that displays in numerical form, but when I try and run PRCC (from epiR package) I get the following error message: Error in solve.default(C) : Lapack routine dgesv: system is exactly singular It appears this is because the data frame is passing character strings rather than the numerical data to R. An example of my original data frame minmaxfunc is as follows: min max T1 1.50e+01 3.54e+01 SE1 0.00e+00 1.00e+00 PRE 0.00e+00 1.00e+00 WET 0.00e+00 5.98e+00 BE1 4.664642e+00 5.866620e+00 Kappa1 5.50e+03 2.00e+04 Kappa3 1.00e+04 2.00e+04 Then I created a latin hypercube set using (qunif(x[,i], minmaxfunc$min[i], minmaxfunc$max[i]). The new data frame looks as follows: T1 SE1 PRE WET BE1Kappa1 Kappa3 131.35590 0.7066388715 0.8665111432 4.965701530 5.783424 12240.019 12675.12 228.27640 0.5442730461 0.7000693454 3.181014435 5.183708 16626.566 10759.27 328.14695 0.6295741145 0.7818034368 2.262515130 4.670685 16930.360 13857.44 430.51873 0.3983581045 0.4026640041 2.730221171 5.058697 19546.625 14408.89 516.03162 0.0440886703 0.9954737808 1.002989298 5.310149 13188.279 19500.85 619.48413 0.4280443098 0.8500412067 1.668042962 5.068510 11742.748 18891.87 736.44783 0.5033961511 0.8249423312 5.582521574 4.722634 8738.121 16457.21 839.76318 0.8805976090 0.3430379347 4.876022801 4.787737 19873.134 18660.02 939.99782 0.4109272317 0.6606016486 0.191627831 5.625588 11086.803 13569.30 Each cell contains a vector that is computing the numerical output, but how do I save the latin hypercube sampling data frame in numerical form?? I've tried as.numeric but the error message is (list) object cannot be coerced to type 'double' regardless of whether it's write.table, read.table or as.data.frame that I'm using as.numeric with. Data frame is a list so as it can hold different class of objects together. as.numeric requires number or vector. Maybe you could change it by as.matrix. However without some reproducible code (as required by posting guide) it is just a guess. Please, try to show at least str(your.object) and preferably copy dput(some.part.of.your.object) to your post. Regards Petr Sorry if this is information dense, and thanks for any help you are able to give. Aimee. __ 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] plotting
It is easy to do in base graphics, but probably a bad idea just because it is very hard to decode the symbol/color combinations. I just appropriated your data set and tried it in ggplot2 and your objection looks valid there as well. And Michael was right, the shape command can go in the first aes statement. library(ggplot2) p - ggplot(dta , aes(time, value, shape = as.factor(id) , colour =as.factor(group ))) + geom_point() p John Kane Kingston ON Canada -Original Message- From: dcarl...@tamu.edu Sent: Thu, 14 Mar 2013 11:23:18 -0500 To: michael.weyla...@gmail.com, hannah@gmail.com Subject: Re: [R] plotting It is easy to do in base graphics, but probably a bad idea just because it is very hard to decode the symbol/color combinations. I added a crude legend: # Provide reproducible data set.seed(42) value - round(rnorm(20), 2) time - round(runif(20)*10, 1) group - sample(1:4) id - sample(1:5) dta - data.frame(value, time, group, id) # Plot and legend plot(value~time, pch=id+20, col=group, bg=group, cex=1.25) legend(bottomright, as.character(1:4), pch=16, col=1:4, bty=n, inset=c(0, .045), title=Group) legend(bottomright, as.character(1:5), pch=21:25, col=gray, inset=c(.1, 0), bty=n, title=ID) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of R. Michael Weylandt Sent: Thursday, March 14, 2013 10:51 AM To: li li Cc: r-help Subject: Re: [R] plotting I think you'll find this easiest with ggplot2: library(ggplot2) ggplot(dat, aes(x = value, y = time, color = group, symbol = id)) + geom_point() # symbol = might not be the right argument -- I'm doing this from memory or similar MW On Thu, Mar 14, 2013 at 3:46 PM, li li hannah@gmail.com wrote: Hi alL, I have a data frame with 4 columns: value, time, group and id. I would like to plot value vs. time with different colors for different levels of group and different symbols for different values of id. I think I could do this but I would like to see what is an easier way to plot the data this way. Thank you vey much. Hanna [[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-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. GET FREE SMILEYS FOR YOUR IM EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails __ 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] NLS results different from Excel -- Tricky fortunes nomination
No , but please RSVP if you disagree with me. John Kane Kingston ON Canada -Original Message- From: cl...@ecy.wa.gov Sent: Thu, 14 Mar 2013 09:28:46 -0700 (PDT) To: gunter.ber...@gene.com Subject: Re: [R] NLS results different from Excel -- Tricky fortunes nomination Following up on Bert's nomination, may I take one from a recent email I received? The second file is air concentrations against frequencies plotted by SAS; however we don't have the SAS statistical package... I thought the original name for SAS was Statistical Analysis System--am I missing something? Clint Clint Bowman INTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600 FAX:(360) 407-7534 Olympia, WA 98504-7600 USPS: PO Box 47600, Olympia, WA 98504-7600 Parcels:300 Desmond Drive, Lacey, WA 98503-1274 On Wed, 20 Feb 2013, Bert Gunter wrote: Folks: I thought the following excerpt from Bruce McCullough's post would be a good candidate for the R fortunes package -- except that it's about Excel, not R! So I nominate it... but leave it to others to say whether it's really qualified to be nominated. The idea that the Excel solver has a good reputation for being fast and accurate does not withstand an examination of the Excel solver's ability to solve the StRD nls test problems. ... Excel solver does have the virtue that it will always produce an answer, albeit one with zero accurate digits. --- I also leave it to others to modify what is excerpted if appropriate. Cheers, Bert On Wed, Feb 20, 2013 at 7:58 AM, Bruce McCullough bdmccullo...@drexel.edu wrote: The idea that the Excel solver has a good reputation for being fast and accurate does not withstand an examination of the Excel solver's ability to solve the StRD nls test problems. Solver's ability is abysmal. 13 of 27 answers have zero accurate digits, and three more have fewer than two accurate digits -- and this is after tuning the solver to get a good answer. For details see B. D. McCullough and Berry Wilson On the Accuracy of Statistical Procedures in Microsoft Excel 2000 and Excel XP, /Computational Statistics and Data Analysis/ *40*(4), 713-721, 2002 The situation is the same for Excel 2003 and Excel 2007. The alleged improvements for Excel 2010 have had not much practical effect. Excel solver does have the virture that it will always produce an answer, albeit one with zero accurate digits. To see an extended example of precisely how solver fails: B. D. McCullough Some Details of Nonlinear Estimation, Chapter Eight in /Numerical Methods in Statistical Computing for the Social Sciences, / Micah Altman, Jeff Gill and Michael P. McDonald, editors New York: Wiley, 2004 I am unaware of R being applied to the StRD, but I did apply S+ to the StRD and, with analytic derivatives, it performed flawlessly. On 02/19/2013 08:38 PM, r-help-requ...@r-project.org wrote: May I be allowed to say that the general comments on MS Excel may be alright, in this special case they are not. The Excel Solver -- which is made by an external company, not MS -- has a good reputation for being fast and accurate. And it indeed solves least-squares and nonlinear problems better than some of the solvers available in R. There is a professional version of this solver, not available from Microsoft, that could be called excellent. We, and this includes me, should not be too arrogant towards the outside, non-R world, the 'barbarians' as the ancient Greeks called it. Hans Werner -- B. D. McCullough, Professor Department of Decision Sciences LeBow College of Business So what's getting ubiquitous and cheap? Data. And what is complementary to data? Analysis. So my recommendation is to take lots of courses about how to manipulate and analyze data: databases, machine learning, econometrics, statistics, visualization, and so on. Google Chief Economist, Hal Varian, New York Times, 25 February 2008 [[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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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,
[R] Features Selection using RWeka
Does this package include any methods to do features selection? 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] evtree
On Thu, 14 Mar 2013, G Girija wrote: hi I got the following error in 'evtree'. could u help pl. Error in if (var(mf[, nVariables]) = 0) stop(variance of the denpendent variable is 0) : argument is of length zero I would guess that your model formula and/or corresponding data frame is somehow incorrect or misspecified. But it's hard to say with the information you provide. Please see the posting guide (in the footer of this e-mail) on how to ask a better question. [[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] error: object of type 'closure' is not subsettable
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of robert.koellner Sent: Thursday, March 14, 2013 1:05 PM To: r-help@r-project.org Subject: Re: [R] error: object of type 'closure' is not subsettable Edit: OK I got it for ( dye in c(A,B,C,F,G,K,L,M)) + { + for (cond in 1:8) + { + measurement = *my*table[mytable[,bed]==cond mytable[,dye]==dye,differenz] + print(median(measurement)) + wilcox.test(measurement,mu=0) + } + } But now I get new error massages: Error in wilcox.test.default(measurement, mu = 0) : not enough (finite) 'x' observations In addition: There were 11 warnings (use warnings() to see them) warnings() Warning messages: 1: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 2: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with zeroes 3: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with zeroes 4: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 5: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 6: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 7: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with zeroes 8: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with zeroes 9: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 10: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties 11: In wilcox.test.default(measurement, mu = 0) : cannot compute exact p-value with ties What does this mean? It probably means that measurement = *my*table[mytable[,bed]==cond mytable[,dye]==dye,differenz] gives you too few items in measurement variable what is the result of *my*table[mytable[,bed]==1 mytable[,dye]==A,differenz] But it is just guess as the code is not reproducible. Regards Petr OK can´t compute with zeros, but why? The test should compare the mediandifference to 0 and if the values are 0 it should be 1, or not? And what means 'cannot compute exact p-value with ties'? Greetings Robert -- View this message in context: http://r.789695.n4.nabble.com/error- object-of-type-closure-is-not-subsettable-tp4661305p4661316.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.
[R] ggplot2 problem
Hello all! I have a problem with ggplot2 library. I want to do an heat map and the y variables are the year months. If I use the following code, he y values are in alphabetical order, but I want it in month order. The code is: library(reshape) library(ggplot2) library(scales) p - ggplot(data.m, aes(variable, Month)) + geom_tile(aes(fill = value), colour = white) p + scale_fill_gradient(low = white, high = black) Thank you! The used data is: Month variable value 1 Jan 1961 87.667 2 Feb 1961 133.667 3 Mar 1961 113.667 4 Apr 1961 50.667 5 May 1961 7.500 6 Jun 1961 0.000 7 Jul 1961 0.000 8 Aug 1961 0.000 9 Sep 1961 0.000 10Oct 1961 0.333 11Nov 1961 3.000 12Dec 1961 17.333 13Jan 1962 37.333 14Feb 1962 60.333 15Mar 1962 102.000 16Apr 1962 90.667 17May 1962 17.000 18Jun 1962 7.000 19Jul 1962 0.000 20Aug 1962 0.000 21Sep 1962 0.000 22Oct 1962 0.000 23Nov 1962 2.333 24Dec 1962 21.333 25Jan 1963 68.333 26Feb 1963 84.333 27Mar 1963 102.000 28Apr 1963 62.000 29May 1963 0.000 30Jun 1963 0.000 31Jul 1963 0.000 32Aug 1963 0.000 33Sep 1963 0.000 34Oct 1963 0.000 35Nov 1963 0.000 36Dec 1963 0.000 37Jan 1964 68.667 38Feb 1964 57.000 39Mar 1964 62.667 40Apr 1964 25.500 41May 1964 7.500 42Jun 1964 0.000 43Jul 1964 0.000 44Aug 1964 0.000 45Sep 1964 0.000 46Oct 1964 0.000 47Nov 1964 2.333 48Dec 1964 14.000 49Jan 1965 13.667 50Feb 1965 20.333 51Mar 1965 42.333 52Apr 1965 15.333 53May 1965 7.000 54Jun 1965 0.000 55Jul 1965 0.000 56Aug 1965 0.000 57Sep 1965 0.000 58Oct 1965 0.000 59Nov 1965 11.667 60Dec 1965 13.000 61Jan 1966 25.667 62Feb 1966 21.333 63Mar 1966 31.667 64Apr 1966 27.333 65May 1966 1.000 66Jun 1966 0.000 67Jul 1966 0.000 68Aug 1966 0.000 69Sep 1966 0.000 70Oct 1966 0.000 71Nov 1966 2.333 72Dec 1966 10.667 73Jan 1967 8.000 74Feb 1967 7.667 75Mar 1967 33.333 76Apr 1967 24.667 77May 1967 0.000 78Jun 1967 0.000 79Jul 1967 0.000 80Aug 1967 0.000 81Sep 1967 0.000 82Oct 1967 0.000 83Nov 1967 2.500 84Dec 1967 21.333 85Jan 1968 24.000 86Feb 1968 45.333 87Mar 1968 56.667 88Apr 1968 9.000 89May 1968 1.500 90Jun 1968 0.000 91Jul 1968 0.000 92Aug 1968 0.000 93Sep 1968 0.000 94Oct 1968 2.333 95Nov 1968 1.000 96Dec 1968 12.333 97Jan 1969 10.667 98Feb 1969 6.667 99Mar 1969 7.667 100 Apr 1969 13.000 101 May 1969 0.000 102 Jun 1969 0.000 103 Jul 1969 0.000 104 Aug 1969 0.000 105 Sep 1969 0.000 106 Oct 1969 0.667 107 Nov 1969 3.667 108 Dec 1969 19.333 109 Jan 1970 23.000 110 Feb 1970 43.667 111 Mar 1970 25.333 112 Apr 1970 27.667 113 May 1970 2.000 114 Jun 1970 0.000 115 Jul 1970 0.000 116 Aug 1970 0.000 117 Sep 1970 0.000 118 Oct 1970 5.667 119 Nov 1970 2.333 120 Dec 1970 10.333 121 Jan 1971 15.000 122 Feb 1971 21.333 123 Mar 1971 19.333 124 Apr 1971 1.500 125 May 1971 0.000 126 Jun 1971 0.000 127 Jul 1971 0.000 128 Aug 1971 0.000 129 Sep 1971 2.000 130 Oct 1971 1.667 131 Nov 1971 16.000 132 Dec 1971 16.000 133 Jan 1972 13.333 134 Feb 1972 8.333 135 Mar 1972 15.000 136 Apr 1972 4.333 137 May 1972 0.000 138 Jun 1972 0.000 139 Jul 1972 0.000 140 Aug 1972 0.000 141 Sep 1972 7.000 142 Oct 1972 8.000 143 Nov 1972 12.333 144 Dec 1972 2.333
Re: [R] does R read commands from scripts instantanously or seuqently during processing
Your use of the redirection operator is an operating system feature, not an R feature. I am not aware of any operating system that that would function properly in the use case you describe. It is possible, and common, to construct your input file as a stream as you go. But a stream is not a file on disk. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Jannis bt_jan...@yahoo.de wrote: Dear R community, when I source a script into R via: R --slave scriptname.R is the whole script file read at once during startup or is each indivdual line of code read seqnetially during the execution (i.e. directly before r processes the respective command)? In other words, can I savely edit the scriptname.R file even when an active R process still runs the command above? Thanks for your help Jannis __ 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] Add a continuous color ramp legend to a 3d scatter plot
Marc, Thank you so much! It works! I really appreciate your help! best, Z On Wed, Mar 13, 2013 at 8:39 PM, Marc Girondot marc_...@yahoo.fr wrote: Hi, Try this. Sincelery, Marc x - rnorm(128, 10, 2) y - rnorm(128, 10, 2) z - x+y nbcol - heat.colors(128) # standardize z to be from 1 to 128 zcol - ((z-min(z))/(max(z)-min(z)))*127+1 library(scatterplot3d) library(fields) scatterplot3d(x,y,z, pch=16,color=nbcol[zcol], grid=FALSE, box=FALSE, mar=c(5, 3, 5, 7)+0.1) par(mar=c(5, 4, 4, 2) + 0.1) image.plot( legend.only=TRUE, zlim= c(min(z), max(z)), nlevel=128, col=heat.colors(128)) Le 13/03/13 17:36, Zhuoting Wu a écrit : Thanks Marc! I tried the colorbar.plot and image.plot. The colorbar.plot gives color bars within the plot, but I want a color bar legend on the side of the plot. The image.plot gives a legend that overlaps the plot, and the scale doesn't match the 3d scatterplot at all (see attached). Here's my R script: cols - myColorRamp(c(topo.colors(10)),z) scatterplot3d(x,y,z, pch=16,color=cols, grid=FALSE, box=FALSE) zr- range(c(z)) image.plot(legend.only=TRUE,col=cols, zlim=zr) I wanted to have a color ramp legend based on z on the side of the plot. I'll greatly appreciate any help! thanks, Z On Wed, Mar 13, 2013 at 2:11 AM, Marc Girondot marc_...@yahoo.fr wrote: Le 12/03/13 23:43, Zhuoting Wu a écrit : I have a 3 column dataset x,y,z, and I plotted a 3d scatter plot using: cols - myColorRamp(c(topo.colors(10)),z) plot3d(x=x, y=y, z=z, col=cols) I wanted to add a legend to the 3d plot showing the color ramp. Any help will be greatly appreciated! Look at the package fields: ?colorbar.plot Marc -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot [[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. -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot [[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] date time manipulation- R 2.15.1 windows 7
On Thu, Mar 14, 2013 at 9:45 AM, yash kajaria yash.kaja...@gmail.com wrote: Hi, I wanted to learn how to solve a date and time manipulation where i can do the following two 1. difference of two dates eg (differnce between 5th jan 2013 and 1st jan 2013) 2.Suppose i have week number of the year, i want to know if i can find out the day it refers to eg( say week 2 of 2013 would be 6th jan 2013 and the day is sunday) i need my result to tell me that its the 6th of jan 2013 as well as the day (sunday) Try this: dif - d - as.Date(cut(d, year)) dif Time difference of 4 days as.numeric(dif) [1] 4 The year and week don't imply the day of the week. We can input the year, week number and day of the week to get the date: year - 2013 week - 2 day - Sun as.Date(paste(year, week-1, day), %Y %W %a) [1] 2013-01-06 -- Statistics Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at 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] Add a continuous color ramp legend to a 3d scatter plot
I have two follow-up questions: 1. If I want to reverse the heat.colors (i.e., from yellow to red instead of red to yellow), is there a way to do that? 2. I also created this interactive 3d scatter plot as below: library(rgl) plot3d(x=x, y=y, z=z, col=nbcol[zcol], box=FALSE) Is there any way to add the same legend to this 3d plot? I'm new to R and try to learn it. I'm very grateful for any help! thanks, Z On Thu, Mar 14, 2013 at 9:56 AM, Zhuoting Wu zhuotin...@gmail.com wrote: Marc, Thank you so much! It works! I really appreciate your help! best, Z On Wed, Mar 13, 2013 at 8:39 PM, Marc Girondot marc_...@yahoo.fr wrote: Hi, Try this. Sincelery, Marc x - rnorm(128, 10, 2) y - rnorm(128, 10, 2) z - x+y nbcol - heat.colors(128) # standardize z to be from 1 to 128 zcol - ((z-min(z))/(max(z)-min(z)))*127+1 library(scatterplot3d) library(fields) scatterplot3d(x,y,z, pch=16,color=nbcol[zcol], grid=FALSE, box=FALSE, mar=c(5, 3, 5, 7)+0.1) par(mar=c(5, 4, 4, 2) + 0.1) image.plot( legend.only=TRUE, zlim= c(min(z), max(z)), nlevel=128, col=heat.colors(128)) Le 13/03/13 17:36, Zhuoting Wu a écrit : Thanks Marc! I tried the colorbar.plot and image.plot. The colorbar.plot gives color bars within the plot, but I want a color bar legend on the side of the plot. The image.plot gives a legend that overlaps the plot, and the scale doesn't match the 3d scatterplot at all (see attached). Here's my R script: cols - myColorRamp(c(topo.colors(10)),z) scatterplot3d(x,y,z, pch=16,color=cols, grid=FALSE, box=FALSE) zr- range(c(z)) image.plot(legend.only=TRUE,col=cols, zlim=zr) I wanted to have a color ramp legend based on z on the side of the plot. I'll greatly appreciate any help! thanks, Z On Wed, Mar 13, 2013 at 2:11 AM, Marc Girondot marc_...@yahoo.fr wrote: Le 12/03/13 23:43, Zhuoting Wu a écrit : I have a 3 column dataset x,y,z, and I plotted a 3d scatter plot using: cols - myColorRamp(c(topo.colors(10)),z) plot3d(x=x, y=y, z=z, col=cols) I wanted to add a legend to the 3d plot showing the color ramp. Any help will be greatly appreciated! Look at the package fields: ?colorbar.plot Marc -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot [[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. -- __ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: marc.giron...@u-psud.fr Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot [[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] ggplot2 problem
Hi Catalin, Untested, but I think data.m$Month - factor(data.m$Month, levels = month.abb) before plotting will do it. Best, Ista On Thu, Mar 14, 2013 at 12:51 PM, catalin roibu catalinro...@gmail.com wrote: Hello all! I have a problem with ggplot2 library. I want to do an heat map and the y variables are the year months. If I use the following code, he y values are in alphabetical order, but I want it in month order. The code is: library(reshape) library(ggplot2) library(scales) p - ggplot(data.m, aes(variable, Month)) + geom_tile(aes(fill = value), colour = white) p + scale_fill_gradient(low = white, high = black) Thank you! The used data is: Month variable value 1 Jan 1961 87.667 2 Feb 1961 133.667 3 Mar 1961 113.667 4 Apr 1961 50.667 5 May 1961 7.500 6 Jun 1961 0.000 7 Jul 1961 0.000 8 Aug 1961 0.000 9 Sep 1961 0.000 10Oct 1961 0.333 11Nov 1961 3.000 12Dec 1961 17.333 13Jan 1962 37.333 14Feb 1962 60.333 15Mar 1962 102.000 16Apr 1962 90.667 17May 1962 17.000 18Jun 1962 7.000 19Jul 1962 0.000 20Aug 1962 0.000 21Sep 1962 0.000 22Oct 1962 0.000 23Nov 1962 2.333 24Dec 1962 21.333 25Jan 1963 68.333 26Feb 1963 84.333 27Mar 1963 102.000 28Apr 1963 62.000 29May 1963 0.000 30Jun 1963 0.000 31Jul 1963 0.000 32Aug 1963 0.000 33Sep 1963 0.000 34Oct 1963 0.000 35Nov 1963 0.000 36Dec 1963 0.000 37Jan 1964 68.667 38Feb 1964 57.000 39Mar 1964 62.667 40Apr 1964 25.500 41May 1964 7.500 42Jun 1964 0.000 43Jul 1964 0.000 44Aug 1964 0.000 45Sep 1964 0.000 46Oct 1964 0.000 47Nov 1964 2.333 48Dec 1964 14.000 49Jan 1965 13.667 50Feb 1965 20.333 51Mar 1965 42.333 52Apr 1965 15.333 53May 1965 7.000 54Jun 1965 0.000 55Jul 1965 0.000 56Aug 1965 0.000 57Sep 1965 0.000 58Oct 1965 0.000 59Nov 1965 11.667 60Dec 1965 13.000 61Jan 1966 25.667 62Feb 1966 21.333 63Mar 1966 31.667 64Apr 1966 27.333 65May 1966 1.000 66Jun 1966 0.000 67Jul 1966 0.000 68Aug 1966 0.000 69Sep 1966 0.000 70Oct 1966 0.000 71Nov 1966 2.333 72Dec 1966 10.667 73Jan 1967 8.000 74Feb 1967 7.667 75Mar 1967 33.333 76Apr 1967 24.667 77May 1967 0.000 78Jun 1967 0.000 79Jul 1967 0.000 80Aug 1967 0.000 81Sep 1967 0.000 82Oct 1967 0.000 83Nov 1967 2.500 84Dec 1967 21.333 85Jan 1968 24.000 86Feb 1968 45.333 87Mar 1968 56.667 88Apr 1968 9.000 89May 1968 1.500 90Jun 1968 0.000 91Jul 1968 0.000 92Aug 1968 0.000 93Sep 1968 0.000 94Oct 1968 2.333 95Nov 1968 1.000 96Dec 1968 12.333 97Jan 1969 10.667 98Feb 1969 6.667 99Mar 1969 7.667 100 Apr 1969 13.000 101 May 1969 0.000 102 Jun 1969 0.000 103 Jul 1969 0.000 104 Aug 1969 0.000 105 Sep 1969 0.000 106 Oct 1969 0.667 107 Nov 1969 3.667 108 Dec 1969 19.333 109 Jan 1970 23.000 110 Feb 1970 43.667 111 Mar 1970 25.333 112 Apr 1970 27.667 113 May 1970 2.000 114 Jun 1970 0.000 115 Jul 1970 0.000 116 Aug 1970 0.000 117 Sep 1970 0.000 118 Oct 1970 5.667 119 Nov 1970 2.333 120 Dec 1970 10.333 121 Jan 1971 15.000 122 Feb 1971 21.333 123 Mar 1971 19.333 124 Apr 1971 1.500 125 May 1971 0.000 126 Jun 1971 0.000 127 Jul 1971 0.000 128 Aug 1971 0.000 129 Sep 1971 2.000 130 Oct 1971 1.667 131 Nov 1971 16.000 132 Dec 1971 16.000 133 Jan
[R] Equivalent of deal in R?
HI, I'm looking for a function that does the same as deal() in MATLAB, i,e, for an array x[1 2 3] [a,b,c]=x; such that a=1, b=2, c=3 Does R have any functions similar to this? [[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] Working with string
In addition to Marc's suggestion: sprintf(%-5s,Vec) #[1] sada asdsa sa formatC(Vec,width=-5) #[1] sada asdsa sa formatC(Vec,width=5) #[1] sada asdsa sa format(Vec,justify=right) #[1] sada asdsa sa A.K. - Original Message - From: Marc Schwartz marc_schwa...@me.com To: Christofer Bogaso bogaso.christo...@gmail.com Cc: r-help r-help@r-project.org Sent: Thursday, March 14, 2013 11:02 AM Subject: Re: [R] Working with string On Mar 14, 2013, at 9:42 AM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hello again, Let say I have following string: Vec - c(sada, asdsa, sa) Now I want to make each element of this vector with equal length. Basically I want following vector: c(sada , asdsa, sa ) Therefore we can get: nchar(c(sada , asdsa, sa )) [1] 5 5 5 Is there any possiblity that we can do it programetically? Because I need to handle a really big vector. Thanks for your help. ?format will by default, left justify and pad with spaces to the longest length element in the character vector: Vec - c(sada, asdsa, sa) format(Vec) [1] sada asdsa sa Regards, Marc Schwartz __ 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] Equivalent of deal in R?
Maybe x - array(1:3) for(i in seq_along(x)) { assign(letters[i], x[i]) } but usually there is no need for this kind of thing. Why do you want to do that? Best, Ista On Thu, Mar 14, 2013 at 1:17 PM, Sahana Srinivasan sahanasrinivasan...@gmail.com wrote: HI, I'm looking for a function that does the same as deal() in MATLAB, i,e, for an array x[1 2 3] [a,b,c]=x; such that a=1, b=2, c=3 Does R have any functions similar to this? [[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] Equivalent of deal in R?
On Mar 14, 2013, at 12:17 PM, Sahana Srinivasan sahanasrinivasan...@gmail.com wrote: HI, I'm looking for a function that does the same as deal() in MATLAB, i,e, for an array x[1 2 3] [a,b,c]=x; such that a=1, b=2, c=3 Does R have any functions similar to this? There are various R/MATLAB references floating around, one being: http://cran.r-project.org/doc/contrib/Hiebeler-matlabR.pdf A quick search suggests that there is no parallel for 'deal'. In actuality, splitting up an array/vector in this manner would be somewhat un-R-like, where the general paradigm is to take a whole object approach and process/manipulate R objects in their entirety, taking advantage of R's innate vectorized approach to such things. That being said, the ?assign function would take arguments of an R object and a name and assign the object to the name. Since assign() is not vectorized (which is arguably a hint), you would need to use a looping approach, perhaps along these lines: deal - function(x, Vars) { for (i in seq(along = x)) assign(Vars[i], x[i], envir = parent.frame()) } This will take an object 'x' and assign the value(s) of x to the name(s) contained in 'Vars'. It will assign the value(s) in the calling environment of the function. Thus: ls() [1] deal deal(c(1, 2, 3), c(a, b, c)) ls() [1] abcdeal a [1] 1 b [1] 2 c [1] 3 I did not include any error checking, but you would want to make sure that length(x) == length(Vars) within the function. I would however, urge you to reconsider what you are doing and take advantage of R's philosophy and therefore, strengths. It may be that coercing your source vector to a list would serve you well. Regards, Marc Schwartz __ 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] date time manipulation- R 2.15.1 windows 7
HI, 1. date1-c(5 jan 2013, 1 jan 2013) date1-as.Date(date1,format=%d %b %Y) date1[1]-date1[2] #Time difference of 4 days 2. If you only have the week number of year without any other information, it would be difficult to predict which day that would be. You could get the week number from the date: library(lubridate) date2-2013-01-26 wday(ymd(date2),label=TRUE) # 1 parsed with %Y-%m-%d #[1] Sat week(ymd(date2)) # 1 parsed with %Y-%m-%d #[1] 4 A.K. - Original Message - From: yash kajaria yash.kaja...@gmail.com To: r-help@r-project.org Cc: Sent: Thursday, March 14, 2013 9:45 AM Subject: [R] date time manipulation- R 2.15.1 windows 7 Hi, I wanted to learn how to solve a date and time manipulation where i can do the following two 1. difference of two dates eg (differnce between 5th jan 2013 and 1st jan 2013) 2.Suppose i have week number of the year, i want to know if i can find out the day it refers to eg( say week 2 of 2013 would be 6th jan 2013 and the day is sunday) i need my result to tell me that its the 6th of jan 2013 as well as the day (sunday) Can u please help me out? Thanks, Yashvardhan Kajaria [[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] Error message in vars package
Hi I'm getting an error message with the roots() function in the vars package. Even the example in the help file comes up with an error: data(Canada) var.2c - VAR(Canada, p = 2, type = const) roots(var.2c) Error in UseMethod(roots) : no applicable method for 'roots' applied to an object of class varest The error is odd, for the help file explains that one of the arguments of the roots() function is an object of class varest generated by VAR() -exactly the class of object that var.2c is: class(var.2c) [1] varest May it be that I'm using the latest version of R -in Windows- (ie 2.15.3 ), perhaps? Jose Wrap Up and Run 10k is back! Also, new for 2013 – 2km intergenerational walks at selected venues. So recruit a buddy, dust off the trainers and beat the winter blues by signing up now: http://www.ageuk.org.uk/10k Milton Keynes | Oxford | Sheffield | Crystal Palace | Exeter | Harewood House, Leeds | Tatton Park, Cheshire | Southampton | Coventry Age UK Improving later life http://www.ageuk.org.uk --- Age UK is a registered charity and company limited by guarantee, (registered charity number 1128267, registered company number 6825798). Registered office: Tavis House, 1-6 Tavistock Square, London WC1H 9NA. For the purposes of promoting Age UK Insurance, Age UK is an Appointed Representative of Age UK Enterprises Limited, Age UK is an Introducer Appointed Representative of JLT Benefit Solutions Limited and Simplyhealth Access for the purposes of introducing potential annuity and health cash plans customers respectively. Age UK Enterprises Limited, JLT Benefit Solutions Limited and Simplyhealth Access are all authorised and regulated by the Financial Services Authority. -- This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you receive a message in error, please advise the sender and delete immediately. Except where this email is sent in the usual course of our business, any opinions expressed in this email are those of the author and do not necessarily reflect the opinions of Age UK or its subsidiaries and associated companies. Age UK monitors all e-mail transmissions passing through its network and may block or modify mails which are deemed to be unsuitable. Age Concern England (charity number 261794) and Help the Aged (charity number 272786) and their trading and other associated companies merged on 1st April 2009. Together they have formed the Age UK Group, dedicated to improving the lives of people in later life. The three national Age Concerns in Scotland, Northern Ireland and Wales have also merged with Help the Aged in these nations to form three registered charities: Age Scotland, Age NI, Age Cymru. __ 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] plotting
Thank you very much! 2013/3/14 John Kane jrkrid...@inbox.com It is easy to do in base graphics, but probably a bad idea just because it is very hard to decode the symbol/color combinations. I just appropriated your data set and tried it in ggplot2 and your objection looks valid there as well. And Michael was right, the shape command can go in the first aes statement. library(ggplot2) p - ggplot(dta , aes(time, value, shape = as.factor(id) , colour =as.factor(group ))) + geom_point() p John Kane Kingston ON Canada -Original Message- From: dcarl...@tamu.edu Sent: Thu, 14 Mar 2013 11:23:18 -0500 To: michael.weyla...@gmail.com, hannah@gmail.com Subject: Re: [R] plotting It is easy to do in base graphics, but probably a bad idea just because it is very hard to decode the symbol/color combinations. I added a crude legend: # Provide reproducible data set.seed(42) value - round(rnorm(20), 2) time - round(runif(20)*10, 1) group - sample(1:4) id - sample(1:5) dta - data.frame(value, time, group, id) # Plot and legend plot(value~time, pch=id+20, col=group, bg=group, cex=1.25) legend(bottomright, as.character(1:4), pch=16, col=1:4, bty=n, inset=c(0, .045), title=Group) legend(bottomright, as.character(1:5), pch=21:25, col=gray, inset=c(.1, 0), bty=n, title=ID) -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of R. Michael Weylandt Sent: Thursday, March 14, 2013 10:51 AM To: li li Cc: r-help Subject: Re: [R] plotting I think you'll find this easiest with ggplot2: library(ggplot2) ggplot(dat, aes(x = value, y = time, color = group, symbol = id)) + geom_point() # symbol = might not be the right argument -- I'm doing this from memory or similar MW On Thu, Mar 14, 2013 at 3:46 PM, li li hannah@gmail.com wrote: Hi alL, I have a data frame with 4 columns: value, time, group and id. I would like to plot value vs. time with different colors for different levels of group and different symbols for different values of id. I think I could do this but I would like to see what is an easier way to plot the data this way. Thank you vey much. Hanna [[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-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-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.htmlhttp://www.r-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. GET FREE SMILEYS FOR YOUR IM EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk and most webmails [[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] Elasticnet - Cross validation problem
Hello, I am attempting to use elasticnet to classify a number of documents. The features are words. The data is coded into a matrix with each document as a row and each word as a column. The data is binary, with {0,1} indicating the presence of a word. I want to use the cross validation function of elasticnet (cv.enet). However, when the code selects a random subset of the data for a given run, some of the word columns may be all 0. (A given word simply isn't present in the subset of data sampled.) This causes the the function to return an error about variance of 0. Any suggestions on how to mitigate this issue? Given that I want a 5-fold cross validation to determine optimal tuning? Thanks! -- Noah Silverman, M.S. UCLA Department of Statistics 8117 Math Sciences Building Los Angeles, CA 90095 __ 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] Accuracy of some classifiers
On Wed, 13-Mar-2013 at 09:04AM +0100, Nicolás Sánchez wrote: | I am using machine learning for one researching. I am using some | classifiers with 5-fold CV . I would like to know how it is possible to | extract the accuracy, for example, for KNN,neural networks and J48, for | each one of 5-fold because when I apply CV to my classifier, I obtain the | mean accuracy of 5-fold but each accuracy/error of each fold is not | returned. What definition of accuracy? Precision, Recall, AUC or what? | | Any help is welcome and grateful. Thanks in advance! | | Regards!! | | [[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. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ 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] Tomorrow: The Evolution of Regression from Classical Linear Regression to Modern Ensembles (hands-on)
Tomorrow, Friday March 15 Maybe you missed Part 1 of The Evolution of Regression Modeling from Classical Linear Regression to Modern Ensembles webinar series, but you can still join for Parts 2, 3, 4 Register Now for Parts 2, 3, 4: https://www1.gotomeeting.com/register/500959705 Course Outline: Overcoming Linear Regression Limitations Regression is one of the most popular modeling methods, but the classical approach has significant problems. This webinar series addresses these problems. Are you working with larger datasets? Is your data challenging? Does your data include missing values, nonlinear relationships, local patterns and interactions? This webinar series is for you! We will cover improvements to conventional and logistic regression, and will include a discussion of classical, regularized, and nonlinear regression, as well as modern ensemble and data mining approaches. This series will be of value to any classically trained statistician or modeler. Part 2 (Hands-on): March 15, 10-11am PST - Hands-on demonstration of concepts discussed in Part 1 (Classical Regression, Logistic Regression, Regularized Regression: GPS Generalized Path Seeker, Nonlinear Regression: MARS Regression Splines) Step-by-step demonstration Datasets and software available for download Instructions for reproducing demo at your leisure For the dedicated student: apply these methods to your own data (optional) · Part 1 recording: http://www.salford-systems.com/videos/tutorials/805-the-evolution-of-regression-modeling-part-1 Part 3: March 29, 10-11am PST - Regression methods discussed *Part 1 is a recommended pre-requisite Nonlinear Ensemble Approaches: TreeNet Gradient Boosting; Random Forests; Gradient Boosting incorporating RF Ensemble Post-Processing: ISLE; RuleLearner Part 4: April 12, 10-11am PST - Hands-on demonstration of concepts discussed in Part 3 Step-by-step demonstration Datasets and software available for download Instructions for reproducing demo at your leisure For the dedicated student: apply these methods to your own data (optional) [[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] get the sign of a value
Hello! Can't figure it out - hope it's simple: # I have some value (can be anything), e.g.: x = 12 # I'd like it to become 1. # If the value is negative (again, it can be anything), e.g.: y = -12 # I'd like it to become -1. How could I do it? Thanks a lot! -- Dimitri Liakhovitski [[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] get the sign of a value
You might perhaps look at: ?sign On Thu, Mar 14, 2013 at 3:41 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! Can't figure it out - hope it's simple: # I have some value (can be anything), e.g.: x = 12 # I'd like it to become 1. # If the value is negative (again, it can be anything), e.g.: y = -12 # I'd like it to become -1. How could I do it? Thanks a lot! -- Dimitri Liakhovitski -- Sarah Goslee http://www.functionaldiversity.org __ 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] get the sign of a value
Thanks a lot, Sarah, - that's it! Never used it before! Dimitri On Thu, Mar 14, 2013 at 3:48 PM, Sarah Goslee sarah.gos...@gmail.comwrote: You might perhaps look at: ?sign On Thu, Mar 14, 2013 at 3:41 PM, Dimitri Liakhovitski dimitri.liakhovit...@gmail.com wrote: Hello! Can't figure it out - hope it's simple: # I have some value (can be anything), e.g.: x = 12 # I'd like it to become 1. # If the value is negative (again, it can be anything), e.g.: y = -12 # I'd like it to become -1. How could I do it? Thanks a lot! -- Dimitri Liakhovitski -- Sarah Goslee http://www.functionaldiversity.org -- Dimitri Liakhovitski [[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] Course Birmingham: Regression, GLM GAM. With R intro
There are a few places left on the following course: Data exploration, regression, GLM, GAM in R - With introduction to R - When: 22 - 26 April 2013 Where: Conference Aston Hotel and Event Venues Aston University, Aston Triangle, Birmingham, UK Further information: http://www.highstat.com/statscourse.htm Flyer: http://www.highstat.com/Courses/FlyerEABrirmingham2013.pdf Kind regards, Alain Zuur __ 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] get the sign of a value
Hi, On Mar 14, 2013, at 3:41 PM, Dimitri Liakhovitski wrote: Hello! Can't figure it out - hope it's simple: # I have some value (can be anything), e.g.: x = 12 # I'd like it to become 1. # If the value is negative (again, it can be anything), e.g.: y = -12 # I'd like it to become -1. How could I do it? Perhaps like this? x = (-5):5 x [1] -5 -4 -3 -2 -1 0 1 2 3 4 5 sign(x) [1] -1 -1 -1 -1 -1 0 1 1 1 1 1 Cheers, Ben Thanks a lot! -- Dimitri Liakhovitski [[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. Ben Tupper Bigelow Laboratory for Ocean Sciences 60 Bigelow Drive, P.O. Box 380 East Boothbay, Maine 04544 http://www.bigelow.org __ 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.