Re: [R] Sweave and printing error
Le mar. 25 mars à 17:12, Christophe Genolini a écrit : Hi the list. I am writing a tutorial for my student using LaTeX and sweave. I include some example that work (obiously) but I would also like to include some example that do NOT work (for pedagogie)... Is it possible ? At this point, I find that : - if there is a error in the code, Sweave stop - if I put the error in try(), Sweave compile but does not print the error as output. Any solution ? Thanks a lot Christophe Something along these lines should do what you want: echo=TRUE, eval=FALSE= TRUE - 3 @ echo=FALSE, eval=TRUE= cat(try(TRUE - 3)) @ If I recall correctly, this was discussed here before. HTH --- Vincent Goulet, Associate Professor École d'actuariat Université Laval, Québec [EMAIL PROTECTED] http://vgoulet.act.ulaval.ca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] out of colors in Mclust with 12 clusters
I'm running Mclust 3.0 in R-2.7.0 and have run into a situation where the optimal number of clusters, 12, seems to be greater than the number of colors available to Mclust. The code below, which demonstrates errors, does not if the max no of clusters is set at 10. sessionInfo, after a restart of R and loading of packages, follows the output. Is this a known problem with Mclust? Can I supply more colors? As an aside, Mclust is crashing when it runs out of memory with high dimensional datasets. R and Emacs freeze, my SystemMonitor in Ubuntu shows that the CPU grinds to a halt but the memory is exhausted. Shouldn't a process in R exit and return an error when memory can no longer be allocated? Wishful thinking Mark exprs.clust - Mclust(exprs(AOP.sig), G=9:12, modelNames=VEI) Warning messages: 1: In summary.mclustBIC(Bic, data, G = G, modelNames = modelNames) : best model occurs at the min or max # of components considered 2: In Mclust(exprs(AOP.sig), G = 9:12, modelNames = VEI) : optimal number of clusters occurs at max choice plot(exprs.clust, data = exprs(AOP.sig)) Hit Return to see next plot: Hit Return to see next plot: Hit Return to see next plot: Hit Return to see next plot: Warning message: In clPairs(data[, 1:min(5, p)], classification = x$classification, : more colors needed myMclustOutput.func(exprs.clust) #Above just outputs the classificatin and uncertainty in a data.frame. #Usually works fine Error: bad value No suitable frames for recover() 2 + 4 Error: bad value No suitable frames for recover() sessionInfo() Error: bad value No suitable frames for recover() #After R-devel restart sessionInfo() R version 2.7.0 Under development (unstable) (2008-03-05 r44683) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] tools stats graphics grDevices datasets utils methods [8] base other attached packages: [1] lme4_0.99875-9 Matrix_0.999375-5lattice_0.17-6 [4] affy_1.17.9 preprocessCore_1.1.5 affyio_1.7.17 [7] Biobase_1.99.3 mclust_3.1-3 loaded via a namespace (and not attached): [1] grid_2.7.0 -- Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 204-4202 Home (no voice mail please) mwkimpelatgmaildotcom __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Newbie help with Sweave *on Windows*
I agree this is a LaTeX on Windows issue -- it is a shame that LaTex is unable to accept valid file paths on the platform it runs on (using \ as a path separator is also a problem). I've changed 2.7.0-alpha to use the short path to Sweave.sty, as given by shortPathName() but with / as path separator. That seems the magic needed to get at least MikTeX's executables to accept the path. On Wed, 26 Mar 2008, Vincent Goulet wrote: Le mar. 25 mars à 10:19, Duncan Murdoch a écrit : On 3/25/2008 10:06 AM, James W. MacDonald wrote: Hi Kevin, I usually install R in e.g., C:\R-2.6.2 to avoid such problems. Explicitly including \usepackage{Sweave} may also help, so that Sweave doesn't try to give an explicit path. Then again, it may not, depending on which LaTeX you're using. This is really a LaTeX problem, rather than an R problem: different LaTeX distributions keep changing the rules for how to specify include directories. Duncan Murdoch I also explicitly include \usepackage{Sweave} in my Sweave documents, but in addition I put a copy of the Sweave.sty file in my local texmf tree. After updating the TeX database, TeX/LaTeX finds the package file without any problem. (Kevin: email off-list if you're not familiar with the concepts of local texmf tree and updating the TeX database.) You may well need to use 'personal' rather than 'local': the latter is usually read-only on shared installations. HTH Best, Jim Zembower, Kevin wrote: Kevin, thanks for writing. Yes, sorry, I forgot to mention that this is a Windows XP Professional system running GNU Emacs 22.1.1 (i386-mingw-nt5.1.2600) from Vincent Goulet, and R 2.6.2 Windows version. I pasted in the sessionInfo() output from ESS inside of Emacs to the end of this note. Was your TA successful in correcting this error? How? Should I report this to R-development as something worth fixing for the next release? Thanks, again, for your response and advice. -Kevin -Original Message- From: Kevin E. Thorpe [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2008 9:01 PM To: Zembower, Kevin Cc: [EMAIL PROTECTED] Subject: Re: [R] Newbie help with Sweave Is this in a windows system? A TA of mine was just getting the exact same message. He tracked it down to the pathname for Sweave.sty having trouble with Program Files in the path. Kevin Zembower, Kevin wrote: I think I've gotten my Emacs/Sweave/R system set up correctly, thanks to Vincent and Jim, but I haven't been successful getting my first document produced. I'm trying to use one of Friedrich Leisch's examples, http://www.ci.tuwien.ac.at/~leisch/Sweave/example-1.Snw. I cut and pasted the text into a document sweaveexample.Rnw in Emacs. It seemed to be processed successfully with R: Sweave(sweaveexample.Rnw) Writing to file sweaveexample.tex Processing code chunks ... You can now run LaTeX on 'sweaveexample.tex' However, when I try to open the file sweaveexample.tex and process it with Latex in Emacs, I get this error: ERROR: Missing \endcsname inserted. --- TeX said --- to be read again \protect l.7 \begin {document} --- HELP --- From the .log file... The control sequence marked to be read again should not appear between \csname and \endcsname. I've tried a variety of examples, but the error messages are the same. Can anyone point out my errors or mistakes? I've pasted in the full files below. Thanks so much for your help and advice. -Kevin Kevin Zembower Internet Services Group manager Center for Communication Programs Bloomberg School of Public Health Johns Hopkins University 111 Market Place, Suite 310 Baltimore, Maryland 21202 410-659-6139 == sweaveexample.tex: == \documentclass[a4paper]{article} \title{Sweave Example 1} \author{Friedrich Leisch} \usepackage{C:/PROGRA~1/R/R-26~1.2/share/texmf/Sweave} \begin{document} \maketitle In this example we embed parts of the examples from the \texttt{kruskal.test} help page into a \LaTeX{} document: \begin{Schunk} \begin{Sinput} data(airquality) library(ctest) kruskal.test(Ozone ~ Month, data = airquality) \end{Sinput} \begin{Soutput} Kruskal-Wallis rank sum test data: Ozone by Month Kruskal-Wallis chi-squared = 29.2666, df = 4, p-value = 6.901e-06 \end{Soutput} \end{Schunk} which shows that the location parameter of the Ozone distribution varies significantly from month to month. Finally we include a boxplot of the data: \begin{center} \includegraphics{sweaveexample-002} \end{center} \end{document} sweaveexample.Rnw: == \documentclass[a4paper]{article} \title{Sweave Example 1} \author{Friedrich Leisch} \begin{document} \maketitle In this example we embed parts of the examples from the \texttt{kruskal.test} help page into a \LaTeX{} document: = data(airquality) library(ctest) kruskal.test(Ozone ~ Month, data = airquality) @ which shows that
[R] deconv
I'm translating a matlab routine to R and I need some equivalent to deconv(): Description: deconv() [q,r] = deconv(v,u) deconvolves vector u out of vector v, using long division. The quotient is returned in vector q and the remainder in vector r such that v = conv(u,q)+r . If u and v are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials, and deconvolution is polynomial division. The result of dividing v by u is quotient q and remainder r. I'll agree some help on the translation of this operator to R. Thanks in advance -- Ferran Carrascosa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] deconv
See package polynom (and 'S Programming', for which it is a running example). On Wed, 26 Mar 2008, Ferran Carrascosa wrote: I'm translating a matlab routine to R and I need some equivalent to deconv(): Description: deconv() [q,r] = deconv(v,u) deconvolves vector u out of vector v, using long division. The quotient is returned in vector q and the remainder in vector r such that v = conv(u,q)+r . If u and v are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials, and deconvolution is polynomial division. The result of dividing v by u is quotient q and remainder r. I'll agree some help on the translation of this operator to R. Thanks in advance -- Ferran Carrascosa __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] adjusted means and adjusted standard errors after ANOVA
I am trying to obtain adjusted means and standard errors for a three way ANOVA I have three effects, two continuous; fire frequency and annual precipitation, and one categorical; soil type in an unbalanced design. I am testing the effect of annual precipition (AP), soil type (ST), and fire frequency (FF) on stem count (SCt) My data table looks as such: ST FF AP SCt 3 Coy 4 888 312 4 Coy 3 911 185 6 Coy 3 937 136 7 Coy 5 1011 42 8 Coy 4 1015 138 9 Cop 4 950 290 11 Cop 4 951 252 16 Coy 4 988 124 17 Coy 5 988 118 20 Coy 5 1000 242 24 Cop 3 901 220 25 Cop 2 929 238 26 Cop 2 954 133 27 Cop 1 934 180 28 Cop 1 938 119 30 Cop 2 918 195 My R output for a 3 way ANOVA is as such: SCt.aov = aov (SCt ~ AP + ST + FF, data) summary ( SCt.aov ) Df Sum Sq Mean Sq F value Pr(F) AP 1 23696 23696 8.4237 0.01327 * ST 1313 313 0.1114 0.74429 FF 1 21532 21532 7.6544 0.01707 * Residuals 12 337572813 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 I would like to present my data so that it shows the significance of the p value for FF after the variability of AP and ST have been taken out, so I will need R to output the adjusted means and standard errors. This I do not know how to do. What is the easiest way to do this in R from this analysis? Kind regards, Burak Pekin Burak Pekin Ecosystem Research Group School of Plant Biology (M090) University of Western Australia 35 Stirling Highway Crawley, WA 6009 Australia Ph: +61 08 6488 7923 Fax: +61 08 6488 1001 [[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] Thinking about using two y-scales on your plot?
hadley wickham wrote: Please read this first: http://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf It's a reasoned discussion of why it's a bad idea and proposes some alternative methods. Another good article is: K. W. Haemer. Double scales are dangerous. The American Statistician, 2(3):24–24, 1948. People have been advising dual-axis plots for (at least) 60 years! As I am an obvious offender in the dual-ordinate plot field (I actually used one once about 25 years ago), I suppose I should at least contribute to the debate. Few's paper makes some very good points in my opinion. The dual ordinate barplot is too often misinterpreted for exactly the reason Few states. Bars starting from zero are just too easy to interpret as relative magnitudes. The inquiring reader will find that twoord.plot doesn't have a barplot option (although the enterprising user can easily hack barplot). As the paper goes on, Few relies more on assertions than demonstrations. Consider the last injunction: It is inappropriate to use more than one quantitative scale on a single axis, because, to some degree, this encourages people to compare magnitudes of values between then, but this is meaningless. The crucial phrase, buried in the middle of this, is to some degree. If the degree to which the viewer realizes that it is meaningless is greater than the degree to which that viewer is encouraged to compare magnitudes, there does not seem to be much of a problem. No evidence to support Few's implied outcome is adduced. My own use of a dual-ordinate plot arose from a circumstance much like the final illustration in the paper. I wanted to show that the performance of rats on one aspect of a task was near perfect, while performance on another aspect was at chance level. However, instead of trying to convert the units into probabilities, I simply used the raw units scaled to equate the probabilities and added a horizontal line at the level of chance performance. No one complained. Did I successfully illustrate the dissociation of performance or merely get away with it? Unfortunately, I cannot answer that question, but I would love to have someone do a good study to either cheer me or knock me on the head. That's the way we improve our illustrative techniques. 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] genotype analysis
Dear mailing list, I'm still quite a newbie in the statistical analysis of genotype/allele data, resp. more generally in the analysis of categorical variables. Moreover, I'm currently totally confused by the many R packages available to do such analysis. Here is my case: I've got a list of genes, and a number of case-control population pairs, and for each population and gene, the various genotypes that have been found. I've got both aggregate data (ex. gene1: homozygote wildtype: 201, heterozygote mutation carrier: 34, homozygote mutation carrier: 5) and per-gene data (i.e. for gene1 a list of e.g. V/V, V/I, II etc). The question asked is whether there is a difference in the mutation pattern between the case and the control groups influencing the outcome, both at the level of a single gene, and at the level of their combination. Moreover, I would like to check for linkage desequilibrium (LD), as I know that some of these genes are located quite closely on the chromosome. OK, so up to now I've been doing the Chi-square tests, McNemar matched pairs test, Fisher test if my numbers were too small. As for the LD question, if I have understood correctly, I have to use log-linear regression. I have been trying several R packages, and I'm so confused now, because I don't know which one is best suited for my problem. I have to add that I'm new also to log-linear regression... I've used hwde, and read the paper on which it is based (see hwde doc), but the package leaves out certain output rows that are shown in the paper, and it doesn't show which of the output rows is significant, as the paper does. Is there any simply way to interpret hwde output (something like a p-value)? Then there are the GeneticsBase, Genetics, mapLD, Hardy-Weinberg packages. Some work only for a single gene, some apply a thing called MLE, some general linearized models, etc. I know these questions are as much basic statistical than R questions. But I'd be glad if you could help me find the best solution for my type of analysis, resp. point me to good resources that show me how to do this. The problem is that most resources show how to do the analysis, but they don't explain at all how to *interpret* their output. Thanks a lot in advance, Anne-Marie __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Excel numbers at the R prompt
Dear all, I was wonderin how to copy data from an Excel sheet to the R prompt. For a single culumn it works to select the data in Excel, copy to the clipboard with ctrl-c and to use in R: --- x-scan() [paste data with ctrl-v (paste)] [ctrl-z, to end input] --- But with multiple columns Excels tabs are eaten by the R-promt, and the numbers concatenated without separator. Is there a handy method for this? Thanks, Gerrit. -- Gerrit Draisma Department of Public Health Erasmus MC, University Medical Center Rotterdam Room AE-103 P.O. Box 2040 3000 CA Rotterdam The Netherlands Phone: +31 10 7043124 Fax: +31 10 010-7038474 http://mgzlx4.erasmusmc.nl/pwp/?gdraisma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 copy Excel numbers at the R prompt
Use read.delim(clipboard) Uwe Ligges G. Draisma wrote: Dear all, I was wonderin how to copy data from an Excel sheet to the R prompt. For a single culumn it works to select the data in Excel, copy to the clipboard with ctrl-c and to use in R: --- x-scan() [paste data with ctrl-v (paste)] [ctrl-z, to end input] --- But with multiple columns Excels tabs are eaten by the R-promt, and the numbers concatenated without separator. Is there a handy method for this? Thanks, Gerrit. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Thinking about using two y-scales on your plot?
On Tue, Mar 25, 2008 at 05:29:38PM -0500, hadley wickham wrote: Please read this first: http://www.perceptualedge.com/articles/visual_business_intelligence/dual-scaled_axes.pdf Thanks for this pointer, interesting read. As an additional alternative to dual scales, le'ts not forget about scatterplots, which I didn't see mentioned in that paper -- frequently, when you're stuck because you can't dispense with either y-axis, it's easy to forget the option to do without your current x-axis... ;-) Best regards, Jan It's a reasoned discussion of why it's a bad idea and proposes some alternative methods. Another good article is: K. W. Haemer. Double scales are dangerous. The American Statistician, 2(3):24?24, 1948. People have been advising dual-axis plots for (at least) 60 years! Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- +- Jan T. Kim ---+ | email: [EMAIL PROTECTED] | | WWW: http://www.cmp.uea.ac.uk/people/jtk | *-= hierarchical systems are for files, not for humans =-* __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Compare two data sets
Easiest way to do it is to try it out and time it. Here is a case where I generated two sets of data with 120,000 characters each (just random numbers converted to character strings) and then asked for the intersection of them. Came up with 3 matched in about 0.2 seconds. That would seem fastest enough, unless you plan to do this operation tens of thousands of times: x - as.character(runif(12)) y - as.character(runif(12)) system.time(z - intersect(x,y)) user system elapsed 0.220.000.22 str(z) chr [1:3] 0.289942682255059 0.75132836541161 0.638638160191476 Here is the timing if you get 5 matches and it is about the same: x - as.character(round(runif(12),5)) y - as.character(round(runif(12),5)) system.time(z - intersect(x,y)) user system elapsed 0.2 0.0 0.2 str(z) chr [1:48908] 0.08385 0.62639 0.47603 0.18578 0.89447 0.58435 0.15297 ... On Tue, Mar 25, 2008 at 10:28 PM, Suhaila Zainudin [EMAIL PROTECTED] wrote: Hi, Thanks for the feedback. I have tried it on the small size sample and ref and it works. Now I want to use a larger dataset for myref (the reference file) . The reference file contains 112189 rows. Can I use the same approach that works for the small example? Or are there other alternatives when dealing with data of that magnitude? -- Suhaila Zainudin PhD Candidate Universiti Teknologi Malaysia -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Combining several mappings in ggplot2
Apologies! I though that the Orange dataset comes with R, but it is in fact in the package datasets. So here's another Orange2 dataset for the example: Tree_v = rep(c(1:5),each = 5) age_v = rep(seq(1,25, by = 5),5) + 10*runif(25) circumference_v - rep(seq(21,45, by = 5), 5)*Tree_v + 25*runif(25) Orange2 - data.frame(Tree = as.factor(Tree_v), age = age_v, circumference = circumference_v) This works fine: ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree)) + geom_line() These generate errors (included): ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree, linetype = Tree)) + geom_line() Error in get(check_domain, env = ., inherits = TRUE)(., ...) : Too many values in domain (5 4) ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree)) + geom_line() + scale_linetype_manual(value = c(1:5)) Error in unit(values, units, data = data) : 'x' and 'units' must have length 0 What am I doing wrong? Regards, TL On Wed, Mar 26, 2008 at 2:08 AM, hadley wickham [EMAIL PROTECTED] wrote: On Tue, Mar 25, 2008 at 11:48 AM, Tribo Laboy [EMAIL PROTECTED] wrote: Hello, I want to be able to make a plot that has several series with different color and linetype. Online documentation suggest that this is possible, but I haven't found how: We can also create redundant mappings, mapping the same variable to multiple aesthetics. This is most useful when producing a graphic for both colour and black and white display. Here's what I have to get the color ggplot(data = Orange, aes(x = age, y = circumference, color = Tree)) + geom_line() if i try this I get an error: ggplot(data = Orange, aes(x = age, y = circumference, color = Tree, linetype = Tree)) + geom_line() Please provide a reproducible example (or at least describe the error!), otherwise we have no way to help you. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading Excel file
If you want to read in the numeric values from EXCEL and the use them, here is a function I use to go the other way -- take a POSIXct value and convert it to what EXCEL wants. So you can just write the inverse of this function: unix2EXCEL - function (time) time/86400 + 25569 On Tue, Mar 25, 2008 at 11:41 PM, Utkarsh Singhal [EMAIL PROTECTED] wrote: Sorry but I was interested in reading as date format from the excel itself. Is there any way of doing this? Regards Utkarsh -Original Message- From: Gabor Grothendieck [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 25, 2008 8:43 PM To: Utkarsh Singhal Cc: [EMAIL PROTECTED] Subject: Re: [R] reading Excel file If d is the number of days since the Epoch then now - Sys.Date() now - julian(now) + d will give you a Date class variable. There is some info on dates in R News 4/1. On Tue, Mar 25, 2008 at 10:00 AM, Utkarsh Singhal [EMAIL PROTECTED] wrote: Hi R, I have an excel file in which the third column is date and others are character and numeric. Number of columns are 12 If I use this to read the file in R: x = read.xls(D:\\file.xls) The problem is that my date column is read in julian dates. So I am using: x = read.xls(D:\\file.xls, colClasses= c(rep(character,2),isodate,rep(character,9))) But what can I do in case I don't know the number of columns in my file?? I mean is there any way I can specify the colClass of only third column and for other columns it can take the default classes?? Regards Utkarsh This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This e-mail may contain confidential and/or privileged i...{{dropped:13}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cbind and mean by week
Is this what you want? You have to add na.rm=TRUE to the calculations: week-c(28,28,28,28,28,28,28,29,29,29,29,29,29,29,30,30,30,30,30,30,30) td-c(0.015,0.012,NA,0.015,NA,0.014,0.014,0.013,0.013,0.013,0.013,NA,0.010,0.013,0.015,0.011,0.014,0.014,0.014,0.014,0.016) pd-c(0,0,NA,80,NA,45,223,228,224,488,525,NA,80,417,413,373,914,213,651,521,979) x-data.frame(week,td,pd) x weektd pd 128 0.015 0 228 0.012 0 328NA NA 428 0.015 80 528NA NA 628 0.014 45 728 0.014 223 829 0.013 228 929 0.013 224 10 29 0.013 488 11 29 0.013 525 12 29NA NA 13 29 0.010 80 14 29 0.013 417 15 30 0.015 413 16 30 0.011 373 17 30 0.014 914 18 30 0.014 213 19 30 0.014 651 20 30 0.014 521 21 30 0.016 979 pmean- tapply(x[,3], x$week, mean, na.rm=TRUE) pmean 28 29 30 69.6000 327. 580.5714 pdmean- data.frame(pmean) pdmean pmean 28 69.6000 29 327. 30 580.5714 xweek - aggregate(x, list(x$week), mean, na.rm=TRUE) xweek Group.1 week td pd 1 28 28 0.0140 69.6000 2 29 29 0.0125 327. 3 30 30 0.0140 580.5714 On Tue, Mar 25, 2008 at 10:18 PM, Felipe Carrillo [EMAIL PROTECTED] wrote: Hi: I have been able to finally crunch my data by importing it by week(thank you all for your help),but here we go again.. Now I'am trying to do it for the the whole year. Since the dataset is huge I'm only making a 3 weeks dataframe. - I want to get the mean of pd by week - I want to count the number of days by week and bind it to the existing dataframe(x) - I want to remove the NA's by week and bind another column counting the rows after the NA's are removed. Don't think that I'am crazy but I need those fields for my annual report. I was trying to use some of the functions below but nothing seems to work..One of these days I'll be an R pro(we'll see about that) Thanks week-c(28,28,28,28,28,28,28,29,29,29,29,29,29,29,30,30,30,30,30,30,30) td-c(0.015,0.012,NA,0.015,NA,0.014,0.014,0.013,0.013,0.013,0.013,NA,0.010,0.013,0.015,0.011,0.014,0.014,0.014,0.014,0.016) pd-c(0,0,NA,80,NA,45,223,228,224,488,525,NA,80,417,413,373,914,213,651,521,979) x-data.frame(week,td,pd) x pmean- tapply(x[,3], x$week, mean) pdmean pdmean- data.frame(pmean) pdmean xweek - aggregate(x, list(x$week), mean) xweek Felipe D. Carrillo Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA Be a better friend, newshound, and __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Combining several mappings in ggplot2
Tribo, It looks like geom_line() accepts only 4 linetypes and you asked for 5. library(ggplot2) Tree_v - rep(c(1:5),each = 5) age_v - rep(seq(1,25, by = 5),5) + 10*runif(25) circumference_v - rep(seq(21,45, by = 5), 5)*Tree_v + 25*runif(25) #This will work Orange2 - data.frame(Tree = as.factor(Tree_v), age = age_v, circumference = circumference_v, Lines = factor(as.numeric(Orange2$Tree) %% 4)) ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree, linetype = Lines)) + geom_line() #This won't Orange2 - data.frame(Tree = as.factor(Tree_v), age = age_v, circumference = circumference_v, Lines = factor(as.numeric(Orange2$Tree) %% 5)) ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree, linetype = Lines)) + geom_line() HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 [EMAIL PROTECTED] www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Tribo Laboy Verzonden: woensdag 26 maart 2008 12:01 Aan: hadley wickham CC: r-help@r-project.org Onderwerp: Re: [R] Combining several mappings in ggplot2 Apologies! I though that the Orange dataset comes with R, but it is in fact in the package datasets. So here's another Orange2 dataset for the example: Tree_v = rep(c(1:5),each = 5) age_v = rep(seq(1,25, by = 5),5) + 10*runif(25) circumference_v - rep(seq(21,45, by = 5), 5)*Tree_v + 25*runif(25) Orange2 - data.frame(Tree = as.factor(Tree_v), age = age_v, circumference = circumference_v) This works fine: ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree)) + geom_line() These generate errors (included): ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree, linetype = Tree)) + geom_line() Error in get(check_domain, env = ., inherits = TRUE)(., ...) : Too many values in domain (5 4) ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree)) + geom_line() + scale_linetype_manual(value = c(1:5)) Error in unit(values, units, data = data) : 'x' and 'units' must have length 0 What am I doing wrong? Regards, TL On Wed, Mar 26, 2008 at 2:08 AM, hadley wickham [EMAIL PROTECTED] wrote: On Tue, Mar 25, 2008 at 11:48 AM, Tribo Laboy [EMAIL PROTECTED] wrote: Hello, I want to be able to make a plot that has several series with different color and linetype. Online documentation suggest that this is possible, but I haven't found how: We can also create redundant mappings, mapping the same variable to multiple aesthetics. This is most useful when producing a graphic for both colour and black and white display. Here's what I have to get the color ggplot(data = Orange, aes(x = age, y = circumference, color = Tree)) + geom_line() if i try this I get an error: ggplot(data = Orange, aes(x = age, y = circumference, color = Tree, linetype = Tree)) + geom_line() Please provide a reproducible example (or at least describe the error!), otherwise we have no way to help you. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Adding name labels to x-axis of matplot
Hello, I have a gene expression matrix with columns being samples and rows being genes. I would like to display the expression values for each gene. I have two groups which I colour differently. The aim is to see if there is any difference between the two groups consistently across genes. So the following works well: matplot(as.matrix(nonormexpr),pch=16,col=c(rep(1,length(left)),rep(2,length(right))),cex=0.4) The only thing is that the x-axis has numbers 1 ... 10, whereas I would like to give them the names of the genes. I have tried using the labels parameter but I get: Error in axis(side, at, as.graphicsAnnot(labels), tick, line, pos, outer, : 'labels' is supplied and not 'at' Any ideas? Is there are a more appropriate plot type? -- ** Daniel Brewer, Ph.D. Institute of Cancer Research Molecular Carcinogenesis Email: [EMAIL PROTECTED] ** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the a...{{dropped:2}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Adding name labels to x-axis of matplot
try this: dat - matrix(rnorm(20), 10, 2) dimnames(dat) - list(1:10, c(sample1, sample2)) matplot(dat, pch = 16, xaxt = n, col = 1:2, ylab = Expression Value) axis(1, at = 1:10, labels = paste(Gene, 1:10), cex.axis = 0.7) I hope it helps. Best, Dimitris Dimitris Rizopoulos Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: Daniel Brewer [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 26, 2008 12:10 PM Subject: [R] Adding name labels to x-axis of matplot Hello, I have a gene expression matrix with columns being samples and rows being genes. I would like to display the expression values for each gene. I have two groups which I colour differently. The aim is to see if there is any difference between the two groups consistently across genes. So the following works well: matplot(as.matrix(nonormexpr),pch=16,col=c(rep(1,length(left)),rep(2,length(right))),cex=0.4) The only thing is that the x-axis has numbers 1 ... 10, whereas I would like to give them the names of the genes. I have tried using the labels parameter but I get: Error in axis(side, at, as.graphicsAnnot(labels), tick, line, pos, outer, : 'labels' is supplied and not 'at' Any ideas? Is there are a more appropriate plot type? -- ** Daniel Brewer, Ph.D. Institute of Cancer Research Molecular Carcinogenesis Email: [EMAIL PROTECTED] ** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the...{{dropped:14}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] p-values for classification
Check this out, this might help http://arxiv.org/abs/0801.2934 Ben Spycher PhD student Division of Clinical Epidemiology Biostatistics Institute of Social and Preventive Medicine University of Berne Finkenhubelweg 11 - CH-3012 Berne, Switzerland Tel +41 31 631 35 07 / Fax +41 31 631 35 20 www.ispm.ch http://www.ispm.ch/ [[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] GNUplot to R conversion?
Hi, I have some scripts creating GNUplot graphs that I would like to convert to R. It would be a great help if there would be a reasonable converter that takes over plot commands and initial settings and put these into R commands (I'm an R beginner and thus this kind of Kickstart would be helpful). Remark: Asking Google for gnuplot to R conversion or similar things does not really help because seeking for 'R' seems to be a hard task for search engines. Is there any trick to find R-related things easily? Kind regards Andreas. -- http://fam-tille.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Equivalent of TensorRank
Hi, In Mathematica, if we have a 3X3 matrix A, we can get its dimensions by: Dimensions[A] = {3,3} TensorRank[A] = 2 In R, we have dim() for Dimensions[]. Is there any direct function similar to TensorRank in R? Thank you [[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] Latentnet Data Import
Hello everone, I am a computer science researcher in the UK - and have a quick question regarding importing data into R and more specifically latentnet. I am trying to import data such as a text file containing: (This is based on the Sampson data set) --- Network attributes: vertices = 3 directed = TRUE hyper = FALSE loops = FALSE multiple = FALSE total edges= 3 Vertex attribute names: group vertex.names edgelist matrix: [,1] [,2] [1,] 31 [2,]21 [3, ]32 What command should I use to import this data? I have attempted many such as read.delim and read.table - but either an error message is returned, or the strings in the data (such as edges=3) appear to become objects that are analysed by the latentnet functions such as 'ergmm'. I look forward to your replys, Many thanks 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] GNUplot to R conversion?
On Wednesday 26 March 2008 01:31:46 pm Andreas Tille wrote: AT reasonable converter that takes over plot commands and initial AT settings and put these into R commands Not that I know. But I doubt that someone would make this effort since the capabilities of gnuplot and R are quite different. AT Remark: Asking Google for gnuplot to R conversion or similar things AT does not really help because seeking for 'R' seems to be a hard task AT for search engines. Is there any trick to find R-related things AT easily? If you look at http://www.r-project.org/search.html you find links to different help sources. I have a preference for rseek but just compare... Stefan -- Microeconomics University of Erfurt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Optimization with nonlinear constraints
Hello. I have some further problems with modelling an optimization problem in R: How can I model some optimization problem in R with a linear objective function with subject to some nonlinear constraints? I would like to use optim or constrOptim, maybe with respect to methods like Simulated Annealing or Sequential Quadric Programming or something else, which can solve the problem. But I have no idea how to code in R! Example: min (x1 + x2 + x3) s.t. p * (a*x1 + b*x2 + c*x3)^(-3) + (1-p) * (d*x1 + e*x2 + f*x3)^(-3) = g with a,b,c,d,e,f,g,p constant 0 and x1,x2,x3 0 also: a,b,c d,e,f I hope you can help me with some code for the above problem so I can transfer it to my real problem. You can also put some real numbers for the above problem. I only wanted to abstract the problem with some general constant. Regards, Andreas Klein. Lesen Sie Ihre E-Mails jetzt einfach von unterwegs. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Bootstrap
Hello, my name is Alfonso, I'm trying to apply bootstrap to a process to calculate the confidence intervals for a final value. I've revised all whole process and any mistake has been encuntered in the script. But when I try to apply boostrap the begining error message appears: Error in n * nboot : non-numeric argument to binary operator Could you help me with this setback? Thank you very much in advance. _ Tecnología, moda, motor, viajes, suscríbete a nuestros boletines para estar siempre a la última enanceBrand=WLRU=http%3a%2f%2fmail.live.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] Equivalent of TensorRank
length(dim())? Amit Soni wrote: Hi, In Mathematica, if we have a 3X3 matrix A, we can get its dimensions by: Dimensions[A] = {3,3} TensorRank[A] = 2 In R, we have dim() for Dimensions[]. Is there any direct function similar to TensorRank in R? Thank you [[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] colours bars in barplot
Dear all, I have two matrices: matrix 1: height 23121 2125 25 25 2121 0 21 216767 33 22725 0 1 92 190 7171 192 067 0 00 8671 0 067 0 00 0 0 0 0 67 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 0 00 0 0 0 0 0 1916 18 116 0 2 3 matrix 2: colours gray78 bisque2 bisque2 blanchedalmond blanchedalmond blanchedalmond bisque2 bisque2 0 bisque2 bisque2 cornsilk4 cornsilk4 brown1 gray74 blanchedalmond 0 gray39 gray37 cyan3 cyan3 gray39 0 cornsilk4 0 0 0darkolivegreen1cyan3 0 0 cornsilk4 0 0 0 0 0 0 0 cornsilk4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 red red red red red redred red Matrices 1 and 2 are obtained in an automatic way, but note that: 1) 231-gray78, 21-bisque2, 192-gray39 and so on 2) 19 = (250-231) -red, 16 = (250-21-21-190)-red, 18 =(250-21-21-190)=red and so on I would like a barplot with: (beside=F horiz=T) and the colours bars specified in matrix 2(colours). How can I do this? Best regards _ Confira vídeos com notícias do NY Times, gols direto do Lance, videocas[[elided Hotmail spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rcmder Error
John and Rich, Thankyou for the suggestion of I've gone over my data and found that one of the text values had an extra space in it. Error fixed. It's good to know what the error means, now if I encounter it again I don't need to ask about it here. Thanks again! -Max It happens that John Fox formulated : Dear Max, As Rich Heiberger has suggested, it's difficult to diagnose the error without the data, and it's especially curious that this previously worked (I assume from your message with the same data) and doesn't now. Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Max Sent: March-25-08 5:56 PM To: [EMAIL PROTECTED] Subject: [R] Rcmder Error Hi Guys, I am trying to show a plot of means with two groups. i.e. plotMeans(s$CON, s$GENERAL.STARTING.DEPT, s$Cat, error.bars=se) and I get the error in Rcmdr: ERROR: need finite 'ylim' values Pasting the code in R gets the following error: x) : no non-missing arguments to min; returning Inf Warning in max(x) : no non-missing arguments to max; returning -Inf Error in plot.window(...) : need finite 'ylim' values I'm not sure what's going on. I know in R 2.6 I ran the same code and had no problem. Any suggestions on what I can do to fix it? Thanks, -Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] reading Excel file
yet another possibility... if you look at 'help(package=xlsReadWrite)' you'll find a function 'dateTimeToStr' by which you can convert your date-numbers from column 3 into a string. Something along (untested): myRead - function( fn ) { dat - read.xls( file = fn, dateTimeAs = numeric ) dat[,3] - dateTimeToStr( dat[,3] ) # or any other conversion function dat } 'dateTimeAs' argument is (probably) needed to retrieve plain numbers and override the default conversion to date string. -- Regards, Hans-Peter [[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] sample size in bootstrap(boot)
Hi, Can someone tell me how to control sample size (n) in bootstrap function boot in R. Can we give some option like we give for # of repeated samples(R=say 100). Will appreciate any help. 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] Rcmder Error
Dear Max, So Rich's guess that you had a factor level with only one observation (and consequently an empty cell in the two-way table of means) proved correct. I'll modify the plotMeans() function so that it prints a more informative message under this circumstance. Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Max Sent: March-26-08 10:44 AM To: [EMAIL PROTECTED] Subject: Re: [R] Rcmder Error John and Rich, Thankyou for the suggestion of I've gone over my data and found that one of the text values had an extra space in it. Error fixed. It's good to know what the error means, now if I encounter it again I don't need to ask about it here. Thanks again! -Max It happens that John Fox formulated : Dear Max, As Rich Heiberger has suggested, it's difficult to diagnose the error without the data, and it's especially curious that this previously worked (I assume from your message with the same data) and doesn't now. Regards, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Max Sent: March-25-08 5:56 PM To: [EMAIL PROTECTED] Subject: [R] Rcmder Error Hi Guys, I am trying to show a plot of means with two groups. i.e. plotMeans(s$CON, s$GENERAL.STARTING.DEPT, s$Cat, error.bars=se) and I get the error in Rcmdr: ERROR: need finite 'ylim' values Pasting the code in R gets the following error: x) : no non-missing arguments to min; returning Inf Warning in max(x) : no non-missing arguments to max; returning -Inf Error in plot.window(...) : need finite 'ylim' values I'm not sure what's going on. I know in R 2.6 I ran the same code and had no problem. Any suggestions on what I can do to fix it? Thanks, -Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R Hang up - Can't Save
R 2.6.2 gets hung up when I use the Save. It saves the R script document but I must use Force Quit (not responding) and reboot after saving. I tried updating R and all its packages, ran the Mac Disk Utilities program. I hope that the following while help determine the problem. Any suggestions to fix the problem will be appreciated. Paul J. Ossenbruggen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] pseudo R square and/or C statistic in R logistic regression
Dear all, I am now doing the logistic regression using R. (glm, family=binomial). Besides the standardize summary statistics generated from R, I am also interested in some more informations concerning the model fitting / prediction etc; Particularly I am interested in pseudo R squar and C statistic. I searched the R- help and could only get very limited information. (Post by Frank Harrell mentioning about the somers2 or rcorr.cens functions in the Hmisc library. ) However, I tried but still could not get through it. Also I found someone mentioned about do it manually. Could someone give me a more detailed information on how I could get these two summary statistics after performed the the logistic regression using glm? Thank you very much. *** Xiaojing WangPhD Research Assistant Professor, Dept. of Oral Biology School of Dental Medicine, University of Pittsburgh Suite 500, Bridgeside Point 100 Technology Drive Pittsburgh, PA 15219 Tel:412-648-9206 Fax:412-648-8779 Email:[EMAIL PROTECTED] *** [[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] pseudo R square and/or C statistic in R logistic regression
Dear all, I am now doing the logistic regression using R. (glm, family=binomial). Besides the standardize summary statistics generated from R, I am also interested in some more informations concerning the model fitting / prediction etc; Particularly I am interested in pseudo R squar and C statistic. I searched the R- help and could only get very limited information. (Post by Frank Harrell mentioning about the somers2 or rcorr.cens functions in the Hmisc library. ) However, I tried but still could not get through it. Also I found someone mentioned about do it manually. Could someone give me a more detailed information on how I could get these two summary statistics after performed the the logistic regression using glm? Thank you very much. *** Xiaojing WangPhD Research Assistant Professor, Dept. of Oral Biology School of Dental Medicine, University of Pittsburgh Suite 500, Bridgeside Point 100 Technology Drive Pittsburgh, PA 15219 Tel:412-648-9206 Fax:412-648-8779 Email:[EMAIL PROTECTED] *** [[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] Join R Group on LinkedIn
Greetings: If you use LinkedIn please join our R Group. ***http://www.linkedin.com/e/gis/77616/0AEFE3574537* Regards, Ajit -- _ Ajit Gemunu de Silva Oakland CA 94619 skype: ajit_de_silva [[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] adjusted means and adjusted standard errors after ANOVA
Dear Burak, Since two of the explanatory variables are quantitative, it is unusual to call this a three-way ANOVA (as opposed to a dummy-variable regression or analysis of covariance). I'd also think about fitting the model with lm() rather than aov(), so that you can more easily see the regression coefficients, and about whether you really want F-tests based on sequential sums of squares. In any event, you can get adjusted means and their standard errors from the effects package. I hope this helps, John John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of burak pekin Sent: March-26-08 4:50 AM To: r-help@r-project.org Subject: [R] adjusted means and adjusted standard errors after ANOVA I am trying to obtain adjusted means and standard errors for a three way ANOVA I have three effects, two continuous; fire frequency and annual precipitation, and one categorical; soil type in an unbalanced design. I am testing the effect of annual precipition (AP), soil type (ST), and fire frequency (FF) on stem count (SCt) My data table looks as such: ST FF AP SCt 3 Coy 4 888 312 4 Coy 3 911 185 6 Coy 3 937 136 7 Coy 5 1011 42 8 Coy 4 1015 138 9 Cop 4 950 290 11 Cop 4 951 252 16 Coy 4 988 124 17 Coy 5 988 118 20 Coy 5 1000 242 24 Cop 3 901 220 25 Cop 2 929 238 26 Cop 2 954 133 27 Cop 1 934 180 28 Cop 1 938 119 30 Cop 2 918 195 My R output for a 3 way ANOVA is as such: SCt.aov = aov (SCt ~ AP + ST + FF, data) summary ( SCt.aov ) Df Sum Sq Mean Sq F value Pr(F) AP 1 23696 23696 8.4237 0.01327 * ST 1313 313 0.1114 0.74429 FF 1 21532 21532 7.6544 0.01707 * Residuals 12 337572813 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 I would like to present my data so that it shows the significance of the p value for FF after the variability of AP and ST have been taken out, so I will need R to output the adjusted means and standard errors. This I do not know how to do. What is the easiest way to do this in R from this analysis? Kind regards, Burak Pekin Burak Pekin Ecosystem Research Group School of Plant Biology (M090) University of Western Australia 35 Stirling Highway Crawley, WA 6009 Australia Ph: +61 08 6488 7923 Fax: +61 08 6488 1001 [[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] sample size in bootstrap(boot)
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Zaihra T Sent: Wednesday, March 26, 2008 7:57 AM To: Jan T. Kim; R-help@r-project.org Subject: [R] sample size in bootstrap(boot) Hi, Can someone tell me how to control sample size (n) in bootstrap function boot in R. Can we give some option like we give for # of repeated samples(R=say 100). Will appreciate any help. thanks I don't believe so. Isn't one of the differences between the bootstrap and other kinds of resampling that the bootstrap samples with replacement a sample of the same size as the original data? You could use the function sample() to select your subsets and compute your statistics of interest. Hope this is helpful, Dan Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Loop problem
Dear all, I have a problem with a loop, if anyone has any knowledge on these things I would appreciate some comments. The code below is designed to allow me to extract the top record of the data frame, and them remove rows from the data frame which have an index close to the extracted top record. topstorm-subset(rankeddataset[1,]) ## Extracts the top storm topstormindex-rankeddataset[1,1] ## Finds the top storm start index startindex-topstormindex-48 ## sets the start and end indexes endindex-topstorminde+48 rankeddataset-rankeddataset[-1,] ## Creates a new list with the top storm removed ##This section of code needs looped. It removes storms from the list which are too close to the extracted storm for (i in 1:30){ if (rankeddataset[i,1]startindex rankeddataset[i,1]endindex) {rankeddataset-rankeddataset[-i,]} } Here is some example data: 82856 15 / 6 / 1966 82856:8287925.9 82857 15 / 6 / 1966 82857:8288020.5 83036 23 / 6 / 1966 83036:8305917.3 87250 15 / 12 / 1966 87250:8727315.9 The loop does not currently work, it seems to remove every second line or so. Can anyone suggest why this might be, I'm not particularly experienced in using loops so it may be a rookie mistake. Thanks in advance. Jamie Ledingham __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Loop problem
Basically you are moving the data up and then incrementing to the next row. Here is an example; assume that you are at the 2nd entry: 1 2 == here 3 4 Now your loop index is 2 and you remove the current data ('2') and are left with: 1 3 == index of 2 points here 4 Now you increment the index to 3 and you get 1 3 4 == now here So you have skipped 3. What you should be doing is determining all the index values that meet your criteria and then deleting them all at once, or start from the bottom of the dataframe and work up. On 3/26/08, Jamie Ledingham [EMAIL PROTECTED] wrote: Dear all, I have a problem with a loop, if anyone has any knowledge on these things I would appreciate some comments. The code below is designed to allow me to extract the top record of the data frame, and them remove rows from the data frame which have an index close to the extracted top record. topstorm-subset(rankeddataset[1,]) ## Extracts the top storm topstormindex-rankeddataset[1,1] ## Finds the top storm start index startindex-topstormindex-48 ## sets the start and end indexes endindex-topstorminde+48 rankeddataset-rankeddataset[-1,] ## Creates a new list with the top storm removed ##This section of code needs looped. It removes storms from the list which are too close to the extracted storm for (i in 1:30){ if (rankeddataset[i,1]startindex rankeddataset[i,1]endindex) {rankeddataset-rankeddataset[-i,]} } Here is some example data: 82856 15 / 6 / 1966 82856:8287925.9 82857 15 / 6 / 1966 82857:8288020.5 83036 23 / 6 / 1966 83036:8305917.3 87250 15 / 12 / 1966 87250:8727315.9 The loop does not currently work, it seems to remove every second line or so. Can anyone suggest why this might be, I'm not particularly experienced in using loops so it may be a rookie mistake. Thanks in advance. Jamie Ledingham __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sample size in bootstrap(boot)
Hi Dan, Thanks for response yes i do know that bootstrap samples generated by function boot are of the same size as original dataset but somewhere in the R-help threads i saw a suggestion that one can control sample size (n) by using the following command(plz see below) but my problem is it doesnt work it gives error ( error in : n * nboot : non-numeric argument to binary operator) bootstrap(data,statistic,sampler=samp.bootstrap(size=20)) this is what somebody on R help suggested... can we fix that error somehow ? On Wed, 26 Mar 2008 08:26:22 -0700 Nordlund, Dan (DSHS/RDA) wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Zaihra T Sent: Wednesday, March 26, 2008 7:57 AM To: Jan T. Kim; R-help@r-project.org Subject: ! [R] sample size in bootstrap(boot) Hi, Can someone tell me how to control sample size (n) in bootstrap function boot in R. Can we give some option like we give for # of repeated samples(R=say 100). Will appreciate any help. thanks I don't believe so. Isn't one of the differences between the bootstrap and other kinds of resampling that the bootstrap samples with replacement a sample of the same size as the original data? You could use the function sample() to select your subsets and compute your statistics of interest. Hope this is helpful, Dan Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and! Health Services Olympia, WA 98504-5204 g t; __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Simulate ARX model.
I have obtained from transfer functions, the state space matrices for the following state space model. x* = Ax + Bu y = Cx + Du I have A, B, C, and D, now I would like to take the exogenous inputs and simulate the data using the state space model. I know there is a simulate function in the package dse1, but I am unsure as to what type of TSmodel to create to put into it. Could anyone give me some hints? Thanks. Todd Remund [[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] Latentnet Data Import
It all depends. If your looks like your sample, then you will probably want to read the data with 'readLine' and bring in the entire line without trying to parse it. You would then go through the data with 'grep' to find the lines of interest and then you can use 'strsplit' or regular expressions to parse the line to get the data. There is probably no automatic way of doing it. You might also consider PERL to preprocess the data and put it into a format that is more acceptable to R. But most of it can probably be done within R if the structure of your input is reasonable. On 3/26/08, Ben Morley [EMAIL PROTECTED] wrote: Hello everone, I am a computer science researcher in the UK - and have a quick question regarding importing data into R and more specifically latentnet. I am trying to import data such as a text file containing: (This is based on the Sampson data set) --- Network attributes: vertices = 3 directed = TRUE hyper = FALSE loops = FALSE multiple = FALSE total edges= 3 Vertex attribute names: group vertex.names edgelist matrix: [,1] [,2] [1,] 31 [2,]21 [3, ]32 What command should I use to import this data? I have attempted many such as read.delim and read.table - but either an error message is returned, or the strings in the data (such as edges=3) appear to become objects that are analysed by the latentnet functions such as 'ergmm'. I look forward to your replys, Many thanks 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 argument handling odd
Hello there, I'm trying to do lots of plots in one for-loop. But somehow ggplot does not evaluate arguments as expected. Here is an example: library(lattice) library(ggplot2) pl - list() pl2 - list() cDat - as.data.frame(cbind(x1=0:100,x2=0:10,x3=1:20)) for(obs in c(x1, x2)) { pl[[obs]] - xyplot(cDat[,obs] ~ cDat[,x3], main=obs) pl2[[obs]] - qplot(cDat[,x3], cDat[,obs], main=obs) } The pl list contains finally my desired result pl$x1 and pl$x2 are different and show what I want it to. Now, the plots pl2$x1 and pl2$x2 are the same - they both show an x2 ~ x3 plot since this is the current value of obs. So how can I force the variable name substitution? I tried some combinations of parse/eval/substitute with no success. Thanks for your help in advance. Greetings, Sebastian Weber __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] unix.time
Hi, As far as I can tell, The R function unix.time calculates elapsed CPU time. Is there a command within R to measure actual elapsed time (I think this is sometimes referred to as wall time)? For example, the time command from GNU time calculates the actual elapsed time, as far as I can tell. (Please CC me, I'm not subscribed.) Thanks, Faheem. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R objects layout
Hi, Can anyone point me to documentation of how R objects such as vectors, lists, matrices and data frames are laid out in memory? For example, which of these are laid out as a 1-d array, 2-d array and so forth? The R Internals document seems like the natural place to look, but I don't see it there. If such things are only documented in source code, could you point me to the relevant place(s)? (Please CC me; I'm not subscribed.) Thanks, Faheem. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [R-pkgs] New package: epiR
A new package 'epiR' is available on CRAN. Package description as follows: Package: epiR Version: 0.9-3 Date: 2008-03-24 Title: Functions for analysing epidemiological data Author: Mark Stevenson [EMAIL PROTECTED] with contributions from Telmo Nunes, Javier Sanchez, and Ron Thornton. Maintainer: Mark Stevenson [EMAIL PROTECTED] Description: A package for analysing epidemiological data. Contains functions for directly and indirectly adjusting measures of disease frequency, quantifying measures of association on the basis of single or multiple strata of count data presented in a contingency table, and computing confidence intervals around incidence risk and incidence rate estimates. Miscellaneous functions for use in meta-analysis, diagnostic test interpretation, and sample size calculations. Depends: R (= 2.0.0) License: GPL (= 2) URL: http://epicentre.massey.ac.nz Regards, Mark S * Mark Stevenson Associate Professor, Veterinary Epidemiology IVABS, Massey University Private Bag 11-222 Palmerston North New Zealand Ph: + 64 (06) 350 5915 Fx: + 64 (06) 350 5716 [EMAIL PROTECTED] ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Optimization with nonlinear constraints
On Wed, Mar 26, 2008 at 1:17 PM, Andreas Klein [EMAIL PROTECTED] wrote: I have some further problems with modelling an optimization problem in R: How can I model some optimization problem in R with a linear objective function with subject to some nonlinear constraints? I would like to use optim or constrOptim, maybe with respect to methods like Simulated Annealing or Sequential Quadric Programming or something else, which can solve the problem. But I have no idea how to code in R! Example: min (x1 + x2 + x3) s.t. p * (a*x1 + b*x2 + c*x3)^(-3) + (1-p) * (d*x1 + e*x2 + f*x3)^(-3) = g with a,b,c,d,e,f,g,p constant 0 and x1,x2,x3 0 also: a,b,c d,e,f I hope you can help me with some code for the above problem so I can transfer it to my real problem. You can also put some real numbers for the above problem. I only wanted to abstract the problem with some general constant. I think that your optimization problem, Andreas, has no solution, but please correct me if I am wrong. In fact, when x1, x2 and x3 tend simultaneously to zero, the constrain is satisfied; the minimum would then be x1 = x2 = x3 = 0, but by your assumption, x1,x2,x3 0. Thus, the search for the minimum would be endless; no minimum exists. Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] OdfWeave and contingency tables
Hi, I would like to use odfWeave to output some contingency tables (the output of table) into OOo. I know I can do this in LaTex (using latex in the Hmisc package), but I was wondering if it is possible in OdfWeave. My documentation to odfTable says inputs can only be vector, matrix or data.frame, and I'm having a hard time converting my table into one of these formats. Regards Abhijit __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Moving data between R and Matlab back and forth?
Hi to the list, I am trying to find a way to painlessly move structured data back and forth between R and Matlab (also Octave). For this purpose I found the R.matlab package great help. I wish to use a Matlab -v6 MAT file as an intermediary format, because it is well read by both Matlab and Octave. It is also well read by 'readMat' function in R.matlab package, but that is where I run into problems because of poor knowledge of R. By structured data I mean data in data frames in R and the closest equivalent - structures in Matlab. Here is what I have done. - Make a data frame in R and export it - Maker - factor(c(HP, HP, Sony, DELL, whitebox, whitebox)) CPUspeed - c(2,4,2.5,2.5,2,5) HDD - c(80, 250, 100, 100, 80, 300) RAM - c(2, 2, 1, 2, 2, 4) labpc - data.frame(Maker, CPUspeed, HDD, RAM) labpc Maker CPUspeed HDD RAM 1 HP 2.0 80 2 2 HP 4.0 250 2 3 Sony 2.5 100 1 4 DELL 2.5 100 2 5 whitebox 2.0 80 2 6 whitebox 5.0 300 4 library(R.matlab) writeMat(labpc.mat, labpcdata = labpc) -- -- In MATLAB - everything is as expected -- load('labpc.mat') labpcdata labpcdata = Maker: {6x1 cell} CPUspeed: [6x1 double] HDD: [6x1 double] RAM: [6x1 double] class(labpcdata) ans = struct labpcstruct = labpcdata save('labpcstruct.mat', 'labpcstruct') - --- Back in R - how to rebuild the data frame from the list labpcstruct? --- labpcfile - readMat(labpcstruct.mat) labpcfile $labpcstruct , , 1 [,1] MakerList,6 CPUspeed Numeric,6 HDD Numeric,6 RAM Numeric,6 attr(,header) attr(,header)$description [1] MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Wed Mar 26 15:49:21 2008 attr(,header)$version [1] 5 attr(,header)$endian [1] little labpcstruct - labpcfile$labpcstruct labpcstruct , , 1 [,1] MakerList,6 CPUspeed Numeric,6 HDD Numeric,6 RAM Numeric,6 typeof(labpcstruct) [1] list So if there is any kind soul that will tell me how to get back the original data frame from the imported list 'labpcstruct', that would be great. Regards, TL __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] [R-pkgs] Naive Gibbs Sampling with Metropolis Steps (pkg: gibbs.met)
Hi R Users: This package provides two generic functions for performing Markov chain sampling in a naive way for a user-defined target distribution, which involves only continuous variables. The function gibbs_met performs Gibbs sampling with each 1-dimensional distribution sampled with Metropolis update using Gaussian proposal distribution centered at the previous state. The function met_gaussian updates the whole state with Metropolis method using independent Gaussian proposal distribution centered at the previous state. The sampling is carried out without considering any special tricks for improving efficiency. This package is aimed at only routine applications in moderate-dimensional problems. The website for this software is http://math.usask.ca/~longhai/software/gibbs.met/release.html -- Longhai Li, PhD Assistant Professor Department of Mathematics and Statistics University of Saskatchewan Homepage: http://math.usask.ca/~longhai ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] unix.time
see ?system.time Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, Mobile VoiceMail (317) 204-4202 Home (no voice mail please) mwkimpelatgmaildotcom ** Faheem Mitha wrote: Hi, As far as I can tell, The R function unix.time calculates elapsed CPU time. Is there a command within R to measure actual elapsed time (I think this is sometimes referred to as wall time)? For example, the time command from GNU time calculates the actual elapsed time, as far as I can tell. (Please CC me, I'm not subscribed.) Thanks, Faheem. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] (pscl) hurdle model and sandwich: applicable?
Dear helpeR's, I am estimating a hurdle model with the hurdle function of the pscl package. (negative binomial for the count data and logit for the hurdle). I am interested in robust estimates. In stata I can do this with robust cluster(group). Since R is faster by roughly factor 20 in the model estimation I would like to use R for estimations but I like to obtain also robust estimates. I tried the sandwich package and ended up with coeftest(model,df=Inf,vcov=NeweyWest) which gives me standard errors which are very close to those of the stata function with robust cluster(group). Now I am wondering whether this method is applicable for the hurdle models ( I am not a statistician/econometrician) and whether it is problematic if it complains with: Error in estfun(x)/model.matrix(x) : non-conformable arrays - although it still gives the test resultes. Kind regards Stefan -- Microeconomics University of Erfurt __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] OdfWeave and contingency tables
I believe that work is in progress to make odfTable work on tables as well, in the meantime if you use unclass on a table you get back a matrix that works with odfTable. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Abhijit Dasgupta Sent: Wednesday, March 26, 2008 10:28 AM To: r-help@r-project.org Subject: [R] OdfWeave and contingency tables Hi, I would like to use odfWeave to output some contingency tables (the output of table) into OOo. I know I can do this in LaTex (using latex in the Hmisc package), but I was wondering if it is possible in OdfWeave. My documentation to odfTable says inputs can only be vector, matrix or data.frame, and I'm having a hard time converting my table into one of these formats. Regards Abhijit __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] unix.time
Where did you get that idea from? Not from the help page: 'system.time' calls the function 'proc.time', evaluates 'expr', and then calls 'proc.time' once more, returning the difference between the two 'proc.time' calls. 'unix.time' is an alias of 'system.time', for compatibility with S. Value: A object of class 'proc_time': see 'proc.time' for details. and ?proc.time says 'proc.time' returns five elements for backwards compatibility, but its 'print' method prints a named vector of length 3. The first two entries are the total user and system CPU times of the current R process and any child processes on which it has waited, and the third entry is the ‘real’ elapsed time since the process was started. So, you get measurements of user and system CPU time _and_ elapsed time. E.g. system.time(Sys.sleep(1.7)) user system elapsed 0.0 0.0 1.7 system.time(Sys.sleep(1.7))[3] elapsed 1.69 On Wed, 26 Mar 2008, Faheem Mitha wrote: Hi, As far as I can tell, The R function unix.time calculates elapsed CPU time. Is there a command within R to measure actual elapsed time (I think this is sometimes referred to as wall time)? For example, the time command from GNU time calculates the actual elapsed time, as far as I can tell. (Please CC me, I'm not subscribed.) Thanks, Faheem. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Latentnet Data Import
Try this. If the format varies you may need to modify it from below. Replace textConnection(rawLines) with the name of your file. This extracts lines with a = and rereads them using read.table with = as the separator. It also gets lines with a number that has spaces on both sides, deletes everything to the ] and rereads them using read.table. rawLines - Network attributes: vertices = 3 directed = TRUE hyper = FALSE loops = FALSE multiple = FALSE total edges= 3 Vertex attribute names: group vertex.names edgelist matrix: [,1] [,2] [1,] 31 [2,]21 [3, ]32 Lines - readLines(textConnection(rawLines)) Lines0 - grep(=, Lines, value = TRUE) attributes - read.table(textConnection(Lines0), sep = =, as.is = TRUE) Lines1 - sub(.*\\], , grep( [0-9]+ , Lines, value = TRUE)) edgelist - read.table(textConnection(Lines1)) On Wed, Mar 26, 2008 at 7:15 AM, Ben Morley [EMAIL PROTECTED] wrote: Hello everone, I am a computer science researcher in the UK - and have a quick question regarding importing data into R and more specifically latentnet. I am trying to import data such as a text file containing: (This is based on the Sampson data set) --- Network attributes: vertices = 3 directed = TRUE hyper = FALSE loops = FALSE multiple = FALSE total edges= 3 Vertex attribute names: group vertex.names edgelist matrix: [,1] [,2] [1,] 31 [2,]21 [3, ]32 What command should I use to import this data? I have attempted many such as read.delim and read.table - but either an error message is returned, or the strings in the data (such as edges=3) appear to become objects that are analysed by the latentnet functions such as 'ergmm'. I look forward to your replys, Many thanks 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. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Replace with previous value
Hi R, I have a dataframe with dim(test) [1] 435150 4 class(test) [1] data.frame In the third column every time a number with - appears I need to replace with previous value I am using the following code s=which(substr(as.character(test[,3]),1,1)==-) for(i in 1:length(s)) test[s[i],3] = test[s[i]-1,3] Is there a faster way of doing this? sessionInfo() R version 2.5.1 (2007-06-27) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods [7] base Thanks in advance Ravi Shankar S This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 argument handling odd
On Wed, Mar 26, 2008 at 11:03 AM, Sebastian Weber [EMAIL PROTECTED] wrote: Hello there, I'm trying to do lots of plots in one for-loop. But somehow ggplot does not evaluate arguments as expected. Here is an example: library(lattice) library(ggplot2) pl - list() pl2 - list() cDat - as.data.frame(cbind(x1=0:100,x2=0:10,x3=1:20)) for(obs in c(x1, x2)) { pl[[obs]] - xyplot(cDat[,obs] ~ cDat[,x3], main=obs) pl2[[obs]] - qplot(cDat[,x3], cDat[,obs], main=obs) } The pl list contains finally my desired result pl$x1 and pl$x2 are different and show what I want it to. Now, the plots pl2$x1 and pl2$x2 are the same - they both show an x2 ~ x3 plot since this is the current value of obs. So how can I force the variable name substitution? I tried some combinations of parse/eval/substitute with no success. In this case you are better off moving away from qplot (which does various substitute tricks to assemble the named variables in a data frame) to a more explicit form of ggplot: pl2[[obs]] - ggplot(cData, aes_string(x=x3, y=obs)) + geom_point() + opts(title = obs) Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R objects layout
On 3/26/2008 12:20 PM, Faheem Mitha wrote: Hi, Can anyone point me to documentation of how R objects such as vectors, lists, matrices and data frames are laid out in memory? For example, which of these are laid out as a 1-d array, 2-d array and so forth? Vectors, lists and matrices are 1-d arrays. Data frames are lists of vectors. This is in various places in the Intro and Language Reference manuals. For example, from the latter: Matrices and arrays are simply vectors with the attribute dim and optionally dimnames attached to the vector. Duncan Murdoch The R Internals document seems like the natural place to look, but I don't see it there. If such things are only documented in source code, could you point me to the relevant place(s)? (Please CC me; I'm not subscribed.) Thanks, Faheem. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sample size in bootstrap(boot)
I may have misread your original posting, I thought you were using the boot package but I don't see any function bootstrap. I also don't see any documentation for the sampler parameter. What package are you using? If it is possible, I am sure I will be corrected. Sorry, I can't be of more help, Dan Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and Health Services Olympia, WA 98504-5204 From: Zaihra T [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 26, 2008 8:56 AM To: Nordlund, Dan (DSHS/RDA); Jan T. Kim; R-help@r-project.org Subject: Re: [R] sample size in bootstrap(boot) Hi Dan, Thanks for response yes i do know that bootstrap samples generated by function boot are of the same size as original dataset but somewhere in the R-help threads i saw a suggestion that one can control sample size (n) by using the following command(plz see below) but my problem is it doesnt work it gives error ( error in : n * nboot : non-numeric argument to binary operator) bootstrap(data,statistic,sampler=samp.bootstrap(size=20)) this is what somebody on R help suggested... can we fix that error somehow ? On Wed, 26 Mar 2008 08:26:22 -0700 Nordlund, Dan (DSHS/RDA) wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Zaihra T Sent: Wednesday, March 26, 2008 7:57 AM To: Jan T. Kim; R-help@r-project.org Subject: ! [R] sample size in bootstrap(boot) Hi, Can someone tell me how to control sample size (n) in bootstrap function boot in R. Can we give some option like we give for # of repeated samples(R=say 100). Will appreciate any help. thanks I don't believe so. Isn't one of the differences between the bootstrap and other kinds of resampling that the bootstrap samples with replacement a sample of the same size as the original data? You could use the function sample() to select your subsets and compute your statistics of interest. Hope this is helpful, Dan Daniel J. Nordlund Research and Data Analysis Washington State Department of Social and! Health Services Olympia, WA 98504-5204 g t; [[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] unix.time
On Wed, 26 Mar 2008, Prof Brian Ripley wrote: Where did you get that idea from? Not from the help page: No. From direct observation. Ie. comparing what the function actually returned vs actual elapsed time. In one case I observed, these two are dramatically different. It is possible I made an error. I'll check it again. Faheem. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generate random numbers subject to constraints
I am trying to generate a set of random numbers that fulfill the following constraints: X1 + X2 + X3 + X4 = 1 aX1 + bX2 + cX3 + dX4 = n where a, b, c, d, and n are known. Any function to do this? Thanks, -Ala' __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generating a paired t-test with multiple levels of a factor
I have been trying to run this analysis and finally want to ask for help. I am trying to run a paired t-test in which I have 19 subjects who have reaction times for 5 different conditions. The data frame has 114 rows total (6 rows for each subject representing six average reaction times by condition). Is there a way to run all paired t-tests where a paired t-test is run for every possible combination? 103cou 778 498.6250 104 nyc 778 494.5750 105 scr 778 419.7500 106 sub 778 526.2500 107 vie 778 483.7000 108 wtc 778 488.3000 109 cou 783 993.2571 110 nyc 7831209. 111 scr 783 680.2000 112 sub 7831177.9032 113 vie 7831363.5946 114 wtc 7831377.2581 [[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] Newbie question
Hey everyone, For my research, I needed a peak detector algorithm that can spot peaks in an intensity graph. The excel http://www.nabble.com/file/p16313309/sample%2Bdata.xls sample data that I've attached contains columns of such intensity graphs. I came found an algorithm developed by the http://www.bioconductor.com Bioconductor team and was excited to test it out on my own data. However, it is written in R. With my own programming experience being Matlab and having little experience with programming to begin with, I've hit a bit of a road block and need whatever help you guys can offer. I need to run my data through this algorithm and see what kind of peaks are detected. How do I format my excel data to a .rda format that the algorithm can work with? The algorithm can be found http://www.bioconductor.org/packages/bioc/html/MassSpecWavelet.html here . To load the package, enter: source(http://bioconductor.org/biocLite.R;) biocLite(MassSpecWavelet) library(MassSpecWavelet) The package comes with a sample data that is VERY similar to my own data (which is why I think it will work for my project) To load the packaged example data and see what the package does, enter: data(exampleMS) SNR.Th - 3 peakInfo - peakDetectionCWT(exampleMS, SNR.Th=SNR.Th) majorPeakInfo = peakInfo$majorPeakInfo peakIndex - majorPeakInfo$peakIndex plotPeak(exampleMS, peakIndex, main=paste('Identified peaks with SNR ', SNR.Th)) Any help you guys can offer will be greatly appreciated. Thanks! -- View this message in context: http://www.nabble.com/Newbie-question-tp16313309p16313309.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] generate random numbers subject to constraints
You have 4 random variables that satisfy 2 linear constraints, so you are trying to generate a point in a (4-2) = 2 dimensional linear (affine, in fact) subspace of R^4. If you don't have any further requirement for the distribution of the random points you want to generate, there are infinitely many ways of doing it. It would be a good idea if you could explain in some more detail what you want to do, so that we can give you relevant suggestions. Best, Giovanni Date: Wed, 26 Mar 2008 11:28:28 -0700 From: Ala' Jaouni [EMAIL PROTECTED] Sender: [EMAIL PROTECTED] Precedence: list I am trying to generate a set of random numbers that fulfill the following constraints: X1 + X2 + X3 + X4 = 1 aX1 + bX2 + cX3 + dX4 = n where a, b, c, d, and n are known. Any function to do this? Thanks, -Ala' __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Giovanni Petris GPetris @ uark.edu Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Newbie question
Hi Chaser -- Ask on the Bioconductor mailing list (http://www.bioconductor.org/docs/mailList.html) to connect with other Bioconductor users likely to have experience with the package. Use an informative subject line, so that people able to help can see that the help they can provide is needed. Use the facilities in R to find out about the required data, especially help on individual functions and the data set, e.g., ?exampleMS ?peakDetectionCWT Do you know about vignettes? After library(MassSpecWavelet), try library(Biobase) openVignette() and select the appropriate vignette. And then to get to your question: it looks like the example data is a matrix with 1 row and many columns (evenly spaced mass spec values). data(exampleMS) class(exampleMS) [1] matrix dim(exampleMS) [1] 1 37656 You'll want to export your data from Excel as a 'comma-separated value' (csv) file, import it into R, and transform it as appropriate. These operations are described in manuals such as 'An Introduction to R', 'R Data Import / Export'. It might be as easy as myMS - t(as.matrix(read.csv(myFile.csv))) Look up the help pages of read.csv, as.matrix, and t for more information. Martin Chaser wrote: Hey everyone, For my research, I needed a peak detector algorithm that can spot peaks in an intensity graph. The excel http://www.nabble.com/file/p16313309/sample%2Bdata.xls sample data that I've attached contains columns of such intensity graphs. I came found an algorithm developed by the http://www.bioconductor.com Bioconductor team and was excited to test it out on my own data. However, it is written in R. With my own programming experience being Matlab and having little experience with programming to begin with, I've hit a bit of a road block and need whatever help you guys can offer. I need to run my data through this algorithm and see what kind of peaks are detected. How do I format my excel data to a .rda format that the algorithm can work with? The algorithm can be found http://www.bioconductor.org/packages/bioc/html/MassSpecWavelet.html here . To load the package, enter: source(http://bioconductor.org/biocLite.R;) biocLite(MassSpecWavelet) library(MassSpecWavelet) The package comes with a sample data that is VERY similar to my own data (which is why I think it will work for my project) To load the packaged example data and see what the package does, enter: data(exampleMS) SNR.Th - 3 peakInfo - peakDetectionCWT(exampleMS, SNR.Th=SNR.Th) majorPeakInfo = peakInfo$majorPeakInfo peakIndex - majorPeakInfo$peakIndex plotPeak(exampleMS, peakIndex, main=paste('Identified peaks with SNR ', SNR.Th)) Any help you guys can offer will be greatly appreciated. Thanks! -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 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] generate random numbers subject to constraints
On Wed, Mar 26, 2008 at 7:27 PM, Ala' Jaouni [EMAIL PROTECTED] wrote: I failed to mention that the X values have to be positive and between 0 and 1. Use Robert's method, and to do his step 1, use runif (?runif) to get random numbers from the uniform distribution between 0 and 1. Paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generate random numbers subject to constraints
On 26-Mar-08 20:13:50, Robert A LaBudde wrote: At 01:13 PM 3/26/2008, Ala' Jaouni wrote: I am trying to generate a set of random numbers that fulfill the following constraints: X1 + X2 + X3 + X4 = 1 aX1 + bX2 + cX3 + dX4 = n where a, b, c, d, and n are known. Any function to do this? 1. Generate random variates for X1, X2, based upon whatever unspecified distribution you wish. 2. Solve the two equations for X3 and X4. The trouble is that the original problem is not well specified. Your suggestion, Robert, gives a solution to one version of the problem -- enabling Ala' Jaouni to say I have generated 4 random numbers X1,X2,X3,X4 such that X1 and X2 have specified distributions, and X1,X2,X3,X4 satisfy the two equations ... . However, suppose the real problem was: let X2,X2,X3,X4 have independent distributions F1,F2,F3,F4. Now sample X1,X2,X3,X4 conditional on the two equations (i.e. from the coditional density). That is a different problem. As a slightly simpler example, suppose we have just X1,X2,X3 and they are independently uniform on (0,1). Now sample from the conditional distribution, conditional on X1 + X2 + X3 = 1. The result is a random point uniformly distributed on the planar triangle whose vertices are at (1,0,0),(0,1,0),(0,0,1). Then none of X1,X2,X3 is uniformly distributed (in fact the marginal density of each is 2*(1-x)). However, your solution would work from either point of view if the distributions were Normal. If X1,X2,X3,X4 were neither Normally nor uniformly distributed, then finding or simulating the conditional distribution would in general be difficult. Ala' Jaouni needs to tell us whether what he precisely wants is as you stated the problem, Robert, or whether he wants a conditional distribution for given distributions if X1,X2,X3,X4, or whether he wants something else. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-08 Time: 19:52:16 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Want to draw 3D cylinder objects
Hello, I want to draw 3D cylinder objects in R. Given is the length and the diameter of the cylinder. Has anybody an example? Thank you very much! Best regards -- -- Dr. Hans-Joachim Klemmt Forstoberrat Organisationsprogrammierer IHK Bayerische Landesanstalt für Wald und Forstwirtschaft zugewiesen an Lehrstuhl für Waldwachstumskunde Technische Universität München Am Hochanger 13 85354 Freising Tel.: 08161/ 7147-14 Fax : 08161/ 7147-21 eMail: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R and Excel question
A friend of mine can't send emails to the R-list from his work and he had a question that he asked me to send because I don't know the answer to his question. I did suggest the cran packages list and the search function but I think he wasn't successful ? He needs to do a quick prototype in R with Excel interface and was wondering if it was possible to implemented R calls from Excel, ( I guess using some kind of a package ) ? Thanks for any suggestions, packages etc. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Range across a List
Hi R, I have a list class(pp2) [1] list length(pp2) [1] 1244 It is in the below format RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27CNY 0.1392 2.125584 ABCD.SZ 2007/12/31 14.88CNY 0.1371 2.040048 ABCD.SZ 2007/11/30 11.07CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77CNY 0.1334 1.703518 I want to find the range of pp2$New.Price for length(pp2) for each date Any help would be appreciated Thanks in advance Ravi This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] R and Excel question
http://cran.r-project.org/contrib/extra/dcom/00ReadMe.html is the easiest way. On Wed, 26 Mar 2008, [EMAIL PROTECTED] wrote: A friend of mine can't send emails to the R-list from his work and he had a question that he asked me to send because I don't know the answer to his question. I did suggest the cran packages list and the search function but I think he wasn't successful ? He needs to do a quick prototype in R with Excel interface and was wondering if it was possible to implemented R calls from Excel, ( I guess using some kind of a package ) ? Thanks for any suggestions, packages etc. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Range across a List
Not exactly clear what the data in the list looks like. Is it a dataframe of the format you listed? Do you want just a single range for the dates? Do you want to create one large dataframe and then partition it by date to find the range? You can do do.call(rbind,pp2) to create the one large dataframe and then use tapply to find the range of each date. On 3/26/08, Ravi S. Shankar [EMAIL PROTECTED] wrote: Hi R, I have a list class(pp2) [1] list length(pp2) [1] 1244 It is in the below format RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27CNY 0.1392 2.125584 ABCD.SZ 2007/12/31 14.88CNY 0.1371 2.040048 ABCD.SZ 2007/11/30 11.07CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77CNY 0.1334 1.703518 I want to find the range of pp2$New.Price for length(pp2) for each date Any help would be appreciated Thanks in advance Ravi This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Want to draw 3D cylinder objects
Can you give a little more detail? Do you want the nice 3d shading effect? Or is an ellipse, 2 lines and another ellipse good enough? Does the viewing angle matter (flatness of ellipses). Do the cylinders need to be placed at certain locations? Or are you trying to do a barplot with 3d cylinders instead of bars? (please, please, please say no to that last one) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hans-Joachim Klemmt Sent: Wednesday, March 26, 2008 2:03 PM To: r-help@r-project.org Subject: [R] Want to draw 3D cylinder objects Hello, I want to draw 3D cylinder objects in R. Given is the length and the diameter of the cylinder. Has anybody an example? Thank you very much! Best regards -- -- Dr. Hans-Joachim Klemmt Forstoberrat Organisationsprogrammierer IHK Bayerische Landesanstalt für Wald und Forstwirtschaft zugewiesen an Lehrstuhl für Waldwachstumskunde Technische Universität München Am Hochanger 13 85354 Freising Tel.: 08161/ 7147-14 Fax : 08161/ 7147-21 eMail: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Range across a List
To add more clarity to my question My data pp2 is a list (pp2[[1]]) RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30 CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27 CNY 0.1392 2.040048 ABCD.SZ 2007/11/30 11.07 CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89 CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77 CNY 0.1334 1.703518 (pp2[[2]]) RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price PQRS.SZ 2008/02/299.27 CNY 0.1408 1.305216 PQRS.SZ 2008/01/318.07 CNY 0.1392 1.123344 PQRS.SZ 2007/12/318.76 CNY 0.1371 1.200996 PQRS.SZ 2007/11/306.43 CNY 0.1357 0.872551 PQRS.SZ 2007/10/316.80 CNY 0.1340 0.911200 PQRS.SZ 2007/09/287.94 CNY 0.1334 1.059196 And so on till (pp2[[1244]]) Each of pp2[[i]] is a data frame. For each date I need to find the range of New.Price across the list i.e.for 2008/02/29 it would be max(pp2[[i]]$New.Price[1])-min(pp2[[i]]$New.Price[1]) where i ranges from 1 to 1244 Thank you, Ravi -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 2:12 AM To: Ravi S. Shankar Subject: Re: [R] Range across a List From: Ravi S. Shankar [EMAIL PROTECTED] Date: 2008/03/26 Wed PM 03:28:52 CDT To: [EMAIL PROTECTED] Subject: [R] Range across a List i think it's a dataframe ( it looks like one ) or convert it to one if it's not and then I think below should work. temp-lapply(split(pp2,pp2$Trade.Date), function(.df) { data.frame(.df$Trade.Date[1],range(.df$New.Price)) }) result-do.call(rbind,temp) test it though because i didn't. Hi R, I have a list class(pp2) [1] list length(pp2) [1] 1244 It is in the below format RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27CNY 0.1392 2.125584 ABCD.SZ 2007/12/31 14.88CNY 0.1371 2.040048 ABCD.SZ 2007/11/30 11.07CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77CNY 0.1334 1.703518 I want to find the range of pp2$New.Price for length(pp2) for each date Any help would be appreciated Thanks in advance Ravi This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Range across a List
I think something like this should work. I will give you the range for each date across all the data: x - do.call(rbind, pp2) tapply(x$New.Price, x$Trade.Date, range) On 3/26/08, Ravi S. Shankar [EMAIL PROTECTED] wrote: To add more clarity to my question My data pp2 is a list (pp2[[1]]) RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30 CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27 CNY 0.1392 2.040048 ABCD.SZ 2007/11/30 11.07 CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89 CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77 CNY 0.1334 1.703518 (pp2[[2]]) RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price PQRS.SZ 2008/02/299.27 CNY 0.1408 1.305216 PQRS.SZ 2008/01/318.07 CNY 0.1392 1.123344 PQRS.SZ 2007/12/318.76 CNY 0.1371 1.200996 PQRS.SZ 2007/11/306.43 CNY 0.1357 0.872551 PQRS.SZ 2007/10/316.80 CNY 0.1340 0.911200 PQRS.SZ 2007/09/287.94 CNY 0.1334 1.059196 And so on till (pp2[[1244]]) Each of pp2[[i]] is a data frame. For each date I need to find the range of New.Price across the list i.e.for 2008/02/29 it would be max(pp2[[i]]$New.Price[1])-min(pp2[[i]]$New.Price[1]) where i ranges from 1 to 1244 Thank you, Ravi -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 2:12 AM To: Ravi S. Shankar Subject: Re: [R] Range across a List From: Ravi S. Shankar [EMAIL PROTECTED] Date: 2008/03/26 Wed PM 03:28:52 CDT To: [EMAIL PROTECTED] Subject: [R] Range across a List i think it's a dataframe ( it looks like one ) or convert it to one if it's not and then I think below should work. temp-lapply(split(pp2,pp2$Trade.Date), function(.df) { data.frame(.df$Trade.Date[1],range(.df$New.Price)) }) result-do.call(rbind,temp) test it though because i didn't. Hi R, I have a list class(pp2) [1] list length(pp2) [1] 1244 It is in the below format RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27CNY 0.1392 2.125584 ABCD.SZ 2007/12/31 14.88CNY 0.1371 2.040048 ABCD.SZ 2007/11/30 11.07CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77CNY 0.1334 1.703518 I want to find the range of pp2$New.Price for length(pp2) for each date Any help would be appreciated Thanks in advance Ravi This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This e-mail may contain confidential and/or privileged...{{dropped:16}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generate random numbers subject to constraints
X1,X2,X3,X4 should have independent distributions. They should be between 0 and 1 and all add up to 1. Is this still possible with Robert's method? Thanks On Wed, Mar 26, 2008 at 12:52 PM, Ted Harding [EMAIL PROTECTED] wrote: On 26-Mar-08 20:13:50, Robert A LaBudde wrote: At 01:13 PM 3/26/2008, Ala' Jaouni wrote: I am trying to generate a set of random numbers that fulfill the following constraints: X1 + X2 + X3 + X4 = 1 aX1 + bX2 + cX3 + dX4 = n where a, b, c, d, and n are known. Any function to do this? 1. Generate random variates for X1, X2, based upon whatever unspecified distribution you wish. 2. Solve the two equations for X3 and X4. The trouble is that the original problem is not well specified. Your suggestion, Robert, gives a solution to one version of the problem -- enabling Ala' Jaouni to say I have generated 4 random numbers X1,X2,X3,X4 such that X1 and X2 have specified distributions, and X1,X2,X3,X4 satisfy the two equations ... . However, suppose the real problem was: let X2,X2,X3,X4 have independent distributions F1,F2,F3,F4. Now sample X1,X2,X3,X4 conditional on the two equations (i.e. from the coditional density). That is a different problem. As a slightly simpler example, suppose we have just X1,X2,X3 and they are independently uniform on (0,1). Now sample from the conditional distribution, conditional on X1 + X2 + X3 = 1. The result is a random point uniformly distributed on the planar triangle whose vertices are at (1,0,0),(0,1,0),(0,0,1). Then none of X1,X2,X3 is uniformly distributed (in fact the marginal density of each is 2*(1-x)). However, your solution would work from either point of view if the distributions were Normal. If X1,X2,X3,X4 were neither Normally nor uniformly distributed, then finding or simulating the conditional distribution would in general be difficult. Ala' Jaouni needs to tell us whether what he precisely wants is as you stated the problem, Robert, or whether he wants a conditional distribution for given distributions if X1,X2,X3,X4, or whether he wants something else. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-08 Time: 19:52:16 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generate random numbers subject to constraints
X1,X2,X3,X4 should have independent distributions. They should be between 0 and 1 and all add up to 1. Is this still possible with Robert's method? 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] generate random numbers subject to constraints
Ala' Jaouni wrote: I am trying to generate a set of random numbers that fulfill the following constraints: X1 + X2 + X3 + X4 = 1 aX1 + bX2 + cX3 + dX4 = n where a, b, c, d, and n are known. Any function to do this? You must give more information. How are those numbers distributed? Are they normal? Positive? If they can be anything, just generate X1, X2 and then compute X3, X4. Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] avoiding loops
Hi, I need to compute an array from a matrix and an array: A - array(1:20,c(2,2,5)) B - matrix(1:10,5) And I would like the result to be an array consisting of the following: rbind(A[1,,1]*B[1,], A[2,,1]*B[1,]) rbind(A[1,,2]*B[2,], A[2,,2]*B[2,]) rbind(A[1,,3]*B[2,], A[2,,3]*B[2,]) etc. Hence the result should have the same dimension as A, ie a series of 2 by 2 matrices. Short of a for loop over the the last index of A I have struggled with versions of apply but to no avail ... Any insights much appreciated, Best, Ingmar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] generate random numbers subject to constraints
On 26-Mar-08 21:26:59, Ala' Jaouni wrote: X1,X2,X3,X4 should have independent distributions. They should be between 0 and 1 and all add up to 1. Is this still possible with Robert's method? Thanks I don't think so. A whileago you wrote The numbers should be uniformly distributed (but in the context of an example where you had 5 variable; now you are back to 4 variables). Let's take the 4-case first. The two linear constraints confine the point (X1,X2,X3,X4) to a triangular region within the 4-dimensional unit cube. Say it has vertices A, B, C. You could then start by generating points uniformly distributed over a specific triangle in 2 dimentions, say the one with vertices at A0=(0,0), B0=(0,1), C0=(1,0). This is easy. Then you need to find a linear transformation which will map this triangle (A0,B0,C0) onto the triangle (A,B,C). Then the points you have sampled in (A0,B0,C0) will map into points which are uniformly distributed over the triangle (A,B,C). More generally, you will be seeking to generate points uniformly distributed over a simplex. For example, the case (your earlier post) of 5 points with 2 linear constraints requires a tetrahedron with vertices (A,B,C,D) in 5 dimensions whose coordinates you will have to find. Then take an easy tetrahedron with vertices (A0,B0,C0,D0) and sample uniformly within this. Then find a linear mapping from (A0,B0,C0,D0) to (A,B,C,D) and apply this to the sampled points. This raises a general question: Does anyone know of an R function to sample uniformly in the interior of a general (k-r)-dimensional simplex embedded in k dimensions, with (k+1) given vertices? Best wishes to all, Ted. On Wed, Mar 26, 2008 at 12:52 PM, Ted Harding [EMAIL PROTECTED] wrote: On 26-Mar-08 20:13:50, Robert A LaBudde wrote: At 01:13 PM 3/26/2008, Ala' Jaouni wrote: I am trying to generate a set of random numbers that fulfill the following constraints: X1 + X2 + X3 + X4 = 1 aX1 + bX2 + cX3 + dX4 = n where a, b, c, d, and n are known. Any function to do this? 1. Generate random variates for X1, X2, based upon whatever unspecified distribution you wish. 2. Solve the two equations for X3 and X4. The trouble is that the original problem is not well specified. Your suggestion, Robert, gives a solution to one version of the problem -- enabling Ala' Jaouni to say I have generated 4 random numbers X1,X2,X3,X4 such that X1 and X2 have specified distributions, and X1,X2,X3,X4 satisfy the two equations ... . However, suppose the real problem was: let X2,X2,X3,X4 have independent distributions F1,F2,F3,F4. Now sample X1,X2,X3,X4 conditional on the two equations (i.e. from the coditional density). That is a different problem. As a slightly simpler example, suppose we have just X1,X2,X3 and they are independently uniform on (0,1). Now sample from the conditional distribution, conditional on X1 + X2 + X3 = 1. The result is a random point uniformly distributed on the planar triangle whose vertices are at (1,0,0),(0,1,0),(0,0,1). Then none of X1,X2,X3 is uniformly distributed (in fact the marginal density of each is 2*(1-x)). However, your solution would work from either point of view if the distributions were Normal. If X1,X2,X3,X4 were neither Normally nor uniformly distributed, then finding or simulating the conditional distribution would in general be difficult. Ala' Jaouni needs to tell us whether what he precisely wants is as you stated the problem, Robert, or whether he wants a conditional distribution for given distributions if X1,X2,X3,X4, or whether he wants something else. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-08 Time: 19:52:16 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-08 Time: 22:06:38 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] barplot as Trellis graphic (corrected)
In the code of my previous message the barplot should be: barplot(apply(sel[,-1],2,mean)) instead of barplot(sel) Sorry for the confusion. Agus Mensaje original Asunto: barplot as Trellis graphic Fecha: Wed, 26 Mar 2008 22:24:04 +0100 De: Agustin Lobo [EMAIL PROTECTED] Responder a: [EMAIL PROTECTED] Para: r-help@r-project.org Dear list, Is there any way of making barplots as a Trellis graphic? Currently I do something like: class - unique(mydata[,1]) par(mfrow=c(3,3)) for(i in class){ sel - mydata[mydata[,1]==i,] barplot(sel) title(i) } where class would take values between 1 and 9 and the first column of mydata would be the class. But I'm looking for a nicer code and a nicer graphic using the approach of the lattice package. Thanks! -- Dr. Agustin Lobo Institut de Ciencies de la Terra Jaume Almera (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster -- Dr. Agustin Lobo Institut de Ciencies de la Terra Jaume Almera (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster -- Dr. Agustin Lobo Institut de Ciencies de la Terra Jaume Almera (CSIC) LLuis Sole Sabaris s/n 08028 Barcelona Spain Tel. 34 934095410 Fax. 34 934110012 email: [EMAIL PROTECTED] http://www.ija.csic.es/gt/obster __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] recursive multivariate filter with time-varying coefficients
Hi, I've been searching CRAN and the web for a recursive multivariate filter with time-varying coefficients. What I mean is the following: I have a series of square matrices A_t an initial value vector y_0 and I need to compute y_t =A_t%*%y_t-1 As these y_t may diverge quickly and/or lead to underflow problems, the y_t need to be scaled by eg y_t =y_t/sum(y_t-1) Is anyone aware whether this has been implemented somewhere? Best, Ingmar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Range across a List
I did the following DF-do.call(rbind, pp2) DF1=na.omit(DF) DF1[,2]=as.Date(DF1[,2]) str(DF) 'data.frame': 18660 obs. of 6 variables: I tried the following code temp-lapply(split(DF1,DF1$Trade.Date), function(.df) { + data.frame(DATE=.df$Trade.Date,RANGE=max(.df$New.Price)-min(.df$New.Pric e)) + }) temp[[1]][1:5,] DATERANGE 1 2006-12-29 1276.670 2 2006-12-29 1276.670 3 2006-12-29 1276.670 4 2006-12-29 1276.670 5 2006-12-29 1276.670 What am I doing wrong? I also tried the below and that seemed to give me the range nn=tapply(DF1$New.Price, DF1$Trade.Date, range) head(nn) $`2006-12-29` [1]0.0074638 1276.6772880 $`2006-12-31` [1] 4.673445 227.60 $`2007-01-31` [1]0.0030772 1255.2080450 $`2007-02-28` [1]0.003978 1316.638200 $`2007-03-29` [1] 5.25585 216.2 $`2007-03-30` [1]0.0047214 1266.825 Thanks Ravi Shankar S -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 2:49 AM To: Ravi S. Shankar Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [R] Range across a List I think something like this should work. I will give you the range for each date across all the data: x - do.call(rbind, pp2) tapply(x$New.Price, x$Trade.Date, range) On 3/26/08, Ravi S. Shankar [EMAIL PROTECTED] wrote: To add more clarity to my question My data pp2 is a list (pp2[[1]]) RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30 CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27 CNY 0.1392 2.040048 ABCD.SZ 2007/11/30 11.07 CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89 CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77 CNY 0.1334 1.703518 (pp2[[2]]) RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price PQRS.SZ 2008/02/299.27 CNY 0.1408 1.305216 PQRS.SZ 2008/01/318.07 CNY 0.1392 1.123344 PQRS.SZ 2007/12/318.76 CNY 0.1371 1.200996 PQRS.SZ 2007/11/306.43 CNY 0.1357 0.872551 PQRS.SZ 2007/10/316.80 CNY 0.1340 0.911200 PQRS.SZ 2007/09/287.94 CNY 0.1334 1.059196 And so on till (pp2[[1244]]) Each of pp2[[i]] is a data frame. For each date I need to find the range of New.Price across the list i.e.for 2008/02/29 it would be max(pp2[[i]]$New.Price[1])-min(pp2[[i]]$New.Price[1]) where i ranges from 1 to 1244 Thank you, Ravi -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 2:12 AM To: Ravi S. Shankar Subject: Re: [R] Range across a List From: Ravi S. Shankar [EMAIL PROTECTED] Date: 2008/03/26 Wed PM 03:28:52 CDT To: [EMAIL PROTECTED] Subject: [R] Range across a List i think it's a dataframe ( it looks like one ) or convert it to one if it's not and then I think below should work. temp-lapply(split(pp2,pp2$Trade.Date), function(.df) { data.frame(.df$Trade.Date[1],range(.df$New.Price)) }) result-do.call(rbind,temp) test it though because i didn't. Hi R, I have a list class(pp2) [1] list length(pp2) [1] 1244 It is in the below format RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27CNY 0.1392 2.125584 ABCD.SZ 2007/12/31 14.88CNY 0.1371 2.040048 ABCD.SZ 2007/11/30 11.07CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77CNY 0.1334 1.703518 I want to find the range of pp2$New.Price for length(pp2) for each date Any help would be appreciated Thanks in advance Ravi This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This e-mail may contain confidential and/or privileged...{{dropped:30}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Slow code display in R console
Hi When I copy a block of code to R console, the code would be displayed line by line very slowly. I am using R version 2.6.2(2008-2-8). Does anybody know what is the reason for the slow display? It was not like this when I used earlier versions. Huilin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Loading library lme4
Dear all, I an running R on a Windows 2000 machine (1.5Gb RAM) and am trying to load the lme4 package, however, whenever I attempt to load the library lme4 I get the following error message I have installed lme4 and Matrix locally from the zip file with no problems. R version 2.6.2 (2008-02-08) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 ##snip the blurb library(lme4) Loading required package: Matrix Loading required package: lattice Error in dyn.load(file, ...) : unable to load shared library 'C:/PROGRA~1/R/R-26~1.2/library/Matrix/libs/Matrix.dll': LoadLibrary failure: The specified module could not be found. Error: package 'Matrix' could not be loaded I am using lme4 v0.99875-9 and Matrix v0.999375-7 Any pointers would be appreciated Many thanks in advance Guy J Forrester Guy J Forrester Biometrician Manaaki Whenua - Landcare Research PO Box 40, Lincoln 7640, New Zealand. Tel. +64 3 321 9670 Fax +64 3 321 9998 E-mail [EMAIL PROTECTED] www.LandcareResearch.co.nz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] avoiding loops
If you have lots of memory there is an obvious strategy: d12 - prod(dim(A)[1:2]) A - A * array(rep(B, each = d12), dim = dim(A)) I don't really see much wrong with the obvious for() loop, though: for(b in 1:length(B)) A[,,b] - A[,,b] * B[b] Bill Venables CSIRO Laboratories PO Box 120, Cleveland, 4163 AUSTRALIA Office Phone (email preferred): +61 7 3826 7251 Fax (if absolutely necessary): +61 7 3826 7304 Mobile: +61 4 8819 4402 Home Phone: +61 7 3286 7700 mailto:[EMAIL PROTECTED] http://www.cmis.csiro.au/bill.venables/ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ingmar Visser Sent: Thursday, 27 March 2008 7:58 AM To: R-help@r-project.org Subject: [R] avoiding loops Hi, I need to compute an array from a matrix and an array: A - array(1:20,c(2,2,5)) B - matrix(1:10,5) And I would like the result to be an array consisting of the following: rbind(A[1,,1]*B[1,], A[2,,1]*B[1,]) rbind(A[1,,2]*B[2,], A[2,,2]*B[2,]) rbind(A[1,,3]*B[2,], A[2,,3]*B[2,]) etc. Hence the result should have the same dimension as A, ie a series of 2 by 2 matrices. Short of a for loop over the the last index of A I have struggled with versions of apply but to no avail ... Any insights much appreciated, Best, Ingmar __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Resizing Graph Window Macintosh and Graph disapears
Mac OSX 10.4.10 and R 2.6.2 Whenever I resize a quartz window the graph disapears. I have to size the window and then reprint the graph. Should I report this to the R-developer's list? Are there any work arounds? thanks Stephen Sefick -- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generate random numbers subject to constraints
OOPS! A mistake below. I should have written: This raises a general question: Does anyone know of an R function to sample uniformly in the interior of a general (k-r)-dimensional simplex embedded in k dimensions, with (k-r+1) given vertices? On 26-Mar-08 22:06:54, Ted Harding wrote: On 26-Mar-08 21:26:59, Ala' Jaouni wrote: X1,X2,X3,X4 should have independent distributions. They should be between 0 and 1 and all add up to 1. Is this still possible with Robert's method? Thanks I don't think so. A whileago you wrote The numbers should be uniformly distributed (but in the context of an example where you had 5 variable; now you are back to 4 variables). Let's take the 4-case first. The two linear constraints confine the point (X1,X2,X3,X4) to a triangular region within the 4-dimensional unit cube. Say it has vertices A, B, C. You could then start by generating points uniformly distributed over a specific triangle in 2 dimentions, say the one with vertices at A0=(0,0), B0=(0,1), C0=(1,0). This is easy. Then you need to find a linear transformation which will map this triangle (A0,B0,C0) onto the triangle (A,B,C). Then the points you have sampled in (A0,B0,C0) will map into points which are uniformly distributed over the triangle (A,B,C). More generally, you will be seeking to generate points uniformly distributed over a simplex. For example, the case (your earlier post) of 5 points with 2 linear constraints requires a tetrahedron with vertices (A,B,C,D) in 5 dimensions whose coordinates you will have to find. Then take an easy tetrahedron with vertices (A0,B0,C0,D0) and sample uniformly within this. Then find a linear mapping from (A0,B0,C0,D0) to (A,B,C,D) and apply this to the sampled points. This raises a general question: Does anyone know of an R function to sample uniformly in the interior of a general (k-r)-dimensional simplex embedded in k dimensions, with (k+1) given vertices? Best wishes to all, Ted. On Wed, Mar 26, 2008 at 12:52 PM, Ted Harding [EMAIL PROTECTED] wrote: On 26-Mar-08 20:13:50, Robert A LaBudde wrote: At 01:13 PM 3/26/2008, Ala' Jaouni wrote: I am trying to generate a set of random numbers that fulfill the following constraints: X1 + X2 + X3 + X4 = 1 aX1 + bX2 + cX3 + dX4 = n where a, b, c, d, and n are known. Any function to do this? 1. Generate random variates for X1, X2, based upon whatever unspecified distribution you wish. 2. Solve the two equations for X3 and X4. The trouble is that the original problem is not well specified. Your suggestion, Robert, gives a solution to one version of the problem -- enabling Ala' Jaouni to say I have generated 4 random numbers X1,X2,X3,X4 such that X1 and X2 have specified distributions, and X1,X2,X3,X4 satisfy the two equations ... . However, suppose the real problem was: let X2,X2,X3,X4 have independent distributions F1,F2,F3,F4. Now sample X1,X2,X3,X4 conditional on the two equations (i.e. from the coditional density). That is a different problem. As a slightly simpler example, suppose we have just X1,X2,X3 and they are independently uniform on (0,1). Now sample from the conditional distribution, conditional on X1 + X2 + X3 = 1. The result is a random point uniformly distributed on the planar triangle whose vertices are at (1,0,0),(0,1,0),(0,0,1). Then none of X1,X2,X3 is uniformly distributed (in fact the marginal density of each is 2*(1-x)). However, your solution would work from either point of view if the distributions were Normal. If X1,X2,X3,X4 were neither Normally nor uniformly distributed, then finding or simulating the conditional distribution would in general be difficult. Ala' Jaouni needs to tell us whether what he precisely wants is as you stated the problem, Robert, or whether he wants a conditional distribution for given distributions if X1,X2,X3,X4, or whether he wants something else. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-08 Time: 19:52:16 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 26-Mar-08 Time: 22:06:38 -- XFMail -- __ R-help@r-project.org mailing list
Re: [R] Range across a List
This statement: temp-lapply(split(DF1,DF1$Trade.Date), function(.df) { + data.frame(DATE=.df$Trade.Date,RANGE=max(.df$New.Price)-min(.df$New.Pric e)) + }) has many results for DATE and one for RANGE; that is the reason you are getting multiple copies. Instead you need to write: temp-lapply(split(DF1,DF1$Trade.Date), function(.df) { + data.frame(DATE=.df$Trade.Date[1],RANGE=max(.df$New.Price)-min(.df$New.Pric e)) + }) where you only that the first ([1]) instance of Trade.Date For the tapply, you can write: nn=tapply(DF1$New.Price, DF1$Trade.Date, function(.x) max(.x) - min(.x)) On Wed, Mar 26, 2008 at 5:22 PM, Ravi S. Shankar [EMAIL PROTECTED] wrote: I did the following DF-do.call(rbind, pp2) DF1=na.omit(DF) DF1[,2]=as.Date(DF1[,2]) str(DF) 'data.frame': 18660 obs. of 6 variables: I tried the following code temp-lapply(split(DF1,DF1$Trade.Date), function(.df) { + data.frame(DATE=.df$Trade.Date,RANGE=max(.df$New.Price)-min(.df$New.Pric e)) + }) temp[[1]][1:5,] DATERANGE 1 2006-12-29 1276.670 2 2006-12-29 1276.670 3 2006-12-29 1276.670 4 2006-12-29 1276.670 5 2006-12-29 1276.670 What am I doing wrong? I also tried the below and that seemed to give me the range nn=tapply(DF1$New.Price, DF1$Trade.Date, range) head(nn) $`2006-12-29` [1]0.0074638 1276.6772880 $`2006-12-31` [1] 4.673445 227.60 $`2007-01-31` [1]0.0030772 1255.2080450 $`2007-02-28` [1]0.003978 1316.638200 $`2007-03-29` [1] 5.25585 216.2 $`2007-03-30` [1]0.0047214 1266.825 Thanks Ravi Shankar S -Original Message- From: jim holtman [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 2:49 AM To: Ravi S. Shankar Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: [R] Range across a List I think something like this should work. I will give you the range for each date across all the data: x - do.call(rbind, pp2) tapply(x$New.Price, x$Trade.Date, range) On 3/26/08, Ravi S. Shankar [EMAIL PROTECTED] wrote: To add more clarity to my question My data pp2 is a list (pp2[[1]]) RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30 CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27 CNY 0.1392 2.040048 ABCD.SZ 2007/11/30 11.07 CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89 CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77 CNY 0.1334 1.703518 (pp2[[2]]) RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price PQRS.SZ 2008/02/299.27 CNY 0.1408 1.305216 PQRS.SZ 2008/01/318.07 CNY 0.1392 1.123344 PQRS.SZ 2007/12/318.76 CNY 0.1371 1.200996 PQRS.SZ 2007/11/306.43 CNY 0.1357 0.872551 PQRS.SZ 2007/10/316.80 CNY 0.1340 0.911200 PQRS.SZ 2007/09/287.94 CNY 0.1334 1.059196 And so on till (pp2[[1244]]) Each of pp2[[i]] is a data frame. For each date I need to find the range of New.Price across the list i.e.for 2008/02/29 it would be max(pp2[[i]]$New.Price[1])-min(pp2[[i]]$New.Price[1]) where i ranges from 1 to 1244 Thank you, Ravi -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, March 27, 2008 2:12 AM To: Ravi S. Shankar Subject: Re: [R] Range across a List From: Ravi S. Shankar [EMAIL PROTECTED] Date: 2008/03/26 Wed PM 03:28:52 CDT To: [EMAIL PROTECTED] Subject: [R] Range across a List i think it's a dataframe ( it looks like one ) or convert it to one if it's not and then I think below should work. temp-lapply(split(pp2,pp2$Trade.Date), function(.df) { data.frame(.df$Trade.Date[1],range(.df$New.Price)) }) result-do.call(rbind,temp) test it though because i didn't. Hi R, I have a list class(pp2) [1] list length(pp2) [1] 1244 It is in the below format RIC Trade.Date Close.Price Currency.Code Convertion.Rate New.Price ABCD.SZ 2008/02/29 15.30CNY 0.1408 2.154240 ABCD.SZ 2008/01/31 15.27CNY 0.1392 2.125584 ABCD.SZ 2007/12/31 14.88CNY 0.1371 2.040048 ABCD.SZ 2007/11/30 11.07CNY 0.1357 1.502199 ABCD.SZ 2007/10/31 10.89CNY 0.1340 1.459260 ABCD.SZ 2007/09/28 12.77CNY 0.1334 1.703518 I want to find the range of pp2$New.Price for length(pp2) for each date Any help would be appreciated Thanks in advance Ravi This e-mail may contain confidential and/or privileged i...{{dropped:10}} __ R-help@r-project.org mailing list
[R] issue with predict.loess
Hi, I am creating a model with loess but predict complains about missing variables. This doesn't help with single variable formulas or with lm with any formula. Looks like a bug to me # doesn't work l = loess(y ~ log(x) + log(z) , data.frame(z = 1:100, x=1:100 + rnorm(100), y=1:100)) predict(l, data.frame(x=1:100, z=1:100)) Error in predict.loess(l, data.frame(x = 1:100, z = 1:100)) : 'newdata' does not contain the variables needed #works with lm l = lm(y ~ log(x) + log(z) , data.frame(z = 1:100, x=1:100 + rnorm(100), y=1:100)) predict(l, data.frame(x=1:100, z=1:100)) 1 2 3 4 5 6 7 8 9 10 11 12 -53.790533 -33.916997 -22.291724 -14.043461 -7.645611 -2.418188 2.001536 5.830075 9.207086 12.227925 14.960606 17.455348 [...] #works with simpler formula l = loess(y ~ log(x) , data.frame(z = 1:100, x=1:100 + rnorm(100), y=1:100)) predict(l, data.frame(x=1:100)) [1] 3.213052 5.524131 19.785356 54.505929NANA NANANANANANANA [14]NANANANANANA NANANANANANANA [...] Suggestions? Thanks A [[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] pseudo R square and/or C statistic in R logistic regression
From: Wang, Xiaojing [EMAIL PROTECTED] Date: 2008/03/26 Wed AM 10:08:01 CDT To: 'r-help@r-project.org' r-help@r-project.org Subject: [R] pseudo R square and/or C statistic in R logistic regression The analogue to the regression R rsquared in a GLM is the deviance. I don't know what C is but hopefully someone else does and will reply. Also, John Fox's text, Applied Regression Analysis, Linear Models and Related Methods and Modern Applied Statistics with S, by Bill Venables and Brian Ripley, both do a very nice job of covering GLM's so I would look at one of those tests for the technical details. Agresti is the supposed bible but I think those are quite sufficient. Dear all, I am now doing the logistic regression using R. (glm, family=binomial). Besides the standardize summary statistics generated from R, I am also interested in some more informations concerning the model fitting / prediction etc; Particularly I am interested in pseudo R squar and C statistic. I searched the R- help and could only get very limited information. (Post by Frank Harrell mentioning about the somers2 or rcorr.cens functions in the Hmisc library. ) However, I tried but still could not get through it. Also I found someone mentioned about do it manually. Could someone give me a more detailed information on how I could get these two summary statistics after performed the the logistic regression using glm? Thank you very much. *** Xiaojing WangPhD Research Assistant Professor, Dept. of Oral Biology School of Dental Medicine, University of Pittsburgh Suite 500, Bridgeside Point 100 Technology Drive Pittsburgh, PA 15219 Tel:412-648-9206 Fax:412-648-8779 Email:[EMAIL PROTECTED] *** [[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] generate random numbers subject to constraints
Ala' Jaouni ajaouni at gmail.com writes: X1,X2,X3,X4 should have independent distributions. They should be between 0 and 1 and all add up to 1. Is this still possible with Robert's method? NO. If they add to 1 they are not independent. As Ted remarked, the constraints define two simplexes and the solution you seek lies in their intersection. However, depending on the choices of a, b, c, d, and n in a*X1+b*X2+c*X3+d*X4=n, there may not be a solution that satisfies your constraints (no intersection between the two simplexes - as when an, bn, cn and dn), or the two constraints share a vertex and nothing else (as when a=n, bn, cn, and dn), the two simplexes intersect along a line (as when a=n, b=n, cn, dn), the intersection of the two simplexes lies on a plane (as when a=b=c=n and dn), or the two simplexes are the same (a=n, b=n, c=n, and d=n). Now you can develop sampling schemes that will satisfy any of these possibilities, but are they really what you need? To answer this question, you may need help in formulating this problem beyond what a forum like this can provide. HTH, Chuck __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Want to draw 3D cylinder objects
Check out the 'rgl' package for creating 3D objects. On Wed, Mar 26, 2008 at 3:02 PM, Hans-Joachim Klemmt [EMAIL PROTECTED] wrote: Hello, I want to draw 3D cylinder objects in R. Given is the length and the diameter of the cylinder. Has anybody an example? Thank you very much! Best regards -- -- Dr. Hans-Joachim Klemmt Forstoberrat Organisationsprogrammierer IHK Bayerische Landesanstalt für Wald und Forstwirtschaft zugewiesen an Lehrstuhl für Waldwachstumskunde Technische Universität München Am Hochanger 13 85354 Freising Tel.: 08161/ 7147-14 Fax : 08161/ 7147-21 eMail: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] indexing
Is there an on-line source that explains index vectors? I used 'strsplit' to generate a lengthy list of pairs of character vectors. I only want the first of each pair. Brackets, double brackets, and '$' operator don't work [[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] indexing
Is this what you were asking for? x - c('a b', 'c d', 'e f') y - strsplit(x, ' ') y [[1]] [1] a b [[2]] [1] c d [[3]] [1] e f sapply(y, '[[', 1) [1] a c e On Wed, Mar 26, 2008 at 8:55 PM, [EMAIL PROTECTED] wrote: Is there an on-line source that explains index vectors? I used 'strsplit' to generate a lengthy list of pairs of character vectors. I only want the first of each pair. Brackets, double brackets, and '$' operator don't work [[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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] indexing
I find R books to be helpful for beginners. There is a fairly comprehensive list on the R web site, www.r-project.org. Is this what you had in mind though? Without example code, it's hard for me to tell exactly your situation. test - list(first = c(string1a, string2a), second = c(string1b, string2b)) sapply(test, [[, 1) Best, Erik Iverson [EMAIL PROTECTED] wrote: Is there an on-line source that explains index vectors? I used 'strsplit' to generate a lengthy list of pairs of character vectors. I only want the first of each pair. Brackets, double brackets, and '$' operator don't work [[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] Want to draw 3D cylinder objects
Hans-Joachim Klemmt h-j.klemmt at lrz.tu-muenchen.de writes: Hello, I want to draw 3D cylinder objects in R. Given is the length and the diameter of the cylinder. Has anybody an example? Thank you very much! Best regards Here's a starting point, if you want to use the rgl package: cylinder3d - function(len=1,rad=1,n=30,ctr=c(0,0,0), trans = par3d(userMatrix),...) { if (missing(trans) !rgl.cur()) trans - diag(4) degvec - seq(0,2*pi,length=n) circ - cbind(rad*cos(degvec),rad*sin(degvec)) x - rad*cos(degvec) y - rad*sin(degvec) p - c(1,1,rep(2:n,each=4),1,1) z - rep(c(-1,1,1,-1)*len/2,n) quads3d(x[p],y[p],z,...) } it doesn't draw the ends of the cylinder. good luck, 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] Moving data between R and Matlab back and forth?
I realized that not everyone has Matlab and that basically the issue is purely how to deal with the returned data in R, so I have revised my example code and made it easier to copy-paste and run: #Make a data frame in R Maker - factor(c(HP, HP, Sony, DELL, whitebox, whitebox)) CPUspeed - c(2,4,2.5,2.5,2,5) HDD - c(80, 250, 100, 100, 80, 300) RAM - c(2, 2, 1, 2, 2, 4) labpc - data.frame(Maker, CPUspeed, HDD, RAM) labpc #Save in Matlab v6 format with 'writeMat' library(R.matlab) writeMat(labpc.mat, labpcexport = labpc) #Load the file in R with 'readMat' labpcfile - readMat(labpc.mat) labpcimport - labpcfile$labpcexport labpcimport # This is the last line output #, , 1 # # [,1] #MakerList,6 #CPUspeed Numeric,6 #HDD Numeric,6 #RAM Numeric,6 Now, how do I convert the result held in labpcimport back to a data frame? Thanks in advance, TL On Thu, Mar 27, 2008 at 1:27 AM, Tribo Laboy [EMAIL PROTECTED] wrote: Hi to the list, I am trying to find a way to painlessly move structured data back and forth between R and Matlab (also Octave). For this purpose I found the R.matlab package great help. I wish to use a Matlab -v6 MAT file as an intermediary format, because it is well read by both Matlab and Octave. It is also well read by 'readMat' function in R.matlab package, but that is where I run into problems because of poor knowledge of R. By structured data I mean data in data frames in R and the closest equivalent - structures in Matlab. Here is what I have done. - Make a data frame in R and export it - Maker - factor(c(HP, HP, Sony, DELL, whitebox, whitebox)) CPUspeed - c(2,4,2.5,2.5,2,5) HDD - c(80, 250, 100, 100, 80, 300) RAM - c(2, 2, 1, 2, 2, 4) labpc - data.frame(Maker, CPUspeed, HDD, RAM) labpc Maker CPUspeed HDD RAM 1 HP 2.0 80 2 2 HP 4.0 250 2 3 Sony 2.5 100 1 4 DELL 2.5 100 2 5 whitebox 2.0 80 2 6 whitebox 5.0 300 4 library(R.matlab) writeMat(labpc.mat, labpcdata = labpc) -- -- In MATLAB - everything is as expected -- load('labpc.mat') labpcdata labpcdata = Maker: {6x1 cell} CPUspeed: [6x1 double] HDD: [6x1 double] RAM: [6x1 double] class(labpcdata) ans = struct labpcstruct = labpcdata save('labpcstruct.mat', 'labpcstruct') - --- Back in R - how to rebuild the data frame from the list labpcstruct? --- labpcfile - readMat(labpcstruct.mat) labpcfile $labpcstruct , , 1 [,1] MakerList,6 CPUspeed Numeric,6 HDD Numeric,6 RAM Numeric,6 attr(,header) attr(,header)$description [1] MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Wed Mar 26 15:49:21 2008 attr(,header)$version [1] 5 attr(,header)$endian [1] little labpcstruct - labpcfile$labpcstruct labpcstruct , , 1 [,1] MakerList,6 CPUspeed Numeric,6 HDD Numeric,6 RAM Numeric,6 typeof(labpcstruct) [1] list So if there is any kind soul that will tell me how to get back the original data frame from the imported list 'labpcstruct', that would be great. Regards, TL __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Simulate ARX model.
Have you tried the vignette: (dse - vignette(dse-guide)) Stangle(dse$file) This should open dse-guide.pdf in Acrobat and create a file dse-guide.R in the working directory. The latter file should contain the R commands used in the vignette. Do you really need the innovations form with 'u' driving both the transitions and the observations? If no, you may also want to consider the 'dlm' vignette: (dlm - vignette(dlm)) Stangle(dlm$file) Both of these vignettes describe simulations. If you'd like more help from this listserve, PLEASE do read the posting guide http://www.R-project.org/posting-guide.html, especially the part about providing commented, minimal, self-contained, reproducible code. Hope this helps. Spencer Todd Remund wrote: I have obtained from transfer functions, the state space matrices for the following state space model. x* = Ax + Bu y = Cx + Du I have A, B, C, and D, now I would like to take the exogenous inputs and simulate the data using the state space model. I know there is a simulate function in the package dse1, but I am unsure as to what type of TSmodel to create to put into it. Could anyone give me some hints? Thanks. Todd Remund [[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] Combining several mappings in ggplot2
On Wed, Mar 26, 2008 at 6:01 AM, Tribo Laboy [EMAIL PROTECTED] wrote: Apologies! I though that the Orange dataset comes with R, but it is in fact in the package datasets. So here's another Orange2 dataset for the example: Tree_v = rep(c(1:5),each = 5) age_v = rep(seq(1,25, by = 5),5) + 10*runif(25) circumference_v - rep(seq(21,45, by = 5), 5)*Tree_v + 25*runif(25) Orange2 - data.frame(Tree = as.factor(Tree_v), age = age_v, circumference = circumference_v) This works fine: ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree)) + geom_line() These generate errors (included): ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree, linetype = Tree)) + geom_line() Error in get(check_domain, env = ., inherits = TRUE)(., ...) : Too many values in domain (5 4) ggplot(data = Orange2, aes(x = age, y = circumference, color = Tree)) + geom_line() + scale_linetype_manual(value = c(1:5)) Error in unit(values, units, data = data) : 'x' and 'units' must have length 0 What am I doing wrong? It works fine for me, which implies that it's a bug that I've fixed in the development version. I should be releasing a new version soon (just as soon as I've handed in my thesis on Monday) so your best bet is to wait for that. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.