Re: [R] ANOVA: Does a Between-Subjects Factor belong in the Error Term?
On 7/9/07, Alex Baugh [EMAIL PROTECTED] wrote: I am executing a Repeated Measures Analysis of Variance with 1 DV (LOCOMOTOR RESPONSE), 2 Within-Subjects Factors (AGE, ACOUSTIC CONDITION), and 1 Between-Subjects Factor (SEX). Does anyone know whether the between-subjects factor (SEX) belongs in the Error Term of the aov or not? It does not. If you have between-subjects factors A, B and within-subjects factors X, Y, Z, use: aov( dv ~ a*b*x*y*z + Error(subj/(x*y*z)) The subj/(x*y*z) formula includes subj:x subj:y subj:z and all their interactions as error terms. The effect of a within subject factor 'x' is assessed against the error term subj:x -- 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] character string to name
On Mon, 9 Jul 2007, Thomas Lumley wrote: On Mon, 9 Jul 2007, Jim Lemon wrote: Hi folks, I thought I recalled a request for turning a character string into an object name as in: Yes. It's a FAQ. There is an FAQ about turning character strings into objects (Q7.21), but this seems a bit different. In the first example, he really does want a name. Since $ does not evaluate its rhs, ways to do that are yy - y x$[[yy]] - 1:4 eval(substitute(x$yy - 1:4, list(yy=yy))) and of course parse(text=). For the second, I think something like e - quote(data.frame(yy=1:4)) names(e)[2] - yy x - eval(e) is probably the simplest way. -thomas x$as.name(y)-1:4 OR x-data.frame(as.name(y)=1:4) However, as.name and a few other uninformed attempts didn't even come close. A search of character to name produced no helpful functions. This isn't a very urgent request, but if anyone knows some trick to perform this transformation, I would like to hear about it. Thanks. Jim -- 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] sspir: how to forecast data?
Hello. I'm playing with Kalman filter. library(sspir) m1 - SS(y=t(t(sin(1:20 # dummy data plot(m1$y, type=l) m1.f - kfilter(m1) m1.s - smoother(m1.f) lines(m1.f$m, lty=dotted,col=blue) lines(m1.s$m, lty=dotted,col=red) I was wondering how it's possible to forecast using sspir library. I read the topic Kalman Filter Forecast using SSPIR, but I have no a great math basis, so I need an hint to write the forecasting code. Another great package I explored is dse. It seems there is a function to do forecasting, but I am not to be able to translate my snippet using dse library. Can you help me? Thanks in advance, Alberto Santini [[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] Repeated Measure different results to spss
Hi, I have some problems with my repeated measures analysis. When I compute it with SPSS I get different results than with R. Probably I am doing something wrong in R. I have two groups (1,2) both having to solve a task under two conditions (1,2). That is one between subject factor (group) and one within subject factor (task). I tried the following: aov(Score ~factor(Group)*factor(Task)+Error(Id))) aov(Score ~factor(Group)*factor(Task)) but it leads to different results than my spss. I definitely miss some point here . Thanks for you help. Id Group TaskScore 1 1 1 0.39 2 1 1 0.48 3 1 1 0.59 4 1 1 0.33 5 1 1 0.38 6 1 1 0.37 7 1 1 0.47 8 1 1 0.2 9 1 1 0.29 10 1 1 0.41 11 1 1 0.24 12 1 1 0.28 13 1 1 0.32 14 1 1 0.26 15 2 1 0.65 16 2 1 0.41 17 2 1 0.62 18 2 1 0.39 19 2 1 0.81 20 2 1 0.34 21 2 1 0.32 22 2 1 0.33 23 2 1 0.33 24 2 1 0.38 1 1 2 0.46 2 1 2 0.27 3 1 2 0.41 4 1 2 0.13 5 1 2 0.41 6 1 2 0.36 7 1 2 0.32 8 1 2 0.33 9 1 2 0.44 10 1 2 0.36 11 1 2 0.2 12 1 2 0.3 13 1 2 0.27 14 1 2 0.4 15 2 2 0.35 16 2 2 0.37 17 2 2 0.34 18 2 2 0.24 19 2 2 0.44 20 2 2 0.34 21 2 2 0.4 22 2 2 0.28 23 2 2 0.32 24 2 2 0.33 -- View this message in context: http://www.nabble.com/Repeated-Measure-different-results-to-spss-tf4054506.html#a11516870 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] histogram with absolute figures
In the absence of a data set, it may help to read the help file carefully: ?hist Note, in particular, that the argument freq defaults to TRUE if and only if breaks are equidistant (and probability is not specified). Regards, Mark. Sarah Goslee wrote: Well, how about an example of what you are doing, and a description of what the results you get and the results you want are? When I do a histogram, I get frequencies. Sarah On 7/9/07, Mag. Ferri Leberl [EMAIL PROTECTED] wrote: Meanwhile I have recognized, that the breaks-option enforces density as the default. But if I try to force frequencies (freq=TRUE) I get the following feedback: Warning message: the AREAS in the plot are wrong -- rather use freq=FALSE in: plot.histogram(r, freq = freq, col = col, border = border, angle = angle, And the machine hasn't promised too much: the result IS wrong. Yours, Mag. Ferri Leberl Am Freitag, den 06.07.2007, 16:17 -0400 schrieb Sarah Goslee: The default of hist() is counts rather than percentages. Sarah On 7/6/07, Mag. Ferri Leberl [EMAIL PROTECTED] wrote: Dear everybody! Is ist easily possible to make up a histogram with absolute numbers instead of percentages? Thank you in advance! Yours, Mag. Ferri Leberl ___ -- Sarah Goslee http://www.functionaldiversity.org __ 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/histogram-with-absolute-figures-tf4037852.html#a11517345 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] The results of your email commands
confirm 03122ac6f26ed0e761c70bde1bb41c3063b82211 [EMAIL PROTECTED] wrote: The results of your email command are provided below. Attached is your original message. - Results: Ignoring non-text/plain MIME parts - Unprocessed: Regards Dimple [EMAIL PROTECTED] wrote: Mailing list subscription confirmation notice for mailing list R-help We have received a request from 129.234.4.76 for subscription of your email address, [EMAIL PROTECTED], to the r-help@stat.math.ethz.ch mailing list. To confirm that you want to be added to this mailing list, simply reply to this message, keeping the Subject: header intact. Or visit this web page: https://stat.ethz.ch/mailman/confirm/r-help/03122ac6f26ed0e761c70bde1bb41c3063b82211 Or include the following line -- and only the following line -- in a message to [EMAIL PROTECTED]: confirm 03122ac6f26ed0e761c70bde1bb41c3063b82211 Note that simply sending a `reply' to this message should work from most mail readers, since that usually leaves the Subject: line in the right form (additional Re: text in the Subject: is okay). - Ignored: If you do not wish to be subscribed to this list, please simply disregard this message. If you think you are being maliciously subscribed to the list, or have any other questions, send them to [EMAIL PROTECTED] Dimple T Venkat 4 Red Rose Terrace Chester-le-Street Durham County DH3 3 LN Phone : 0044 (0)786 334 9863. - - Done. Date: Tue, 10 Jul 2007 02:42:43 -0700 (PDT) Subject: Header intact : Re: confirm 03122ac6f26ed0e761c70bde1bb41c3063b82211 To: [EMAIL PROTECTED] I would like to confirm my request on adding my ID to the mailing list Regards Dimple [EMAIL PROTECTED] wrote: Mailing list subscription confirmation notice for mailing list R-help We have received a request from 129.234.4.76 for subscription of your mailing list. To confirm that you want to be added to this mailing list, simply reply to this message, keeping the Subject: header intact. Or visit this web page: https://stat.ethz.ch/mailman/confirm/r-help/03122ac6f26ed0e761c70bde1bb41c3063b82211 Or include the following line -- and only the following line -- in a message to [EMAIL PROTECTED]: confirm 03122ac6f26ed0e761c70bde1bb41c3063b82211 Note that simply sending a `reply' to this message should work from most mail readers, since that usually leaves the Subject: line in the right form (additional Re: text in the Subject: is okay). If you do not wish to be subscribed to this list, please simply disregard this message. If you think you are being maliciously subscribed to the list, or have any other questions, send them to [EMAIL PROTECTED] Dimple T Venkat 4 Red Rose Terrace Chester-le-Street Durham County DH3 3 LN Phone : 0044 (0)786 334 9863. - Dimple T Venkat 4 Red Rose Terrace Chester-le-Street Durham County DH3 3 LN Phone : 0044 (0)786 334 9863. - Building a website is a piece of cake. [[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] Repeated Measure different results to spss
We don't know what you are after (or what you did in SPSS), but dat - read.table(mb2.dat, header=TRUE, colClasses=c(rep(factor,3), double)) summary(aov(Score ~ Group * Task + Error(Id), dat)) would seem to be the sort of thing your description indicates. If you tell us what you are looking for (and why) we may be able to tell you how to get it in R. On Tue, 10 Jul 2007, mb2 wrote: Hi, I have some problems with my repeated measures analysis. When I compute it with SPSS I get different results than with R. Probably I am doing something wrong in R. I have two groups (1,2) both having to solve a task under two conditions (1,2). That is one between subject factor (group) and one within subject factor (task). I tried the following: aov(Score ~factor(Group)*factor(Task)+Error(Id))) aov(Score ~factor(Group)*factor(Task)) but it leads to different results than my spss. I definitely miss some point here . Thanks for you help. IdGroup TaskScore 1 1 1 0.39 2 1 1 0.48 3 1 1 0.59 4 1 1 0.33 5 1 1 0.38 6 1 1 0.37 7 1 1 0.47 8 1 1 0.2 9 1 1 0.29 101 1 0.41 111 1 0.24 121 1 0.28 131 1 0.32 141 1 0.26 152 1 0.65 162 1 0.41 172 1 0.62 182 1 0.39 192 1 0.81 202 1 0.34 212 1 0.32 222 1 0.33 232 1 0.33 242 1 0.38 1 1 2 0.46 2 1 2 0.27 3 1 2 0.41 4 1 2 0.13 5 1 2 0.41 6 1 2 0.36 7 1 2 0.32 8 1 2 0.33 9 1 2 0.44 101 2 0.36 111 2 0.2 121 2 0.3 131 2 0.27 141 2 0.4 152 2 0.35 162 2 0.37 172 2 0.34 182 2 0.24 192 2 0.44 202 2 0.34 212 2 0.4 222 2 0.28 232 2 0.32 242 2 0.33 -- 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] Repeated Measure different results to spss
mb2 wrote: Hi, I have some problems with my repeated measures analysis. When I compute it with SPSS I get different results than with R. Probably I am doing something wrong in R. I have two groups (1,2) both having to solve a task under two conditions (1,2). That is one between subject factor (group) and one within subject factor (task). I tried the following: aov(Score ~factor(Group)*factor(Task)+Error(Id))) aov(Score ~factor(Group)*factor(Task)) but it leads to different results than my spss. I definitely miss some point here . Did you mean Error(factor(Id)) ? With that modification, things look sane. Can't vouch for SPSS... (As a general matter, I prefer to do the factor conversions up front, rather than inside model formulas.) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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] The results of your email commands
dimple thyagarajan wrote: ... Building a website is a piece of cake. But sending an email is another matter altogether. Jim __ 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] ca.jo
Hello Yihsu, have a look at ?cajorls. With this function a VECM is estimated, whence the cointegration rank has been determined (ca.jo). For further analysis, you might want to consider the function vec2var in package vars and methods irf, fevd and predict, as well as the diagnostic tests that are available in vars. Best, Bernhard Dear R users; I'm using ca.jo for a VECM model. Is there a way that I can get sd/p-value to see whether coefficients estimated are statistical significant? Thank you Yours, Yihsu [[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. * Confidentiality Note: The information contained in this mess...{{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] iid.test package
Hi Sir In iid.test package the function iid.test() has been developed for N sites having same number of observations. Can we use this function for a single site? Because I have sites with different numer of observations. Regards -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. Email: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [[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] integration over a simplex
Hello The excellent adapt package integrates over multi-dimensional hypercubes. I want to integrate over a multidimensional simplex. Has anyone implemented such a thing in R? I can transform an n-simplex to a hyperrectangle but the Jacobian is a rapidly-varying (and very lopsided) function and this is making adapt() slow. [ A \dfn{simplex} is an n-dimensional analogue of a triangle or tetrahedron. It is the convex hull of (n+1) points in an n-dimensional Euclidean space. My application is a variant of the Dirichlet distribution: With p~D(a), if length(p) = n+1 then the requirement that all(p0) and sum(p)=1 mean that the support of the Dirichlet distribution is an n-simplex. ] -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ 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] type III ANOVA for a nested linear model
Hello, is it possible to obtain type III sums of squares for a nested model as in the following: lmod - lm(resp ~ A * B + (C %in% A), mydata)) I have tried library(car) Anova(lmod, type=III) but this gives me an error (and I also understand from the documentation of Anova as well as from a previous request (http://finzi.psych.upenn.edu/R/Rhelp02a/archive/64477.html) that it is not possible to specify nested models with car's Anova). anova(lmod) works, of course. My data (given below) is balanced so I expect the results to be similar for both type I and type III sums of squares. But are they *exactly* the same? The editor of the journal which I'm sending my manuscript to requests what he calls conventional type III tests and I'm not sure if can convince him to accept my type I analysis. R mydata A B C resp 1 1 1 1 34.12 2 1 1 2 32.45 3 1 1 3 44.55 4 1 2 1 20.88 5 1 2 2 22.32 6 1 2 3 27.71 7 2 1 6 38.20 8 2 1 7 31.62 9 2 1 8 38.71 102 2 6 18.93 112 2 7 20.57 122 2 8 31.55 133 1 9 40.81 143 1 10 42.23 153 1 11 41.26 163 2 9 28.41 173 2 10 24.07 183 2 11 21.16 Thanks a lot, Carsten __ 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] Barplot with multiple categories
Dear all Thanks in advance for replies I am trying to make a barplot out of this data which I read from a file tb - read.table(tmp.dat , na.string=c(-)) tmp.dat: (the file is much longer and includes NAs as -) #A1A2A3B1B2B3C1C2C3D1D2D3 2P122P112F12P7 2S62S62P112x6 2x342x212S23I7 3I253I212T13S2 3N23S12x153x4 3x253x163I154S8 4C14S263x154Y1 4S324x124S154x4 4x195P264x155P8 5L15R25P155S1 5P315x105x155x4 5R16I276I136I9 5x196N16M16x4 6I326x106N17E9 6N17E296x157x4 6x197x97D18T9 7D18R17E148x4 7E328T297x159V10 7x198x88T159x3 8T349V308x1510P11 8x189x89V1710x2 9I110H19x1311V11 9V3510P2910A211x2 9x1610x810P1512K13 10P3611V3010S113L13 10x1611x810x1214K13 11V3612K3011V2015P12 11x1612R111x1015[PA]1 12K4112x712K2316G13 12x1113L3312R117M13 13I213x512x618D13 13L4214K3213L2719G13 13x814N113x320P13 14K4614x514K2721K12 # end Data Data explanation : position : A1, B1, C1, D1 for different samples [these are amino-acids positions in biological sequences] value found : A2, B2, ... number of occurences : C1, C2 the barplot type I would like to obtain : | | y|| || | || | ... ie : number of occurences (A3, B3, ...) |___ PSx PSx FPSTx Px | INx ISx Ix ISx ... ie : values in A2, B2 (not always the same length) 2 |3 ... ie : position in A1, B1, ... I have tried to read as matrix, simple vectors, but I cannot manage to reach this type of barplot. Any hint towards this goal would be much appreciated All the best Noel __ 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] type III ANOVA for a nested linear model
Carsten Jaeger wrote: Hello, is it possible to obtain type III sums of squares for a nested model as in the following: lmod - lm(resp ~ A * B + (C %in% A), mydata)) I have tried library(car) Anova(lmod, type=III) but this gives me an error (and I also understand from the documentation of Anova as well as from a previous request (http://finzi.psych.upenn.edu/R/Rhelp02a/archive/64477.html) that it is not possible to specify nested models with car's Anova). anova(lmod) works, of course. My data (given below) is balanced so I expect the results to be similar for both type I and type III sums of squares. But are they *exactly* the same? The editor of the journal which I'm sending my manuscript to requests what he calls conventional type III tests and I'm not sure if can convince him to accept my type I analysis. In balanced designs, type I-IV SSD's are all identical. However, I don't think the model does what I think you think it does. Notice that nesting is used with two diferent meanings, in R it would be that the codings of C only makes sense within levels of A - e.g. if they were numbered 1:3 within each group, but with C==1 when A==1 having nothing to do with C==1 when A==2. SAS does something. er. else... What I think you want is a model where C is a random terms so that main effects of A can be tested, like in summary(aov(resp ~ A * B + Error(C), dd)) Error: C Df Sum Sq Mean Sq F value Pr(F) A 2 33.123 16.562 0.4981 0.6308 Residuals 6 199.501 33.250 Error: Within Df Sum Sq Mean Sq F value Pr(F) B 1 915.21 915.21 83.7846 9.57e-05 *** A:B2 16.138.07 0.7384 0.5168 Residuals 6 65.54 10.92 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (This is essentially the same structure as Martin Bleichner had earlier today, also @web.de. What is this? an epidemic? ;-)) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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 R on Interix 6.0
Dear all, I have been trying to build R-2.5.1 on the Interix-6.0 Unix subsystem that ships with Vista and everything looks fine during the configure except towards the end when sed throws an error: sed: 1: s/\*/\\\*/g: invalid command code A few lines later I then get: ./configure: : bad substitution So I guess sed is trying to do something and because it failed the rest of the configure process breaks. It would be very helpful to get R to build (or at least the standalone bits) because then I can link it in to perl scripts running on Interix that make use of R libraries. If anyone can make a suggestion I would really appreciate it as the alternative (cygwin) is REALLY slow compared to Interix. The output from the ./configure command is listed below in case I missed something. Thanks Ed -- checking build system type... i586-pc-interix6.0 checking host system type... i586-pc-interix6.0 loading site script './config.site' loading build specific script './config.site' checking for pwd... /bin/pwd checking whether builddir is srcdir... yes checking for working aclocal... found checking for working autoconf... found checking for working automake... found checking for working autoheader... found checking for gawk... gawk checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking whether ln -s works... yes checking for ranlib... ranlib checking for bison... bison -y checking for ar... ar checking for a BSD-compatible install... /bin/install -c checking for sed... /bin/sed checking for less... /bin/less checking for perl... /usr/local/bin/perl checking whether perl version is at least 5.004... yes checking for dvips... no checking for tex... no checking for latex... no checking for makeindex... no checking for pdftex... no checking for pdflatex... no checking for makeinfo... /usr/local/bin/makeinfo checking whether makeinfo version is at least 4.7... yes checking for unzip... /usr/contrib/bin/unzip checking for zip... /usr/contrib/bin/zip checking for gzip... /usr/local/bin/gzip checking for firefox... no checking for mozilla... no checking for netscape... no checking for galeon... no checking for kfmclient... no checking for opera... no checking for gnome-moz-remote... no checking for open... no checking for acroread... no checking for acroread4... no checking for xpdf... no checking for gv... no checking for gnome-gv... no checking for ggv... no checking for kghostview... no checking for open... no checking for gpdf... no checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking whether gcc needs -traditional... no checking how to run the C preprocessor... gcc -E checking for g77... g77 checking whether we are using the GNU Fortran 77 compiler... yes checking whether g77 accepts -g... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C++ preprocessor... g++ -E checking whether __attribute__((visibility())) is supported... no checking whether gcc accepts -fvisibility... no checking whether g77 accepts -fvisibility... no checking for gcc... gcc checking whether we are using the GNU Objective C compiler... yes checking whether gcc accepts -g... yes checking whether g++ can compile ObjC++... yes checking for Objective C++ compiler... g++ checking for a sed that does not truncate output... /bin/sed checking for ld used by gcc... /opt/gcc.3.3/i586-pc-interix3/bin/ld checking if the linker (/opt/gcc.3.3/i586-pc-interix3/bin/ld) is GNU ld... yes checking for /opt/gcc.3.3/i586-pc-interix3/bin/ld option to reload object files... -r checking for BSD-compatible nm... /bin/nm -B checking how to recognise dependent libraries... unknown checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking the maximum length of command line arguments... 262144 checking command to parse /bin/nm -B output from gcc object... ok checking for objdir... .libs checking for ranlib... (cached) ranlib checking for strip... strip checking if gcc static flag works... yes checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC checking if gcc PIC flag -fPIC works... yes checking if gcc supports
Re: [R] type III ANOVA for a nested linear model
The message from this cute little data set is very clear. Consider fm - aov(resp ~ A*B + A/C, mydata) drop1(fm, test = F) Single term deletions Model: resp ~ A * B + A/C Df Sum of Sq RSS AIC F value Pr(F) none 65.540 47.261 A:B 216.132 81.672 47.222 0.7384 0.5168 A:C 6 199.501 265.041 60.411 3.0440 0.1007 So neither of the non-marginal terms is significant. To address questions about the main effects the natural next step is to remove the interactions. By orthogonality you can safely cut a few corners and do both at once: drop1(update(fm, .~A+B), test = F) Single term deletions Model: resp ~ A + B Df Sum of Sq RSS AIC F value Pr(F) none 281.17 57.47 A 2 33.12 314.30 55.48 0.82460.4586 B 1915.21 1196.38 81.54 45.5695 9.311e-06 There is a very obvious, even trivial, B main effect, but nothing else. All this becomes even more glaring if you take the unusal step of plotting the data. What sort of editor would overlook this clear and demonstrable message leaping out from the data in favour of some arcane argument about types of sums of squares? Several answers come to mind: A power freak, a SAS afficianado, an idiot. If you get nowhere with this editor, my suggestion, hard as it may seem, is that you do not submit to that kind of midnless idealogy and make fatuous compromises for the sake of immediate publication. If necessary, part company with that editor and find somewhere else to publish where the editor has some inkling of what statistical inference is all about. Bill Venables. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Carsten Jaeger Sent: Tuesday, 10 July 2007 4:15 AM To: R help list Subject: [R] type III ANOVA for a nested linear model Hello, is it possible to obtain type III sums of squares for a nested model as in the following: lmod - lm(resp ~ A * B + (C %in% A), mydata)) I have tried library(car) Anova(lmod, type=III) but this gives me an error (and I also understand from the documentation of Anova as well as from a previous request (http://finzi.psych.upenn.edu/R/Rhelp02a/archive/64477.html) that it is not possible to specify nested models with car's Anova). anova(lmod) works, of course. My data (given below) is balanced so I expect the results to be similar for both type I and type III sums of squares. But are they *exactly* the same? The editor of the journal which I'm sending my manuscript to requests what he calls conventional type III tests and I'm not sure if can convince him to accept my type I analysis. R mydata A B C resp 1 1 1 1 34.12 2 1 1 2 32.45 3 1 1 3 44.55 4 1 2 1 20.88 5 1 2 2 22.32 6 1 2 3 27.71 7 2 1 6 38.20 8 2 1 7 31.62 9 2 1 8 38.71 102 2 6 18.93 112 2 7 20.57 122 2 8 31.55 133 1 9 40.81 143 1 10 42.23 153 1 11 41.26 163 2 9 28.41 173 2 10 24.07 183 2 11 21.16 Thanks a lot, Carsten __ 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] TukeyHSD test
Hello, I think that to apply the Neuman-Keuls test under R it's possible with the TukeyHSD function and I know that to do a Neuman-Keuls test I have to sort the means but I can't use the TukeyHSD function I don't understand how to do to apply this function to my data. In the R help they use the TukeyHSD function to a aov() do you think that I have to do teh same? 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] Building R on Interix 6.0
Oakeley, Edward wrote: Dear all, I have been trying to build R-2.5.1 on the Interix-6.0 Unix subsystem that ships with Vista and everything looks fine during the configure except towards the end when sed throws an error: sed: 1: s/\*/\\\*/g: invalid command code A few lines later I then get: ./configure: : bad substitution So I guess sed is trying to do something and because it failed the rest of the configure process breaks. It would be very helpful to get R to build (or at least the standalone bits) because then I can link it in to perl scripts running on Interix that make use of R libraries. If anyone can make a suggestion I would really appreciate it as the alternative (cygwin) is REALLY slow compared to Interix. Ouch. Good luck... Looks like you also have some serious issues with shared libraries, without which you will have trouble loading R packages (i.e. with everything, basically). The sed issue appears to involve quoting; could it be related to whichever shell is being used? The output from the ./configure command is listed below in case I missed something. Thanks Ed -- checking build system type... i586-pc-interix6.0 checking host system type... i586-pc-interix6.0 loading site script './config.site' loading build specific script './config.site' checking for pwd... /bin/pwd checking whether builddir is srcdir... yes checking for working aclocal... found checking for working autoconf... found checking for working automake... found checking for working autoheader... found checking for gawk... gawk checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking whether ln -s works... yes checking for ranlib... ranlib checking for bison... bison -y checking for ar... ar checking for a BSD-compatible install... /bin/install -c checking for sed... /bin/sed checking for less... /bin/less checking for perl... /usr/local/bin/perl checking whether perl version is at least 5.004... yes checking for dvips... no checking for tex... no checking for latex... no checking for makeindex... no checking for pdftex... no checking for pdflatex... no checking for makeinfo... /usr/local/bin/makeinfo checking whether makeinfo version is at least 4.7... yes checking for unzip... /usr/contrib/bin/unzip checking for zip... /usr/contrib/bin/zip checking for gzip... /usr/local/bin/gzip checking for firefox... no checking for mozilla... no checking for netscape... no checking for galeon... no checking for kfmclient... no checking for opera... no checking for gnome-moz-remote... no checking for open... no checking for acroread... no checking for acroread4... no checking for xpdf... no checking for gv... no checking for gnome-gv... no checking for ggv... no checking for kghostview... no checking for open... no checking for gpdf... no checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking whether gcc needs -traditional... no checking how to run the C preprocessor... gcc -E checking for g77... g77 checking whether we are using the GNU Fortran 77 compiler... yes checking whether g77 accepts -g... yes checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C++ preprocessor... g++ -E checking whether __attribute__((visibility())) is supported... no checking whether gcc accepts -fvisibility... no checking whether g77 accepts -fvisibility... no checking for gcc... gcc checking whether we are using the GNU Objective C compiler... yes checking whether gcc accepts -g... yes checking whether g++ can compile ObjC++... yes checking for Objective C++ compiler... g++ checking for a sed that does not truncate output... /bin/sed checking for ld used by gcc... /opt/gcc.3.3/i586-pc-interix3/bin/ld checking if the linker (/opt/gcc.3.3/i586-pc-interix3/bin/ld) is GNU ld... yes checking for /opt/gcc.3.3/i586-pc-interix3/bin/ld option to reload object files... -r checking for BSD-compatible nm... /bin/nm -B checking how to recognise dependent libraries... unknown checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking the maximum
[R] Help Needed!!
Hi, Can anyone help me with repeated meausres MANOVA in R ? For repeated measures ANOVA I used function aov. Is there something like this exists for MANOVA? Thanks, Deepa - [[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] Help Needed!!
See ?summary.manova -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 10/07/07, deepa gupta [EMAIL PROTECTED] wrote: Hi, Can anyone help me with repeated meausres MANOVA in R ? For repeated measures ANOVA I used function aov. Is there something like this exists for MANOVA? Thanks, Deepa - [[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] Simple table generation question
Hey all, I'm doing some work with machine learning on R (I'm a fairly new user of R), and I have a question about generating new tables from existing tables. I'm currently using a table of measurements I read in from a CSV file to generate training and validation data set tables for future use in a machine learning algorithm using the code: #generate probabilities to divide up training / validation data sets randomly device_Prob_Vector - runif(num_Devices) #NULL-initialize training and validation sets. This seems like a bit of a hack... training_Set - measurements[0] validation_Set - measurements[0] #divide up the training and validation data sets from measurements. for ( i in 1:num_Devices) { if ( device_Prob_Vector[i] 0.5 ) { training_Set - rbind(training_Set, measurements[i,]) } else { validation_Set - rbind(validation_Set, measurements[i,]) } } This code works correctly, but takes quite a long time to execute. I suspect this is because rbind() is dynamically resizing the tables as it adds new rows to each table of data. Is there a way to pre-allocate memory for each of the two tables, and then shrink them after the loop has completed? Thanks for the help. ~Nate -- View this message in context: http://www.nabble.com/Simple-table-generation-question-tf4056042.html#a11521582 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] Lattice: vertical barchart
barchart(Titanic, stack=F) produces a very nice horizontal barchart. Each panel has four groups of two bars. barchart(Titanic, stack=F, horizontal=F) doesn't produce the results I would have expected, as it produces this warning message: Warning message: y should be numeric in: bwplot.formula(x = as.formula(form), data = list(Class = c(1, And it results in each panel having 22 groups of 0-2 bars. How can I produce something just like the original except with the orientation changed? Thanks in advance. __ 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] overlay boxplot
You will get more useful answers if you specify exactly how you want to overlay the boxplots (overlay them on what?). You can certainly do this with the ggplot2 package, or lattice or base graphics. Hadley On 7/10/07, Hao Liu [EMAIL PROTECTED] wrote: hi, All: I need to overlay two boxplot, I played around with points() but found it does not seem to work with boxplot, it works fine with other. Is there a way to overlay two boxplot (using different color) in R? There was a thread talking about using ggplot package, however, I don't think there is a final solution... the answer give does not give overlay but a new plot. Thanks Hao __ 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] Writing Excel (.xls) files on non-Windows OSs using Perl
Greg, You are certainly welcome to use my Perl script as the basis for a write.xls() function for gdata. You can even change the name of the script to csv2xls.pl if you wish, for consistency with the existing function. If you might want to use the script largely 'as is', I won't have time for a couple of weeks until I finish an interim analysis in progress, but I could take a look at crafting a version of write.xls() as a wrapper to the Perl script and create a .Rd file for it. For ease of use and installation, we would need to think about including the Perl modules that the script currently utilizes, which I see you do with others for gdata in the 'perl' sub-dir. It looks like you have OLE::Storage_Lite.pm there, which means that I could modify the code to use Spreadsheet::WriteExcel rather than the 'Big' version, since the former (as of version 2.17) supports .xls files 7Mb with Storage_Lite installed. These would be: http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel http://search.cpan.org/dist/Getopt-Long/ http://search.cpan.org/~nwclark/perl-5.8.8/ext/File/Glob/Glob.pm http://search.cpan.org/~nwclark/perl-5.8.8/lib/File/Basename.pm http://search.cpan.org/~hmbrand/Text-CSV_XS-0.29/CSV_XS.pm HTH, Marc On Mon, 2007-07-09 at 17:53 -0400, Gregory Warnes wrote: Since I wrote the xls2csv.pl and read.xls() code for gdata, a perl module for writing MS-Excel files has come on the scene. I don't have the time at the moment to create an csv2xls.pl file, but it should be straightforward, and I would gladly add it to the gdata package. -G On Jul 9, 2007, at 12:15PM , Uwe Ligges wrote: Gabor Grothendieck wrote: Note that there already is a function, read.xls, in gdata that uses Perl. Note that Marc talked about *writing* in his original message. Uwe Ligges On 7/9/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Mon, 2007-07-09 at 16:42 +0300, Hans-Peter wrote: Hi, 2007/7/8, Marc Schwartz [EMAIL PROTECTED]: [snip] There exists the xlsReadWrite package on CRAN by Hans-Peter Suter, which is restricted to Windows, since it utilizes the non-FOSS MS Office API to write the Excel formats. The non-FOSS API is not the problem(#) but its implementation is: The 3rd party library I use is written in Pascal and supports Delphi and Kylix. Kylix would allow to port the package to Linux but as Kylix has unfortunately been abandoned by CodeGear (Borland) I am not ready/interested to spend my time on this dead road. Though it probably could be done quickly. A much more interesting way is to port the package using FreePascal. -- I plan to do this since long but... -- Maybe someone fluent on Linux and FreePascal could have a look at the pascal header files (treetron.googlepages.com) and make the demos run on Linux..., that would be great and speed up an eventual xlsReadWrite port! Thanks for the clarification. However, I think that if you are going to pursue a cross-platform solution, providing source code requiring compilation (as opposed to a pre-compiled Windows binary), you should consider what the installation requirements for your package would then be. If you are going to take the step of requiring a prospective end- user to have a particular Pascal compiler in place, you may as well have the requirement for a Perl interpreter and associated packages. Since Perl is widely available and you are more likely to find Perl-fluent coders as opposed to Pascal-fluent coders (eg. I have not used Pascal since the late 80's), I would urge you to consider Perl as a future substrate for your functions. While compiled code will run faster than interpreted code, for these types of file I/O functions, I am not sure that you lose much with Perl from a performance standpoint and you certainly gain the eyes of a wider audience with respect to use, debugging and enhancements. To that end, you (or any other interested parties) are free to utilize my code in any way you deem appropriate. I did not state this in my original post, but I make the code available under GPL(v2), freeing you from any restrictions in its use, including your Pro version, as long as you make the source available in a fashion consistent with the GPL requirements. Regards, 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-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,
[R] Fraction ECDF
Hi all, I would like to plot part of the emperical CDF. Suppose the variable is x, I just need the part when x1,therefore, I am using the following codes. tail - x1 plot(ecdf(x[tail]), do.points=FALSE, verticals=TRUE) The x value starts from 1, but the yaxs still begins from 0, not the corresponding value when x is 1. How can I make it match? Could anyone give me some advice? Many thanks. -- View this message in context: http://www.nabble.com/Fraction-ECDF-tf4056229.html#a11522204 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] Lattice: vertical barchart
Michael Hoffman said the following on 7/10/2007 7:06 AM: barchart(Titanic, stack=F) produces a very nice horizontal barchart. Each panel has four groups of two bars. barchart(Titanic, stack=F, horizontal=F) doesn't produce the results I would have expected, as it produces this warning message: Warning message: y should be numeric in: bwplot.formula(x = as.formula(form), data = list(Class = c(1, And it results in each panel having 22 groups of 0-2 bars. How can I produce something just like the original except with the orientation changed? Thanks in advance. Hi, Michael, It seems that barchart.table doesn't allow the horizontal = FALSE argument. With a slight modification to barchart.table this can be accomplished. Also, I don't get a warning with your original code using R-2.5.1 and lattice 0.16-1. HTH, --sundar barchart.table - function (x, data = NULL, groups = TRUE, origin = 0, stack = TRUE, horizontal = TRUE, ...) ## add horizontal argument { formula - x ocall - sys.call(sys.parent()) if (!is.null(data)) warning(explicit 'data' specification ignored) data - as.data.frame(formula) nms - names(data) freq - which(nms == Freq) nms - nms[-freq] ## SD: change formula if horizontal == FALSE form - if(horizontal) { paste(nms[1], Freq, sep = ~) } else { paste(Freq, nms[1], sep = ~) } ## SD: end change nms - nms[-1] len - length(nms) if (is.logical(groups) groups len 0) { groups - as.name(nms[len]) nms - nms[-len] len - length(nms) } else groups - NULL if (len 0) { rest - paste(nms, collapse = +) form - paste(form, rest, sep = |) } ans - barchart(as.formula(form), data, groups = eval(groups), origin = origin, stack = stack, ...) ans$call - ocall ans } barchart(Titanic, stack = FALSE) barchart(Titanic, stack = FALSE, horizontal = FALSE) __ 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] integration over a simplex
Hi Robin, A Monte-Carlo approach could be attempted, if one could generate samples that are either uniformly distributed over the simplex. There is a small section in Luc Devroye's book (Generation of Non-uniform random deviates) on random uniform sampling from a simplex, if I remeber correctly. Another approach is importance sampling, where the sampling points have a characterized distribution. I have seen a technique called polyEDA, based on Gibbs sampling and truncated multivariate normal distribution. I had previously emailed the authors of this approach for the code, but haven't received a reply yet. You can google polyEDA for more info. I am interested in various computational problems related to polyhedra (e.g. enumeration of vertices, locating extrema, random sampling). I would appreciate if you'd keep me posted on how you solved this problem. Best, Ravi. - Original Message - From: Robin Hankin [EMAIL PROTECTED] Date: Tuesday, July 10, 2007 6:58 am Subject: [R] integration over a simplex To: RHelp help r-help@stat.math.ethz.ch Hello The excellent adapt package integrates over multi-dimensional hypercubes. I want to integrate over a multidimensional simplex. Has anyone implemented such a thing in R? I can transform an n-simplex to a hyperrectangle but the Jacobian is a rapidly-varying (and very lopsided) function and this is making adapt() slow. [ A \dfn{simplex} is an n-dimensional analogue of a triangle or tetrahedron. It is the convex hull of (n+1) points in an n-dimensional Euclidean space. My application is a variant of the Dirichlet distribution: With p~D(a), if length(p) = n+1 then the requirement that all(p0) and sum(p)=1 mean that the support of the Dirichlet distribution is an n-simplex. ] -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743 __ R-help@stat.math.ethz.ch mailing list PLEASE do read the posting guide 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] overlay boxplot
Thanks... I just realized using add=TRUE will work... Best Hao hadley wickham wrote: You will get more useful answers if you specify exactly how you want to overlay the boxplots (overlay them on what?). You can certainly do this with the ggplot2 package, or lattice or base graphics. Hadley On 7/10/07, Hao Liu [EMAIL PROTECTED] wrote: hi, All: I need to overlay two boxplot, I played around with points() but found it does not seem to work with boxplot, it works fine with other. Is there a way to overlay two boxplot (using different color) in R? There was a thread talking about using ggplot package, however, I don't think there is a final solution... the answer give does not give overlay but a new plot. Thanks Hao __ 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 plot two variables using a secondary Y axis
Date Fo Co6/27/2007 57.1 13.96/28/2007 57.7 14.3 6/29/2007 57.8 14.36/30/2007 57 13.97/1/2007 57.1 13.9 7/2/2007 57.2 14.07/3/2007 57.3 14.17/4/2007 57.6 14.2 7/5/2007 58 14.47/6/2007 58.1 14.57/7/2007 58.2 14.67/8/2007 58.4 14.77/9/200758.7 14.8 Hello all: I am a newbie to R, and I was wondering how can I plot the Temperature values above using Lattice or ggplot2 code. I want Date(X axis), Degrees F(Y axis) and Degrees C( on a secondary Y axis). 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.
[R] overlay boxplot
hi, All: I need to overlay two boxplot, I played around with points() but found it does not seem to work with boxplot, it works fine with other. Is there a way to overlay two boxplot (using different color) in R? There was a thread talking about using ggplot package, however, I don't think there is a final solution... the answer give does not give overlay but a new plot. Thanks Hao __ 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] Fraction ECDF
On 7/10/2007 10:36 AM, livia wrote: Hi all, I would like to plot part of the emperical CDF. Suppose the variable is x, I just need the part when x1,therefore, I am using the following codes. tail - x1 plot(ecdf(x[tail]), do.points=FALSE, verticals=TRUE) The x value starts from 1, but the yaxs still begins from 0, not the corresponding value when x is 1. How can I make it match? Could anyone give me some advice? Many thanks. Rather than subsetting the x, I'd just use xlim and ylim arguments to plot() to change the range. For example, plot(ecdf(x), do.points=FALSE, verticals=TRUE, xlim=c(1, max(x)), ylim=c(1-sum(x1)/length(x), 1)) 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] How to plot two variables using a secondary Y axis
Felipe Carrillo said the following on 7/10/2007 7:58 AM: Date Fo Co6/27/2007 57.1 13.96/28/2007 57.7 14.3 6/29/2007 57.8 14.36/30/2007 57 13.97/1/2007 57.1 13.9 7/2/2007 57.2 14.07/3/2007 57.3 14.17/4/2007 57.6 14.2 7/5/2007 58 14.47/6/2007 58.1 14.57/7/2007 58.2 14.6 7/8/2007 58.4 14.77/9/200758.7 14.8 Hello all: I am a newbie to R, and I was wondering how can I plot the Temperature values above using Lattice or ggplot2 code. I want Date(X axis), Degrees F(Y axis) and Degrees C( on a secondary Y axis). Thanks For lattice, see this thread: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/102768.html HTH, --sundar __ 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] Lattice: vertical barchart
Sundar Dorai-Raj wrote: It seems that barchart.table doesn't allow the horizontal = FALSE argument. With a slight modification to barchart.table this can be accomplished. Thanks for supplying that. Also, I don't get a warning with your original code using R-2.5.1 and lattice 0.16-1. Thanks. I should have specified I am using R-2.4.0. __ 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 of bins with different length
Dear users, please help to define the following data structure: I would like to have a matrix, where every element is a container of different size , containing real numbers. The containers (bins) are addressed by an index pair [i,j] (i is number of corresponding row of the matrix, j is the coloumn of the matrix). The containers are initially empty, I would like to fill them dynamically (put certain numbers into different bins in each iteration). I can not define a 3 dimensional array, because I don't know the length of the third dimension in advance, and because the vectors (containers) in the matrix are usually of different length. Any help greatly appreciated, Balazs Torma __ 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] matrix of bins with different length
Try this: m - matrix(list(1, 1:2, 1:3, 1:4), 2) m[[1,1]] [1] 1 m[[2,1]] [1] 1 2 m [,1] [,2] [1,] 1 Integer,3 [2,] Integer,2 Integer,4 On 7/10/07, Balazs Torma [EMAIL PROTECTED] wrote: Dear users, please help to define the following data structure: I would like to have a matrix, where every element is a container of different size , containing real numbers. The containers (bins) are addressed by an index pair [i,j] (i is number of corresponding row of the matrix, j is the coloumn of the matrix). The containers are initially empty, I would like to fill them dynamically (put certain numbers into different bins in each iteration). I can not define a 3 dimensional array, because I don't know the length of the third dimension in advance, and because the vectors (containers) in the matrix are usually of different length. Any help greatly appreciated, Balazs Torma __ 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 preserve data across function calls in a library package
Hi, I am writing an R package with two functions in C++. So far everything works. Now, i would like to write a third function which would use a pointer (it is a pointer to a class object) created by first function. I tried placing this pointer outside of the function definitions (i.e to make it global) but when called in the 3rd function i get *** caught bus error *** address 0x0, cause 'invalid alignment' I tried Callocing it in the 1st function but to no avail. Here is a quick summary. When foo is called (through do_foo, **after** having called do_kNN_e) i get the aforementioned error. Can anyone provide some pointers (no pun intended) on this? Thanks Saptarshi ANN* book; int* foot; void foo(void){ Rprintf(many times\n); Rprintf(%p\n,book); Rprintf(%p\n,foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and the last the number of cols see http://cran.r- project.org/doc/manuals/R-exts.html PROTECT(distance=allocMatrix(REALSXP,nrow,k)); ANNpointArray datapoints; ANNpoint qpoint; ANNkd_tree* kdTree; book=Calloc(1,ANN*); foot=Calloc(1,int); book=kdTree; *foot=10; ... } extern C { void do_foo(void){ foo(); } SEXP do_kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP k,SEXP eps) { return kNN_e(data,Nrow, Ncol, k,eps); } [[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] why doesn't as.character of this factor create a vector of characters?
I'm trying to figure out why when I use as.character() on one row of a data.frame, I get factor numbers instead of a character vector. Any suggestions? See the following code: a-c(Abraham,Jonah,Moses) b-c(Sarah,Hannah,Mary) c-c(Billy,Joe,Bob) df-data.frame(a=a,b=b,c=c) #Suppose I'm interested in one line of this data frame but as a vector one.line - df[df$a==Abraham,] #However the following illustrates the problem I'm having one.line - as.vector(df[df$a==Abraham,]) #Creates a one row data.frame instead of a vector! #compare above to one.line - as.character(df[df$a==Abraham,]) #Creates a vector of 1, 3, 1! #In the end, this creates the output that I'd like: one.line -as.vector(t(df[df$a==Abraham,])) #but it seems like a lot of work! __ 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] type III ANOVA for a nested linear model
I nominate the following 2 pieces from Bill's reply for fortunes (probably 2 separate fortunes): All this becomes even more glaring if you take the unusal step of plotting the data. and What sort of editor would overlook this clear and demonstrable message leaping out from the data in favour of some arcane argument about types of sums of squares? Several answers come to mind: A power freak, a SAS afficianado, an idiot. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 __ 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] Fraction ECDF
Thank you very much. Duncan Murdoch-2 wrote: On 7/10/2007 10:36 AM, livia wrote: Hi all, I would like to plot part of the emperical CDF. Suppose the variable is x, I just need the part when x1,therefore, I am using the following codes. tail - x1 plot(ecdf(x[tail]), do.points=FALSE, verticals=TRUE) The x value starts from 1, but the yaxs still begins from 0, not the corresponding value when x is 1. How can I make it match? Could anyone give me some advice? Many thanks. Rather than subsetting the x, I'd just use xlim and ylim arguments to plot() to change the range. For example, plot(ecdf(x), do.points=FALSE, verticals=TRUE, xlim=c(1, max(x)), ylim=c(1-sum(x1)/length(x), 1)) 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. -- View this message in context: http://www.nabble.com/Fraction-ECDF-tf4056229.html#a11524206 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] How to preserve data across function calls in a library package
Hi, Some progress: I am using SEXP retty; book=Calloc(1,int); *book=10; PROTECT(retty=R_MakeExternalPtr(book,R_NilValue,R_NilValue)); then UNPROTECTING and returning retty. In a another function, foo(SEXP s){ int* f=(int *)R_ExternalPtrAddr(p); Rprintf(many times %d\n,*f); } When called do_foo(p) where do_foo calls foo and p is the pointer returned by the former code snippet, the Rprintf successfully prints the correct value but subsequently crashes *** caught bus error *** address 0x0, cause 'invalid alignment'. I can't figure out why... I would appreciate any advice provided. Rgds Saptarshi On Jul 10, 2007, at 11:41 AM, Saptarshi Guha wrote: Hi, I am writing an R package with two functions in C++. So far everything works. Now, i would like to write a third function which would use a pointer (it is a pointer to a class object) created by first function. I tried placing this pointer outside of the function definitions (i.e to make it global) but when called in the 3rd function i get *** caught bus error *** address 0x0, cause 'invalid alignment' I tried Callocing it in the 1st function but to no avail. Here is a quick summary. When foo is called (through do_foo, **after** having called do_kNN_e) i get the aforementioned error. Can anyone provide some pointers (no pun intended) on this? Thanks Saptarshi ANN* book; int* foot; void foo(void){ Rprintf(many times\n); Rprintf(%p\n,book); Rprintf(%p\n,foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and the last the number of cols see http://cran.r- project.org/doc/manuals/R-exts.html PROTECT(distance=allocMatrix(REALSXP,nrow,k)); ANNpointArray datapoints; ANNpoint qpoint; ANNkd_tree* kdTree; book=Calloc(1,ANN*); foot=Calloc(1,int); book=kdTree; *foot=10; ... } extern C { void do_foo(void){ foo(); } SEXP do_kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP k,SEXP eps) { return kNN_e(data,Nrow, Ncol, k,eps); } [[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. Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha Would you people stop playing these stupid games?!?!? __ 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] ECDF, distribution of Pareto, distribution of Normal
Hello all, I would like to plot the emperical CDF, normal CDF and pareto CDF in the same graph and I amusing the following codes. z is a vector and I just need the part when z between 1.6 and 3. plot(ecdf(z), do.points=FALSE, verticals=TRUE, xlim=c(1.6,3),ylim=c(1-sum(z1.6)/length(z), 1)) x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col=red) y - seq(1.6, 3, 0.1) lines(y,pnorm(y, mean(z),sqrt(var(z))), col=blue) The emperical CDF and normal CDF look rather resonable, but the pareto CDF looks quite odd. I am not sure whether I plot the pareto CDF correctly e.g. in the right yaxs or any other mistake? At the same time, let t represents the vector whose values are larger than 1.6(the part we want). If I implement the following codes and plot the emperical CDF and pareto CDF, the pareto CDF seems fit. plot(ecdf(t), do.points=FALSE, verticals=TRUE) x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col=red) Could anyone give me some advice on this? Many thanks. -- View this message in context: http://www.nabble.com/ECDF%2C-distribution-of-Pareto%2C-distribution-of-Normal-tf4056943.html#a11524560 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] Simple table generation question
Maybe this is what you want: you are right about the re-allocating the tables, but you can subset your table into a new one: selection - which(device_Prob_Vector 0.5) # or via sample: selection - sample(num_Devices) training_Set - measurements[selection] validation_Set - measurements[-selection] good luck Bart natekupp wrote: Hey all, I'm doing some work with machine learning on R (I'm a fairly new user of R), and I have a question about generating new tables from existing tables. I'm currently using a table of measurements I read in from a CSV file to generate training and validation data set tables for future use in a machine learning algorithm using the code: #generate probabilities to divide up training / validation data sets randomly device_Prob_Vector - runif(num_Devices) #NULL-initialize training and validation sets. This seems like a bit of a hack... training_Set - measurements[0] validation_Set - measurements[0] #divide up the training and validation data sets from measurements. for ( i in 1:num_Devices) { if ( device_Prob_Vector[i] 0.5 ) { training_Set - rbind(training_Set, measurements[i,]) } else { validation_Set - rbind(validation_Set, measurements[i,]) } } This code works correctly, but takes quite a long time to execute. I suspect this is because rbind() is dynamically resizing the tables as it adds new rows to each table of data. Is there a way to pre-allocate memory for each of the two tables, and then shrink them after the loop has completed? Thanks for the help. ~Nate -- View this message in context: http://www.nabble.com/Simple-table-generation-question-tf4056042.html#a11522530 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] Crossing native ArcGis GRID with a XY coordinate table
Dear All, I have about 50 native ArcGis GRID maps and I need read them on R. After that I need to cross these maps with a set of XY coordinates which are stored on a table. When XY coordinates of my table match with the pixels of my maps, I would like to store the values of the pixels as a collumn on my table. Thanks in advance for all help Miltinho Brazil Flickr agora em português. Você cria, todo mundo vê. http://www.flickr.com.br/ [[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] integration over a simplex
On 7/10/2007 6:57 AM, Robin Hankin wrote: Hello The excellent adapt package integrates over multi-dimensional hypercubes. I want to integrate over a multidimensional simplex. Has anyone implemented such a thing in R? I can transform an n-simplex to a hyperrectangle but the Jacobian is a rapidly-varying (and very lopsided) function and this is making adapt() slow. [ A \dfn{simplex} is an n-dimensional analogue of a triangle or tetrahedron. It is the convex hull of (n+1) points in an n-dimensional Euclidean space. My application is a variant of the Dirichlet distribution: With p~D(a), if length(p) = n+1 then the requirement that all(p0) and sum(p)=1 mean that the support of the Dirichlet distribution is an n-simplex. I don't know what shape of simplex you're working with, but I believe the subset of an n-cube with coordinates ordered x[1] x[2] ... x[n] is a simplex, and the cube can be tiled with n! of those, by permuting the order of the coordinates. So if your function is smooth enough at the edges you might be able to map n! copies of it onto a cube, and use adapt to integrate over that. That is: if f() is your function, defined on 0 x[1] x[2] ... x[n] 1, define g - function(x) f(sort(x)), and the integral you want is (1/n!) times the integral of g over the unit cube. 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] ECDF, distribution of Pareto, distribution of Normal
Original Message Subject: [R] ECDF, distribution of Pareto, distribution of Normal From: livia [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Tue Jul 10 2007 18:35:04 GMT+0200 Hello all, I would like to plot the emperical CDF, normal CDF and pareto CDF in the same graph and I amusing the following codes. z is a vector and I just need the part when z between 1.6 and 3. plot(ecdf(z), do.points=FALSE, verticals=TRUE, xlim=c(1.6,3),ylim=c(1-sum(z1.6)/length(z), 1)) x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col=red) There is something wrong with your pgpd function, see ?pgpd for help and parameters... (I wonder how you got something plotted here...) y - seq(1.6, 3, 0.1) lines(y,pnorm(y, mean(z),sqrt(var(z))), col=blue) The emperical CDF and normal CDF look rather resonable, but the pareto CDF looks quite odd. I am not sure whether I plot the pareto CDF correctly e.g. in the right yaxs or any other mistake? At the same time, let t represents the vector whose values are larger than 1.6(the part we want). If I implement the following codes and plot the emperical CDF and pareto CDF, the pareto CDF seems fit. plot(ecdf(t), do.points=FALSE, verticals=TRUE) x - seq(1.6, 3, 0.1) lines(x,pgpd(x, 1.544,0.4373,-0.2398), col=red) Could anyone give me some advice on this? Many thanks. __ 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 with write.foreign (exporting data to Stata)
Hi. I'm trying to export a dataframe from R into Stata to use a statistical function I have there. I attached library write.foreign and renamed my variables to get them to match Stata's required format, and now have the following error: file /tmp/Rtmps7rmrM/file1c06dac8.raw not found Other than typing write.foreign, do I need to do something in R to get it to save the file on my hard drive? When I search for the file name on my computer nothing comes up. I'm using a Mac in case that makes a difference. Thanks, Kate -- View this message in context: http://www.nabble.com/Help-with-write.foreign-%28exporting-data-to-Stata%29-tf4057346.html#a11525796 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] why doesn't as.character of this factor create a vector ofcharacters?
Andrew: As you haven't received a reply yet ... ?factor,?UseMethod, and An Introduction to R may help. But it's a bit subtle. Factors are objects that are integer vectors (codes) with a levels attribute that associates the codes with levels as character names. So df[df$a==Abraham,] is a data.frame in which the columns are still factors. as.character() is a S3 generic function that calls the (internal) default method on a data.frame. This obviously just turns the vector of integers into characters and ignores the levels attribute. t() is also a S3 generic with a data.frame method. This merely converts the data.frame to a matrix via as.matrix and then applies t() to the matrix. The as.matrix() method for data.frames captures the levels and converts the data.frame to a character matrix with the level names, not their numeric codes.So another perhaps more intuitive but also more storage intensive way (I think) of doing what you wantthat avoids the transpose and as.vector() conversion would be: mx - as.matrix(df) mx[mx[,a]==Abraham,,drop=TRUE] HTH. Bert Gunter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew Yee Sent: Tuesday, July 10, 2007 8:57 AM To: r-help@stat.math.ethz.ch Subject: [R] why doesn't as.character of this factor create a vector ofcharacters? I'm trying to figure out why when I use as.character() on one row of a data.frame, I get factor numbers instead of a character vector. Any suggestions? See the following code: a-c(Abraham,Jonah,Moses) b-c(Sarah,Hannah,Mary) c-c(Billy,Joe,Bob) df-data.frame(a=a,b=b,c=c) #Suppose I'm interested in one line of this data frame but as a vector one.line - df[df$a==Abraham,] #However the following illustrates the problem I'm having one.line - as.vector(df[df$a==Abraham,]) #Creates a one row data.frame instead of a vector! #compare above to one.line - as.character(df[df$a==Abraham,]) #Creates a vector of 1, 3, 1! #In the end, this creates the output that I'd like: one.line -as.vector(t(df[df$a==Abraham,])) #but it seems like a lot of work! __ 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] Formatting panel borders in lattice package
Hello all -- I would like to thicken the borders between panels -- or more generally, all borders -- in a plot generated using lattice (specifically, levelplot). Something similar perhaps to box() function in graphics. I haven't been successful in reviewing available documentation. The problem stems from using a grayscale colorscheme that puts black colors near the borders, thus obscuring them. Then, another alternative would be to somehow inject white space between panels. In summary: 1) Does anybody know of a good way to increase the line thickness of borders in lattice, specifically those separating panels? 2) Does anybody know of a way to separate panels with whitespace? Advice is very much appreciated. Thanks, Hil Lyons Graduate Student Univ. of Washington Dept of Statistics __ 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] Help with write.foreign (exporting data to Stata)
I am not sure what you are doing there but what you need is library(foreign) and write.dta() see ?write.dta once you have loaded the foreign package Stefan Original Message Subject: [R] Help with write.foreign (exporting data to Stata) From: kdestler [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Tue Jul 10 2007 19:37:54 GMT+0200 Hi. I'm trying to export a dataframe from R into Stata to use a statistical function I have there. I attached library write.foreign and renamed my variables to get them to match Stata's required format, and now have the following error: file /tmp/Rtmps7rmrM/file1c06dac8.raw not found Other than typing write.foreign, do I need to do something in R to get it to save the file on my hard drive? When I search for the file name on my computer nothing comes up. I'm using a Mac in case that makes a difference. Thanks, Kate __ 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 preserve data across function calls in a library package
On Jul 10, 2007, at 12:33 PM, Saptarshi Guha wrote: Hi, Some progress: I am using SEXP retty; book=Calloc(1,int); *book=10; PROTECT(retty=R_MakeExternalPtr(book,R_NilValue,R_NilValue)); then UNPROTECTING and returning retty. In a another function, foo(SEXP s){ int* f=(int *)R_ExternalPtrAddr(p); Rprintf(many times %d\n,*f); } When called do_foo(p) where do_foo calls foo and p is the pointer returned by the former code snippet, the Rprintf successfully prints the correct value but subsequently crashes *** caught bus error *** address 0x0, cause 'invalid alignment'. I can't figure out why... I would appreciate any advice provided. Rgds Saptarshi One quick solution, change the function foo, to SEXP foo(SEXP s){ ... return(s) } and make corresponding changes elsewhere. This should work. Regards Saptarshi On Jul 10, 2007, at 11:41 AM, Saptarshi Guha wrote: Hi, I am writing an R package with two functions in C++. So far everything works. Now, i would like to write a third function which would use a pointer (it is a pointer to a class object) created by first function. I tried placing this pointer outside of the function definitions (i.e to make it global) but when called in the 3rd function i get *** caught bus error *** address 0x0, cause 'invalid alignment' I tried Callocing it in the 1st function but to no avail. Here is a quick summary. When foo is called (through do_foo, **after** having called do_kNN_e) i get the aforementioned error. Can anyone provide some pointers (no pun intended) on this? Thanks Saptarshi ANN* book; int* foot; void foo(void){ Rprintf(many times\n); Rprintf(%p\n,book); Rprintf(%p\n,foot); } SEXP kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP K,SEXP Eps) { int nrow=asInteger(Nrow); int ncol=asInteger(Ncol); int k=asInteger(K); double eps=asReal(Eps); SEXP ans,distance; SEXP retlist; PROTECT(ans=allocMatrix(INTSXP,nrow,k)); //The 2nd argument gives the number of rows, and the last the number of cols see http:// cran.r- project.org/doc/manuals/R-exts.html PROTECT(distance=allocMatrix(REALSXP,nrow,k)); ANNpointArray datapoints; ANNpoint qpoint; ANNkd_tree* kdTree; book=Calloc(1,ANN*); foot=Calloc(1,int); book=kdTree; *foot=10; ... } extern C { void do_foo(void){ foo(); } SEXP do_kNN_e(SEXP data, SEXP Nrow, SEXP Ncol,SEXP k,SEXP eps) { return kNN_e(data,Nrow, Ncol, k,eps); } [[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. Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha Would you people stop playing these stupid games?!?!? __ 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. Saptarshi Guha | [EMAIL PROTECTED] | http://www.stat.purdue.edu/~sguha What ever happened to happily ever after? __ 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] Lattice: vertical barchart
On 7/10/07, Sundar Dorai-Raj [EMAIL PROTECTED] wrote: Michael Hoffman said the following on 7/10/2007 7:06 AM: barchart(Titanic, stack=F) produces a very nice horizontal barchart. Each panel has four groups of two bars. barchart(Titanic, stack=F, horizontal=F) doesn't produce the results I would have expected, as it produces this warning message: Warning message: y should be numeric in: bwplot.formula(x = as.formula(form), data = list(Class = c(1, And it results in each panel having 22 groups of 0-2 bars. How can I produce something just like the original except with the orientation changed? Thanks in advance. Hi, Michael, It seems that barchart.table doesn't allow the horizontal = FALSE argument. With a slight modification to barchart.table this can be accomplished. Thanks Sundar. This seems like a reasonable feature; I'll add it in the next update. -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] Formatting panel borders in lattice package
On 7/10/07, Hil Lyons [EMAIL PROTECTED] wrote: Hello all -- I would like to thicken the borders between panels -- or more generally, all borders -- in a plot generated using lattice (specifically, levelplot). Something similar perhaps to box() function in graphics. I haven't been successful in reviewing available documentation. The problem stems from using a grayscale colorscheme that puts black colors near the borders, thus obscuring them. Then, another alternative would be to somehow inject white space between panels. In summary: 1) Does anybody know of a good way to increase the line thickness of borders in lattice, specifically those separating panels? qqmath(~height | voice.part, singer, par.settings = list(axis.line = list(lwd = 3))) (or probably closer to what you want) qqmath(~height | voice.part, singer, par.settings = list(axis.line = list(lwd = 3)), scales = list(lwd = 1)) 2) Does anybody know of a way to separate panels with whitespace? qqmath(~height | voice.part, singer, between = list(x = 0.5, y = 0.5)) -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] Help with write.foreign (exporting data to Stata)
On Tue, 10 Jul 2007, Stefan Grosse wrote: I am not sure what you are doing there but what you need is library(foreign) and write.dta() write.foreign should also work, though. My guess is that Kate used tempfile() to specify the filenames, and that the data file would then have been deleted on leaving R. This is only a guess, of course. The syntax for write.dta is write.dta(the.data.set, file=dataset.dta) and for write.foreign is write.foreign(the.data.set,codefile=dataset.do, datafile=dataset.raw, package=Stata) -thomas see ?write.dta once you have loaded the foreign package Stefan Original Message Subject: [R] Help with write.foreign (exporting data to Stata) From: kdestler [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date: Tue Jul 10 2007 19:37:54 GMT+0200 Hi. I'm trying to export a dataframe from R into Stata to use a statistical function I have there. I attached library write.foreign and renamed my variables to get them to match Stata's required format, and now have the following error: file /tmp/Rtmps7rmrM/file1c06dac8.raw not found Other than typing write.foreign, do I need to do something in R to get it to save the file on my hard drive? When I search for the file name on my computer nothing comes up. I'm using a Mac in case that makes a difference. Thanks, Kate __ 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. Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ 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] exces return by mktcap decile for each year
I have a data frame, lets call it dat, with 3 columns ( mc, yr, ret) which represent market cap, year, and return. mc is a factor, mc, and ret are real numbers. I want to add a column to the data calculated as follows. For each year, I want to split the data by mc decile, then calculate the mean ret within that mc decile, and finally subtract that year's decile mean from the raw return. Then I want that mean adjusted ret to be the new column. I can get the market cap deciles with my.cut - function(x) { cut( x, quantile( x, probs=seq(0,1,0.1), na.rm=TRUE)) } mc.deciles - by( dat$mc, dat$yr, my.cut) I don't know how to associate the values in mc.deciles with a particular row of the original data frame dat. I don't think I can unlist mc.deciles because the order won't be the same. If I could append mc.deciles as a new column to dat, then I could do something like by( dat$ret, list( dat$yr, dat$decile), mean) In which case I would still be faced with finding the right mean to subtract from each entry in dat$ret. Maybe I'm just stuck on by() and cut() when there is an easier way to handle this. Any suggestions? Thanks. __ 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] Repeated Measure different results to spss
This should work (with x containing the dataframe): x$Id=factor(x$Id) x$Group=factor(x$Group) x$Task=factor(x$Task) str(x) 'data.frame': 48 obs. of 4 variables: $ Id : Factor w/ 24 levels 1,2,3,4,..: 1 2 3 4 5 6 7 8 9 10 ... $ Group: Factor w/ 2 levels 1,2: 1 1 1 1 1 1 1 1 1 1 ... $ Task : Factor w/ 2 levels 1,2: 1 1 1 1 1 1 1 1 1 1 ... $ Score: num 0.39 0.48 0.59 0.33 0.38 0.37 0.47 0.2 0.29 0.41 ... out.aov = aov(Score~Group*Task+Error(Id+Id:Task),data=x) summary(out.aov) Error: Id Df Sum Sq Mean Sq F value Pr(F) Group 1 0.03420 0.03420 2.1382 0.1578 Residuals 22 0.35189 0.01600 Error: Id:Task Df Sum Sq Mean Sq F value Pr(F) Task1 0.048133 0.048133 5.2144 0.03242 * Group:Task 1 0.024687 0.024687 2.6743 0.11621 Residuals 22 0.203080 0.009231 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 out.aov = aov(Score~Group*Task+Error(Id),data=x) will work as well, but the error-term will be labelled simply as ``Within'', rather than as the interaction of Id*Task Hi, I have some problems with my repeated measures analysis. When I compute it with SPSS I get different results than with R. Probably I am doing something wrong in R. I have two groups (1,2) both having to solve a task under two conditions (1,2). That is one between subject factor (group) and one within subject factor (task). I tried the following: aov(Score ~factor(Group)*factor(Task)+Error(Id))) aov(Score ~factor(Group)*factor(Task)) but it leads to different results than my spss. I definitely miss some point here . Thanks for you help. IdGroup TaskScore 1 1 1 0.39 2 1 1 0.48 __ 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] Plot SpatialLinesDataFrame with xlim ylim
I'm running windows xp, R 2.3.1 with maptools 0.6-6, I guess. When plotting from a large SpatialLinesDataFrame and using xlim ylim to reduce the area, the plot axes automatically have the same scale size, even if xlim and ylim ranges differ. E.g.: tmp - readShapeLines(filepath) plot(tmp,xlim=c(-126,-119),ylim=c(50,51)) The y-axis range is actually 47-54, same range as the x-axis. What am I doing wrong? Should I be using a different object for simple coastline river data? Thanks in advance! Michael ___ Michael Folkes Salmon Stock Assessment Canadian Dept. of Fisheries Oceans Pacific Biological Station 3190 Hammond Bay Rd. Nanaimo, B.C., Canada V9T-6N7 Ph (250) 756-7264 Fax (250) 756-7053 [EMAIL PROTECTED] [[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] Making Gehan-Breslow test for Survival data
Jose, The Gehan-Breslow test provides a generalization of the Kruskal-Wallis test for censored data. As an alternative, try using survdiff with rho=1. This method uses weights w(ti) = S(ti) (where S is the Kaplan-Meier estimate of survival) which yields Fleming and Harrington's version of the Kruskal-Wallis test for censored data. This test will give more weight to early differences in the hazards. Regards, -Cody Cody Hamilton Edwards Lifesciences Hi all, The survivals functions can be tested by the Log-rank test and others, for example the Gehan-Breslow. The graham breslow work with the alpha values. But I don't know how is the Gehan-Breslow test with R. Somebody know a type function?.. or other suggestions? Any help will be really appreciated José Bustos Marine Biologist Master Apllied Stat Program University of Concepción [[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] How to plot two variables using a secondary Y axis
We assume the Fo and Co represent the same data except in different units (this seems to be approximately the case) so there is really only one variable being measured here. If that's not the case let me know. Below we read the data, define enough padding around plot to do what we want, call xyplot, draw the right axis and add the right y lablel. library(lattice) library(grid) # needed for grid.text # data Lines.raw - Date Fo Co 6/27/2007 57.1 13.9 6/28/2007 57.7 14.3 6/29/2007 57.8 14.3 6/30/2007 57 13.9 7/1/2007 57.1 13.9 7/2/2007 57.2 14.0 7/3/2007 57.3 14.1 7/4/2007 57.6 14.2 7/5/2007 58 14.4 7/6/2007 58.1 14.5 7/7/2007 58.2 14.6 7/8/2007 58.4 14.7 7/9/200758.7 14.8 # in reality next stmt would be DF - read.table(myfile.dat, header = TRUE) DF - read.table(textConnection(Lines.raw), header = TRUE) DF$Date - as.Date(DF$Date, %m/%d/%Y) par.settings - list( layout.widths = list(left.padding = 10, right.padding = 10), layout.heights = list(bottom.padding = 10, top.padding = 10) ) xyplot(Co ~ Date, DF, default.scales = list(y = list(relation = free)), ylab = C, par.settings = par.settings) trellis.focus(panel, 1, 1, clip.off = TRUE) pr - pretty(DF$Fo) at - 5/9 * (pr - 32) panel.axis(right, at = at, lab = pr, outside = TRUE) grid.text(F, x = 1.1, rot = 90) # right y axis label trellis.unfocus() On 7/10/07, Felipe Carrillo [EMAIL PROTECTED] wrote: Date Fo Co6/27/2007 57.1 13.96/28/2007 57.7 14.3 6/29/2007 57.8 14.36/30/2007 57 13.97/1/2007 57.1 13.9 7/2/2007 57.2 14.07/3/2007 57.3 14.17/4/2007 57.6 14.2 7/5/2007 58 14.47/6/2007 58.1 14.57/7/2007 58.2 14.6 7/8/2007 58.4 14.77/9/200758.7 14.8 Hello all: I am a newbie to R, and I was wondering how can I plot the Temperature values above using Lattice or ggplot2 code. I want Date(X axis), Degrees F(Y axis) and Degrees C( on a secondary Y axis). 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. __ 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] [R-pkgs] package relations updated
Dear useRs, Version 0.2 of package relations appeared on CRAN and is currently propagating to the mirrors. In addition to some bug fixes, the new release includes: o an introductory vignette showing the main features; o new SD fitters for the C (complete) and A (antisymmetric) families of relations; o a fitter for Copeland's method; o the relation_classes() function to extract and pretty-print (ordered) classes from preferences and equivalences; o the function relation_violations() to compute a measure of remoteness from a specified property (e.g., symmetry, transitivity, etc.). David and Kurt. -- Dr. David Meyer Department of Information Systems and Operations Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Tel: +43-1-313 36 4393 Fax: +43-1-313 36 90 4393 HP: http://wi.wu-wien.ac.at/~meyer/ ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ 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] type III ANOVA for a nested linear model
I second the nomination! Simon. On Tue, 2007-07-10 at 10:02 -0600, Greg Snow wrote: I nominate the following 2 pieces from Bill's reply for fortunes (probably 2 separate fortunes): All this becomes even more glaring if you take the unusal step of plotting the data. and What sort of editor would overlook this clear and demonstrable message leaping out from the data in favour of some arcane argument about types of sums of squares? Several answers come to mind: A power freak, a SAS afficianado, an idiot. -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey. __ 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] error using lp function in linux
Hello all, I would like to use the lp function (lpSolve package) on a linux system. Using sample code from the lp function help, I can solve the linear program with no errors or problems. However, when I copy the exact same code to R in linux (after loading the lpSolve package), I get the following error: *** caught segfault *** address 0x3, cause 'memory not mapped' Traceback: 1: .C(quot;lpslinkquot;, direction = as.integer(direction), x.count = as.integer(x.count), objective = as.double(objective), const.count = as.integer(const.count), constraints = as.double(constraints), int.count = as.integer(int.count), int.vec = as.integer(int.vec), objval = as.double(objval), solution = as.double(solution), presolve = as.integer(presolve), compute.sens = as.integer(compute.sens), sens.coef.from = as.double(sens.coef.from), sens.coef.to = as.double(sens.coef.to), duals = as.double(duals), duals.from = as.double(duals.from), duals.to = as.double(duals.to), status = as.integer(status), PACKAGE = quot;lpSolvequot;) 2: lp(quot;maxquot;, f.obj, f.con, f.dir, f.rhs) Possible actions: 1: abort (with core dump, if enabled) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Does this function not work with linux or is there some other explanation?Thanks, Byran Smucker Graduate Student, Dept. of Statistics Penn State University 301 Thomas Building [[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] Gap statistics (Tibshirani et al 2001) for Categorical data
Hi list, has anyone implemented the Gap statistic for clusters based on categorical/mixed data? Slmisc (and SAGx) only work on numerical data. Any suggestions welcome Thanks Herry __ 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.