Re: [R] main effect interaction in 2-way ANOVA
On Thu, 24 Feb 2005, array chip wrote: I am just a little confused of mian effect in the analysis of variance (ANOVA) when you include or do not include an interaction term. Let's assume a simple case of 2-way ANOVA with 2 factors A and B, each with 2 levels. If it shows that main effect for A is significant when the interaction between A and B is NOT included, and the main effect for A is NOT significant when the interaction is included, what simply does this difference mean? I understand that main effect for A generally means averaging over levels of B, Not in the presence of an interaction, with R's default coding. is this explanation for the situation when interaction is included or is not included or is irrelavant? And if my interest is in the main effect of A, in the above senario, should I include the interaction (thus lose the significance) or not include the interaction (thus keep my significance)? In R's default coding you are being told: 1) That the effect of A in the base level of B is not significant 2) There is a significant difference between the effect of A at the two levels of B. So, probably, A has no effect at the base level of B and an effect at the other level. You may or may not be interested in the effect of A averaged over the two levels of B. Note that R's default coding is unusual, and using Helmert contrasts will give results which are easier to interpret from conventional accounts. -- 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
Re: [R] other than default labels in lattice plot
Thank you for quick answer Deepayan. I should have think of relabeling myself but this on the fly action is nice. Thank you again. Petr On 24 Feb 2005 at 11:19, Deepayan Sarkar wrote: On Thursday 24 February 2005 08:03, Petr Pikal wrote: Dear all I solved a problem of customised labels on strips and boxes in bwplot by this construction. bbb - bwplot(zavoj ~ typmleti | pu) bbb$condlevels$pu - c(Povrchov prava, Bez PU) bbb$x.limits - c(Mleto, Mleto a stovno, Nemleto) bbb but I wonder if some other easy option exist. Let say something like bwplot(zavoj~typmleti | pu, some advanced stuff like box.labels=c(Mleto, Mleto a stovno, Nemleto), strip.labels = c(Povrchov prava, Bez PU) ) I think the most natural way to do this would be to change the labels of the factor levels directly. If you don't want to do this to your original data, you can do it on the fly as follows: relabel - function(x, labels) { stopifnot(is.factor(x)) levels(x) - labels x } y - rnorm(100) x - gl(3, 1, 100) g - gl(2, 1, 100) bwplot(y ~ relabel(x, c(Mleto, Mleto a stovno, Nemleto)) | relabel(g, c(Povrchov prava, Bez PU))) Of course, you can also do it your way: bwplot(y ~ x | g, xlim = c(Mleto, Mleto a stovno, Nemleto), strip = strip.custom(factor.levels = c(Povrchov prava, Bez PU))) This use of 'xlim' is a short-hand, the traditional way of changing the x-axis labels is scales = list(x = list(labels = c(Mleto, Mleto a stovno, Nemleto))) Changing strip labels is more complicated if you have more than one conditioning variable. Deepayan Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to set up number of prin comp.
I am trying to use PrinComp to do principle component analysis. I would like to know how to set the number of principle components. I assume you mean the function princomp (case _does_ matter in R) in package stats (which is loaded by default). This function has no way of specifying how many components to calculate; it always gives you all components. You have to select the components you want afterwards. See help(princomp) for details. E.g. X - some matrix pc - princomp(X) pc$scores[,1:4]# The four first score vectors pc$loadings[,1:4] # The four first loadings (The loadings can also be extracted with loadings(pc)[,1:4] .) -- Bjørn-Helge Mevik __ 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
[R] Problem using stepAIC/addterm (MASS package)
Hello, I'm currently dealing with a rather strange problem when using the function stepAIC (MASS package). The setting is the following: From model learning data sets (learndata), I want to be able to build prediction functions (in order to save them in a file for further use). This is done by the function pred.function (see below). Therein, I'd like to use stepAIC for model selection. However, if I try to evaluate pred.function for a specific data set, R sometimes stops with the message --- Error in inherits(x, data.frame) : Object learndata not found --- Debugging stepAIC showed me that the problem occurs in the step where addterm is called. addterm somehow doesn't seem to see the object learndata which is present (?) in the function's environment. Here is my code. The dataset BostonHousing is just an example for which this problem can be observed. my.MC is inspired by the Lexical scoping section in the R FAQ (http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html#Lexical-scoping). --- data(BostonHousing, package = mlbench) my.MC - function (f, env) f # make closure pred.function - function (learndata) { my.model - lm(medv ~ ., learndata) if (!require(MASS)) stop(Package MASS not loadable.) my.model - stepAIC(my.model, scope = list(lower = medv ~ 1, upper = medv ~ .)) my.MC(function(newdata) { predict(my.model, newdata) }, list(my.model = my.model) ) } pf - pred.function(BostonHousing) --- How can I tell addterm (or stepAIC) where to find learndata? Thanks for your help. Regards Michael -- Michael Beer, dipl. math., University of Freiburg/Fribourg Switzerland Seminar of Statistics, Av. de Beauregard 13, CH-1700 Freiburg Phone +41 26 300 8278, Fax +41 26 300 9781 E-mail: [EMAIL PROTECTED], Web: http://www.unifr.ch/stat/ __ 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
[R] Loops and dataframes
Hi, I am experiencing a long delay when using dataframes inside loops and was wordering if this is a bug or not. Example code: st - rep(1,10) ed - rep(2,10) for(i in 1:length(st)) st[i] - ed[i] # works fine df - data.frame(start=st,end=ed) for(i in 1:dim(df)[1]) df[i,1] - df[i,2] #takes for ever R: R 2.0.0 (2004-10-04) OS: Linux, Fedora Core 2 kernel: 2.6.10-1.14_FC2 cpu: AMD Athlon XP 1600. mem: 500MB. The example above is only to illustrate the problem. I need loops to apply some functions on pairs (not necessarily successive) of rows in a dataframe. Thankful for any advices, Firas. __ 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
[R] how to produce disease maps
---BeginMessage--- Hello Oaribile, you've sent the following to R-help-owner (which is me, a person) but you should send it to R-help, the mailing list. Regards, Martin Oarabile == Oarabile Ruth Molaodi [EMAIL PROTECTED] on Thu, 24 Feb 2005 17:06:40 + writes: Oarabile how to do disease maps in R? I want to produce Oarabile disease maps (A map which shows distribution of a Oarabile disease in areas of a city , country e.t.c) for Oarabile the spatial geographical data I have and I'm Oarabile wondering if this can be done in R. I realise that Oarabile there is maps package ,mapdata and e.tc. but these Oarabile do not show how. Oarabile Thanks Oarabile ---End Message--- __ 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
RE: [R] Loops and dataframes
You are discovering part of the overhead of using a data frame. The way you specify the subset of data frame to replace matters somewhat: st - rep(1,1e4) ed - rep(2,1e4) df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df[i,1] - df[i,2], gcFirst=TRUE) [1] 35.96 0.10 36.37NANA df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df[[1]][i] - df[[2]][i], gcFirst=TRUE) [1] 22.63 0.17 22.88NANA df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df$start[i] - df$end[i], gcFirst=TRUE) [1] 19.29 0.13 19.46NANA If you have all numeric data, you might as well use a matrix instead of data frame: m - cbind(start=st, end=ed) str(m) num [1:1, 1:2] 2 2 2 2 2 2 2 2 2 2 ... - attr(*, dimnames)=List of 2 ..$ : NULL ..$ : chr [1:2] start end system.time(for (i in 1:nrow(df)) m[i,1] - m[i,2], gcFirst=TRUE) [1] 0.06 0.00 0.08 NA NA Andy From: Firas Swidan Hi, I am experiencing a long delay when using dataframes inside loops and was wordering if this is a bug or not. Example code: st - rep(1,10) ed - rep(2,10) for(i in 1:length(st)) st[i] - ed[i] # works fine df - data.frame(start=st,end=ed) for(i in 1:dim(df)[1]) df[i,1] - df[i,2] #takes for ever R: R 2.0.0 (2004-10-04) OS: Linux, Fedora Core 2 kernel: 2.6.10-1.14_FC2 cpu: AMD Athlon XP 1600. mem: 500MB. The example above is only to illustrate the problem. I need loops to apply some functions on pairs (not necessarily successive) of rows in a dataframe. Thankful for any advices, Firas. __ 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 __ 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
RE: [R] Loops and dataframes
An addendum: If you must use a data frame (e.g., you have mixed data types), the following might help: df - list(start=st, end=ed) system.time({for (i in 1:length(df[[1]])) df$start[i] - df$end[i]; + df - as.data.frame(df)}, gcFirst=TRUE) [1] 0.14 0.01 0.15 NA NA I.e., keep it as a list until all manipulations are done, then coerce to data frame. Andy From: Liaw, Andy You are discovering part of the overhead of using a data frame. The way you specify the subset of data frame to replace matters somewhat: st - rep(1,1e4) ed - rep(2,1e4) df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df[i,1] - df[i,2], gcFirst=TRUE) [1] 35.96 0.10 36.37NANA df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df[[1]][i] - df[[2]][i], gcFirst=TRUE) [1] 22.63 0.17 22.88NANA df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df$start[i] - df$end[i], gcFirst=TRUE) [1] 19.29 0.13 19.46NANA If you have all numeric data, you might as well use a matrix instead of data frame: m - cbind(start=st, end=ed) str(m) num [1:1, 1:2] 2 2 2 2 2 2 2 2 2 2 ... - attr(*, dimnames)=List of 2 ..$ : NULL ..$ : chr [1:2] start end system.time(for (i in 1:nrow(df)) m[i,1] - m[i,2], gcFirst=TRUE) [1] 0.06 0.00 0.08 NA NA Andy From: Firas Swidan Hi, I am experiencing a long delay when using dataframes inside loops and was wordering if this is a bug or not. Example code: st - rep(1,10) ed - rep(2,10) for(i in 1:length(st)) st[i] - ed[i] # works fine df - data.frame(start=st,end=ed) for(i in 1:dim(df)[1]) df[i,1] - df[i,2] #takes for ever R: R 2.0.0 (2004-10-04) OS: Linux, Fedora Core 2 kernel: 2.6.10-1.14_FC2 cpu: AMD Athlon XP 1600. mem: 500MB. The example above is only to illustrate the problem. I need loops to apply some functions on pairs (not necessarily successive) of rows in a dataframe. Thankful for any advices, Firas. __ 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 __ 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 -- Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- __ 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
Re: [R] Loops and dataframes
On Feb 25, 2005, at 6:06 AM, Firas Swidan wrote: Hi, I am experiencing a long delay when using dataframes inside loops and was wordering if this is a bug or not. Example code: st - rep(1,10) ed - rep(2,10) for(i in 1:length(st)) st[i] - ed[i] # works fine df - data.frame(start=st,end=ed) for(i in 1:dim(df)[1]) df[i,1] - df[i,2] #takes for ever R: R 2.0.0 (2004-10-04) OS: Linux, Fedora Core 2 kernel: 2.6.10-1.14_FC2 cpu: AMD Athlon XP 1600. mem: 500MB. The example above is only to illustrate the problem. I need loops to apply some functions on pairs (not necessarily successive) of rows in a dataframe. I'm not an expert, but working with dataframes is typically slower than the eqivalent matrix. If it is possible (the data is of the same type, as it is above), working with the equivalent matrix is prabably faster. So, I think the general answer to the implied question is that dataframe processing is slower than vector processing or the equivalent matrix processing. If you post more details about your specific problem, folks may be able to find creative ways of speeding things up, if speed remains a concern. Sean __ 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
[R] Oriented PCA in R?
Is there an R implementation of Oriented PCA? Thanks for your help. Gorden __ 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
[R] Strange Colnames
Hello world, I am trying to create a matrix of lagged time series with the following code fragment (I know that I can use acf-function...). I want to set the variable/column name to something like lag 1 etc. If I try to do it I get text like lagtest.lagtest.lagtest.lag 1 where does this come from? After a conversion to a data.frame it works as expected. What did I miss? Thanks and greetings, Georg == lagtest - as.ts(seq(1:100)) ; for (i in 1:4) {lagtest - cbind(lagtest,lag(ts_test,i)); colnames(lagtest)[i+1]- paste(lag,i)} colnames(lagtest)[1]-H_GW; colnames(lagtest) [1] H_GW lagtest.lagtest.lagtest.lag 1 lagtest.lagtest.lag 2 [4] lagtest.lag 3 lag 4 # this works... t5 - as.data.frame(lagtest) for (i in 1:4) {names(t5)[i+1] - paste(var,i) } names(t5) [1] H_GW var 1 var 2 var 3 var 4 __ 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
Re: [R] Simulation Progress
I've made a function that executes a monte-carlo simulation. It always needs a lot of time until e.g. 1Mio simulation steps are done. So I would like to know, how many percent of the work is already done. This reminds me of my 'iterator' class I was working on - but never really finished. Instead of doing: for(i in 1:1000){ dostuff(i) } which creates a vector of c(1,2,...,1000), you create an iterator object, and do a while loop: myLoop = loop(N=1000) while(iterate(myLoop)){ dostuff(iteration(myLoop)) } now all the information about the loop is encapsulated in the iterator object 'myLoop', and there are methods for working out when the loop might finish: predictEnd(myLoop) Predicted finish at 12-Dec-02 12:12:34 I also started work on a superclass of this for MCMC runs, where you could specify a burn-in period and a sampling thinning parameter, and then there were methods for telling if you were in the burn-in period or if this was an interation that you were sampling in your output. Maybe I'll have a go at cleaning this all up over the easter break and making a proper package of it. Baz __ 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
Re: [R] Loops and dataframes
or something like: df - data.frame(start=st, end=ed) system.time(df[] - lapply(df, function(x) x[1] - x[2]), gcFirst=TRUE) # or in general if you have a vectorized function `f()' and you wish to apply it # in the ith and jth column of the data frame, e.g., # df[] - lapply(df, function(x, f) f(x[i], x[j]), f=function(x, y) x*y) Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Liaw, Andy [EMAIL PROTECTED] To: 'Firas Swidan' [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Sent: Friday, February 25, 2005 12:33 PM Subject: RE: [R] Loops and dataframes An addendum: If you must use a data frame (e.g., you have mixed data types), the following might help: df - list(start=st, end=ed) system.time({for (i in 1:length(df[[1]])) df$start[i] - df$end[i]; + df - as.data.frame(df)}, gcFirst=TRUE) [1] 0.14 0.01 0.15 NA NA I.e., keep it as a list until all manipulations are done, then coerce to data frame. Andy From: Liaw, Andy You are discovering part of the overhead of using a data frame. The way you specify the subset of data frame to replace matters somewhat: st - rep(1,1e4) ed - rep(2,1e4) df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df[i,1] - df[i,2], gcFirst=TRUE) [1] 35.96 0.10 36.37NANA df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df[[1]][i] - df[[2]][i], gcFirst=TRUE) [1] 22.63 0.17 22.88NANA df - data.frame(start=st, end=ed) system.time(for (i in 1:dim(df)[1]) df$start[i] - df$end[i], gcFirst=TRUE) [1] 19.29 0.13 19.46NANA If you have all numeric data, you might as well use a matrix instead of data frame: m - cbind(start=st, end=ed) str(m) num [1:1, 1:2] 2 2 2 2 2 2 2 2 2 2 ... - attr(*, dimnames)=List of 2 ..$ : NULL ..$ : chr [1:2] start end system.time(for (i in 1:nrow(df)) m[i,1] - m[i,2], gcFirst=TRUE) [1] 0.06 0.00 0.08 NA NA Andy From: Firas Swidan Hi, I am experiencing a long delay when using dataframes inside loops and was wordering if this is a bug or not. Example code: st - rep(1,10) ed - rep(2,10) for(i in 1:length(st)) st[i] - ed[i] # works fine df - data.frame(start=st,end=ed) for(i in 1:dim(df)[1]) df[i,1] - df[i,2] #takes for ever R: R 2.0.0 (2004-10-04) OS: Linux, Fedora Core 2 kernel: 2.6.10-1.14_FC2 cpu: AMD Athlon XP 1600. mem: 500MB. The example above is only to illustrate the problem. I need loops to apply some functions on pairs (not necessarily successive) of rows in a dataframe. Thankful for any advices, Firas. __ 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 __ 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 -- Notice: This e-mail message, together with any attachments, contains information of Merck Co., Inc. (One Merck Drive, Whitehouse Station, New Jersey, USA 08889), and/or its affiliates (which may be known outside the United States as Merck Frosst, Merck Sharp Dohme or MSD and in Japan, as Banyu) that may be confidential, proprietary copyrighted and/or legally privileged. It is intended solely for the use of the individual or entity named on this message. If you are not the intended recipient, and have received this message in error, please notify us immediately by reply e-mail and then delete it from your system. -- __ 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 __ 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
Re: [R] Strange Colnames
You probably want to have a look at help(embed). It might be all you need. On Friday 25 February 2005 12:49, Georg Hoermann wrote: Hello world, I am trying to create a matrix of lagged time series with the following code fragment (I know that I can use acf-function...). I want to set the variable/column name to something like lag 1 etc. If I try to do it I get text like lagtest.lagtest.lagtest.lag 1 where does this come from? After a conversion to a data.frame it works as expected. What did I miss? Thanks and greetings, Georg == lagtest - as.ts(seq(1:100)) ; for (i in 1:4) {lagtest - cbind(lagtest,lag(ts_test,i)); colnames(lagtest)[i+1]- paste(lag,i)} colnames(lagtest)[1]-H_GW; colnames(lagtest) [1] H_GW lagtest.lagtest.lagtest.lag 1 lagtest.lagtest.lag 2 [4] lagtest.lag 3 lag 4 # this works... t5 - as.data.frame(lagtest) for (i in 1:4) {names(t5)[i+1] - paste(var,i) } names(t5) [1] H_GW var 1 var 2 var 3 var 4 __ 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 __ 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
[R] display full form in args
Forgive me for I do not fully comprehend the idea of classes and methods but I was wondering if someone could help explain why the function args () behaves the way it does. Why does args(cut) show the simplified version instead of the more complete one as in help(cut). This is true for few other functions (e.g. plot, rep). args(cut) function (x, ...) Sometime I can get around this by using the default method as in args(cut.default) function (x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ...) But sometimes I cannot use this workaround. e.g. args(merge.default) does not give the full form as in the help file. I find it almost always useful to see the full form. Is there a more reliable workaround or do I have to look up the help to be certain. Thank you. Regards, Adai __ 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
[R] anova grouping of factors in lme4 / lmer
Hi. I'm using lmer() from the lme4 package (version 0.8-3) and I can't get anova() to group variables properly. I'm fitting the mixed model Response ~ Weight + Experimenter + (1|SUBJECT.NAME) + (1|Date.StudyDay) where Weight is numeric and Experimenter is a factor, ie, str(data.df) `data.frame': 4266 obs. of 5 variables: $ SUBJECT.NAME : Factor w/ 2133 levels A0480,A0..,..: 1 1 2 2 ... $ Response : num -0.490 0.145 1.992 -0.391 0.917 ... $ Date.StudyDay: Factor w/ 161 levels 16,22,24,..: 24 24 ... $ Experimenter : Factor w/ 7 levels amyt,carmena,..: 5 5 1 1 3 3 ... $ Weight : num 25.3 25.3 16.7 16.7 28.2 28.2 27.1 27.1 ... The model fits fine but when I call anova() to see the effect of the Experimenter factor, I get a sequential anova table where factor levels are fit one at a time, ie, anova(lmer(Response ~ Weight + Experimenter ++ (1 | SUBJECT.NAME) + (1 | Date.StudyDay), +data=data.df)) Analysis of Variance Table Df Sum Sq Mean Sq Denom F valuePr(F) Weight110.810.8 4242.0 14.4457 0.0001463 *** Experimentercarmena 1 0.5 0.5 4242.0 0.6708 0.4128136 Experimentercnunez1 4.8 4.8 4242.0 6.5042 0.0107969 * Experimenterlsolberg 1 0.4 0.4 4242.0 0.5910 0.4420783 Experimenterpeterb1 0.01430 0.01430 4242.0 0.0192 0.8898029 Experimenterpolinka 1 0.2 0.2 4242.0 0.2290 0.6322775 Experimenterstuart1 0.9 0.9 4242.0 1.2505 0.2635116 ... rather than what I want, which is a sequential anova table where the levels are grouped, eg [using lme()], anova(lme(Response ~ Weight + Experimenter, random = ~ 1 | SUBJECT.NAME, + data=data.df)) Analysis of Variance Table Df Sum Sq Mean Sq Denom F valuePr(F) Weight19.5 9.5 4242.0 12.7213 0.0003655 *** Experimenter 68.5 1.4 4242.0 1.9067 0.0759496 . Does anyone know how to make anova() group properly with lmer objects? Many thanks, William =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dr William Valdar ++44 (0)1865 287 717 Wellcome Trust Centre [EMAIL PROTECTED] for Human Genetics, Oxford www.well.ox.ac.uk/~valdar __ 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
RE: [R] how to produce disease maps
Oarabile == Oarabile Ruth Molaodi [EMAIL PROTECTED] on Thu, 24 Feb 2005 17:06:40 + writes: Oarabile how to do disease maps in R? I want to produce Oarabile disease maps (A map which shows distribution of a Oarabile disease in areas of a city , country e.t.c) for Oarabile the spatial geographical data I have and I'm Oarabile wondering if this can be done in R. I realise that Oarabile there is maps package ,mapdata and e.tc. but these Oarabile do not show how. Please study the two vignettes in the 'spdep' package. They should put you on the right track. Christophe -- Christophe Declercq, MD Observatoire regional de la sante Nord-Pas-de-Calais 13, rue Faidherbe F-59046 LILLE Cedex Phone 33 3 20 15 49 24 Fax 33 3 20 55 92 30 E-mail [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Repeated measures MANOVA
Hi, sorry to bother you again, but I can't figure it out myself and I also can't find any in-depth documentation about it... Consider the following SAS code (A1II2... contain the measurements for 40 subjects): proc glm; model A1II2 A1IN2 A1NI2 A1NN2 = /nouni; repeated CONTEXT 2, TARGET_SATZ 2; title A1 500-900 ms; This produces not only the univariate ANOVAs, but also a number of multivariate MANOVAs, including some test statistics (Wilks' Lambda, Pillai's Trace, etc.) on various hypothesis (no CONTEXT effect, no TARGET_SATZ effect, no CONTEXT*TARGET_SATZ effect). Unfortunately, I can't seem to be able to figure out how to reproduce this in R. There's obviously little sense in treating A1II2..A1NN2 as separate responses, so I came up with the following (for testing a single effect): resp - cbind( c(A1II2,A1IN2), c(A1NI2,A1NN2)) cond - gl(2,40,80) subj - gl(40,1,80) summary(manova( resp ~ cond + Error(subj/cond) )) Error: subj Df Pillai approx F num Df den Df Pr(F) Residuals 39 Error: subj:cond Df Pillai approx F num Df den Df Pr(F) cond 1 0.07911 1.63232 2 38 0.2089 Residuals 39 Warning message: Error model is singular in: aov(resp ~ cond + Error(subj/cond)) Now, this looks halfway reasonable, but it's not quite there. My questions are: - why is the Error model singular? - am I even on the right path, or is this completely wrong? - what do I do for interaction effects? I'd be very happy if you could give me any hints of where I should be going with this... Thanks again Bela __ 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
Re: [R] How to set up number of prin comp.
Hi Bjørn-Helge, Thanks for your help. In my case, there are more variables in the matrix than the units, so I have to use Prcomp with covariance to do PCA. The problem I am facing is how to get fisrt 8 coefficients and scores and how to write the result into text file. Thanks again. When I change princomp to prcomp below, I will NULL for pc$scores pc$loadings. X - some matrix pc - prcomp(X) pc$scores[,1:4]# The four first score vectors pc$loadings[,1:4] # The four first loadings Best Regards, WeiQiang Li [EMAIL PROTECTED] (Bjørn-Helge Mevik) Sent by: [EMAIL PROTECTED] No Phone Info Available 02/25/2005 05:38 PM To r-help@stat.math.ethz.ch cc Subject Re: [R] How to set up number of prin comp. I am trying to use PrinComp to do principle component analysis. I would like to know how to set the number of principle components. I assume you mean the function princomp (case _does_ matter in R) in package stats (which is loaded by default). This function has no way of specifying how many components to calculate; it always gives you all components. You have to select the components you want afterwards. See help(princomp) for details. E.g. X - some matrix pc - princomp(X) pc$scores[,1:4]# The four first score vectors pc$loadings[,1:4] # The four first loadings (The loadings can also be extracted with loadings(pc)[,1:4] .) -- Bjørn-Helge Mevik __ 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 [[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
Re: [R] Strange Colnames
Georg Hoermann georg.hoermann at gmx.de writes: : : Hello world, : : I am trying to create a matrix of lagged time series with the : following code fragment (I know that I can use acf-function...). : I want to set the variable/column name to something like : lag 1 etc. If I try to do it I get text like : lagtest.lagtest.lagtest.lag 1 where does this come from? : : After a conversion to a data.frame it works as expected. : What did I miss? : : Thanks and greetings, : : Georg : == : : lagtest - as.ts(seq(1:100)) ; : for (i in 1:4) {lagtest - cbind(lagtest,lag(ts_test,i)); : colnames(lagtest)[i+1]- paste(lag,i)} : colnames(lagtest)[1]-H_GW; : colnames(lagtest) : [1] H_GW lagtest.lagtest.lagtest.lag 1 : lagtest.lagtest.lag 2 : [4] lagtest.lag 3 lag 4 : : # this works... : :t5 - as.data.frame(lagtest) : for (i in 1:4) {names(t5)[i+1] - paste(var,i) } : names(t5) : [1] H_GW var 1 var 2 var 3 var 4 Here is something you could try: # define lags and their names lags - 0:4 names(lags) - c(G_HW, paste(lag, 1:4)) # build mts do.call(cbind, lapply(lags, lag, x = lagtest)) __ 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
[R] Re: anova grouping of factors in lme4 / lmer
Hi. Yesterday a revised version of lme4 came out that makes my question unnecessary. I was using the latest version available from my mirror (which was 6 days old rather than 1 day old). Please disregard my earlier posting. Thanks. William On Fri, 25 Feb 2005, William Valdar wrote: Hi. I'm using lmer() from the lme4 package (version 0.8-3) and I can't get anova() to group variables properly. I'm fitting the mixed model Response ~ Weight + Experimenter + (1|SUBJECT.NAME) + (1|Date.StudyDay) where Weight is numeric and Experimenter is a factor, ie, str(data.df) `data.frame': 4266 obs. of 5 variables: $ SUBJECT.NAME : Factor w/ 2133 levels A0480,A0..,..: 1 1 2 2 ... $ Response : num -0.490 0.145 1.992 -0.391 0.917 ... $ Date.StudyDay: Factor w/ 161 levels 16,22,24,..: 24 24 ... $ Experimenter : Factor w/ 7 levels amyt,carmena,..: 5 5 1 1 3 3 ... $ Weight : num 25.3 25.3 16.7 16.7 28.2 28.2 27.1 27.1 ... The model fits fine but when I call anova() to see the effect of the Experimenter factor, I get a sequential anova table where factor levels are fit one at a time, ie, anova(lmer(Response ~ Weight + Experimenter ++ (1 | SUBJECT.NAME) + (1 | Date.StudyDay), +data=data.df)) Analysis of Variance Table Df Sum Sq Mean Sq Denom F valuePr(F) Weight110.810.8 4242.0 14.4457 0.0001463 *** Experimentercarmena 1 0.5 0.5 4242.0 0.6708 0.4128136 Experimentercnunez1 4.8 4.8 4242.0 6.5042 0.0107969 * Experimenterlsolberg 1 0.4 0.4 4242.0 0.5910 0.4420783 Experimenterpeterb1 0.01430 0.01430 4242.0 0.0192 0.8898029 Experimenterpolinka 1 0.2 0.2 4242.0 0.2290 0.6322775 Experimenterstuart1 0.9 0.9 4242.0 1.2505 0.2635116 ... rather than what I want, which is a sequential anova table where the levels are grouped, eg [using lme()], anova(lme(Response ~ Weight + Experimenter, random = ~ 1 | SUBJECT.NAME, + data=data.df)) Analysis of Variance Table Df Sum Sq Mean Sq Denom F valuePr(F) Weight19.5 9.5 4242.0 12.7213 0.0003655 *** Experimenter 68.5 1.4 4242.0 1.9067 0.0759496 . Does anyone know how to make anova() group properly with lmer objects? Many thanks, William =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dr William Valdar ++44 (0)1865 287 717 Wellcome Trust Centre [EMAIL PROTECTED] for Human Genetics, Oxford www.well.ox.ac.uk/~valdar =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Dr William Valdar ++44 (0)1865 287 717 Wellcome Trust Centre [EMAIL PROTECTED] for Human Genetics, Oxford www.well.ox.ac.uk/~valdar __ 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
Re: [R] display full form in args
On Fri, 25 Feb 2005, Adaikalavan Ramasamy wrote: Forgive me for I do not fully comprehend the idea of classes and methods but I was wondering if someone could help explain why the function args () behaves the way it does. Why does args(cut) show the simplified version instead of the more complete one as in help(cut). This is true for few other functions (e.g. plot, rep). args(cut) function (x, ...) Adai, That _is_ the full form: those are formal arguments shared by all methods. For help(cut) I get Usage: cut(x, ...) which is the same. Sometime I can get around this by using the default method as in args(cut.default) function (x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ...) but other methods have other args, e.g. args(cut.Date) function (x, breaks, labels = NULL, start.on.monday = TRUE, right = FALSE, ...) But sometimes I cannot use this workaround. e.g. args(merge.default) does not give the full form as in the help file. It is the *data frame* method that you are looking at in the help file. Usage: merge(x, y, ...) ## Default S3 method: merge(x, y, ...) ## S3 method for class 'data.frame': merge(x, y, by = intersect(names(x), names(y)), by.x = by, by.y = by, all = FALSE, all.x = all, all.y = all, sort = TRUE, suffixes = c(.x,.y), ...) I find it almost always useful to see the full form. Is there a more reliable workaround or do I have to look up the help to be certain. You can look at the method you want to use. Try not to overlook those comments in the help files' usage sections. -- 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
Re: [R] Strange Colnames
Miguel A. Arranz wrote: You probably want to have a look at help(embed). It might be all you need. embed wraps around (no NAs at begin and end of the dataset), this makes no sense in hydrology. Gruss Georg -- Georg Hoermann, Dep. of Hydrology, Ecology, Kiel University, Germany Tel. 0431-880-1207, Home: 0451/477032, 0172/4315715, Penguin #189476 __ 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
Re: [R] display full form in args
you are looking for the arguments of `merge.data.frame' and not `merge.default'. Maybe this function could be helpful: show.args - function(fun, method=c(default, all)){ old - options(warn=(-1)) on.exit(options(old)) method - match.arg(method) mfun - methods(fun) if( method==default length(ind - grep(.default, mfun))0 ) args(mfun[ind]) else{ res - lapply(mfun, args); names(res) - as.character(mfun); res} } show.args(rep) show.args(plot) show.args(seq, a) show.args(merge, a) Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Adaikalavan Ramasamy [EMAIL PROTECTED] To: R-help r-help@stat.math.ethz.ch Sent: Friday, February 25, 2005 1:14 PM Subject: [R] display full form in args Forgive me for I do not fully comprehend the idea of classes and methods but I was wondering if someone could help explain why the function args () behaves the way it does. Why does args(cut) show the simplified version instead of the more complete one as in help(cut). This is true for few other functions (e.g. plot, rep). args(cut) function (x, ...) Sometime I can get around this by using the default method as in args(cut.default) function (x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ...) But sometimes I cannot use this workaround. e.g. args(merge.default) does not give the full form as in the help file. I find it almost always useful to see the full form. Is there a more reliable workaround or do I have to look up the help to be certain. Thank you. Regards, Adai __ 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 __ 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
Re: [R] How to set up number of prin comp.
On Fri, 2005-02-25 at 20:29 +0800, [EMAIL PROTECTED] wrote: Hi Bjrn-Helge, Thanks for your help. In my case, there are more variables in the matrix than the units, so I have to use Prcomp with covariance to do PCA. The problem I am facing is how to get fisrt 8 coefficients and scores and how to write the result into text file. Thanks again. When I change princomp to prcomp below, I will NULL for pc$scores pc$loadings. X - some matrix pc - prcomp(X) pc$scores[,1:4]# The four first score vectors pc$loadings[,1:4] # The four first loadings Three most useful commands are help(), str() and names(). The first tells you how to use prcomp() and how it names its results. Try help(prcomp). The second peeks into the result so you see what is in there. Try (with your result) srt(pc). The third tells you what names are available in your result. The first (help) is the most useful of these commands, since it tells you what these names and items are. If you read it, you should say: pc$x[, 1:4] # The four first score vectors pc$rotation[, 1:4] # The four first loadings Also, loadings(pc) should work with prcomp. I think I'll write functions as.prcomp.princomp and as.princomp.prcomp someday. cheers, jari oksanen -- Jari Oksanen [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] display full form in args
Prof. Ripley, As usual thank you for helpful comments. In future, I will check methods(cut) or methods(merge) which shows the available methods before using args() on the appropriate function. Thanks again. Regards, Adai On Fri, 2005-02-25 at 12:52 +, Prof Brian Ripley wrote: On Fri, 25 Feb 2005, Adaikalavan Ramasamy wrote: Forgive me for I do not fully comprehend the idea of classes and methods but I was wondering if someone could help explain why the function args () behaves the way it does. Why does args(cut) show the simplified version instead of the more complete one as in help(cut). This is true for few other functions (e.g. plot, rep). args(cut) function (x, ...) Adai, That _is_ the full form: those are formal arguments shared by all methods. For help(cut) I get Usage: cut(x, ...) which is the same. Sometime I can get around this by using the default method as in args(cut.default) function (x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ...) but other methods have other args, e.g. args(cut.Date) function (x, breaks, labels = NULL, start.on.monday = TRUE, right = FALSE, ...) But sometimes I cannot use this workaround. e.g. args(merge.default) does not give the full form as in the help file. It is the *data frame* method that you are looking at in the help file. Usage: merge(x, y, ...) ## Default S3 method: merge(x, y, ...) ## S3 method for class 'data.frame': merge(x, y, by = intersect(names(x), names(y)), by.x = by, by.y = by, all = FALSE, all.x = all, all.y = all, sort = TRUE, suffixes = c(.x,.y), ...) I find it almost always useful to see the full form. Is there a more reliable workaround or do I have to look up the help to be certain. You can look at the method you want to use. Try not to overlook those comments in the help files' usage sections. __ 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
Re: [R] display full form in args
Dimitris, thank you. This is a useful function. On Fri, 2005-02-25 at 14:32 +0100, Dimitris Rizopoulos wrote: you are looking for the arguments of `merge.data.frame' and not `merge.default'. Maybe this function could be helpful: show.args - function(fun, method=c(default, all)){ old - options(warn=(-1)) on.exit(options(old)) method - match.arg(method) mfun - methods(fun) if( method==default length(ind - grep(.default, mfun))0 ) args(mfun[ind]) else{ res - lapply(mfun, args); names(res) - as.character(mfun); res} } show.args(rep) show.args(plot) show.args(seq, a) show.args(merge, a) Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Adaikalavan Ramasamy [EMAIL PROTECTED] To: R-help r-help@stat.math.ethz.ch Sent: Friday, February 25, 2005 1:14 PM Subject: [R] display full form in args Forgive me for I do not fully comprehend the idea of classes and methods but I was wondering if someone could help explain why the function args () behaves the way it does. Why does args(cut) show the simplified version instead of the more complete one as in help(cut). This is true for few other functions (e.g. plot, rep). args(cut) function (x, ...) Sometime I can get around this by using the default method as in args(cut.default) function (x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3, ...) But sometimes I cannot use this workaround. e.g. args(merge.default) does not give the full form as in the help file. I find it almost always useful to see the full form. Is there a more reliable workaround or do I have to look up the help to be certain. Thank you. Regards, Adai __ 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 __ 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
[R] restoring vector v from v[-i]
Hi I have a little function that takes a vector v and an integer i. I want to manipulate v[-i] (to give v.new, say) and then put (unmanipulated) v[i] back into the appropriate place. For example, f - function(v,i){ v.new - v[-i]+10 return(c(v.new[1:(i-1)],v[i],v.new[i:length(v.new)])) } (my example is adding 10 to v[-i], but the real version is the solution of a complicated function involving a call to Solve(A,b)) Function f() works most of the time: f(1:10,4) [1] 11 12 13 4 15 16 17 18 19 20 f(1:10,8) [1] 11 12 13 14 15 16 17 8 19 20 but fails at the edges: f(1:10,1) [1] 12 1 12 13 14 15 16 17 18 19 20 f(1:10,10) [1] 11 12 13 14 15 16 17 18 19 10 NA 19 [ I would want f(1:10,1) to start 1,12,13,... and f(1:10,10) to end . . . 18 19,10] How best to get intended behaviour for i=1 and i=length(v)? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre 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
RE: [R] Simulation Progress
Hi! What about use of %%, so you print every nth iteration on screen, you can afcoures calculate how many % of iterations has already passed etc. Some dummy example: i - 0 x - 1:100 for (i in x) { if (i %% 100 == 0) { print(i) } } -- Lep pozdrav / With regards, Gregor GORJANC University of Ljubljana Biotechnical Faculty URI: http://www.bfro.uni-lj.si/MR/ggorjan Zootechnical Departmentemail: gregor.gorjanc at bfro.uni-lj.si Groblje 3 tel: +386 (0)1 72 17 861 SI-1230 Domzalefax: +386 (0)1 72 17 888 Slovenia Date: Fri, 25 Feb 2005 01:51:30 +0100 From: Carsten Steinhoff [EMAIL PROTECTED] Subject: [R] Simulation Progress To: r-help@stat.math.ethz.ch Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=us-ascii Hi, I've made a function that executes a monte-carlo simulation. It always needs a lot of time until e.g. 1Mio simulation steps are done. So I would like to know, how many percent of the work is already done. In an Excel/VBA Solution I could easily implement a status bar or status window. How could an R-Solution look like? 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
Re: [R] restoring vector v from v[-i]
Robin Hankin wrote: Hi I have a little function that takes a vector v and an integer i. I want to manipulate v[-i] (to give v.new, say) and then put (unmanipulated) v[i] back into the appropriate place. For example, f - function(v,i){ v.new - v[-i]+10 return(c(v.new[1:(i-1)],v[i],v.new[i:length(v.new)])) } Take the complement of 'i', and change the values of v in place? f - function(v,i){ v[-i] - v[-i]+10 v } Now i can be an integer or a vector of integers or true/falses. Baz __ 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
Re: [R] restoring vector v from v[-i]
why not use this: f - function(v,i){ v.new - v + 10 v.new[i] - v[i] v.new } ### f(1:10,4) f(1:10,8) f(1:10,1) f(1:10,10) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/336899 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm - Original Message - From: Robin Hankin [EMAIL PROTECTED] To: R-help@stat.math.ethz.ch Sent: Friday, February 25, 2005 2:52 PM Subject: [R] restoring vector v from v[-i] Hi I have a little function that takes a vector v and an integer i. I want to manipulate v[-i] (to give v.new, say) and then put (unmanipulated) v[i] back into the appropriate place. For example, f - function(v,i){ v.new - v[-i]+10 return(c(v.new[1:(i-1)],v[i],v.new[i:length(v.new)])) } (my example is adding 10 to v[-i], but the real version is the solution of a complicated function involving a call to Solve(A,b)) Function f() works most of the time: f(1:10,4) [1] 11 12 13 4 15 16 17 18 19 20 f(1:10,8) [1] 11 12 13 14 15 16 17 8 19 20 but fails at the edges: f(1:10,1) [1] 12 1 12 13 14 15 16 17 18 19 20 f(1:10,10) [1] 11 12 13 14 15 16 17 18 19 10 NA 19 [ I would want f(1:10,1) to start 1,12,13,... and f(1:10,10) to end . . . 18 19,10] How best to get intended behaviour for i=1 and i=length(v)? -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre 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 __ 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
[R] two line plot title with expression problem
Dear R-users, I am having a problem formatting a two line plot title with the first line text and the second line an expression. I cant get the second line expression to line up with the first by starting at the LHS of the line. A simple example illustrates the situation. x-seq(-5,5,length=100) f-function(x) x^2-x-1 For a one line title the following works fine plot(x,f(x),type=l) title(expression(paste(Golden Section ,fn:(phi^2-phi-1)),sep=)) but when attempting a two line title as follows-- plot(x,f(x),type=l) title(expression(paste(Golden Section\n ,fn:(phi^2-phi-1)),sep=)) the second line containing the expression for phi is indented, to the right, starting immediately after the position of the end letter of the first line. If the second line were to be text, this would not be a problem. How can I format the title so that the expression starts immediately under the first line? Thanks for help. John. [John Wilkinson : [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Strange Colnames
Gabor Grothendieck wrote: Here is something you could try: # define lags and their names lags - 0:4 names(lags) - c(G_HW, paste(lag, 1:4)) # build mts do.call(cbind, lapply(lags, lag, x = lagtest)) thank you for the solution, I will try to understand it during the weekend 8-) Now I tried to change the lag from the default value of 1 to -1, but I apparently missed something: do.call(cbind, lapply(lags, function(x) lag(x,-1), x = lagtest)) Error in FUN(X[[1]], ...) : unused argument(s) ( ...) where is the unused argument? Thanks, Georg -- Georg Hoermann, Dep. of Hydrology, Ecology, Kiel University, Germany Tel. 0431-880-1207, Home: 0451/477032, 0172/4315715, Penguin #189476 __ 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
[R] passing command line arguments to 'R CMD BATCH myScript.R'
Hi Community, I have a question about how to pass command line parameters to R script running in the batch mode. The problem is: there is a banch of data files which are to be processed by R script called from a web-server, i.e. in the batch mode. The web server generates data files and passes their names calling 'R CMD BATCH' one by one for every file. Now the question is how to call 'R CMD BATCH myScript.R' with parameters, like file name to process? I know how to read the parameters passed to an R script, but I don't know how to pass them. There is an option --args that should cut the rest of the line off the command line. The problem is however that BATCH syntax is: 'R CMD BATCH [options] inFile [outFile]', i.e. if I write 'R CMD BATCH --args myDataFile myScript.R' or 'R CMD BATCH --args myDataFile myScript.R' (similar was posted on some R help under Windows) it is not going to work because then BATCH doesn't know about myScript.R - it is considered as a parameter, so only 'R CMD BATCH' is executed. If however I use 'R CMD BATCH myScript --args myDataFile' then R understands --args as an output file and generates a file with that name. Does anyone has a solution for the problem? Best regards Oleg -- Dr Oleg Sklyar European Bioinformatics Institute Wellcome Trust Genome Campus Hinxton, Cambridge, CB10 1SD England phone/fax +44(0)1223 49 4478/4468 e-mail [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Graphics
John Dougherty jwd at surewest.net writes: On Thursday 24 February 2005 04:13, Adrian Dusa wrote: ... You need to check your font installation. Be sure the X-11 fonts are installed. XFree86-fonts-75dpi-4.3.99.902-30 XFree86-fonts-100dpi-4.3.99.902-30 Should both be on your system. If they aren't bring up the YaST control center and select Install and Remove Software. You can use the search option to filter for packages that have fonts in their descritpion. Install any that aren't. SuSE seems to be a little funny about the X-11 fonts. Peter Dalgaard just let me know about that a short time ago. Thank you for the info; I found that thread as well, but I seem to have both 75 and 100 dpi packages installed: xorg-x11-fonts-100dpi version 6.8.1-15 xorg-x11-fonts-75dpi version 6.8.1-15 Googling around, I wasn't able to find any XFree86 .rpm fonts package. I am also playing with the UTF-8 locales, it may have something to do with this. JWDougherty __ R-help at 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 Regards, Adrian __ 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
[R][Rdev] any way to generate bitmap (tif,jpeg,png etc) files in R CMD BATCH
Hi Community, here is the problem, Linux problem (reported to work on Windows). I need to generate graphical output in any of bitmap format under the 'R CMD BATCH'. Whereas the script generating png-s works perfectly in the R session, such things as X11, png and jpeg are not usable in BATCH (they cannot be switched on by --gui-X11 etc) and X11 is prompted to be required for png. At the same time, such things as postscript and pdf, which are generally X-independent work fine. The problem is that as a result I need something previewable in the web browser: png, jpeg. Any suggestions how to proceed? Generally I could use command line linux tools to convert from almost any bitmpa format to the required png or jpeg, but it would be nicer to have them as direct R output. Kind regards Oleg -- Dr Oleg Sklyar European Bioinformatics Institute Wellcome Trust Genome Campus Hinxton, Cambridge, CB10 1SD England phone/fax +44(0)1223 49 4478/4468 e-mail [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
FYI from apple employee RE: [R] Memory error in Mac OS X Aqua GUI v1.01 with cluster
Betty Gilbert wrote: [...] I'm trying to cluster a matrix I created with a simulation with dimensions dim(nca35) [1] 1048112 [...] But I'm still getting errors like the following with funtions in the cluster package [...] I think that the xcluster function in the ctc package from Bioconductor is specifically designed to deal with data sets of this sort of size without using much memory. -- Graham Jones, author of SharpEye Music Reader http://www.visiv.co.uk 21e Balnakeil, Durness, Lairg, Sutherland, IV27 4PT, Scotland, UK __ 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
Re: [R] Strange Colnames
From: Georg Hoermann [EMAIL PROTECTED] Gabor Grothendieck wrote: Here is something you could try: # define lags and their names lags - 0:4 names(lags) - c(G_HW, paste(lag, 1:4)) # build mts do.call(cbind, lapply(lags, lag, x = lagtest)) thank you for the solution, I will try to understand it during the weekend 8-) Now I tried to change the lag from the default value of 1 to -1, but I apparently missed something: do.call(cbind, lapply(lags, function(x) lag(x,-1), x = lagtest)) Error in FUN(X[[1]], ...) : unused argument(s) ( ...) where is the unused argument? The unused argument is: x = lagtest I think what you meant is: do.call(cbind, lapply(lags, function(k) lag(lagtest,-k))) or equivalently: do.call(cbind, lapply(-lags, function(k) lag(lagtest,k))) or more succintly: do.call(cbind, lapply(-lags, lag, x = lagtest)) The way it works is that lapply calls lags(x,k) repeatedly always using the value of x = lagtest for the first argument. Normally lapply repeatedly sets the first argument but since we have already done that by specifying x=lagtest, lapply uses the next argument k thereby setting k successively to each value of the lag. __ 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
[R] outlier threshold
For the analysis of financial data wih a large variance, what is the best way to select an outlier threshold? Listed below, is there a best method to select an outlier threshold and how does R calculate it? In R, how do you find the outlier threshold through an interquartile range? In R, how do you find the outlier threshold using the hist command? In R, how do you find the outlier threshold with Chebyshev Inequality? In R, how do you find the outlier threshold with Kmeans? Also, is there a better way to select an outlier threshold not listed above? __ 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
RE: [R] restoring vector v from v[-i]
From: Robin Hankin [EMAIL PROTECTED] I have a little function that takes a vector v and an integer i. I want to manipulate v[-i] (to give v.new, say) and then put (unmanipulated) v[i] back into the appropriate place. For example, f - function(v,i){ v.new - v[-i]+10 return(c(v.new[1:(i-1)],v[i],v.new[i:length(v.new)])) } f - function(v, i) replace(v+10, i, v[i]) __ 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
Re: [R][Rdev] any way to generate bitmap (tif,jpeg,png etc) files in R CMD BATCH
On Fri, 25 Feb 2005, Oleg Sklyar wrote: Hi Community, here is the problem, Linux problem (reported to work on Windows). I need to generate graphical output in any of bitmap format under the 'R CMD BATCH'. Whereas the script generating png-s works perfectly in the R session, such things as X11, png and jpeg are not usable in BATCH (they cannot be switched on by --gui-X11 etc) and X11 is prompted to be required for png. FAQ 7.19 How do I produce PNG graphics in batch mode? -thomas __ 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
Re: [R][Rdev] any way to generate bitmap (tif,jpeg,png etc) files inR CMD BATCH
On Fri, 25 Feb 2005, Oleg Sklyar wrote: Hi Community, Use a virtual framebuffer - an example of an earlier question about this on the list is: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/15988.html (the searchable archives have lots of good tips) here is the problem, Linux problem (reported to work on Windows). I need to generate graphical output in any of bitmap format under the 'R CMD BATCH'. Whereas the script generating png-s works perfectly in the R session, such things as X11, png and jpeg are not usable in BATCH (they cannot be switched on by --gui-X11 etc) and X11 is prompted to be required for png. At the same time, such things as postscript and pdf, which are generally X-independent work fine. The problem is that as a result I need something previewable in the web browser: png, jpeg. Any suggestions how to proceed? Generally I could use command line linux tools to convert from almost any bitmpa format to the required png or jpeg, but it would be nicer to have them as direct R output. Kind regards Oleg -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] passing command line arguments to 'R CMD BATCH myScript.R'
Oleg Sklyar wrote: Hi Community, I have a question about how to pass command line parameters to R script running in the batch mode. The problem is: there is a banch of data files which are to be processed by R script called from a web-server, i.e. in the batch mode. The web server generates data files and passes their names calling 'R CMD BATCH' one by one for every file. Now the question is how to call 'R CMD BATCH myScript.R' with parameters, like file name to process? I know how to read the parameters passed to an R script, but I don't know how to pass them. There is an option --args that should cut the rest of the line off the command line. The problem is however that BATCH syntax is: 'R CMD BATCH [options] inFile [outFile]', i.e. if I write 'R CMD BATCH --args myDataFile myScript.R' or 'R CMD BATCH --args myDataFile myScript.R' (similar was posted on some R help under Windows) it is not going to work because then BATCH doesn't know about myScript.R - it is considered as a parameter, so only 'R CMD BATCH' is executed. If however I use 'R CMD BATCH myScript --args myDataFile' then R understands --args as an output file and generates a file with that name. Does anyone has a solution for the problem? Best regards Oleg See ?commandArgs Uwe Ligges __ 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
Re: [R] outlier threshold
Melanie Vida wrote: For the analysis of financial data wih a large variance, what is the best way to select an outlier threshold? Listed below, is there a best method to select an outlier threshold and how does R calculate it? In R, how do you find the outlier threshold through an interquartile range? In R, how do you find the outlier threshold using the hist command? In R, how do you find the outlier threshold with Chebyshev Inequality? In R, how do you find the outlier threshold with Kmeans? Also, is there a better way to select an outlier threshold not listed above? This depends on your definition of an outlier and the model for your data - there is no best method in general. The robust folks have quite a lot of theory and methods ... Uwe Ligges __ 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 __ 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
[R] [R-pkgs] new version of survey package
Version 2.9 of survey is on CRAN. In addition to various minor improvements and bug fixes there are two major changes - full multistage finite-population sampling is supported (as in SUDAAN) - the same analysis commands can be used for all design types (eg svymean instead of svrepmean for replicate weight designs) -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle ___ 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
Re: [R] display full form in args
Adaikalavan == Adaikalavan Ramasamy [EMAIL PROTECTED] on Fri, 25 Feb 2005 13:38:27 + writes: Adaikalavan Prof. Ripley, As usual thank you for helpful Adaikalavan comments. Adaikalavan In future, I will check methods(cut) or Adaikalavan methods(merge) which shows the available Adaikalavan methods before using args() on the appropriate Adaikalavan function. Just a side note: Using str() instead of args() does not print the (somewhat ugly) NULL body {but it also does not *return* anything useful. Consequently the show.args() function of Dimitry would have to be rewritten slightly when using str() instead of args()}. Martin __ 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
Re: [R] outlier threshold
You may want to read the discussion on detection of outliers in the mailing list archive. The boxplot definition has an in-built outlier threshold for univariate data, namely 1.5 times IQR distance from the upper and lower quartile. Simple and good is also the threshold c*mad from the median, where c is sometimes recommended to be 5.2 or 6. If you have more complicated data (multivariate/time series), it becomes more complicated. Even for univariate data, it depends on the distributional shape and the aim of outlier identification. What do you mean by threshold with kmeans? If you mean the detection of outliers in presence of clustering, then kmeans does not help you further, but EMclustN (package mclust) and NNclean (package prabclus) may be interesting. Best, Christian On Fri, 25 Feb 2005, Melanie Vida wrote: For the analysis of financial data wih a large variance, what is the best way to select an outlier threshold? Listed below, is there a best method to select an outlier threshold and how does R calculate it? In R, how do you find the outlier threshold through an interquartile range? In R, how do you find the outlier threshold using the hist command? In R, how do you find the outlier threshold with Chebyshev Inequality? In R, how do you find the outlier threshold with Kmeans? Also, is there a better way to select an outlier threshold not listed above? __ 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 *** Christian Hennig Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg [EMAIL PROTECTED], http://www.math.uni-hamburg.de/home/hennig/ From 1 April 2005: Department of Statistical Science, UCL, London ### ich empfehle www.boag-online.de __ 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
Re: [R] help me!
i have 3 questions 1 the english linking r 2 the relivance of sociology to nigeria 3with the aid of any communication model explain the process of communication __ 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
[R] subsetting by NA
I want to know where all the NAs are in a matrix. The data frame looks like this: vmc[1:5,] date year month day snow.new prcp tmin snow.dep tmax 1 01NOV1954 195411 1 NA NA -14.4 NA 12.222 2 02NOV1954 195411 2 NA NA -13.9 NA 2.222 3 03NOV1954 195411 3 NA NA -16.7 NA -1.111 4 04NOV1954 195411 4 NA NANA NA -0.556 5 05NOV1954 195411 5 NA NA -17.2 NA -2.778 tmean yearmo 1 -1.11 195411 2 -5.83 195411 3 -8.89 195411 4 NA 195411 5 -10.00 195411 This does not work: subset(vmc, snow.new==NA) [1] date year monthday snow.new prcp tmin snow.dep [9] tmax tmeanyearmo 0 rows (or 0-length row.names) Because: NA==NA [1] NA How can I return all rows of this data frame that contain NA in a particular field? Thanks, Ben Osborne -- Botany Department University of Vermont 109 Carrigan Drive Burlington, VT 05405 __ 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
Re: [R] subsetting by NA
Benjamin M. Osborne allegedly said on 2/25/2005 10:33 AM: I want to know where all the NAs are in a matrix. The data frame looks like this: vmc[1:5,] date year month day snow.new prcp tmin snow.dep tmax 1 01NOV1954 195411 1 NA NA -14.4 NA 12.222 2 02NOV1954 195411 2 NA NA -13.9 NA 2.222 3 03NOV1954 195411 3 NA NA -16.7 NA -1.111 4 04NOV1954 195411 4 NA NANA NA -0.556 5 05NOV1954 195411 5 NA NA -17.2 NA -2.778 tmean yearmo 1 -1.11 195411 2 -5.83 195411 3 -8.89 195411 4 NA 195411 5 -10.00 195411 This does not work: subset(vmc, snow.new==NA) [1] date year monthday snow.new prcp tmin snow.dep [9] tmax tmeanyearmo 0 rows (or 0-length row.names) Because: NA==NA [1] NA How can I return all rows of this data frame that contain NA in a particular field? Thanks, Ben Osborne Ben, This is a perfect job for ?complete.cases. You should also read Introduction to R, pg. 9-10 in the PDF document, regarding how missing values are handled in R. --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
Re: [Rd] [R][Rdev] any way to generate bitmap (tif, jpeg, png etc) files in R CMD BATCH
On Feb 25, 2005, at 10:05 AM, Oleg Sklyar wrote: here is the problem, Linux problem (reported to work on Windows). I need to generate graphical output in any of bitmap format under the 'R CMD BATCH'. Whereas the script generating png-s works perfectly in the R session, such things as X11, png and jpeg are not usable in BATCH There are other ways, but if you have (or can install) libgd and freetype, you may consider using the GDD device - it can produce jpeg, png and gif on unix w/o the need of X11. The nice thing about it is speed (it doesn't use any external process) and that it uses anti-aliasing of both text and lines. It was designed specifically for graphics-on-demand on web servers. Currenly GDD is not on CRAN (yet), but you can get it from http://www.rosuda.org/R/nightly/ Just make sure that you have libgd and freetype (if you any problems or suggestions, please drop me a line). There are other methods, too, like the bitmap device, which uses gs (AFAICS), or you can run virtual X11 to satisfy the devices that require X11. Cheers, Simon __ 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
Re: [R] subsetting by NA
See ?is.na Uwe Ligges Benjamin M. Osborne wrote: I want to know where all the NAs are in a matrix. The data frame looks like this: vmc[1:5,] date year month day snow.new prcp tmin snow.dep tmax 1 01NOV1954 195411 1 NA NA -14.4 NA 12.222 2 02NOV1954 195411 2 NA NA -13.9 NA 2.222 3 03NOV1954 195411 3 NA NA -16.7 NA -1.111 4 04NOV1954 195411 4 NA NANA NA -0.556 5 05NOV1954 195411 5 NA NA -17.2 NA -2.778 tmean yearmo 1 -1.11 195411 2 -5.83 195411 3 -8.89 195411 4 NA 195411 5 -10.00 195411 This does not work: subset(vmc, snow.new==NA) [1] date year monthday snow.new prcp tmin snow.dep [9] tmax tmeanyearmo 0 rows (or 0-length row.names) Because: NA==NA [1] NA How can I return all rows of this data frame that contain NA in a particular field? Thanks, Ben Osborne __ 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
RE: [R] passing command line arguments to 'R CMD BATCH myScript.R'
I have never understood the difference between R CMD BATCH --vanilla --slave myScript.R outFile.txt and R --vanilla --slave myScript.R outFile.txt I use the latter method, and then the --args construction works great: R --vanilla --slave --args myArg1 myArg2 myScript.R outFile.txt In fact, I define R --vanilla --slave --args to be an environment variable $R, and then it's just $R myArg1 myArg2 myScript.R outFile.txt -- David Brahm ([EMAIL PROTECTED]) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] subsetting by NA
Have you considered is.na? My favorite tool for answering questions like this is www.r-project.org - search - R site search. When I asked there for subsetting by NA just now, I got 101 hits, the third of which mentioned is.na. Also, the posting guide R-project.org/posting-guide.html gives other useful tips for how to find information about R. hope this helps. spencer graves Benjamin M. Osborne wrote: I want to know where all the NAs are in a matrix. The data frame looks like this: vmc[1:5,] date year month day snow.new prcp tmin snow.dep tmax 1 01NOV1954 195411 1 NA NA -14.4 NA 12.222 2 02NOV1954 195411 2 NA NA -13.9 NA 2.222 3 03NOV1954 195411 3 NA NA -16.7 NA -1.111 4 04NOV1954 195411 4 NA NANA NA -0.556 5 05NOV1954 195411 5 NA NA -17.2 NA -2.778 tmean yearmo 1 -1.11 195411 2 -5.83 195411 3 -8.89 195411 4 NA 195411 5 -10.00 195411 This does not work: subset(vmc, snow.new==NA) [1] date year monthday snow.new prcp tmin snow.dep [9] tmax tmeanyearmo 0 rows (or 0-length row.names) Because: NA==NA [1] NA How can I return all rows of this data frame that contain NA in a particular field? Thanks, Ben Osborne __ 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
Re: [R] two line plot title with expression problem
John Wilkinson (pipex) wrote: Dear R-users, I am having a problem formatting a two line plot title with the first line text and the second line an expression. I cant get the second line expression to line up with the first by starting at the LHS of the line. A simple example illustrates the situation. x-seq(-5,5,length=100) f-function(x) x^2-x-1 For a one line title the following works fine plot(x,f(x),type=l) title(expression(paste(Golden Section ,fn:(phi^2-phi-1)),sep=)) but when attempting a two line title as follows-- plot(x,f(x),type=l) title(expression(paste(Golden Section\n ,fn:(phi^2-phi-1)),sep=)) the second line containing the expression for phi is indented, to the right, starting immediately after the position of the end letter of the first line. If the second line were to be text, this would not be a problem. How can I format the title so that the expression starts immediately under the first line? Multi-line expressions are not supported. You can add them by separate calls to title(), though: plot(1:10) title(Golden Section, line=3) title(expression(fn:(phi^2-phi-1)), line=2) or for left-adjustment, try the same with calls to mtext() and specifying arguments adj and at. Uwe Ligges Thanks for help. John. [John Wilkinson : [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ 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
Re: [R] calculatingmean value for duplicates in affy array
Dren Scott wrote: Hi , I was trying read in an affy array/matrix and then to calculate the mean value for all the duplicates. Is there a function in the R package that would do this? I tried the help function and searched for 'duplicate'. Although it provides a list of functions that would eliminate the duplicate probe ids, I couldn't find one that would calculate the mean for the duplicates. Any help would be appreciated. See ?tapply (for sure you are aware of the Bioconductor project). Uwe Ligges 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 __ 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
RE: [R] passing command line arguments to 'R CMD BATCH myScript.R'
On Fri, 25 Feb 2005, Brahm, David wrote: I have never understood the difference between R CMD BATCH --vanilla --slave myScript.R outFile.txt and R --vanilla --slave myScript.R outFile.txt [On Unix-alikes] Mainly cosmetics, e.g. the first adds timings and options(echo=TRUE) and generates a suitably named outfile. [Also sets --restore --save which you then override.] It used to set --gui=none to avoid the overhead of loading the X11 module. More importantly, the first redirects stderr and yours does not, but see my reply to the OP's other thread for a closer equivalent. [...] -- 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
Re: [R] passing command line arguments to 'R CMD BATCH myScript.R'
Hi, I recently solved the problem: I ran a program from Linux. The basic idea is using enviroment variables and ?Sys.getenv This is a general approach to calling R from a script file. Here is part of my codes and explanation: # assign some values to the arguments dvar=5 categorical=3 # export them as env. var. export dvar mod_min mod_max tree_no cp categorical #run your r program in a batch mode R CMD BATCH $HOME/r/batch/mk_trees.r The following is part of my mk_trees.r: #load arguments cargs-Sys.getenv(c('dvar','mod_min','mod_max','tree_no','cp','categorical')) dvar-as.numeric(cargs[1]) mod_min-as.numeric(cargs[2]) mod_max-as.numeric(cargs[3]) tree_no-as.numeric(cargs[4]) cp-as.numeric(cargs[5]) cc-strsplit(cargs[6], \n) categorical-as.numeric(cc[[1]]) HTH, Ed On Fri, 25 Feb 2005 14:57:57 +, Oleg Sklyar [EMAIL PROTECTED] wrote: Hi Community, I have a question about how to pass command line parameters to R script running in the batch mode. The problem is: there is a banch of data files which are to be processed by R script called from a web-server, i.e. in the batch mode. The web server generates data files and passes their names calling 'R CMD BATCH' one by one for every file. Now the question is how to call 'R CMD BATCH myScript.R' with parameters, like file name to process? I know how to read the parameters passed to an R script, but I don't know how to pass them. There is an option --args that should cut the rest of the line off the command line. The problem is however that BATCH syntax is: 'R CMD BATCH [options] inFile [outFile]', i.e. if I write 'R CMD BATCH --args myDataFile myScript.R' or 'R CMD BATCH --args myDataFile myScript.R' (similar was posted on some R help under Windows) it is not going to work because then BATCH doesn't know about myScript.R - it is considered as a parameter, so only 'R CMD BATCH' is executed. If however I use 'R CMD BATCH myScript --args myDataFile' then R understands --args as an output file and generates a file with that name. Does anyone has a solution for the problem? Best regards Oleg -- Dr Oleg Sklyar European Bioinformatics Institute Wellcome Trust Genome Campus Hinxton, Cambridge, CB10 1SD England phone/fax +44(0)1223 49 4478/4468 e-mail [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ 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
Re: [R] two line plot title with expression problem
Uwe Ligges [EMAIL PROTECTED] writes: If the second line were to be text, this would not be a problem. How can I format the title so that the expression starts immediately under the first line? Multi-line expressions are not supported. You can add them by separate calls to title(), though: plot(1:10) title(Golden Section, line=3) title(expression(fn:(phi^2-phi-1)), line=2) or for left-adjustment, try the same with calls to mtext() and specifying arguments adj and at. Well, plotmath does have atop(). It won't get you the same control over alignment though. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- 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
[R] Temporal Analysis of variable x; How to select the outlier threshold in R?
For a financial data set with large variance, I'm trying to find the outlier threshold of one variable x over a two year period. I qqplot(x2001, x2002) and found a normal distribution. The latter part of the normal distribution did not look linear though. Is there a suitable method in R to find the outlier threshold of this variable from 2001 and 2002 in R? __ 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
[R] cda
Hi, there: I am wondering if I can get some general help or source about canonical discriminant analysis in R. My idea is trying to linearly combine 300 variables supervisely (according to the class lables to the observations. I think it is kinda PCA to do some decreasing dimentionality work, but w/ considering the class and I used SAS to do CDA proc before. But I read the introduction from sas on this proc and found the following statement: The process of extracting canonical variables can be repeated until the number of canonical variables equals the number of original variables or the number of classes minus one, whichever is smaller. does it mean I can only have two new variables if I only have 2 classes? I am not a stat guy and sorry for the question if it should not be addressed here. Ed __ 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
Re: [R] Temporal Analysis of variable x; How to select the outlier threshold in R?
Please stop posting (almost) identical questions! You already posted a very similar question to R-help (and received two answers) and you posted the same question on R-SIG-Finance! As both Uwe and Christian indicated in their answers, your question is very vague. If you want to receive better answers, it would help to ask better questions. Please also read the posting guide at http://www.R-project.org/posting-guide.html On Fri, 25 Feb 2005 13:29:38 -0500 Melanie Vida wrote: For a financial data set with large variance, I'm trying to find the outlier threshold of one variable x over a two year period. I To reiterate Uwe: This depends on your definition of an outlier and the model for your data. qqplot(x2001, x2002) and found a normal distribution. The latter part I'm not sure how you could do that from that plot... of the normal distribution did not look linear though. Is there a suitable method in R to find the outlier threshold of this variable from 2001 and 2002 in R? If you think it appropriate you could fit a normal model and cut at a quantile of your choice. Z __ 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
[R] Error in x[good, ] * w : non-conformable arrays
Dear Jacques, Did you ever figure that error out? I have recently hit it too. In my case it comes from glm() when I replace family = binomial with family = cauchit for some home brewed cauchy binary regression. Things are ok with binomial but not with Cauchy. The data set has some missing values. I tried replacing the x by multiple x's and by a matrix. I suspect that the intrinsic binomial regression is doing something smarter with the missing data. The code worked with an older R (1.7.1 or 1.8.1 I think) on other data sets. -Art here's my cauchy regression hack: cauchit = quasibinomial() cauchit$family = binomial cauchit$link = cauchit cauchit$linkfun = function(mu){ qcauchy(mu) } cauchit$linkinv = function(eta){ pcauchy(eta) } cauchit$mu.eta = function(eta){ dcauchy(eta) } then I use glm( family = cauchit ) __ 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
RE: [R] Temporal Analysis of variable x; How to select the outli
On 25-Feb-05 Melanie Vida wrote: For a financial data set with large variance, I'm trying to find the outlier threshold of one variable x over a two year period. I qqplot(x2001, x2002) and found a normal distribution. The latter part of the normal distribution did not look linear though. Is there a suitable method in R to find the outlier threshold of this variable from 2001 and 2002 in R? I don't see how you can infer a normal distribution from qqplot(), which simply compares the distribution of x2002 with the distribution of x2001. See ?qqplot for what's available and what they show. You can check normality with a qqplot() with, e.g., qqnorm(x2001) qqnorm(x2002) or qqnorm(c(x2001,x2002)) if you want to look at their combined distirbution. Have another look at your data, with appropriate method! Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 25-Feb-05 Time: 18:54:19 -- XFMail -- __ 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
Re: [R] Graphics
Adrian, That was my fault. I have the xorg fonts. Peter pointed out the changes and I found that the 100dpi fonts were not installed. Doing so fixed my problem. John __ 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
[R] read.table
I have a commonly recurring problem and wondered if folks would share tips. I routinely get tab-delimited text files that I need to read in. In very many cases, I get: a - read.table('junk.txt.txt',header=T,skip=10,sep=\t) Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 67 did not have 88 elements I am typically able to go through the file and find a single quote or something like that causing the problem, but with a recent set of files, I haven't been able to find such an issue. What can I do to get around this problem? I can use perl, also Thanks, Sean __ 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
RE: [R] read.table
?readLines I'm sure Perl will do nicely, but you can also use readLines and grep() or regexpr() the result in R as you would in Perl to find where the problem lies. ?nchar can also help to find a non-printing character that may be messing you up. It's no fun, I know. Excel files can be a particular pain, especially in their handling of missings. -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA The business of the statistician is to catalyze the scientific learning process. - George E. P. Box -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sean Davis Sent: Friday, February 25, 2005 12:12 PM To: r-help Subject: [R] read.table I have a commonly recurring problem and wondered if folks would share tips. I routinely get tab-delimited text files that I need to read in. In very many cases, I get: a - read.table('junk.txt.txt',header=T,skip=10,sep=\t) Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 67 did not have 88 elements I am typically able to go through the file and find a single quote or something like that causing the problem, but with a recent set of files, I haven't been able to find such an issue. What can I do to get around this problem? I can use perl, also Thanks, Sean __ 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 __ 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
[R] summary method in URCA package doesn't work
I can't figure out how to get the summary method in the URCA package to work. E.g. when I use the following code fragment in the help for the ca.jo function, it always tries to use the summary method from the base package, not the urca package. How do I force it use the summary method of the urca package? I'm sure this is in some documentation somewhere, but after (admittedly quickly) scanning several docs, I've not found any help on this. Thank you. data(finland) sjf - finland sjf.vecm - ca.jo(sjf, constant=FALSE, type=eigen, K=2, spec=longrun, season=4, ctable=A2) summary(sjf.vecm) [[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
[R] return from nested function?
Is is possible from within a function to cause its caller to return()? I have a function that lets user make edits to certain objects, and then checks that the edited objects still make sense. If they don't, the function puts up a notifier that the edits are being discarded and then returns, something like: if(badEdits){ notifyDialog(bad edits will be ignored) return() } else { ## some stuff that assigns the edited objects in the calling frame return() } This works, but I'd really like to put the return() in the notifyDialog() function. Is there an easy way to do this? Jeff __ 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
Re: [R] return from nested function?
On Fri, 25 Feb 2005 [EMAIL PROTECTED] wrote: Is is possible from within a function to cause its caller to return()? Not as such. You probably want to signal and catch a condition. Look at ?tryCatch. -thomas I have a function that lets user make edits to certain objects, and then checks that the edited objects still make sense. If they don't, the function puts up a notifier that the edits are being discarded and then returns, something like: if(badEdits){ notifyDialog(bad edits will be ignored) return() } else { ## some stuff that assigns the edited objects in the calling frame return() } This works, but I'd really like to put the return() in the notifyDialog() function. Is there an easy way to do this? Jeff __ 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 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
RE: [R] read.table
On 25-Feb-05 Sean Davis wrote: I have a commonly recurring problem and wondered if folks would share tips. I routinely get tab-delimited text files that I need to read in. In very many cases, I get: a - read.table('junk.txt.txt',header=T,skip=10,sep=\t) Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 67 did not have 88 elements I am typically able to go through the file and find a single quote or something like that causing the problem, but with a recent set of files, I haven't been able to find such an issue. What can I do to get around this problem? I can use perl, also Hi Sean, This is only a shot in the dark, but your description has reminded me of similar messes in files which have been exported from Excel. What I have often done in such cases, to check (e.g.) the numbers of fields in records (using 'awk' on Linux) is on the following lines: cat filename | awk 'BEGIN{FS=\t} {print NF}' | unique In that case, if there are varying numbers of fields then two or more different numbers will be printed instead of the single value which it should be. If you know how many fields to expect (e.g. 88), then you can find the line numbers of offending records by something like cat filename | awk 'BEGIN{FS=\t} {if(NF!=88){print NR}}' In data files with a lot of records per line, doing it in this kind of way is vastly superior to trying to spot the problem by eye -- it's extemely difficult to count 88 tab-separated fields on screen! Hoping this helps! If not, supply further details and we'll see what we can think up. Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 25-Feb-05 Time: 20:54:43 -- XFMail -- __ 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
RE: [R] read.table
On 25-Feb-05 Ted Harding wrote: On 25-Feb-05 Sean Davis wrote: I have a commonly recurring problem and wondered if folks would share tips. I routinely get tab-delimited text files that I need to read in. In very many cases, I get: a - read.table('junk.txt.txt',header=T,skip=10,sep=\t) Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 67 did not have 88 elements I am typically able to go through the file and find a single quote or something like that causing the problem, but with a recent set of files, I haven't been able to find such an issue. What can I do to get around this problem? I can use perl, also Hi Sean, This is only a shot in the dark, but your description has reminded me of similar messes in files which have been exported from Excel. What I have often done in such cases, to check (e.g.) the numbers of fields in records (using 'awk' on Linux) is on the following lines: cat filename | awk 'BEGIN{FS=\t} {print NF}' | unique OOPS!!! cat filename | awk 'BEGIN{FS=\t} {print NF}' | uniq Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 25-Feb-05 Time: 21:14:55 -- XFMail -- __ 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
Re: [R] read.table
Berton Gunter [EMAIL PROTECTED] writes: ?readLines I'm sure Perl will do nicely, but you can also use readLines and grep() or regexpr() the result in R as you would in Perl to find where the problem lies. ?nchar can also help to find a non-printing character that may be messing you up. It's no fun, I know. Excel files can be a particular pain, especially in their handling of missings. You might also try read.delim() which has options set specifically to be able to read Excel-generated CSV files. Also check out count.fields(). -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- 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
[R] Teaching R in 40 minutes. What should be included?
If _you_ were asked to give a 40 minute dog and pony show about R for a group of scientists ranging from physicists to geographers what would you put in? These people want to know what R can do. I'm thinking about something like: A. Overview B. data structures C. arithmetic and manipulation D. reading data E. linear models using glm F. graphics G. programming H. other tricks like rpart or time series analysis? Thoughts? Other people must do similar things all the time. Is there a repository of intro to R slide shows anywhere? __ 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
Re: [R] summary method in URCA package doesn't work
Please contact (or at least Cc) the maintainer of contributed packages when reporting problems with contributed packages. (I've added Bernhard to Cc: now.) I can't figure out how to get the summary method in the URCA package to work. E.g. when I use the following code fragment in the help for the ca.jo function, it always tries to use the summary method from the base package, not the urca package. How do I force it use the summary method of the urca package? I'm sure this is in some documentation somewhere, but after (admittedly quickly) scanning several docs, I've not found any help on this. Thank you. data(finland) sjf - finland sjf.vecm - ca.jo(sjf, constant=FALSE, type=eigen, K=2, spec=longrun, season=4, ctable=A2) summary(sjf.vecm) If I understand you correctly, the last command does not return the desired output because the wrong summary method is called? The above works smoothly for me (using R 2.0.1 and urca 0.7-5). What version of R and urca are you using? Z __ 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
Re: [R] read.table
Peter Dalgaard [EMAIL PROTECTED] writes: You might also try read.delim() which has options set specifically to be able to read Excel-generated CSV files. Blah. *TAB-delimited* files of course. read.csv() for the other ones. -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- 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
[R] Problems Building R on AIX 5.2.0.0 (Update)
Hi, My previous message is appended: I'm still struggling with building on AIX. I updated my config.site to follow the suggestions from R-admin: MAIN_LDFLAGS=-Wl,brtl SHLIB_LDFLAGS=-Wl,-G This led to an error during configure: checking whether mixed C/Fortran code can be run... configure: WARNING: cannot run mixed C/Fortan code configure: error: Maybe check LDFLAGS for paths to Fortran libraries? This confused me a bit, because before adding the MAIN_LDFLAGS and SHLIB_LDFLAGS to config.site this step of configure did not show an error. When I googled this I found a previous message from last year: http://tolstoy.newcastle.edu.au/R/help/04/04/1622.html At the end of this message Professor Ripley says: You need wherever libg2c.so is installed in your LD_LIBRARY_PATH. So... I went looking for this file and could not find it! In /usr/local/lib I have: $ ls -al libg2c* -rw-r--r-- 1 freeware staff 7751224 Jan 09 2004 libg2c.a -rwxr-xr-x 1 freeware staff 714 Jan 09 2004 libg2c.la But no libg2c.so appears to be on my system. Does this indicate a bad install of gcc, or could anybody offer any suggestions on where to go from here? Paul --- From: Paul Boutros Paul.Boutros_at_utoronto.ca Date: Thu 24 Feb 2005 - 02:43:52 EST Hello, I am trying to build R 2.0.1 on an AIX 5.2.0.0 machine using gcc 3.3.2: $ oslevel 5.2.0.0 $ gcc -v Reading specs from /usr/local/lib/gcc-lib/powerpc-ibm-aix5.2.0.0/3.3.2/specs Configured with: ../gcc-3.3.2/configure : (reconfigured) ../gcc-3.3.2/configure --disable-nls : (reconfigured) ../gcc-3.3.2/configure --disable-nls Thread model: aix gcc version 3.3.2 Configure goes okay, but I get an error that I don't quite know how to interpret during make. I've included the summary output from the end of configure as well as the error that I get during make below. Any suggestions/recommendations are very much appreciate: I'm stuck on ideas for what could be going wrong. Paul $ ./configure --prefix=/db2blaste/R snip R is now configured for powerpc-ibm-aix5.2.0.0 Source directory: . Installation directory: /db2blast/R C compiler:gcc -mno-fp-in-toc -g -O2 C++ compiler: g++ -g -O2 Fortran compiler: g77 -g -O2 Interfaces supported: X11 External libraries: Additional capabilities: PNG, JPEG Options enabled: R profiling Recommended packages: yes configure: WARNING: you cannot build DVI versions of the R manuals configure: WARNING: you cannot build info or html versions of the R manuals configure: WARNING: you cannot build PDF versions of the R manuals configure: WARNING: I could not determine a browser configure: WARNING: I could not determine a PDF viewer $ make snip gcc -Wl,-bM:SRE -Wl,-H512 -Wl,-T512 -Wl,-bnoentry -Wl,-bexpall -Wl,- bI: . ./../../etc/R.exp -L/usr/local/lib -o lapack.so -Wl,-bI:../../../etc/Rlapack.exp Lapack.lo rgeev.lo rsyev.lo -L../../../lib -lRlapack -L/usr/local/lib -L/usr/ local/lib/gcc-lib/ powerpc-ibm-aix5.2.0.0/3.3.2 -L/usr/local/lib/gcc-lib/powe rpc- ibm-aix5.2.0.0/3.3.2/../../.. -lfrtbegin -lg2c -lm -lgcc_s /usr/local/lib/gcclib /powerpc-ibm-aix5.2.0.0/3.3.2/libgcc.a -lg -ldl -ltermcap -lm -lc ld: 0706-006 Cannot find or open library file: -l Rlapack ld:open(): A file or directory in the path name does not exist. collect2: ld returned 255 exit status make: 1254-004 The error code from the last command is 1. Stop. make: 1254-004 The error code from the last command is 2. Stop. make: 1254-004 The error code from the last command is 1. Stop. make: 1254-004 The error code from the last command is 1. Stop. make: 1254-004 The error code from the last command is 1. Stop. __ 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
Re: [R][Rdev] any way to generate bitmap (tif, jpeg, png etc) files in R CMD BATCH
Oleg, Please do not cross-post between r-devel and r-help. It is considered bad taste. On 25 February 2005 at 15:05, Oleg Sklyar wrote: | Hi Community, | | here is the problem, Linux problem (reported to work on Windows). I need | to generate graphical output in any of bitmap format under the 'R CMD | BATCH'. Whereas the script generating png-s works perfectly in the R | session, such things as X11, png and jpeg are not usable in BATCH (they | cannot be switched on by --gui-X11 etc) and X11 is prompted to be | required for png. At the same time, such things as postscript and pdf, | which are generally X-independent work fine. The problem is that as a | result I need something previewable in the web browser: png, jpeg. Any | suggestions how to proceed? Generally I could use command line linux | tools to convert from almost any bitmpa format to the required png or | jpeg, but it would be nicer to have them as direct R output. This is a FAQ, see http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-produce-PNG-graphics-in-batch-mode_003f and, say, ?bitmap in R. Hth, Dirk -- Better to have an approximate answer to the right question than a precise answer to the wrong question. -- John Tukey as quoted by John Chambers __ 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
Re: [R] reshape without timevar argument?
Tiago R Magalhaes tiago17 at socrates.Berkeley.EDU writes: : I have a data.frame with 2 columns. The first column is an ID column. : The other columns are description of the ids. There is more than one : description for each Id. : Want I want to get as a value is a data.frame where each row : corresponds to one ID and has as many columns as different : descriptions. : : I have used a very convoluted step, but I'm very convinced there is : an easier way to do this. : : Basically, I used the reshape function, but even in this convulated : way there is a step that I can't solve. I used a fake timevar using : the table function. : : df - data.frame(id=c(rep('IDa',3), rep('IDb', 5), rep('IDc', 2), : rep('IDd',5)), let=letters[1:5]) table(df) gives a table of zeros and ones corresponding to the incidence matrix of IDs vs. descriptions. Is that sufficient? __ 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