[R] conversion into capital letter
Dear all, I would need a function which convert small letter into capital letter (at least the first letter of a character variable). Does such a function exist in R ? Thanks by advance Jessica __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] conversion into capital letter
Try ?toupper -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, May 15, 2007 12:11 PM To: R-help@stat.math.ethz.ch Subject: [R] conversion into capital letter Dear all, I would need a function which convert small letter into capital letter (at least the first letter of a character variable). Does such a function exist in R ? Thanks by advance Jessica __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: conversion into capital letter
[EMAIL PROTECTED] napsal dne 15.05.2007 08:41:27: Dear all, I would need a function which convert small letter into capital letter (at least the first letter of a character variable). Does such a function exist in R ? ?toupper, ?tolower Regards Petr Thanks by advance Jessica __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] conversion into capital letter
help(toupper) b On May 15, 2007, at 2:41 AM, [EMAIL PROTECTED] wrote: Dear all, I would need a function which convert small letter into capital letter (at least the first letter of a character variable). Does such a function exist in R ? Thanks by advance Jessica -- Benilton Carvalho PhD Candidate Department of Biostatistics Bloomberg School of Public Health Johns Hopkins University [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] conversion into capital letter
On Tue, 2007-05-15 at 08:41 +0200, [EMAIL PROTECTED] wrote: Dear all, I would need a function which convert small letter into capital letter (at least the first letter of a character variable). Does such a function exist in R ? Thanks by advance Jessica See ?toupper and take note of the examples therein. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bootstrap sampling for repeated measures
Dear R users, I'm having some problems trying to create a routine for a bootstrap resampling issue. Suppose I've got a dataset like this: Header inr inf .weeks ... insideaboveunder 12800012.75 2.5 ..0 10 0 12800013.48 2.5 ..1 01 0 . . . . . . i.e. a dataset with n subjects identified by the column header, with a set of repeated mesaures. The amount of repeated measures for each subject is 57, with a few of them being more or lesse frequent. That is, generalizing, that I haven't got the same number of observations for each patient. I've created a function allowing me to to reorder, subsetting and calculate some statistics over this dataset, but now I need to bootstrap it all. I was looking for a routine in R that could resample longitudinal data, in order to resample on the ID of the subjects. This means that while resampling (suppose m samples of n length) I wish to consider (better with replacement) either none or all of the observations related to a subject. So, if my bootstrap 1st sample takes the patient with header 1280001, I want the routine to consider all of the observations related with a subject with such a header. Thus, I shall obtain a bootstrap sample of my original dataset to wich apply the function cited before (whose only argument is the dataset). Can anybody help me? I'm trying to understand how the rm.boot function from Hmisc package resamples this way, but it's not that easy, so if anyone could help me I'd be very grateful. Thanks in advance Niccolò [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] step in Sweave
Dear peRsons, I have a Sweave document which demonstrates the usage of step() function. With current R version 2.5.0 the step() function was changed so that the heading of trace=TRUE output for each model is printed using command message(): if (trace) message(\nStep: AIC=, format(round(bAIC, 2)), \n, cut.string(deparse(as.vector(formula(fit, \n) And the actual models concerned with true blue print(): if (trace) print(aod[o, ]) The problem here is that these parts go to different places: message() prints on the terminal where you run Sweave (or to stderr()), and print() prints to the result file (like it should do). Therefore the result file is without the step header, and looks bad. I believe there must be a way of getting all output to the result file, but I haven't yet found that way. Can anybody here show me the light. I had a similar problem when sink()ing the output to a file, but there I could find a solution (clumsy, but a solution: you need to double your sink()s). An optimal solution would be to change the function back to the old behaviour where all trace output is printed without message(). I bet that won't happen, though. Cheers, Jari Oksanen -- Jari Oksanen [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] textConnection
hello, I don't understand what's happen just before the textConnection function runs good but now it doesn't run Line[1] [1] if C325=. then C743=(C152/C103)*100| else C743=(C152/C325)*100 textConnection(Line[1]) Erreur dans textConnection(Line[1]) : toutes les connexions sont utilisées why R display that? _ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] textConnection
It means what it says. You do need to close() connections, as there is a finite number available. (The number depends on your unstated version of R, but is at least 50.) On Tue, 15 May 2007, elyakhlifi mustapha wrote: hello, I don't understand what's happen just before the textConnection function runs good but now it doesn't run Line[1] [1] if C325=. then C743=(C152/C103)*100| else C743=(C152/C325)*100 textConnection(Line[1]) Erreur dans textConnection(Line[1]) : toutes les connexions sont utilisées why R display that? _ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail [[alternative HTML version deleted]] -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] sliding window approach
Dear all, I would like to know if there is any R package that uses a sliding window approach to assess statistical significance out of my data. My data is composed of DNA sequences (of variable length) that are mapped to a genome with a determined score of alignment. So, I want to see if I can find more tags in a given region of the genome as opposed to finding them by chance. In this sliding window I would like to be able to calculate a p-value for the amount of tags found, compared to the number of tags I would expect to find by chance. P.S. If you know, please recommend other tools that I could use for graphical assessment of p-values from this sliding window approach. Best regards João Fadista Ph.d. student UNIVERSITY OF AARHUS Faculty of Agricultural Sciences Dept. of Genetics and Biotechnology Blichers Allé 20, P.O. BOX 50 DK-8830 Tjele Phone: +45 8999 1900 Direct: +45 8999 1900 E-mail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Web: www.agrsci.org http://www.agrsci.org/ News and news media http://www.agrsci.org/navigation/nyheder_og_presse . This email may contain information that is confidential. Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed. If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] space in R
hello, can you help me I need to seperate words and symbol in a mathematics formula as follow C744=(C627*C177)/100 How could I do please? _ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] space in R
elyakhlifi mustapha wrote: hello, can you help me I need to seperate words and symbol in a mathematics formula as follow C744=(C627*C177)/100 How could I do please? If you need to simply split a character vector, use strsplit. This and previous your posts suggest you need to create a parser. parse can do that. However, R doesn't seem to me an appropriate tool for the lexical analysis. bison and yacc could be the right choise. -- View this message in context: http://www.nabble.com/space-in-R-tf3757462.html#a10620039 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bootstrap sampling for repeated measures
Dear R users, I'm having some problems trying to create a routine for a bootstrap resampling issue. Suppose I've got a dataset like this: Header inr weeks . 12800012.47 0 ... 12800011.48 1 ... 12800012.23 . 2 .. 1280369 2.5 ... 56 i.e. a dataset with n subjects identified by the column header, with a set of repeated mesaures. The amount of repeated measures for each subject is 57, with a few of them being more or lesse frequent. That is, generalizing, that I haven't got the same number of observations for each patient. I've created a function allowing me to to reorder, subsetting and calculate some statistics over this dataset, but now I need to bootstrap it all. I was looking for a routine in R that could resample longitudinal data, in order to resample on the ID of the subjects. This means that while resampling (suppose m samples of n length) I wish to consider (better with replacement) either none or all of the observations related to a subject. So, if my bootstrap 1st sample takes the patient with header 1280001, I want the routine to consider all of the observations related with a subject with such a header. Thus, I shall obtain a bootstrap sample of my original dataset to wich apply the function cited before (whose only argument is the dataset). Can anybody help me? I'm trying to understand how the rm.boot function from Hmisc package resamples this way, but it's not that easy, so if anyone could help me I'd be very grateful. Thanks in advance Niccolò [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] qr.solve and lm (addition)
Vladimir Eremeev wrote: Dear R experts, I have a Matlab code which I am translating to R in order to examine and enhance it. First of all, I need to reproduce in R the results which were already obtained in Matlab (to make sure that everything is correct). There are some matrix manipulations and '\' operation among them in the code. I have the following data frame ABS.df Prosyn unk Chl Y NhV1 1 0.056524968 0.04387755 -0.073925372 0.026477146 0.083527021 0.0031950622 0.02164793 2 0.066456284 0.05992579 -0.094609497 0.031772575 0.054881164 0.0022078221 0.01358594 3 0.036383887 0.04601113 -0.061213302 0.021181717 0.026713530 0.0011716424 0.00824816 4 0.020419528 0.03803340 -0.044517584 0.013935340 0.019204991 0.0008763467 0.00577604 5 0.010209764 0.02968460 -0.030418334 0.009476031 0.013806924 0.0006554761 0.00376991 6 0.006033043 0.02666976 -0.025735131 0.006967670 0.009778344 0.0004838437 0.00441753 7 0.004733618 0.01168831 -0.009732966 0.006688963 0.002351775 0.0001380701 0.00403229 8 0.0 0. 0.0 0.0 0.0 0.00 -0.00060456 9 0.0 0. 0.0 0.0 0.0 0.00 -0.0003 11 0.241505077 0.45843930 -0.611308847 0.0 0.0 0.0584138174 0.07397018 21 0.226065730 0.41703452 -0.558270870 0.0 0.0 0.0516895121 0.07460447 31 0.211956969 0.37139373 -0.495174662 0.0 0.0 0.0426347324 0.07189945 41 0.206558807 0.35022863 -0.466337208 0.0 0.0 0.0392775042 0.06943217 51 0.197535970 0.33100673 -0.441656561 0.0 0.0 0.0363102112 0.06912282 61 0.186798904 0.31656506 -0.416287992 0.0 0.0 0.0335613531 0.06595377 71 0.156005203 0.24868275 -0.329660100 0.0 0.0 0.0250152915 0.06399879 81 0.153751864 0.23900952 -0.324902567 0.0 0.0 0.0232553862 0.05981515 91 0.144414605 0.22782217 -0.297243170 0.0 0.0 0.0209515025 0.05981442 qr.solve(ABS.df[,1:6],ABS.df[,7]) ProsynunkChl Y Nh 0.3877544 0.4282277 0.2221960 -0.8668715 0.2821082 -1.3696411 This reproduces the Matlab's numbers However, I used to lm, its syntax seems to me more clear. ?lm says that it uses QR decomposition to fit the model. Trying it: coef(lm(V1~Pro+syn+unk+Chl+Y+Nh,data=ABS.df)) (Intercept) Pro syn unk Chl Y Nh 0.001640184 0.417253116 0.351472810 0.196977369 -0.899729874 0.265585292 -1.181526491 Numbers differ. Obviously, I don't understand something. Please, could you clarify, what? Thank you. Moreover, coef(lm.fit(x=as.matrix(ABS.df[,1:6]),y=as.matrix(ABS.df[,7]))) ProsynunkChl Y Nh 0.3877544 0.4282277 0.2221960 -0.8668715 0.2821082 -1.3696411 -- View this message in context: http://www.nabble.com/qr.solve-and-lm-tf3757650.html#a10620477 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] qr.solve and lm (SOLVED)
Vladimir Eremeev wrote: Dear R experts, I have a Matlab code which I am translating to R in order to examine and enhance it. First of all, I need to reproduce in R the results which were already obtained in Matlab (to make sure that everything is correct). There are some matrix manipulations and '\' operation among them in the code. I have the following data frame ABS.df Prosyn unk Chl Y NhV1 [skip] qr.solve(ABS.df[,1:6],ABS.df[,7]) ProsynunkChl Y Nh 0.3877544 0.4282277 0.2221960 -0.8668715 0.2821082 -1.3696411 This reproduces the Matlab's numbers However, I used to lm, its syntax seems to me more clear. ?lm says that it uses QR decomposition to fit the model. Trying it: coef(lm(V1~Pro+syn+unk+Chl+Y+Nh,data=ABS.df)) (Intercept) Pro syn unk Chl Y Nh 0.001640184 0.417253116 0.351472810 0.196977369 -0.899729874 0.265585292 -1.181526491 Numbers differ. Obviously, I don't understand something. Please, could you clarify, what? Thank you. This was because of implied intercept term. lm(V1~Pro+syn+unk+Chl+Y+Nh+0,data=ABS.df) Call: lm(formula = V1 ~ Pro + syn + unk + Chl + Y + Nh + 0, data = ABS.df) Coefficients: Pro syn unk ChlY Nh 0.3878 0.4282 0. -0.8669 0.2821 -1.3696 That is, reproduces earlier results. -- View this message in context: http://www.nabble.com/qr.solve-and-lm-tf3757650.html#a10620691 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] New mailing list: R for psychology research
2007/5/14, Andy Fugard [EMAIL PROTECTED]: Hello all, There's a new mailing list for researchers in psychology who are learning and using R. New users of R are especially welcome. Hi List Does anyone know if there is a special list for researchers in medicine using R? -- A. Goralczyk, M.D. Dept. of General Surgery University of Göttingen Göttingen, Germany __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] space in R
1. Use this gsub: txt - C744=(C627*C177)/100 gsub(\\b|([^[:alnum:]]), \\1 , txt) and then strsplit or scan as in prior response. 2. If your text consists of valid R expressions then we can use the R parse function can traverse the tree as shown: txt - C744=(C627*C177)/100 e - parse(text = txt) my.print - function(e) { L - as.list(e) if (length(L) == 0) return(invisible()) if (length(L) == 1) print(L[[1]]) else sapply(L, my.print) return(invisible()) } my.print(e[[1]]) There is a parser for a portion of R in the Ryacas package you could look at. On 5/15/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote: hello, can you help me I need to seperate words and symbol in a mathematics formula as follow C744=(C627*C177)/100 How could I do please? _ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Efficient computation of trimmed stats?
the following seems a bit better: set.seed(1) nc - 30 nr - 25000 x - matrix(rnorm(nc*nr), ncol = nc) g - matrix(sample(1:3, nr*nc, rep = TRUE), ncol = nc) # trimmedMeanByGroup1 - function(y, grp, trim=.05) tapply(y, factor(grp, levels=1:3), mean, trim=trim) trimmedMeanByGroup2 - function(y, grp, trim = .05){ unlist(lapply(split(y, grp), mean, trim = trim)) } out1 - out2 - matrix(0, nr, 3) system.time(for(i in 1:nr) out1[i, ] - trimmedMeanByGroup1(x[i, ], g[i, ])) system.time(for(i in 1:nr) out2[i, ] - trimmedMeanByGroup2(x[i, ], g[i, ])) all.equal(out1, out2) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student 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: Benilton Carvalho [EMAIL PROTECTED] To: [EMAIL PROTECTED] server posting r-help@stat.math.ethz.ch Sent: Monday, May 14, 2007 6:58 PM Subject: [R] Efficient computation of trimmed stats? Hi everyone, I was wondering if there is anything already implemented for efficient (row-wise) computation of group-specific trimmed stats (mean and sd on the trimmed vector) on large matrices. For example: set.seed(1) nc = 300 nr = 25 x = matrix(rnorm(nc*nr), ncol=nc) g = matrix(sample(1:3, nr*nc, rep=T), ncol=nc) trimmedMeanByGroup - function(y, grp, trim=.05) tapply(y, factor(grp, levels=1:3), mean, trim=trim) sapply(1:10, function(i) trimmedMeanByGroup(x[i,], g[i,])) works fine... but: system.time(sapply(1:nr, function(i) trimmedMeanByGroup(x[i,], g [i,]))) user system elapsed 399.928 0.019 399.988 does not look interesting for me. Maybe some package has some implementation of the above? Thank you very much, -b -- Benilton Carvalho PhD Candidate Department of Biostatistics Bloomberg School of Public Health Johns Hopkins University [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Matrix package: writeMM
Hi, I'm finding that readMM() cannot read a file written with writeMM(). Example: library(Matrix) a = Matrix(c(1,0,3,0,0,5), 10, 10) a = as(a, CsparseMatrix) writeMM(a, kk.mm) b = readMM(kk.mm) Error in validObject(.Object) : invalid class dgTMatrix object: all row indices must be between 0 and nrow-1 Thoughts? Thanks, -Jose -- Jose Quesada, PhD. http://www.andrew.cmu.edu/~jquesada __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] aov problem
I am using R to make two-way ANOVA on a number of variables using g - aov(var ~ fact1*fact2) where var is a matrix containing the variables. However the outcome seem to be dependent on the order of fact1 and fact2 (i.e. fact2*fact1) gives a slightly (factor of 1.5) different result. Any ideas why this is? Thanks for any help Anders __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] QR Decompositon and qr.qty
Dear R people, I do not have much knowledge about linear algebra but currently I need to understand what the function qr.qty is actually doing. The documentation states that it calculates t(Q) %*% y via a previously performed QR matrix decomposition. In order to do that, I tried following basic example: m-matrix(c(1,0,0,0,1,0,0,0,1,0,0,1),ncol=3) # 4x3 matrix qr.qty(qr(m),matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4)) [,1] [,2] [,3] [,4] [1,] -1 -2 -1 -2 [2,] -4 -5 -1 -2 [3,]3412 [4,] -2 -3 -1 -2 As far as I understood the documentation a call such as t(qr.Q(qr(m)))%*%matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4) should produce the same result, but this produces a 3 by 4 rather than a four by four matrix as t(qr.Q(qr(m))) has only three rows. [,1] [,2] [,3] [,4] [1,] -1 -2 -1 -2 [2,] -4 -5 -1 -2 [3,]3412 So the last line is missing. Any hints how R adds the last line would be appreciated. Regards, Sebastian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] aov problem
Anders Malmendal wrote: I am using R to make two-way ANOVA on a number of variables using g - aov(var ~ fact1*fact2) where var is a matrix containing the variables. However the outcome seem to be dependent on the order of fact1 and fact2 (i.e. fact2*fact1) gives a slightly (factor of 1.5) different result. Any ideas why this is? RSiteSearch(sequential sums of squares) Thanks for any help Anders __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] QR Decompositon and qr.qty
You need complete = TRUE. See ?qr.Q m - matrix(c(1,0,0,0,1,0,0,0,1,0,0,1), ncol = 3) y - matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2), nrow = 4) t(qr.Q(qr(m), complete = TRUE)) %*% y [,1] [,2] [,3] [,4] [1,] -1 -2 -1 -2 [2,] -4 -5 -1 -2 [3,]3412 [4,] -2 -3 -1 -2 qr.qty(qr(m), y) [,1] [,2] [,3] [,4] [1,] -1 -2 -1 -2 [2,] -4 -5 -1 -2 [3,]3412 [4,] -2 -3 -1 -2 On 5/15/07, Sebastian Bauer [EMAIL PROTECTED] wrote: Dear R people, I do not have much knowledge about linear algebra but currently I need to understand what the function qr.qty is actually doing. The documentation states that it calculates t(Q) %*% y via a previously performed QR matrix decomposition. In order to do that, I tried following basic example: m-matrix(c(1,0,0,0,1,0,0,0,1,0,0,1),ncol=3) # 4x3 matrix qr.qty(qr(m),matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4)) [,1] [,2] [,3] [,4] [1,] -1 -2 -1 -2 [2,] -4 -5 -1 -2 [3,]3412 [4,] -2 -3 -1 -2 As far as I understood the documentation a call such as t(qr.Q(qr(m)))%*%matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4) should produce the same result, but this produces a 3 by 4 rather than a four by four matrix as t(qr.Q(qr(m))) has only three rows. [,1] [,2] [,3] [,4] [1,] -1 -2 -1 -2 [2,] -4 -5 -1 -2 [3,]3412 So the last line is missing. Any hints how R adds the last line would be appreciated. Regards, Sebastian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] QR Decompositon and qr.qty
You've missed the complete=TRUE argument (and also crossprod) as in crossprod(qr.Q(qr(m), TRUE), matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4)) On Tue, 15 May 2007, Sebastian Bauer wrote: Dear R people, I do not have much knowledge about linear algebra but currently I need to understand what the function qr.qty is actually doing. The documentation states that it calculates t(Q) %*% y via a previously performed QR matrix decomposition. In order to do that, I tried following basic example: m-matrix(c(1,0,0,0,1,0,0,0,1,0,0,1),ncol=3) # 4x3 matrix qr.qty(qr(m),matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4)) [,1] [,2] [,3] [,4] [1,] -1 -2 -1 -2 [2,] -4 -5 -1 -2 [3,]3412 [4,] -2 -3 -1 -2 As far as I understood the documentation a call such as t(qr.Q(qr(m)))%*%matrix(c(1,2,3,4,2,3,4,5,1,1,1,1,2,2,2,2),nrow=4) should produce the same result, but this produces a 3 by 4 rather than a four by four matrix as t(qr.Q(qr(m))) has only three rows. [,1] [,2] [,3] [,4] [1,] -1 -2 -1 -2 [2,] -4 -5 -1 -2 [3,]3412 So the last line is missing. Any hints how R adds the last line would be appreciated. Regards, Sebastian __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Re : Bootstrap sampling for repeated measures
Hi, If it was me I would have done this - First reshape the data frame to get some thing like header measure1 measure3 measure3 12800012.471.482.23 ... Since you have same number of measure for all subject. The you define you statistic with the data frame in this form. and you can use the boot function in boot or Hmisc bootstrap function. Justin BEM Elève Ingénieur Statisticien Economiste BP 294 Yaoundé. Tél (00237)9597295. - Message d'origine De : Niccolò Bassani [EMAIL PROTECTED] À : r-help@stat.math.ethz.ch Envoyé le : Mardi, 15 Mai 2007, 11h15mn 51s Objet : [R] Bootstrap sampling for repeated measures Dear R users, I'm having some problems trying to create a routine for a bootstrap resampling issue. Suppose I've got a dataset like this: Header inr weeks . 12800012.47 0 ... 12800011.48 1 ... 12800012.23 . 2 .. 1280369 2.5 ... 56 i.e. a dataset with n subjects identified by the column header, with a set of repeated mesaures. The amount of repeated measures for each subject is 57, with a few of them being more or lesse frequent. That is, generalizing, that I haven't got the same number of observations for each patient. I've created a function allowing me to to reorder, subsetting and calculate some statistics over this dataset, but now I need to bootstrap it all. I was looking for a routine in R that could resample longitudinal data, in order to resample on the ID of the subjects. This means that while resampling (suppose m samples of n length) I wish to consider (better with replacement) either none or all of the observations related to a subject. So, if my bootstrap 1st sample takes the patient with header 1280001, I want the routine to consider all of the observations related with a subject with such a header. Thus, I shall obtain a bootstrap sample of my original dataset to wich apply the function cited before (whose only argument is the dataset). Can anybody help me? I'm trying to understand how the rm.boot function from Hmisc package resamples this way, but it's not that easy, so if anyone could help me I'd be very grateful. Thanks in advance Niccolò [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] * within quote
hello, I have an argument of a the list a like this a[[18]] [1] C744=(C627*C177)/100 and I wanna seperate the character and the mathematics symbol to use it like a formula and why when I used the strsplit function i obtain as follow strsplit(a[[18]], '\\W') [[1]] [1] C744 C627 C177 100 and as follow strsplit(a[[18]], '\\w') [[1]] [1] =( * )/ I don't understand why the star * doesn't create space between C627 and C177 _ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Conditional Sums for Index creation
All, Happy to say that the problem could be solved. The key idea was from Patrick Burns (Convert the data-frame to a matrix!). As written earlier, the steps were to first get a object (call it ad) containing the non-missing entries at each row. Then run a sum over each row, selecting only those columns that are pointed to in the object ad. Another quick step was to use the fact that if there's an NA in any column (after a stock has entered the portfolio), then we could use the previous value just as well (e.g., the market cap of a stock). So na.locf was a big help! Just providing the code here for illustration purposes: set.seed(1) ab - matrix(round(runif(100)*100),nrow=20,ncol=5) ab[1:5,4:5] - NA ab[6:10,5] - NA ac - as.data.frame(ifelse(ab = 7,NA,ab)) ac V1 V2 V3 V4 V5 1 27 93 82 NA NA 2 37 21 65 NA NA 3 57 65 78 NA NA 4 91 13 55 NA NA 5 20 27 53 NA NA 6 90 39 79 26 NA 7 94 NA NA 48 NA 8 66 38 48 77 NA 9 63 87 73 8 NA 10 NA 34 69 88 NA 11 21 48 48 34 24 12 18 60 86 84 NA 13 69 49 44 35 64 14 38 19 24 33 88 15 77 83 NA 48 78 16 50 67 10 89 80 17 72 79 32 86 46 18 99 11 52 39 41 19 38 72 66 78 81 20 78 41 41 96 60 # - # Indexes of all the non-missing in all the rows ad - apply(ac,1,function(y)which(!is.na(y))) af - data.matrix(na.locf(ac,na.rm=FALSE)) # Include another column as placeholder ag - cbind(af,rep(1,nrow(af))) # Call it, sumCorr. colnames(ag)[6] - sumCorr ag[1,6] - sum(ag[1,],na.rm=TRUE) for (r in 2:nrow(ag)){ + sumCorr - unlist(sum(ag[r,unlist(ad[r-1])],na.rm=TRUE)) + ag[r,6] - sumCorr + } ag V1 V2 V3 V4 V5 sumCorr 1 27 93 82 NA NA 203 2 37 21 65 NA NA 123 3 57 65 78 NA NA 200 4 91 13 55 NA NA 159 5 20 27 53 NA NA 100 6 90 39 79 26 NA 208 7 94 39 79 48 NA 260 8 66 38 48 77 NA 143 9 63 87 73 8 NA 231 10 63 34 69 88 NA 254 11 21 48 48 34 24 130 12 18 60 86 84 24 272 13 69 49 44 35 64 197 14 38 19 24 33 88 202 15 77 83 24 48 78 310 16 50 67 10 89 80 286 17 72 79 32 86 46 315 18 99 11 52 39 41 242 19 38 72 66 78 81 335 20 78 41 41 96 60 316 Gaurav, Anything to not implement a double for-loop! :) With the implementation, I was able to generate my index at last. Perhaps it's because I'm quite new with R, but I find it quite arcane sometimes! :) best, -Tir Tirthankar Patnaik India Strategy Citigroup Investment Research +91-22-6631 9887 _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, May 14, 2007 6:29 PM To: Patnaik, Tirthankar [GWM-CIR] Cc: r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: Re: [R] Conditional Sums for Index creation Hi Tirthankar this will help you ind is a matrix which indicates the start of any new stock. ind[i,j] means that in j + 1 column all the values from 1st row to i - 1 row are all NAs. x V2 V3 V4 V5 V6 [1,] 27 93 82 NA NA [2,] 37 21 65 NA NA [3,] 57 65 78 NA NA [4,] 91 13 55 NA NA [5,] 20 27 53 NA NA [6,] 90 39 79 26 NA [7,] 94 NA NA 48 NA [8,] 66 38 48 77 NA [9,] 63 87 73 8 NA [10,] NA 34 69 88 NA [11,] 21 48 48 34 24 [12,] 18 60 86 84 NA [13,] 69 49 44 35 64 [14,] 38 19 24 33 88 [15,] 77 83 NA 48 78 [16,] 50 67 10 89 80 [17,] 72 79 32 86 46 [18,] 99 11 52 39 41 [19,] 38 72 66 78 81 [20,] 78 41 41 96 60 for ( j in 1:length(x[1,]) - 1) { + for ( i in 2:length(x[,1])) { + indicator-TRUE + for (k in 1: i - 1){ + indicator - indicator is.na(x[k,j+1]) + } + ind[i,j]-indicator + + } + } ind V2 V3 V4 V5 V6 [1,] NA NA NA NA NA [2,] 0 0 NA NA 0 [3,] 0 0 NA NA 0 [4,] 0 0 NA NA 0 [5,] 0 0 NA NA 0 [6,] 0 0 NA NA 0 [7,] 0 0 0 NA 0 [8,] 0 0 0 NA 0 [9,] 0 0 0 NA 0 [10,] 0 0 0 NA 0 [11,] 0 0 0 NA 0 [12,] 0 0 0 0 0 [13,] 0 0 0 0 0 [14,] 0 0 0 0 0 [15,] 0 0 0 0 0 [16,] 0 0 0 0 0 [17,] 0 0 0 0 0 [18,] 0 0 0 0 0 [19,] 0 0 0 0 0 [20,] 0 0 0 0 0 Regards, Gaurav Yadav +++ Assistant Manager, CCIL, Mumbai (India) Mob: +919821286118 Email: [EMAIL PROTECTED] Bhagavad Gita: Man is made by his Belief, as He believes, so He is Patnaik, Tirthankar [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 05/14/2007 11:53 AM To r-help@stat.math.ethz.ch cc Subject [R] Conditional Sums for Index creation Hi, Apologies for the long mail. I have a data.frame with columns of price/mcap data for a portfolio of stocks, and the date. To get the total value of the portfolio on a daily basis, I calculate rowSums of the data.frame. set.seed(1) ab - matrix(round(runif(100)*100),nrow=20,ncol=5) ab[1:5,4:5] - NA ab[6:10,5] - NA ac - as.data.frame(ifelse(ab = 7,NA,ab)) ac V1 V2 V3 V4 V5 1 27 93 82 NA NA 2 37 21 65 NA NA 3 57 65 78 NA NA 4 91 13 55 NA NA 5 20 27 53 NA NA 6 90 39 79 26 NA 7 94 NA NA 48 NA 8 66 38 48 77 NA 9 63 87 73 8 NA 10 NA 34 69 88
[R] Problem with lme4
Hi - I'm having a problem trying to use the function GLMM() from lme4. Here is what happens: library(lme4) Loading required package: Matrix Loading required package: lattice f1 - GLMM(success~yearF, data=quality, random=~1|bandnumb, family=binomial, method=PQL) Error: couldn't find function GLMM I remember having used lme4 before, without any problem. Can someone help me understanding what is wrong? I'm using R 2.2.1, could that be a problem? I also tried installing lme4 again, and updating the package, with no success. Thanks for your help, Amelie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Conditional Sums for Index creation
Sending in plain text, as the html version doesn't seem to go through.. Best, -Tir From: Patnaik, Tirthankar [GWM-CIR] Sent: Tuesday, May 15, 2007 2:55 PM To: '[EMAIL PROTECTED]' Cc: r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: RE: [R] Conditional Sums for Index creation All, Happy to say that the problem could be solved. The key idea was from Patrick Burns (Convert the data-frame to a matrix!). As written earlier, the steps were to first get a object (call it ad) containing the non-missing entries at each row. Then run a sum over each row, selecting only those columns that are pointed to in the object ad. Another quick step was to use the fact that if there's an NA in any column (after a stock has entered the portfolio), then we could use the previous value just as well (e.g., the market cap of a stock). So na.locf was a big help! Just providing the code here for illustration purposes: set.seed(1) ab - matrix(round(runif(100)*100),nrow=20,ncol=5) ab[1:5,4:5] - NA ab[6:10,5] - NA ac - as.data.frame(ifelse(ab = 7,NA,ab)) ac V1 V2 V3 V4 V5 1 27 93 82 NA NA 2 37 21 65 NA NA 3 57 65 78 NA NA 4 91 13 55 NA NA 5 20 27 53 NA NA 6 90 39 79 26 NA 7 94 NA NA 48 NA 8 66 38 48 77 NA 9 63 87 73 8 NA 10 NA 34 69 88 NA 11 21 48 48 34 24 12 18 60 86 84 NA 13 69 49 44 35 64 14 38 19 24 33 88 15 77 83 NA 48 78 16 50 67 10 89 80 17 72 79 32 86 46 18 99 11 52 39 41 19 38 72 66 78 81 20 78 41 41 96 60 # - # Indexes of all the non-missing in all the rows ad - apply(ac,1,function(y)which(!is.na(y))) af - data.matrix(na.locf(ac,na.rm=FALSE)) # Include another column as placeholder ag - cbind(af,rep(1,nrow(af))) # Call it, sumCorr. colnames(ag)[6] - sumCorr ag[1,6] - sum(ag[1,],na.rm=TRUE) for (r in 2:nrow(ag)){ + sumCorr - unlist(sum(ag[r,unlist(ad[r-1])],na.rm=TRUE)) + ag[r,6] - sumCorr + } ag V1 V2 V3 V4 V5 sumCorr 1 27 93 82 NA NA 203 2 37 21 65 NA NA 123 3 57 65 78 NA NA 200 4 91 13 55 NA NA 159 5 20 27 53 NA NA 100 6 90 39 79 26 NA 208 7 94 39 79 48 NA 260 8 66 38 48 77 NA 143 9 63 87 73 8 NA 231 10 63 34 69 88 NA 254 11 21 48 48 34 24 130 12 18 60 86 84 24 272 13 69 49 44 35 64 197 14 38 19 24 33 88 202 15 77 83 24 48 78 310 16 50 67 10 89 80 286 17 72 79 32 86 46 315 18 99 11 52 39 41 242 19 38 72 66 78 81 335 20 78 41 41 96 60 316 Gaurav, Anything to not implement a double for-loop! :) With the implementation, I was able to generate my index at last. Perhaps it's because I'm quite new with R, but I find it quite arcane sometimes! :) best, -Tir Tirthankar Patnaik India Strategy Citigroup Investment Research +91-22-6631 9887 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, May 14, 2007 6:29 PM To: Patnaik, Tirthankar [GWM-CIR] Cc: r-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: Re: [R] Conditional Sums for Index creation Hi Tirthankar this will help you ind is a matrix which indicates the start of any new stock. ind[i,j] means that in j + 1 column all the values from 1st row to i - 1 row are all NAs. x V2 V3 V4 V5 V6 [1,] 27 93 82 NA NA [2,] 37 21 65 NA NA [3,] 57 65 78 NA NA [4,] 91 13 55 NA NA [5,] 20 27 53 NA NA [6,] 90 39 79 26 NA [7,] 94 NA NA 48 NA [8,] 66 38 48 77 NA [9,] 63 87 73 8 NA [10,] NA 34 69 88 NA [11,] 21 48 48 34 24 [12,] 18 60 86 84 NA [13,] 69 49 44 35 64 [14,] 38 19 24 33 88 [15,] 77 83 NA 48 78 [16,] 50 67 10 89 80 [17,] 72 79 32 86 46 [18,] 99 11 52 39 41 [19,] 38 72 66 78 81 [20,] 78 41 41 96 60 for ( j in 1:length(x[1,]) - 1) { + for ( i in 2:length(x[,1])) { + indicator-TRUE + for (k in 1: i - 1){ + indicator - indicator is.na(x[k,j+1]) + } + ind[i,j]-indicator + + } + } ind V2 V3 V4 V5 V6 [1,] NA NA NA NA NA [2,] 0 0 NA NA 0 [3,] 0 0 NA NA 0 [4,] 0 0 NA NA 0 [5,] 0 0 NA NA 0 [6,] 0 0 NA NA 0 [7,] 0 0 0 NA 0 [8,] 0 0 0 NA 0 [9,] 0 0 0 NA 0 [10,] 0 0 0 NA 0 [11,] 0 0 0 NA 0 [12,] 0 0 0 0 0 [13,] 0 0 0 0 0 [14,] 0 0 0 0 0 [15,] 0 0 0 0 0 [16,] 0 0 0 0 0 [17,] 0 0 0 0 0 [18,] 0 0 0 0 0 [19,] 0 0 0 0 0 [20,] 0 0 0 0 0 Regards, Gaurav Yadav +++ Assistant Manager, CCIL, Mumbai (India) Mob: +919821286118 Email: [EMAIL PROTECTED] Bhagavad Gita: Man is made by his Belief, as He believes, so He is Patnaik, Tirthankar [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 05/14/2007 11:53 AM To r-help@stat.math.ethz.ch cc Subject [R] Conditional Sums for Index creation Hi, Apologies for the long mail. I have a data.frame with columns of price/mcap data for a portfolio of stocks, and the date. To get the total value of the portfolio on a daily
Re: [R] * within quote
On 5/15/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote: hello, I have an argument of a the list a like this a[[18]] [1] C744=(C627*C177)/100 and I wanna seperate the character and the mathematics symbol to use it like a formula and why when I used the strsplit function i obtain as follow strsplit(a[[18]], '\\W') [[1]] [1] C744 C627 C177 100 and as follow strsplit(a[[18]], '\\w') [[1]] [1] =( * )/ I don't understand why the star * doesn't create space between C627 and C177 You can see what is going on by doing this: txt - C744=(C627*C177)/100 gsub((\\w), [\\1], txt) [1] [C][7][4][4]=([C][6][2][7]*[C][1][7][7])/[1][0][0] gsub((\\W), [\\1], txt) [1] [ ]C744[=][(]C627[*]C177[)][/]100 The portions within [...] are the separators and everything else is output as content separated by those separators. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem with lme4
the lme4 function you want is probably lmer() type ?lmer btw. your R is very old we are at 2.5.0 ... Stefan Amelie LESCROEL wrote: Hi - I'm having a problem trying to use the function GLMM() from lme4. Here is what happens: library(lme4) Loading required package: Matrix Loading required package: lattice f1 - GLMM(success~yearF, data=quality, random=~1|bandnumb, family=binomial, method=PQL) Error: couldn't find function GLMM I remember having used lme4 before, without any problem. Can someone help me understanding what is wrong? I'm using R 2.2.1, could that be a problem? I also tried installing lme4 again, and updating the package, with no success. Thanks for your help, Amelie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists(x) it says that x exists even if y does not. If I had a separate argument to hold the text string y then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a separate argument? Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Anova Test
Hi, I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 The inference is at alpha=0.05. they are all independent. I am trying to find if they differ or the same. test1-c(20) test2-c(25) test3-c(15) test4-c(17) test4-c(10) control-c(17) tester-data.frame(test1,test2,test3,test4,control) tester test1 test2 test3 test4 control 120251510 17 anova(lm(tester)) Analysis of Variance Table Response: test1 Df Sum Sq Mean Sq F value Pr(F) Residuals 0 0 I think i did something wrong. I need to find the correct F statistic test. any help. thanks. -- View this message in context: http://www.nabble.com/Anova-Test-tf3758829.html#a10624007 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] apologies for any corss-posting R package for conjoint choice questionnaire design (not analysis)????
Hi all, I want to develop a choice based questionnaire and I need to generate a set of choice tasks The design is comprised of four attributes (5*3*3*3) with the following 5price 3brand 3service 3installation I need to determine the minimum no of choice tasks which can be used to estimate main effects for each attribute and then actually generate these choice tasks to be included in the survey SPSS has orthoplan but only generates these tasks for a traditional conjoint design, not for conjoint based choice tasks A partial factorial design is what I had in mind . Is there a package to be able to do this in R? Many thanks Paul __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Anova Test
CrazyJoe keizer_61 at hotmail.com writes: I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 You can't make any inferences with the data you have here. You need to have multiple observations per treatment! See the examples for ?lm . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: Anova Test
Hi [EMAIL PROTECTED] napsal dne 15.05.2007 16:39:20: Hi, I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 The inference is at alpha=0.05. they are all independent. I am trying to find if they differ or the same. Maybe t.test? x - c(20,25,15,10) t.test(x-17) One Sample t-test data: x - 17 t = 0.1549, df = 3, p-value = 0.8867 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: -9.771301 10.771301 sample estimates: mean of x 0.5 Regards Petr test1-c(20) test2-c(25) test3-c(15) test4-c(17) test4-c(10) control-c(17) tester-data.frame(test1,test2,test3,test4,control) tester test1 test2 test3 test4 control 120251510 17 anova(lm(tester)) Analysis of Variance Table Response: test1 Df Sum Sq Mean Sq F value Pr(F) Residuals 0 0 I think i did something wrong. I need to find the correct F statistic test. any help. thanks. -- View this message in context: http://www.nabble.com/Anova-Test-tf3758829.html#a10624007 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function [Broadcast]
Not sure which one you want, but the following should cover it: R f - function(x) c(x=missing(x), y=exists(y)) R f(1) x y FALSE FALSE R f() x y TRUE FALSE R y - 1 R f() xy TRUE TRUE R f(1) x y FALSE TRUE Andy From: Talbot Katz Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists(x) it says that x exists even if y does not. If I had a separate argument to hold the text string y then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a separate argument? Thanks! -- TMK -- 212-460-5430 home 917-656-5351 cell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function [Broadcast]
Hi, Andy. Thank you for the quick response! Unfortunately, none of these are exactly what I'm looking for. I'm looking for the following: Suppose object y exists and object z does not exist. If I pass y as the value of the argument to my function, I want to be able to verify, inside my function, the existence of y; similarly, if I pass z as the value of the argument, I want to be able to see, inside the function, that z doesn't exist. The missing function just checks whether the argument is missing; in my case, the argument is not missing, but the object may not exist. And the way you use the exists function inside the user-defined function doesn't test the argument to the user-defined function, it's just hard-coded for the object y. So I'm sorry if I wasn't clear before, and I hope this is clear now. Perhaps what I'm attempting to do is unavailable because it's a bad programming paradigm. But even an explanation if that's the case would be appreciated. -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function [Broadcast] Date: Tue, 15 May 2007 11:03:12 -0400 Not sure which one you want, but the following should cover it: R f - function(x) c(x=missing(x), y=exists(y)) R f(1) x y FALSE FALSE R f() x y TRUE FALSE R y - 1 R f() xy TRUE TRUE R f(1) x y FALSE TRUE Andy From: Talbot Katz Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists(x) it says that x exists even if y does not. If I had a separate argument to hold the text string y then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a separate argument? Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Notice: This e-mail message, together with any attachments...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Anova Test
Thank you Guys. Let say that from Test1 to control i have multiple data Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 . . . . . . . . . . 40 20 1535 45 Is this the method i need to use? anova(lm(..this is where i am not sure how to put them. is this something to do with anova(lm(dependent~independent*independent, data=name) if they are all independent, how do i put them together? thanks. Ben Bolker-2 wrote: CrazyJoe keizer_61 at hotmail.com writes: I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 You can't make any inferences with the data you have here. You need to have multiple observations per treatment! See the examples for ?lm . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Anova-Test-tf3758829.html#a10625154 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] xyplot key using grid.text
Hello, I am trying to print the lm coefficients using grid graphs (code below), and am getting all the coefficients on top of each other. My aim is to put them as legend, showing both coefficients and mean values separated by colors as shown in xyplot. testData - data.frame(f1 = factor(rep(LETTERS[1:5], each = 20)), f2 = factor(rep(letters[6:7], 50)), x1 = rnorm(100, mean = 2, sd = 1), x2 = rnorm(100, mean = 10, sd = 4), x3 = rnorm(100, mean = 4, sd = 3), y = (1:50) + rnorm(50, sd = 3) + rep(c(-2, 2), 50)) grid.newpage() grps - factor(testData[, f2]) xyplot( y ~ x1|f1, groups=grps, panel=function(x, y, ...) { panel.superpose(x, y, ...) }, panel.groups = function(x, y, ...) { fit.lm - lm(y~x) coef.fit - round(coef(fit.lm)[-1], 2) avg.y - round(mean(y), 2) panel.abline(fit.lm) panel.xyplot(x, y, ...) ## Add lm coefficients: grid.text(x= unit(0.1, npc), y= unit(seq(0.1, length= length(levels(grps)), by =0.1), npc), label = paste(expression(beta), =, coef.fit) ), ## Add mean values: (note that mu is not shown as symbol) grid.text(x= unit(0.1, npc), y= unit(seq(0.9, length= length(levels(grps)), by =-0.1), npc), label = paste(expression(mu), =, avg.y) ), }, ## Key key = simpleKey(levels(grps), columns = 2, space = bottom, points = TRUE, lines = TRUE ), ## grid.legend() data= testData ) Thanks. -NJ Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
Just need a bit more work: R f - function(x) exists(deparse(substitute(x))) R f(y) [1] FALSE R y - 1 R f(y) [1] TRUE R f(z) [1] FALSE Andy From: Talbot Katz Hi, Andy. Thank you for the quick response! Unfortunately, none of these are exactly what I'm looking for. I'm looking for the following: Suppose object y exists and object z does not exist. If I pass y as the value of the argument to my function, I want to be able to verify, inside my function, the existence of y; similarly, if I pass z as the value of the argument, I want to be able to see, inside the function, that z doesn't exist. The missing function just checks whether the argument is missing; in my case, the argument is not missing, but the object may not exist. And the way you use the exists function inside the user-defined function doesn't test the argument to the user-defined function, it's just hard-coded for the object y. So I'm sorry if I wasn't clear before, and I hope this is clear now. Perhaps what I'm attempting to do is unavailable because it's a bad programming paradigm. But even an explanation if that's the case would be appreciated. -- TMK -- 212-460-5430 home 917-656-5351 cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function [Broadcast] Date: Tue, 15 May 2007 11:03:12 -0400 Not sure which one you want, but the following should cover it: R f - function(x) c(x=missing(x), y=exists(y)) R f(1) x y FALSE FALSE R f() x y TRUE FALSE R y - 1 R f() xy TRUE TRUE R f(1) x y FALSE TRUE Andy From: Talbot Katz Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists(x) it says that x exists even if y does not. If I had a separate argument to hold the text string y then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a separate argument? Thanks! -- TMK -- 212-460-5430 home 917-656-5351 cell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - - Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu - direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. - - -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Anova Test
[EMAIL PROTECTED] napsal dne 15.05.2007 17:32:35: Thank you Guys. Let say that from Test1 to control i have multiple data Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 . . . . . . . . . . 40 20 1535 45 Is this the method i need to use? Better is to use stacked format. value testno 20 t1 ...t1 40 t1 25 t2 ...t2 20 t2 ... then anova(lm(value~testno, data=yourdata)) will give you anova table. However be carefull to keep testno as a factor. You could also consult some introductory literature which can be find on CRAN, especially about data manipulation and linear models. Maindonald, Verzani or Faraway is a good starting choice. Regards Petr anova(lm(..this is where i am not sure how to put them. is this something to do with anova(lm(dependent~independent*independent, data=name) if they are all independent, how do i put them together? thanks. Ben Bolker-2 wrote: CrazyJoe keizer_61 at hotmail.com writes: I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 You can't make any inferences with the data you have here. You need to have multiple observations per treatment! See the examples for ?lm . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Anova-Test-tf3758829.html#a10625154 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] stacked barplot with positive and negatvie values
Hello I'm trying to create a barplot with a couple of stacked positive values and with one negative value for each group. example: trees-c(20,30,10) shrubs-c(12,23,9) veg-c(2,3,4) soil-c(-100,-123,-89) example1-t(cbind(trees,shrubs,veg)) barplot(example1) #this works so far #but now: example2-t(cbind(trees,shrubs,veg,soil)) barplot(example2) This shows no more stacked bars. But I want to keep the bars like example1 and just add the negative values which have another scale downwards. So I tried: barplot(example1,axes=F) barplot(example2[soil,],add=T,axes=F) axis(side=2,at=c(-150,-100,-50,0,10,20,30)) But I still does not work for the axis?? I would appriciate any kind of hint Greetings Paul Magdon -- ___ BSc. Paul Magdon -Research Assistant- Institute of Forest Management Forest Assessment Remote Sensing, Forest Growth, Forest Planning Faculty of Forest Sciences and Forest Ecology Georg-August-University Göttingen Phone +49 551 39 3573 [EMAIL PROTECTED] / skype: paul.magdon __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Anova Test
If your data is inside a data.frame names 'a' with data from each group in a different columns,..., you can use stack and perform the anova with: l - aov(values~ind,data=stack(a)) anova(l) Christophe Pallier On 5/15/07, CrazyJoe [EMAIL PROTECTED] wrote: Thank you Guys. Let say that from Test1 to control i have multiple data Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 . . . . . . . . . . 40 20 1535 45 Is this the method i need to use? anova(lm(..this is where i am not sure how to put them. is this something to do with anova(lm(dependent~independent*independent, data=name) if they are all independent, how do i put them together? thanks. Ben Bolker-2 wrote: CrazyJoe keizer_61 at hotmail.com writes: I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 You can't make any inferences with the data you have here. You need to have multiple observations per treatment! See the examples for ?lm . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Anova-Test-tf3758829.html#a10625154 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Christophe Pallier (http://www.pallier.org) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re : Bootstrap sampling for repeated measures
justin bem wrote: Hi, If it was me I would have done this - First reshape the data frame to get some thing like header measure1 measure3 measure3 12800012.471.482.23 ... Since you have same number of measure for all subject. The you define you statistic with the data frame in this form. and you can use the boot function in boot or Hmisc bootstrap function. Justin BEM I don't think that's the best way to go. As in the Design package (see the predab.resample, validate, calibrate functions) and the Hmisc rm.boot function you can easily sample from subject IDs and put together the needed records. Frank Harrell Elève Ingénieur Statisticien Economiste BP 294 Yaoundé. Tél (00237)9597295. - Message d'origine De : Niccolò Bassani [EMAIL PROTECTED] À : r-help@stat.math.ethz.ch Envoyé le : Mardi, 15 Mai 2007, 11h15mn 51s Objet : [R] Bootstrap sampling for repeated measures Dear R users, I'm having some problems trying to create a routine for a bootstrap resampling issue. Suppose I've got a dataset like this: Header inr weeks . 12800012.47 0 ... 12800011.48 1 ... 12800012.23 . 2 .. 1280369 2.5 ... 56 i.e. a dataset with n subjects identified by the column header, with a set of repeated mesaures. The amount of repeated measures for each subject is 57, with a few of them being more or lesse frequent. That is, generalizing, that I haven't got the same number of observations for each patient. I've created a function allowing me to to reorder, subsetting and calculate some statistics over this dataset, but now I need to bootstrap it all. I was looking for a routine in R that could resample longitudinal data, in order to resample on the ID of the subjects. This means that while resampling (suppose m samples of n length) I wish to consider (better with replacement) either none or all of the observations related to a subject. So, if my bootstrap 1st sample takes the patient with header 1280001, I want the routine to consider all of the observations related with a subject with such a header. Thus, I shall obtain a bootstrap sample of my original dataset to wich apply the function cited before (whose only argument is the dataset). Can anybody help me? I'm trying to understand how the rm.boot function from Hmisc package resamples this way, but it's not that easy, so if anyone could help me I'd be very grateful. Thanks in advance Niccolò [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Vignette for MiscPsycho Package
By the end of the day I will have a vignette completed for MiscPsycho. This vignette lays out the mathematical details for the primary functions in the package and provides substantive examples on how to use these functions in a sample session. This vignette will ultimately end up being distributed with the package itself. However, I plan to build new versions slowly. So, if you would like a copy of this document please let me know and I can email it to you individually. Harold [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Anova F-Test
Basically, i have 4 tests and 1 control. For example. Tester Test1 Test2 Test3 Test4 20 25 1510 30 45 10 15 .. .. .. .. .. .. .. .. 15 23 1345 The inference is at alpha=0.05. they are all independent. I am trying to find if they differ or the same. Do i use the following method. Step 1. I create matrix using data.frame. for example test1-c(20,30..etc) Step2. is this correct? or do i use aov().. anova(lm(dependent~independent*independent, data=name) this is what i am confuse. I think i did something wrong. I need to find the correct F statistic test. any help. thanks. thanks. -- View this message in context: http://www.nabble.com/Anova-F-Test-tf3759431.html#a10625662 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
Hi. Thanks once more for the swift response. This solution works pretty well. The only small glitch is if I pass the function an argument with the same name as the function argument. That is, suppose x is the argument name in my user-defined function, and that object x does not exist. If I call the function f(x), i.e., using the non-existent object x as the argument value, then the function says that x exists. Here is my example log: chkex5 - function(objn){ + c(exob=exists(deparse(substitute(objn + } exists(objn) [1] FALSE chkex5(objn) exob TRUE But I suppose I can live with this. Thanks again! -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f - function(x) exists(deparse(substitute(x))) R f(y) [1] FALSE R y - 1 R f(y) [1] TRUE R f(z) [1] FALSE Andy From: Talbot Katz Hi, Andy. Thank you for the quick response! Unfortunately, none of these are exactly what I'm looking for. I'm looking for the following: Suppose object y exists and object z does not exist. If I pass y as the value of the argument to my function, I want to be able to verify, inside my function, the existence of y; similarly, if I pass z as the value of the argument, I want to be able to see, inside the function, that z doesn't exist. The missing function just checks whether the argument is missing; in my case, the argument is not missing, but the object may not exist. And the way you use the exists function inside the user-defined function doesn't test the argument to the user-defined function, it's just hard-coded for the object y. So I'm sorry if I wasn't clear before, and I hope this is clear now. Perhaps what I'm attempting to do is unavailable because it's a bad programming paradigm. But even an explanation if that's the case would be appreciated. -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function [Broadcast] Date: Tue, 15 May 2007 11:03:12 -0400 Not sure which one you want, but the following should cover it: R f - function(x) c(x=missing(x), y=exists(y)) R f(1) x y FALSE FALSE R f() x y TRUE FALSE R y - 1 R f() xy TRUE TRUE R f(1) x y FALSE TRUE Andy From: Talbot Katz Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists(x) it says that x exists even if y does not. If I had a separate argument to hold the text string y then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a separate argument? Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - - Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu - direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. - - -- Notice: This e-mail message, together with any
Re: [R] Testing for existence inside a function
Try this modification: chk - function(x) exists(deparse(substitute(x)), parent.env(environment())) ab - 1 chk(ab) [1] TRUE exists(x) [1] FALSE chk(x) [1] FALSE On 5/15/07, Talbot Katz [EMAIL PROTECTED] wrote: Hi. Thanks once more for the swift response. This solution works pretty well. The only small glitch is if I pass the function an argument with the same name as the function argument. That is, suppose x is the argument name in my user-defined function, and that object x does not exist. If I call the function f(x), i.e., using the non-existent object x as the argument value, then the function says that x exists. Here is my example log: chkex5 - function(objn){ + c(exob=exists(deparse(substitute(objn + } exists(objn) [1] FALSE chkex5(objn) exob TRUE But I suppose I can live with this. Thanks again! -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f - function(x) exists(deparse(substitute(x))) R f(y) [1] FALSE R y - 1 R f(y) [1] TRUE R f(z) [1] FALSE Andy From: Talbot Katz Hi, Andy. Thank you for the quick response! Unfortunately, none of these are exactly what I'm looking for. I'm looking for the following: Suppose object y exists and object z does not exist. If I pass y as the value of the argument to my function, I want to be able to verify, inside my function, the existence of y; similarly, if I pass z as the value of the argument, I want to be able to see, inside the function, that z doesn't exist. The missing function just checks whether the argument is missing; in my case, the argument is not missing, but the object may not exist. And the way you use the exists function inside the user-defined function doesn't test the argument to the user-defined function, it's just hard-coded for the object y. So I'm sorry if I wasn't clear before, and I hope this is clear now. Perhaps what I'm attempting to do is unavailable because it's a bad programming paradigm. But even an explanation if that's the case would be appreciated. -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function [Broadcast] Date: Tue, 15 May 2007 11:03:12 -0400 Not sure which one you want, but the following should cover it: R f - function(x) c(x=missing(x), y=exists(y)) R f(1) x y FALSE FALSE R f() x y TRUE FALSE R y - 1 R f() xy TRUE TRUE R f(1) x y FALSE TRUE Andy From: Talbot Katz Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists(x) it says that x exists even if y does not. If I had a separate argument to hold the text string y then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a separate argument? Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - - Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu - direct contact information for affiliates is available at http://www.merck.com/contact/contacts.html) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the
[R] Optimized File Reading with R
Dear All, Hope I am not bumping into a FAQ, but so far my online search has been fruitless I need to read some data file using R. I am using the (I think) standard command: data_150-read.table(y_complete06000, header=FALSE) where y_complete06000 is a 6000 by 40 table of numbers. I am puzzled at the fact that R is taking several minutes to read this file. First I thought it may have been due to its shape, but even re-expressing and saving the matrix as a 1D array does not help. It is not a small file, but not even huge (it amounts to about 5Mb of text file). Is there anything I can do to speed up the file reading? Many thanks Lorenzo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
Another thing to watch out for is that an argument to a function can be an expression (or even literal constants), instead of just the name of an object. exists() wouldn't really do the right thing. I'm not sure how to properly do the exhaustive check. Andy From: Gabor Grothendieck Try this modification: chk - function(x) exists(deparse(substitute(x)), parent.env(environment())) ab - 1 chk(ab) [1] TRUE exists(x) [1] FALSE chk(x) [1] FALSE On 5/15/07, Talbot Katz [EMAIL PROTECTED] wrote: Hi. Thanks once more for the swift response. This solution works pretty well. The only small glitch is if I pass the function an argument with the same name as the function argument. That is, suppose x is the argument name in my user-defined function, and that object x does not exist. If I call the function f(x), i.e., using the non-existent object x as the argument value, then the function says that x exists. Here is my example log: chkex5 - function(objn){ + c(exob=exists(deparse(substitute(objn + } exists(objn) [1] FALSE chkex5(objn) exob TRUE But I suppose I can live with this. Thanks again! -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f - function(x) exists(deparse(substitute(x))) R f(y) [1] FALSE R y - 1 R f(y) [1] TRUE R f(z) [1] FALSE Andy From: Talbot Katz Hi, Andy. Thank you for the quick response! Unfortunately, none of these are exactly what I'm looking for. I'm looking for the following: Suppose object y exists and object z does not exist. If I pass y as the value of the argument to my function, I want to be able to verify, inside my function, the existence of y; similarly, if I pass z as the value of the argument, I want to be able to see, inside the function, that z doesn't exist. The missing function just checks whether the argument is missing; in my case, the argument is not missing, but the object may not exist. And the way you use the exists function inside the user-defined function doesn't test the argument to the user-defined function, it's just hard-coded for the object y. So I'm sorry if I wasn't clear before, and I hope this is clear now. Perhaps what I'm attempting to do is unavailable because it's a bad programming paradigm. But even an explanation if that's the case would be appreciated. -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function [Broadcast] Date: Tue, 15 May 2007 11:03:12 -0400 Not sure which one you want, but the following should cover it: R f - function(x) c(x=missing(x), y=exists(y)) R f(1) x y FALSE FALSE R f() x y TRUE FALSE R y - 1 R f() xy TRUE TRUE R f(1) x y FALSE TRUE Andy From: Talbot Katz Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists(x) it says that x exists even if y does not. If I had a separate argument to hold the text string y then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a separate argument? Thanks! -- TMK -- 212-460-5430home 917-656-5351cell __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - - Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck
Re: [R] Optimized File Reading with R
If it's a matrix, use scan(). If the columns are not all the same type, use the colClasses argument to read.table() to specify their types, instead of leaving it to R to guess. That will speed things up quite a lot. Andy From: Lorenzo Isella Dear All, Hope I am not bumping into a FAQ, but so far my online search has been fruitless I need to read some data file using R. I am using the (I think) standard command: data_150-read.table(y_complete06000, header=FALSE) where y_complete06000 is a 6000 by 40 table of numbers. I am puzzled at the fact that R is taking several minutes to read this file. First I thought it may have been due to its shape, but even re-expressing and saving the matrix as a 1D array does not help. It is not a small file, but not even huge (it amounts to about 5Mb of text file). Is there anything I can do to speed up the file reading? Many thanks Lorenzo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] sobre tutorial
Estimado, te agradeceria me envies el tutorial en espaniol para R. Estoy dando mis primeros pasos con esta aplicacion. Desde ya muchas gracias Danilo Ceschin Ph.D IGBMC 1 rue Laurent Fries 67404 ILLKIRCH CEDEX - FRANCE tel 33 3 88 65 3457 email [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
Maybe this: chk2 - function(x) { chr - deparse(substitute(x)) e - parse(text = chr) structure(exists(chr, parent.env(environment())), is.name = length(e) == 1 is.name(e[[1]])) } chk2(1) # structure(FALSE, is.name = FALSE) ab - 1 chk2(ab+1) # structure(FALSE, is.name = FALSE) chk2(ab) # structure(TRUE, is.name = TRUE) exists(x) # FALSE chk2(x) # structure(FALSE, is.name = TRUE) chk2(x+1) # structure(FALSE, is.name = FALSE) On 5/15/07, Liaw, Andy [EMAIL PROTECTED] wrote: Another thing to watch out for is that an argument to a function can be an expression (or even literal constants), instead of just the name of an object. exists() wouldn't really do the right thing. I'm not sure how to properly do the exhaustive check. Andy From: Gabor Grothendieck Try this modification: chk - function(x) exists(deparse(substitute(x)), parent.env(environment())) ab - 1 chk(ab) [1] TRUE exists(x) [1] FALSE chk(x) [1] FALSE On 5/15/07, Talbot Katz [EMAIL PROTECTED] wrote: Hi. Thanks once more for the swift response. This solution works pretty well. The only small glitch is if I pass the function an argument with the same name as the function argument. That is, suppose x is the argument name in my user-defined function, and that object x does not exist. If I call the function f(x), i.e., using the non-existent object x as the argument value, then the function says that x exists. Here is my example log: chkex5 - function(objn){ + c(exob=exists(deparse(substitute(objn + } exists(objn) [1] FALSE chkex5(objn) exob TRUE But I suppose I can live with this. Thanks again! -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f - function(x) exists(deparse(substitute(x))) R f(y) [1] FALSE R y - 1 R f(y) [1] TRUE R f(z) [1] FALSE Andy From: Talbot Katz Hi, Andy. Thank you for the quick response! Unfortunately, none of these are exactly what I'm looking for. I'm looking for the following: Suppose object y exists and object z does not exist. If I pass y as the value of the argument to my function, I want to be able to verify, inside my function, the existence of y; similarly, if I pass z as the value of the argument, I want to be able to see, inside the function, that z doesn't exist. The missing function just checks whether the argument is missing; in my case, the argument is not missing, but the object may not exist. And the way you use the exists function inside the user-defined function doesn't test the argument to the user-defined function, it's just hard-coded for the object y. So I'm sorry if I wasn't clear before, and I hope this is clear now. Perhaps what I'm attempting to do is unavailable because it's a bad programming paradigm. But even an explanation if that's the case would be appreciated. -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function [Broadcast] Date: Tue, 15 May 2007 11:03:12 -0400 Not sure which one you want, but the following should cover it: R f - function(x) c(x=missing(x), y=exists(y)) R f(1) x y FALSE FALSE R f() x y TRUE FALSE R y - 1 R f() xy TRUE TRUE R f(1) x y FALSE TRUE Andy From: Talbot Katz Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the function or pass the name of the argument as a separate argument? If I do exists(x) or exists(eval(x)) inside the function and y does not exist, it generates an error message. If I do exists(x) it says that x exists even if y does not. If I had a separate argument to hold the text string y then I could check that. But is it possible to check the existence of the argument inside the function without passing its name as a
Re: [R] sobre tutorial
Hello, There are a number of resources (in Spanish) at the bottom of the page http://es.wikipedia.org/wiki/Lenguaje_de_programación_R Regards, Carlos J. Gil Bellosta http://www.datanalytics.com On Tue, 2007-05-15 at 18:49 +0200, Danilo Ceschin wrote: Estimado, te agradeceria me envies el tutorial en espaniol para R. Estoy dando mis primeros pasos con esta aplicacion. Desde ya muchas gracias Danilo Ceschin Ph.D IGBMC 1 rue Laurent Fries 67404 ILLKIRCH CEDEX - FRANCE tel 33 3 88 65 3457 email [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] efficient way of aggregating two variables at once
Hi, I'm working out d' and therefore I'd like to aggregate two variables at once (hits and false alarms). In the raw data frame is subject, stimulus_presence, and response information. I aggregate this into a table now currently by separating out the target_presence=true data and working out a hit rate and then workout out the false alarm rate from the target_presence=false data. Then I cbind the x column from the false alarm aggregate to the hit rate data. Then I can also append a dprime column if I wish. I am just inquiring as to whether there is some facility I am missing for aggregating the variables simultaneously or just generating the d' in one step. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
I think parent.frame() is what is wanted, not parent.env(environment()) in your suggested solution: Consider this: (which does **not** however handle the arbitrary expressions as argument issue): foo1 - function(z){ cat(exists(deparse(substitute(z)),parent.frame()), exists(deparse(substitute(z)),parent.env(environment())), exists(deparse(substitute(z))),\n) invisible() } foo - function(x){ y - x foo1(y) } x-1 ## Then ... foo(x) TRUE FALSE FALSE Note that parent.env() is the **enclosing environment** i.e. the environment in which foo1 is defined (lexical scoping); while parent.frame() is the frame of the caller of foo1, which is what is wanted if foo1 is to work when called within a function. Note that parent.frame() would also work when foo1 is called at the command line. Further corrections/clarifications welcome, of course. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabor Grothendieck Sent: Tuesday, May 15, 2007 10:06 AM To: Liaw, Andy Cc: r-help@stat.math.ethz.ch; Talbot Katz Subject: Re: [R] Testing for existence inside a function Maybe this: chk2 - function(x) { chr - deparse(substitute(x)) e - parse(text = chr) structure(exists(chr, parent.env(environment())), is.name = length(e) == 1 is.name(e[[1]])) } chk2(1) # structure(FALSE, is.name = FALSE) ab - 1 chk2(ab+1) # structure(FALSE, is.name = FALSE) chk2(ab) # structure(TRUE, is.name = TRUE) exists(x) # FALSE chk2(x) # structure(FALSE, is.name = TRUE) chk2(x+1) # structure(FALSE, is.name = FALSE) On 5/15/07, Liaw, Andy [EMAIL PROTECTED] wrote: Another thing to watch out for is that an argument to a function can be an expression (or even literal constants), instead of just the name of an object. exists() wouldn't really do the right thing. I'm not sure how to properly do the exhaustive check. Andy From: Gabor Grothendieck Try this modification: chk - function(x) exists(deparse(substitute(x)), parent.env(environment())) ab - 1 chk(ab) [1] TRUE exists(x) [1] FALSE chk(x) [1] FALSE On 5/15/07, Talbot Katz [EMAIL PROTECTED] wrote: Hi. Thanks once more for the swift response. This solution works pretty well. The only small glitch is if I pass the function an argument with the same name as the function argument. That is, suppose x is the argument name in my user-defined function, and that object x does not exist. If I call the function f(x), i.e., using the non-existent object x as the argument value, then the function says that x exists. Here is my example log: chkex5 - function(objn){ + c(exob=exists(deparse(substitute(objn + } exists(objn) [1] FALSE chkex5(objn) exob TRUE But I suppose I can live with this. Thanks again! -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f - function(x) exists(deparse(substitute(x))) R f(y) [1] FALSE R y - 1 R f(y) [1] TRUE R f(z) [1] FALSE Andy From: Talbot Katz Hi, Andy. Thank you for the quick response! Unfortunately, none of these are exactly what I'm looking for. I'm looking for the following: Suppose object y exists and object z does not exist. If I pass y as the value of the argument to my function, I want to be able to verify, inside my function, the existence of y; similarly, if I pass z as the value of the argument, I want to be able to see, inside the function, that z doesn't exist. The missing function just checks whether the argument is missing; in my case, the argument is not missing, but the object may not exist. And the way you use the exists function inside the user-defined function doesn't test the argument to the user-defined function, it's just hard-coded for the object y. So I'm sorry if I wasn't clear before, and I hope this is clear now. Perhaps what I'm attempting to do is unavailable because it's a bad programming paradigm. But even an explanation if that's the case would be appreciated. -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function [Broadcast] Date: Tue, 15 May 2007 11:03:12 -0400 Not sure which one you want, but the following should cover it: R f - function(x) c(x=missing(x), y=exists(y)) R f(1) x y
Re: [R] Optimized File Reading with R
If you execute the same script several times and the data file does not change, it may be a good idea to save it as an R object: if (file.access('mydata.obj',0)==0) { load('mydata.obj') } else { a-read.table(mydata.csv,...) save(a,file='mydata.obj') } It can speed up things considerably. Christophe Pallier On 5/15/07, Liaw, Andy [EMAIL PROTECTED] wrote: If it's a matrix, use scan(). If the columns are not all the same type, use the colClasses argument to read.table() to specify their types, instead of leaving it to R to guess. That will speed things up quite a lot. Andy From: Lorenzo Isella Dear All, Hope I am not bumping into a FAQ, but so far my online search has been fruitless I need to read some data file using R. I am using the (I think) standard command: data_150-read.table(y_complete06000, header=FALSE) where y_complete06000 is a 6000 by 40 table of numbers. I am puzzled at the fact that R is taking several minutes to read this file. First I thought it may have been due to its shape, but even re-expressing and saving the matrix as a 1D array does not help. It is not a small file, but not even huge (it amounts to about 5Mb of text file). Is there anything I can do to speed up the file reading? Many thanks Lorenzo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Christophe Pallier (http://www.pallier.org) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
Right. Thanks. It should have been parent.frame(). Here is the correction: chk3 - function(x) { chr - deparse(substitute(x)) e - parse(text = chr) structure(exists(chr, parent.frame()), is.name = length(e) == 1 is.name(e[[1]])) } chk3(1) # structure(FALSE, is.name = FALSE) ab - 1 chk3(ab+1) # structure(FALSE, is.name = FALSE) chk3(ab) # structure(TRUE, is.name = TRUE) exists(x) # FALSE chk3(x) # structure(FALSE, is.name = TRUE) chk3(x+1) # structure(FALSE, is.name = FALSE) On 5/15/07, Bert Gunter [EMAIL PROTECTED] wrote: I think parent.frame() is what is wanted, not parent.env(environment()) in your suggested solution: Consider this: (which does **not** however handle the arbitrary expressions as argument issue): foo1 - function(z){ cat(exists(deparse(substitute(z)),parent.frame()), exists(deparse(substitute(z)),parent.env(environment())), exists(deparse(substitute(z))),\n) invisible() } foo - function(x){ y - x foo1(y) } x-1 ## Then ... foo(x) TRUE FALSE FALSE Note that parent.env() is the **enclosing environment** i.e. the environment in which foo1 is defined (lexical scoping); while parent.frame() is the frame of the caller of foo1, which is what is wanted if foo1 is to work when called within a function. Note that parent.frame() would also work when foo1 is called at the command line. Further corrections/clarifications welcome, of course. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabor Grothendieck Sent: Tuesday, May 15, 2007 10:06 AM To: Liaw, Andy Cc: r-help@stat.math.ethz.ch; Talbot Katz Subject: Re: [R] Testing for existence inside a function Maybe this: chk2 - function(x) { chr - deparse(substitute(x)) e - parse(text = chr) structure(exists(chr, parent.env(environment())), is.name = length(e) == 1 is.name(e[[1]])) } chk2(1) # structure(FALSE, is.name = FALSE) ab - 1 chk2(ab+1) # structure(FALSE, is.name = FALSE) chk2(ab) # structure(TRUE, is.name = TRUE) exists(x) # FALSE chk2(x) # structure(FALSE, is.name = TRUE) chk2(x+1) # structure(FALSE, is.name = FALSE) On 5/15/07, Liaw, Andy [EMAIL PROTECTED] wrote: Another thing to watch out for is that an argument to a function can be an expression (or even literal constants), instead of just the name of an object. exists() wouldn't really do the right thing. I'm not sure how to properly do the exhaustive check. Andy From: Gabor Grothendieck Try this modification: chk - function(x) exists(deparse(substitute(x)), parent.env(environment())) ab - 1 chk(ab) [1] TRUE exists(x) [1] FALSE chk(x) [1] FALSE On 5/15/07, Talbot Katz [EMAIL PROTECTED] wrote: Hi. Thanks once more for the swift response. This solution works pretty well. The only small glitch is if I pass the function an argument with the same name as the function argument. That is, suppose x is the argument name in my user-defined function, and that object x does not exist. If I call the function f(x), i.e., using the non-existent object x as the argument value, then the function says that x exists. Here is my example log: chkex5 - function(objn){ + c(exob=exists(deparse(substitute(objn + } exists(objn) [1] FALSE chkex5(objn) exob TRUE But I suppose I can live with this. Thanks again! -- TMK -- 212-460-5430home 917-656-5351cell From: Liaw, Andy [EMAIL PROTECTED] To: Talbot Katz [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f - function(x) exists(deparse(substitute(x))) R f(y) [1] FALSE R y - 1 R f(y) [1] TRUE R f(z) [1] FALSE Andy From: Talbot Katz Hi, Andy. Thank you for the quick response! Unfortunately, none of these are exactly what I'm looking for. I'm looking for the following: Suppose object y exists and object z does not exist. If I pass y as the value of the argument to my function, I want to be able to verify, inside my function, the existence of y; similarly, if I pass z as the value of the argument, I want to be able to see, inside the function, that z doesn't exist. The missing function just checks whether the argument is missing; in my case, the argument is not missing, but the object may not exist. And the way you use the exists function inside the user-defined function doesn't test the argument to the user-defined function, it's just hard-coded for the object y. So I'm sorry if I wasn't clear
[R] How to extract R codes that embedded in a HTML file using Stangle?
I'm using R2HTML package to generate reports, but don't know how to extract R codes from .rnw files using Stangle. It seems Stangle only works on ..tex file that has R codes embedded. Thanks, Tao _ Hotmail. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Optimized File Reading with R
On Tue, 15 May 2007, Lorenzo Isella wrote: Dear All, Hope I am not bumping into a FAQ, but so far my online search has been fruitless I need to read some data file using R. I am using the (I think) standard command: data_150-read.table(y_complete06000, header=FALSE) where y_complete06000 is a 6000 by 40 table of numbers. I am puzzled at the fact that R is taking several minutes to read this file. First I thought it may have been due to its shape, but even re-expressing and saving the matrix as a 1D array does not help. It is not a small file, but not even huge (it amounts to about 5Mb of text file). Is there anything I can do to speed up the file reading? You could try reading the help page or the 'R Data Import/Export' manual. Both point out things like 'read.table' is not the right tool for reading large matrices, especially those with many columns: it is designed to read _data frames_ which may have columns of very different classes. Use 'scan' instead. On the other hand I am surprised at several minutes, but as you haven't even told us your OS, it is hard to know what to expect. My Linux box took 3 secs for a 6000x40 matrix with read.table, 0.8 sec with scan. -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Optimized File Reading with R
Prof Brian Ripley wrote: On Tue, 15 May 2007, Lorenzo Isella wrote: Dear All, Hope I am not bumping into a FAQ, but so far my online search has been fruitless I need to read some data file using R. I am using the (I think) standard command: data_150-read.table(y_complete06000, header=FALSE) where y_complete06000 is a 6000 by 40 table of numbers. I am puzzled at the fact that R is taking several minutes to read this file. First I thought it may have been due to its shape, but even re-expressing and saving the matrix as a 1D array does not help. It is not a small file, but not even huge (it amounts to about 5Mb of text file). Is there anything I can do to speed up the file reading? You could try reading the help page or the 'R Data Import/Export' manual. Both point out things like 'read.table' is not the right tool for reading large matrices, especially those with many columns: it is designed to read _data frames_ which may have columns of very different classes. Use 'scan' instead. On the other hand I am surprised at several minutes, but as you haven't even told us your OS, it is hard to know what to expect. My Linux box took 3 secs for a 6000x40 matrix with read.table, 0.8 sec with scan. If it is 40 rows and 6000 columns, then it might explain it: x - as.data.frame(matrix(rnorm(40*6000),6000)) write.table(x,file=xx.txt) system.time(y - read.table(xx.txt)) user system elapsed 1.229 0.007 1.250 write.table(t(x),file=xx.txt) system.time(y - read.table(xx.txt)) user system elapsed 92.986 0.188 93.912 However, this is still not _several_ minutes, and it is on my laptop which is not particularly fast. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] stacked barplot with positive and negatvie values
On Tue, 2007-05-15 at 17:54 +0200, Paul Magdon wrote: Hello I'm trying to create a barplot with a couple of stacked positive values and with one negative value for each group. example: trees-c(20,30,10) shrubs-c(12,23,9) veg-c(2,3,4) soil-c(-100,-123,-89) example1-t(cbind(trees,shrubs,veg)) barplot(example1) #this works so far #but now: example2-t(cbind(trees,shrubs,veg,soil)) barplot(example2) This shows no more stacked bars. But I want to keep the bars like example1 and just add the negative values which have another scale downwards. So I tried: barplot(example1,axes=F) barplot(example2[soil,],add=T,axes=F) axis(side=2,at=c(-150,-100,-50,0,10,20,30)) But I still does not work for the axis?? I would appriciate any kind of hint Greetings Paul Magdon How about this: # Set up a 2 x 1 plot # See ?par par(mfrow = c(2, 1)) #adjust the axis side 1 margin to 0 # See ?par par(mar = c(0, 4, 4, 2)) # Do the plot of the positive values # define the y limits and set the y axis type to 'i' # See ?par for 'xaxs' and 'yaxs' barplot(example2[-4, ], yaxs = i, ylim = c(0, 60), las = 2) # Set the axis side 4 margin to 0 # so that there is no gap par(mar = c(5, 4, 0, 2)) # Now do the negative values, using the same logic barplot(example2[4, ], yaxs = i, ylim = c(-125, 0), las = 2) HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] stacked barplot with positive and negatvie values
On 5/15/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Tue, 2007-05-15 at 17:54 +0200, Paul Magdon wrote: Hello I'm trying to create a barplot with a couple of stacked positive values and with one negative value for each group. example: trees-c(20,30,10) shrubs-c(12,23,9) veg-c(2,3,4) soil-c(-100,-123,-89) example1-t(cbind(trees,shrubs,veg)) barplot(example1) #this works so far #but now: example2-t(cbind(trees,shrubs,veg,soil)) barplot(example2) This shows no more stacked bars. But I want to keep the bars like example1 and just add the negative values which have another scale downwards. So I tried: barplot(example1,axes=F) barplot(example2[soil,],add=T,axes=F) axis(side=2,at=c(-150,-100,-50,0,10,20,30)) But I still does not work for the axis?? I would appriciate any kind of hint Greetings Paul Magdon How about this: # Set up a 2 x 1 plot # See ?par par(mfrow = c(2, 1)) #adjust the axis side 1 margin to 0 # See ?par par(mar = c(0, 4, 4, 2)) # Do the plot of the positive values # define the y limits and set the y axis type to 'i' # See ?par for 'xaxs' and 'yaxs' barplot(example2[-4, ], yaxs = i, ylim = c(0, 60), las = 2) # Set the axis side 4 margin to 0 # so that there is no gap par(mar = c(5, 4, 0, 2)) # Now do the negative values, using the same logic barplot(example2[4, ], yaxs = i, ylim = c(-125, 0), las = 2) And another alternative is to use the lattice package, e.g. barchart(Freq ~ Var2, data = as.data.frame.table(example2), groups = Var1, stack = TRUE, auto.key = TRUE) -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
Talbot Katz wrote: I'm having trouble testing for existence of an object inside a function. No, you are having trouble testing for existence of an object _before_ the function is called :-) Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. This can't be done, because the error happens before f is called. Try this: f - function(x) x + 1 f(y.does.not.exist) y.does.not.exist The error message is (almost) the same, and it happens when parsing the line. There's no way to change f to change this. Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Getting default aspect ratio from lattice
How can I get the value of the aspect ratio that is used in a lattice plot? In a levelplot for instance, the native units per cm of my x and y axes are different, and I need to know the aspect ratio so that I can correctly plot vectors. I know how to set the aspect in a high-level lattice function but I can't quite figure out how to get it. I would like call to levelplot() without printing anything, get the aspect ratio, use it to create my vector arrows, then call levelplot() again with print() to create the final figure. Scott Waichler Pacific Northwest National Laboratory scott.waichler _at_ pnl.gov __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] sobre tutorial
Danilo, http://cran.r-project.org/other-docs.html#nenglish Manuel Castejón Limas, Joaquín Ordieres Meré, Fco. Javier de Cos Juez, and Fco. Javier Martínez de Pisón Ascacibar. Control de Calidad. Metodologia para el analisis previo a la modelización de datos en procesos industriales. Fundamentos teóricos y aplicaciones con R. Servicio de Publicaciones de la Universidad de La Rioja, 2001. ISBN 84-95301-48-2. [ ]s Rogerio -- Cabeçalho original --- De: [EMAIL PROTECTED] Para: [EMAIL PROTECTED] Cópia: r-help@stat.math.ethz.ch Data: Tue, 15 May 2007 18:20:04 +0100 Assunto: Re: [R] sobre tutorial Hello, There are a number of resources (in Spanish) at the bottom of the page http://es.wikipedia.org/wiki/Lenguaje_de_programación_R Regards, Carlos J. Gil Bellosta http://www.datanalytics.com On Tue, 2007-05-15 at 18:49 +0200, Danilo Ceschin wrote: Estimado, te agradeceria me envies el tutorial en espaniol para R. Estoy dando mis primeros pasos con esta aplicacion. Desde ya muchas gracias Danilo Ceschin Ph.D IGBMC 1 rue Laurent Fries 67404 ILLKIRCH CEDEX - FRANCE tel 33 3 88 65 3457 email [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Anova Test
have a look at the examples in ?aov. Also not that npk is a dataframe in this example --- CrazyJoe [EMAIL PROTECTED] wrote: Thank you Guys. Let say that from Test1 to control i have multiple data Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 . . . . . . . . . . 40 20 1535 45 Is this the method i need to use? anova(lm(..this is where i am not sure how to put them. is this something to do with anova(lm(dependent~independent*independent, data=name) if they are all independent, how do i put them together? thanks. Ben Bolker-2 wrote: CrazyJoe keizer_61 at hotmail.com writes: I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 You can't make any inferences with the data you have here. You need to have multiple observations per treatment! See the examples for ?lm . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Anova-Test-tf3758829.html#a10625154 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
On 5/15/2007 3:06 PM, Alberto Monteiro wrote: Talbot Katz wrote: I'm having trouble testing for existence of an object inside a function. No, you are having trouble testing for existence of an object _before_ the function is called :-) Suppose I have a function: f-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. This can't be done, because the error happens before f is called. Try this: f - function(x) x + 1 f(y.does.not.exist) y.does.not.exist The error message is (almost) the same, and it happens when parsing the line. There's no way to change f to change this. That description is true in some languages, but not in R. R doesn't check that args to functions are valid until it needs to use them. For example: f - function(y) 1 # doesn't care if y exists f(y.does.not.exist) [1] 1 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] confidence intervals on multiple comparisons
Enrico, prop.test is for testing proportions two at a time. If you want to test for differences between 4 proportions simultaneously (rather than two at a time), try a logistic regression model (from which you can get confidence intervals for each of your groups). Cody Hamilton, PhD Staff Biostatistician Edwards Lifesciences Salvatore Enrico Indiogine [EMAIL PROTECTED] To .com R-help@stat.math.ethz.ch Sent by: cc [EMAIL PROTECTED] at.math.ethz.ch Subject [R] confidence intervals on multiple comparisons 05/13/2007 10:51 AM Greetings! I am using prop.test to compare 4 proportions to find out whether they are equal. According to the help function you can not have confidence intervals if you compare more than 2 proportions. I need to find an effect size or confidence interval for these proportions. Any suggestions? Enrico -- Enrico Indiogine Mathematics Education Texas AM University [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Testing for existence inside a function
Duncan Murdoch wrote: Try this: f - function(x) x + 1 f(y.does.not.exist) y.does.not.exist The error message is (almost) the same, and it happens when parsing the line. There's no way to change f to change this. That description is true in some languages, but not in R. R doesn't check that args to functions are valid until it needs to use them. For example: f - function(y) 1 # doesn't care if y exists f(y.does.not.exist) [1] 1 Ok, I guess R optimizes every call to f, ignoring its arguments unless needed. f - function(y) 1 # doesn't care if y exists g - function() cat(g was called\n) f(g()) [1] 1 # g was not called Another test: f1 - function(x, y) if (x == 0) y else 1 f1(1, y.does.not.exist) f1(1, g()) The y-argument is never called. So maybe it _might_ be possible to test if y exists inside the function... Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] confidence intervals on multiple comparisons
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, May 15, 2007 12:52 PM To: Salvatore Enrico Indiogine Cc: R-help@stat.math.ethz.ch; [EMAIL PROTECTED] Subject: Re: [R] confidence intervals on multiple comparisons Enrico, prop.test is for testing proportions two at a time. If you want to test for differences between 4 proportions simultaneously (rather than two at a time), try a logistic regression model (from which you can get confidence intervals for each of your groups). Cody Hamilton, PhD Staff Biostatistician Edwards Lifesciences Yes, but beware: in the default contr.treatment coding for contrasts, you get estimates and confidence intervals for the first group and for the **differences** between the first group and the others. As you said, it's easy to get what you want from this, but you must pay attention to the details here. Bert Gunter Genentech Nonclinical statistics Salvatore Enrico Indiogine [EMAIL PROTECTED] To .com R-help@stat.math.ethz.ch Sent by: cc [EMAIL PROTECTED] at.math.ethz.ch Subject [R] confidence intervals on multiple comparisons 05/13/2007 10:51 AM Greetings! I am using prop.test to compare 4 proportions to find out whether they are equal. According to the help function you can not have confidence intervals if you compare more than 2 proportions. I need to find an effect size or confidence interval for these proportions. Any suggestions? Enrico -- Enrico Indiogine Mathematics Education Texas AM University [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 extract R codes that embedded in a HTML file using Stangle?
Tao Shi wrote: I'm using R2HTML package to generate reports, but don't know how to extract R codes from .rnw files using Stangle. It seems Stangle only works on ..tex file that has R codes embedded. Stangle is meant for Rnw files, not for html ... Uwe Ligges Thanks, Tao _ Hotmail. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Building package on Windows
Hello, I have been trying to build a package for R to use on windows. I have been able to build it with out problems except for one thing. I am creating a zip file to be installed by the R gui. I have four directories under the main dir. I have data, man, R, and src. The problem that I have been having, is that the data directory is being zipped up, then when I install the package the data directory isn't being unzipped when using the gui (This is the main way many of the users that I work with use R). When I make my call to build the zip fill it looks like the following: R CMD build --binary --use-zip-help --docs=normal batdebug I have taken out the --use-zip-help flag and I still created the zipped data directory. I have three items in the data directory, a config file and two java files that are invoked by a dll that is in the src directory. The three files in the data directory is about 1,200 KB in total size. I have R 1.9.1 installed to build with because it doesn't zip up the data directory like the current version of R. I have looked into the R documentation to find if I am not using a flag or something. I have tried the --auto-zip and --use-zip-data flags and neither of these flags did anything different. I have been experiencing this problem with R 2.4.1 ( I have tried with several other versions of R and they all do the same thing since 2.0.0.) Can anyone point me in the correct direction of a flag to include or how to fix this problem. Thanks in advance, Jason E Eglin Rosetta Inpharmatics -- Notice: This e-mail message, together with any attachments,...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Optimized File Reading with R
An apology: it takes roughly a couple of minutes on my laptop, running Debian. I had been running some other simulations for quite some time and, though it looks odd for Linux, the subsequent work I did with R was slowed down. Many thanks Lorenzo Peter Dalgaard wrote: Prof Brian Ripley wrote: On Tue, 15 May 2007, Lorenzo Isella wrote: Dear All, Hope I am not bumping into a FAQ, but so far my online search has been fruitless I need to read some data file using R. I am using the (I think) standard command: data_150-read.table(y_complete06000, header=FALSE) where y_complete06000 is a 6000 by 40 table of numbers. I am puzzled at the fact that R is taking several minutes to read this file. First I thought it may have been due to its shape, but even re-expressing and saving the matrix as a 1D array does not help. It is not a small file, but not even huge (it amounts to about 5Mb of text file). Is there anything I can do to speed up the file reading? You could try reading the help page or the 'R Data Import/Export' manual. Both point out things like 'read.table' is not the right tool for reading large matrices, especially those with many columns: it is designed to read _data frames_ which may have columns of very different classes. Use 'scan' instead. On the other hand I am surprised at several minutes, but as you haven't even told us your OS, it is hard to know what to expect. My Linux box took 3 secs for a 6000x40 matrix with read.table, 0.8 sec with scan. If it is 40 rows and 6000 columns, then it might explain it: x - as.data.frame(matrix(rnorm(40*6000),6000)) write.table(x,file=xx.txt) system.time(y - read.table(xx.txt)) user system elapsed 1.229 0.007 1.250 write.table(t(x),file=xx.txt) system.time(y - read.table(xx.txt)) user system elapsed 92.986 0.188 93.912 However, this is still not _several_ minutes, and it is on my laptop which is not particularly fast. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] JOB: Data Analyst
Boxwood Means, a financial services consultancy specializing in the small balance mortgage sector and REIT analysis, is seeking a Data Analyst. Boxwood maintains several large databases of real estate transactions around the nation as well as financial information on publicly traded equities. We use these data to create market intelligence and forecasts for clients -- principally large banks. The Data Analyst will work directly with clients and principals of the firm to support off-the-shelf reports and customized market statistics and forecast reports for clients. The Data Analyst will work with large databases and is expected to be skilled at data manipulation, data cleaning, producing publication quality graphics and tables, and some statistical modeling. Much of the firm's publications involves pulling data from MySQL into R, then producing latex tables (Hmisc) and documents for delivery to clients. In addition, the Data Analyst will conduct independent research and/or data mining as required. This is a telecommuting position. All work is done remotely on Boxwood's servers. Employees are expected to provide their own working environment. Qualifications A strong knowledge of the R (S-plus) programming language and some familiarity with Linux, MySQL, and basic statistical models is required. Experience in producing graphics and latex tables (Hmisc) using R would be helpful. The successful candidate will have a strong attention to detail, be self-motivated, and capable of independent work. We will consider a flexible part-time position or full-time position for the well qualified candidate. Please contact me off-list for additional information: [EMAIL PROTECTED] -- === Michaell Taylor, Ph.D. Principal Boxwood Means, Inc. Two Stamford Landing Suite 100 68 Southfield Ave Stamford, CT 06902 203.653.4100 ext 2 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Getting default aspect ratio from lattice
On 5/15/07, Waichler, Scott R [EMAIL PROTECTED] wrote: How can I get the value of the aspect ratio that is used in a lattice plot? In a levelplot for instance, the native units per cm of my x and y axes are different, and I need to know the aspect ratio so that I can correctly plot vectors. I know how to set the aspect in a high-level lattice function but I can't quite figure out how to get it. I would like call to levelplot() without printing anything, get the aspect ratio, use it to create my vector arrows, then call levelplot() again with print() to create the final figure. Your question doesn't necessarily have a well defined answer, because the aspect ratio may be computed only on printing (and not even then, as the aspect ratio may change after printing if you resize the device). In fact, this is the default behaviour (aspect = fill). The good news is that for any other value of 'aspect', you are in luck. ?trellis.object says: A trellis object, as returned by high level lattice functions like 'xyplot', is a list with the 'class' attribute set to 'trellis'. Many of the components of this list are simply the arguments to the high level function that produced the object. Among them are [...]. Some other typical components are: [...] 'aspect.fill' logical, whether 'aspect' is 'fill' 'aspect.ratio' numeric, aspect ratio to be used if 'aspect.fill' is 'FALSE' and we have: levelplot(volcano, aspect = fill)$aspect.ratio [1] 1 levelplot(volcano, aspect = iso)$aspect.ratio [1] 0.7011494 levelplot(volcano, aspect = 2)$aspect.ratio [1] 2 etc. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem with lme4
It should be lmer(success ~ yearF + (1 | bandnumb), data=quality, family = binomial, method = PQL) Reza On 5/15/07, Stefan Grosse [EMAIL PROTECTED] wrote: the lme4 function you want is probably lmer() type ?lmer btw. your R is very old we are at 2.5.0 ... Stefan Amelie LESCROEL wrote: Hi - I'm having a problem trying to use the function GLMM() from lme4. Here is what happens: library(lme4) Loading required package: Matrix Loading required package: lattice f1 - GLMM(success~yearF, data=quality, random=~1|bandnumb, family=binomial, method=PQL) Error: couldn't find function GLMM I remember having used lme4 before, without any problem. Can someone help me understanding what is wrong? I'm using R 2.2.1, could that be a problem? I also tried installing lme4 again, and updating the package, with no success. Thanks for your help, Amelie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 installation of R on Unix (SunOs 5.8)
Dr. Ripley, Thanks for you reply and hints. I was able to install R on the Unix system (SunOs 5.8) by issuing the following commands: ./configure --with-readline=no --with-iconv=no make It may lose some functionality by specifying these options, I guess. But I use Unix R only when I need to execute codes that will run for long time. Otherwise I am satisfied with Windows R. As for your comments #1, the file I downloaded is the same as the original R resource file. Thanks again. Biao -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Monday, May 14, 2007 10:14 PM To: Biao Xing Cc: r-help@stat.math.ethz.ch Subject: Re: [R] How to installation of R on Unix (SunOs 5.8) On Mon, 14 May 2007, Biao Xing wrote: Hi there: Can someone help me with installing R on Unix? I tried the followings, but failed: (1) I downloaded http://cran.cnr.berkeley.edu/bin/linux/debian/stable/r-base_2.5.0.orig.tar.g z and unzipped the file. That is not where the R FAQ says to get the R sources. See http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-obtained_003f It may be the same as the documented file, but I'll leave you to verify that. On the other hand, I would always recommend starting with the current R-patched tarball, and there are three changes there that may help with such an old OS as yours (see below). (2) I issued ./config command, which ended up with a long log file. I attached below the last few lines. If anyone needs the full log, I can send it over. This looks like part of the output of ./configure. In the top level directory there should be a file called INSTALL. This asks you to read the 'R Installation and Administration Manual'. The online version is at http://cran.r-project.org/doc/manuals/R-admin.html: please search for 'readline'. [...] configure: error: --with-readline=yes (default) and headers/libs are not available (3) I issued make command, then the message I got was: make: Fatal error: No arguments to build The Unix system that I use is SunOS 5.8. I wanted to install R on my home directory, not a system wide installation. There seem to be a lot of QA messages posted on the list regarding how to install R on Unix. But I didn't get a clue from reading them. Can someone provide a summary for a 'Unix dummy'? I don't see 'a lot', and I have seen this one quite a few times. Try searching the list archives for '--with-readline=yes' if you want to confirm this. More generally, Solaris 8 (aka SunOS 5.8) is a rather old OS (our box says 'October 2001') and did not even come with compilers. Please read the section on Solaris in the 'Platform Notes' in the manual I cited to make sure you have the necessary tools and that they are recent enough. (You may need to seek help from your sysadmins on this.) As well as libreadline, you will need libiconv (unless you use R-patched and --without-iconv). -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem with lme4
On 5/15/07, Seyed Reza Jafarzadeh [EMAIL PROTECTED] wrote: It should be lmer(success ~ yearF + (1 | bandnumb), data=quality, family = binomial, method = PQL) It has to be method = PQL (the quotes are important) except that the PQL method is no longer an option in lmer. Beginning with lme4_0.99875-0, which was uploaded today, the Laplace approximation is the default method for generalized linear mixed models. It would be simplest to use lmer(success ~ yearF + (1|bandnumb), quality, binomial) On 5/15/07, Stefan Grosse [EMAIL PROTECTED] wrote: the lme4 function you want is probably lmer() type ?lmer btw. your R is very old we are at 2.5.0 ... Stefan Amelie LESCROEL wrote: Hi - I'm having a problem trying to use the function GLMM() from lme4. Here is what happens: library(lme4) Loading required package: Matrix Loading required package: lattice f1 - GLMM(success~yearF, data=quality, random=~1|bandnumb, family=binomial, method=PQL) Error: couldn't find function GLMM I remember having used lme4 before, without any problem. Can someone help me understanding what is wrong? I'm using R 2.2.1, could that be a problem? I also tried installing lme4 again, and updating the package, with no success. Thanks for your help, Amelie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 group a count
Hello R users I have a dataset that has different types of records with different dates and times pertaining to each. I would like to have a bar graph of a count of the types(ie. The number of types) of recods by hour grouped by year. So the count of the types would be the y axis, the hour on the x axis and then grouped by year for easy comparison. I think that I have to use barchart however I don't know how to get barchart to do a count and not graph values. Thanks [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Barplot by two variables
Thanks for your solution, it worked perfectly, it was exactly what I wanted. I do have two more questions and hope you can help. I have another analysis exactly like the last one except it is done by month instead of year. When I graph it using barchart it makes the months go in alphabetical order. Is there anyway to change it so that the months go in the correct order (jan, feb, march, etc,). And how do I change the colors of the bars in the graph, they are weird colors and I want to change them. Thanks so much for your help. -Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: May 10, 2007 4:58 PM To: Spilak,Jacqueline [Edm] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Barplot by two variables On 5/10/07, Spilak,Jacqueline [Edm] [EMAIL PROTECTED] wrote: Hi all I have a bit of a problem. I want to make a barplot of some data. My data is of a score that is separated by year and by a limit (above 3 and below 3 to calculate the score). YearLimit HSS 1999ALT 0.675 1999VFR 0.521 2000ALT 0.264 2000VFR 0.295 I would like to have a barplot with year on the x axis and HSS on the y axis and the two limits as two different colors to show the difference. Using (dataset$HSS, col=c(green,purple)) I get some of the plot but I don't know how to get labels on the bottom for each year and I can't get a legend for my barplot. Not really sure what I am doing wrong but any help would be much appreciated. Here's one solution using the lattice package: library(lattice) barchart(HSS ~ factor(Year), data = dataset, origin = 0, groups = Limit, auto.key = TRUE) -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 group a count
Here is my data. I tried table but it doesn't do what I want it to do when it graphs. I want a count of the types (R for one graph and A for another) by hour grouped by year. Hope that helps. ID,,MM,DD,HH,MM,Type YEG,2002,01,01,01,24,A YEG,2002,01,01,02,40,R YEG,2002,01,01,05,39,R YEG,2002,01,01,09,17,A -Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: May 15, 2007 3:46 PM To: Spilak,Jacqueline [Edm] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] How to group a count On 5/15/07, Spilak,Jacqueline [Edm] [EMAIL PROTECTED] wrote: Hello R users I have a dataset that has different types of records with different dates and times pertaining to each. I would like to have a bar graph of a count of the types(ie. The number of types) of recods by hour grouped by year. So the count of the types would be the y axis, the hour on the x axis and then grouped by year for easy comparison. I think that I have to use barchart however I don't know how to get barchart to do a count and not graph values. I think you want to use table or xtabs to get a frequency table, and use barchart on the result. Hard to say more without an example. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 group a count
On 5/15/07, Spilak,Jacqueline [Edm] [EMAIL PROTECTED] wrote: Hello R users I have a dataset that has different types of records with different dates and times pertaining to each. I would like to have a bar graph of a count of the types(ie. The number of types) of recods by hour grouped by year. So the count of the types would be the y axis, the hour on the x axis and then grouped by year for easy comparison. I think that I have to use barchart however I don't know how to get barchart to do a count and not graph values. I think you want to use table or xtabs to get a frequency table, and use barchart on the result. Hard to say more without an example. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 group a count
On 5/15/07, Spilak,Jacqueline [Edm] [EMAIL PROTECTED] wrote: Here is my data. I tried table but it doesn't do what I want it to do when it graphs. I want a count of the types (R for one graph and A for another) by hour grouped by year. Hope that helps. ID,,MM,DD,HH,MM,Type YEG,2002,01,01,01,24,A YEG,2002,01,01,02,40,R YEG,2002,01,01,05,39,R YEG,2002,01,01,09,17,A I assume you have more data than that. Here's a sample use of xtabs, which you should adapt to your example (I'm not sure if you want to disregard MM and DD): foo ID MM DD HH MM.1 Type 1 YEG 2002 1 1 1 24A 2 YEG 2002 1 1 2 40R 3 YEG 2002 1 1 5 39R 4 YEG 2002 1 1 9 17A as.data.frame(xtabs(~Type + + HH, foo)) Type HH Freq 1A 2002 11 2R 2002 10 3A 2002 20 4R 2002 21 5A 2002 50 6R 2002 51 7A 2002 91 8R 2002 90 (xtabs itself will produce a 3-D array, which you may or may not be comfortable working with). -Deepayan -Original Message- From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] Sent: May 15, 2007 3:46 PM To: Spilak,Jacqueline [Edm] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] How to group a count On 5/15/07, Spilak,Jacqueline [Edm] [EMAIL PROTECTED] wrote: Hello R users I have a dataset that has different types of records with different dates and times pertaining to each. I would like to have a bar graph of a count of the types(ie. The number of types) of recods by hour grouped by year. So the count of the types would be the y axis, the hour on the x axis and then grouped by year for easy comparison. I think that I have to use barchart however I don't know how to get barchart to do a count and not graph values. I think you want to use table or xtabs to get a frequency table, and use barchart on the result. Hard to say more without an example. -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Efficiently reading random lines form a large file
I need to read two different random lines at a time from a large ASCII file (120 x 296976) containing space delimited 0-1 entries. The following code does the job and it's reasonable fast for my needs: lineNumber = sample(120, 2) line1 = scan(filename, what = integer, skip=lineNumber[1]-1, nlines=1) line2 = scan(filename, what = integer, skip=lineNumber[2]-1, nlines=1) system.time(for (i in 50){ + lineNumber = sample(120, 2) + line1 = scan(filename, what = integer, skip=lineNumber[1]-1, nlines=1) + line2 = scan(filename, what = integer, skip=lineNumber[2]-1, nlines=1) + }) Read 296976 items Read 296976 items [1] 14.24 0.12 14.51NANA However, I'm wondering if there's an even faster way to do this. Is there? sessionInfo() R version 2.4.1 (2006-12-18) i386-pc-mingw32 Juan Pablo Lewinger Department of Preventive Medicine Keck School of Medicine University of Southern California 1540 Alcazar Street, CHP-220 Los Angeles, CA 90089-9011, USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Efficiently reading random lines form a large file
On Tue, 2007-05-15 at 16:02 -0700, Juan Pablo Lewinger wrote: I need to read two different random lines at a time from a large ASCII file (120 x 296976) containing space delimited 0-1 entries. The following code does the job and it's reasonable fast for my needs: lineNumber = sample(120, 2) line1 = scan(filename, what = integer, skip=lineNumber[1]-1, nlines=1) line2 = scan(filename, what = integer, skip=lineNumber[2]-1, nlines=1) system.time(for (i in 50){ + lineNumber = sample(120, 2) + line1 = scan(filename, what = integer, skip=lineNumber[1]-1, nlines=1) + line2 = scan(filename, what = integer, skip=lineNumber[2]-1, nlines=1) + }) Read 296976 items Read 296976 items [1] 14.24 0.12 14.51NANA However, I'm wondering if there's an even faster way to do this. Is there? You might want to take a look at this post by Jim Holtman from earlier in the year for some ideas: http://tolstoy.newcastle.edu.au/R/e2/help/07/02/9709.html HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] converting a row of a data.frame to a vector
I've searched for the answer to this in the help list archive, but wasn't able to get the answer to work. I'm interested in converting a row of a data.frame into a vector. However, when I use as.vector(x,[1,]) I get another data.frame, instead of a vector. (On the other hand, when I use as.vector(x,[,1]), I get a vector.) Thanks, Andrew [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Getting default aspect ratio from lattice
How can I get the value of the aspect ratio that is used in a lattice plot? In a levelplot for instance, the native units per cm of my x and y axes are different, and I need to know the aspect ratio so that I can correctly plot vectors. I know how to set the aspect in a high-level lattice function but I can't quite figure out how to get it. I would like call to levelplot() without printing anything, get the aspect ratio, use it to create my vector arrows, then call levelplot() again with print() to create the final figure. Your question doesn't necessarily have a well defined answer, because the aspect ratio may be computed only on printing (and not even then, as the aspect ratio may change after printing if you resize the device). In fact, this is the default behaviour (aspect = fill). Thanks for the help, Deepayan. Yes, I guess what I am looking for is the actual numerical value for aspect.ratio that is used when aspect = fill. My device is a pdf and I don't resize it. Could I execute the whole plot, including printing it, while saving the aspect.ratio that was used, then create the plot again? Scott Waichler __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] converting a row of a data.frame to a vector
probably something like, unlist(x[1,]) HTH. H. Andrew Yee [EMAIL PROTECTED] 5/15/2007 4:37 PM I've searched for the answer to this in the help list archive, but wasn't able to get the answer to work. I'm interested in converting a row of a data.frame into a vector. However, when I use as.vector(x,[1,]) I get another data.frame, instead of a vector. (On the other hand, when I use as.vector(x,[,1]), I get a vector.) Thanks, Andrew [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Getting default aspect ratio from lattice
On 5/15/07, Waichler, Scott R [EMAIL PROTECTED] wrote: How can I get the value of the aspect ratio that is used in a lattice plot? In a levelplot for instance, the native units per cm of my x and y axes are different, and I need to know the aspect ratio so that I can correctly plot vectors. I know how to set the aspect in a high-level lattice function but I can't quite figure out how to get it. I would like call to levelplot() without printing anything, get the aspect ratio, use it to create my vector arrows, then call levelplot() again with print() to create the final figure. Your question doesn't necessarily have a well defined answer, because the aspect ratio may be computed only on printing (and not even then, as the aspect ratio may change after printing if you resize the device). In fact, this is the default behaviour (aspect = fill). Thanks for the help, Deepayan. Yes, I guess what I am looking for is the actual numerical value for aspect.ratio that is used when aspect = fill. My device is a pdf and I don't resize it. Could I execute the whole plot, including printing it, while saving the aspect.ratio that was used, then create the plot again? Sort of, if you use something like: getAspect - function(obj) { print(obj) trellis.focus(panel, 1, 1, highlight = FALSE) cpl - current.panel.limits(unit = inches) ans - diff(cpl$ylim) / diff(cpl$xlim) trellis.unfocus() ans } Using this, I get: foo - levelplot(volcano, aspect = fill) x11() getAspect(foo) [1] 1.096661 dev.off() x11(, 5, 9) getAspect(foo) [1] 2.342152 dev.off() But if you know the size of your device, you won't do much worse if you supply a numeric aspect based on that (unless you have a multipanel plot and the automatic layout calculation is important to you). -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] converting a row of a data.frame to a vector
If the data frame has factors and numeric vectors, there is a question on what form you want the row vector to be in. Only a data frame (list) can have a mixture of the two. Consider: dat - data.frame(x=1:3, y=4:6, z=letters[1:3]) (r1 - dat[1,]) x y z 1 1 4 a class(r1) [1] data.frame (r1 - data.matrix(dat)[1,]) x y z 1 4 1 class(r1) [1] integer (r1 - as.matrix(dat)[1,]) x y z 1 4 a class(r1) [1] character 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: (I don't have one!) 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 Andrew Yee Sent: Wednesday, 16 May 2007 9:37 AM To: r-help@stat.math.ethz.ch Subject: [R] converting a row of a data.frame to a vector I've searched for the answer to this in the help list archive, but wasn't able to get the answer to work. I'm interested in converting a row of a data.frame into a vector. However, when I use as.vector(x,[1,]) I get another data.frame, instead of a vector. (On the other hand, when I use as.vector(x,[,1]), I get a vector.) Thanks, Andrew [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem with Sweave
I am using R 2.5 on a Linux Redhat platform. I can successfully run some example *.Rnw files through Sweave and generate pdf files. When I try my own example file, test.Rnw: \documentclass[a4paper]{article} \title{Test Sweave Example} \author{Thomas Adams} \begin{document} \maketitle In this example we embed parts of the examples from the \texttt{boxplot} and \texttt{lattice} figures into a \LaTeX{} document = library(verification) library(lattice) dat-read.table(verification_summary_20051024_table.txt,sep=\t,header=TRUE) \begin{center} fig=TRUE,echo=FALSE= boxplot(dat$MAE ~ dat$BASINID) abline(h=1) abline(h=0.5,col=red) @ \end{center} \end{document} I get the following error: xt4-tir:adams echo 'Sweave(test.Rnw)' | R --vanilla --quiet Sweave(test.Rnw) Writing to file test.tex Processing code chunks ... 1 : echo term verbatim Error: chunk 1 Error in parse(file, n, text, prompt, srcfile, encoding) : syntax error, unexpected $undefined in: Execution halted I really do not know where to begin to decipher the error messages. Any suggestions? Regards, Tom -- Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: [EMAIL PROTECTED] VOICE: 937-383-0528 FAX:937-383-0033 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem with Sweave
On 15/05/2007 9:22 PM, Thomas Adams wrote: I am using R 2.5 on a Linux Redhat platform. I can successfully run some example *.Rnw files through Sweave and generate pdf files. When I try my own example file, test.Rnw: \documentclass[a4paper]{article} \title{Test Sweave Example} \author{Thomas Adams} \begin{document} \maketitle In this example we embed parts of the examples from the \texttt{boxplot} and \texttt{lattice} figures into a \LaTeX{} document = library(verification) library(lattice) dat-read.table(verification_summary_20051024_table.txt,sep=\t,header=TRUE) \begin{center} fig=TRUE,echo=FALSE= boxplot(dat$MAE ~ dat$BASINID) abline(h=1) abline(h=0.5,col=red) @ \end{center} \end{document} I get the following error: xt4-tir:adams echo 'Sweave(test.Rnw)' | R --vanilla --quiet Sweave(test.Rnw) Writing to file test.tex Processing code chunks ... 1 : echo term verbatim Error: chunk 1 Error in parse(file, n, text, prompt, srcfile, encoding) : syntax error, unexpected $undefined in: Execution halted I really do not know where to begin to decipher the error messages. Any suggestions? You didn't end the first code chunk (no @ at the end). This isn't obvious from the error message, but it is obvious if you run Stangle, and look at the resulting R file, because you know the error is in chunk 1, and that last line of it doesn't look much like R code: ### ### chunk number 1: ### library(verification) library(lattice) dat-read.table(verification_summary_20051024_table.txt,sep=\t,header=TRUE) \begin{center} ### ### chunk number 2: ### boxplot(dat$MAE ~ dat$BASINID) abline(h=1) abline(h=0.5,col=red) Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem with Sweave
Duncan, Thank you for your help — that certainly did the trick. With Sweave being new to me, I somehow missed the obvious… Regards, Tom Duncan Murdoch wrote: On 15/05/2007 9:22 PM, Thomas Adams wrote: I am using R 2.5 on a Linux Redhat platform. I can successfully run some example *.Rnw files through Sweave and generate pdf files. When I try my own example file, test.Rnw: \documentclass[a4paper]{article} \title{Test Sweave Example} \author{Thomas Adams} \begin{document} \maketitle In this example we embed parts of the examples from the \texttt{boxplot} and \texttt{lattice} figures into a \LaTeX{} document = library(verification) library(lattice) dat-read.table(verification_summary_20051024_table.txt,sep=\t,header=TRUE) \begin{center} fig=TRUE,echo=FALSE= boxplot(dat$MAE ~ dat$BASINID) abline(h=1) abline(h=0.5,col=red) @ \end{center} \end{document} I get the following error: xt4-tir:adams echo 'Sweave(test.Rnw)' | R --vanilla --quiet Sweave(test.Rnw) Writing to file test.tex Processing code chunks ... 1 : echo term verbatim Error: chunk 1 Error in parse(file, n, text, prompt, srcfile, encoding) : syntax error, unexpected $undefined in: Execution halted I really do not know where to begin to decipher the error messages. Any suggestions? You didn't end the first code chunk (no @ at the end). This isn't obvious from the error message, but it is obvious if you run Stangle, and look at the resulting R file, because you know the error is in chunk 1, and that last line of it doesn't look much like R code: ### ### chunk number 1: ### library(verification) library(lattice) dat-read.table(verification_summary_20051024_table.txt,sep=\t,header=TRUE) \begin{center} ### ### chunk number 2: ### boxplot(dat$MAE ~ dat$BASINID) abline(h=1) abline(h=0.5,col=red) Duncan Murdoch -- Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: [EMAIL PROTECTED] VOICE: 937-383-0528 FAX:937-383-0033 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] log rank test p value
How can I get the Log - Rank p value to be output? The chi square value can be output, so I was thinking if I can also have the degrees of freedom output I could generate the p value, but can't see how to find df either. (survtest - survdiff(Surv(time, cens) ~ group, data = surv,rho=0)) Call: survdiff(formula = Surv(time, cens) ~ group, data = surv, rho = 0) N Observed Expected (O-E)^2/E (O-E)^2/V group=1 20 16 11.0 2.23 4.64 group=2 20 12 17.0 1.45 4.64 Chisq= 4.6 on 1 degrees of freedom, p= 0.0312 survtest$chisq [1] 4.641028 survtest$df NULL -- Murray Pung Statistician, Datapharm Australia Pty Ltd 0404 273 283 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Building package on Windows
On Tue, 15 May 2007, Eglin, Jason wrote: Hello, I have been trying to build a package for R to use on windows. I have been able to build it with out problems except for one thing. I am creating a zip file to be installed by the R gui. I have four directories under the main dir. I have data, man, R, and src. The problem that I have been having, is that the data directory is being zipped up, then when I install the package the data directory isn't being unzipped when using the gui (This is the main way many of the users that I work with use R). When I make my call to build the zip fill it looks like the following: R CMD build --binary --use-zip-help --docs=normal batdebug I have taken out the --use-zip-help flag and I still created the zipped data directory. I have three items in the data directory, a config file and two java files that are invoked by a dll that is in the src directory. The three files in the data directory is about 1,200 KB in total size. I have R 1.9.1 installed to build with because it doesn't zip up the data directory like the current version of R. Packages installed under 1.9.1 will be unusable under current R. I have looked into the R documentation to find if I am not using a flag or something. I have tried the --auto-zip and --use-zip-data flags and neither of these flags did anything different. I have been experiencing this problem with R 2.4.1 ( I have tried with several other versions of R and they all do the same thing since 2.0.0.) Can anyone point me in the correct direction of a flag to include or how to fix this problem. Not use the data directory for non-R data? R is perfectly capable of unzipping the data for its own use. As 'Writing R Extensions' says The @file{data} subdirectory is for additional data files the package makes available for loading using @code{data()}. Currently, data files can have one of three types as indicated by their extension: plain R code (@file{.R} or @file{.r}), tables (@file{.tab}, @file{.txt}, or @file{.csv}), or @code{save()} images (@file{.RData} or @file{.rda}). You could for example install via the inst directory. -- 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@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] log rank test p value
On Wed, 2007-05-16 at 11:54 +1000, Murray Pung wrote: How can I get the Log - Rank p value to be output? The chi square value can be output, so I was thinking if I can also have the degrees of freedom output I could generate the p value, but can't see how to find df either. (survtest - survdiff(Surv(time, cens) ~ group, data = surv,rho=0)) Call: survdiff(formula = Surv(time, cens) ~ group, data = surv, rho = 0) N Observed Expected (O-E)^2/E (O-E)^2/V group=1 20 16 11.0 2.23 4.64 group=2 20 12 17.0 1.45 4.64 Chisq= 4.6 on 1 degrees of freedom, p= 0.0312 survtest$chisq [1] 4.641028 survtest$df NULL That part of the output is created in print.survdiff(), which you can review by using: survival:::print.survdiff The degrees of freedom and the p value are calculated in that function. Using the example in ?survdiff: survtest - survdiff(Surv(futime, fustat) ~ rx, data = ovarian) survtest Call: survdiff(formula = Surv(futime, fustat) ~ rx, data = ovarian) N Observed Expected (O-E)^2/E (O-E)^2/V rx=1 137 5.23 0.596 1.06 rx=2 135 6.77 0.461 1.06 Chisq= 1.1 on 1 degrees of freedom, p= 0.303 str(survtest) List of 6 $ n: 'table' int [, 1:2] 13 13 ..- attr(*, dimnames)=List of 1 .. ..$ groups: chr [1:2] rx=1 rx=2 $ obs : num [1:2] 7 5 $ exp : num [1:2] 5.23 6.77 $ var : num [1:2, 1:2] 2.94 -2.94 -2.94 2.94 $ chisq: num 1.06 $ call : language survdiff(formula = Surv(futime, fustat) ~ rx, data = ovarian) - attr(*, class)= chr survdiff We can then do the following to secure the p value: 1 - pchisq(survtest$chisq, 1) [1] 0.3025911 See ?str and ?pchisq for more information. HTH, Marc Schwartz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Reshape a sparse matrix
Hi, I'd like to reshape a sparse matrix generated from the Matrix package. I can't seem to do it with the command dim(A) - c(6,9) which works perfectly with the base package matrices, but with the sparse matrices it errors with Error in dim(A) = c(6, 9) : dim- : invalid first argument Manipulating the Dim attribute of the sparse Matrix does not produce the desired effect. [EMAIL PROTECTED] - c(as.integer(9),as.integer(6)) does not produce a column ordering result, which I am assuming is because the data is stored in a row (i) and column (j) format instead (class dgTMatrix) Does a function for this exist? -Scott __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] GLMM for unbalanced data
Hi friends, I need some help regarding generalized linear mixed model of unbalanced data. 1. Is their any package for applying Monte-Carlo Newton-Raphson (MCNR) or Monte-Carlo EM (MCEM) to estimate fixed and random effects? 2. My data is unbalanced (groups having unequal number of observations) and random-effect design matrix is not containing only 1's but some function of x(predictors). e.g., z = [avg(x1jk)0 0 0 00 0 avg(x2jk)0 0 00 ...... ......... ... 00 0 0 0 avg(x6jk)] where avg(xijk) = an (n_k X 1) column vector of average of jth measurement available for the ith subject in group k and n_k is the no. of observations in kth group. is it possible to apply glmmPQL or any other packge in this situation? If possible kindly tell me how? Thanks in advance. Waiting for reply. -- View this message in context: http://www.nabble.com/GLMM-for-unbalanced-data-tf3762358.html#a10635105 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.