[R] Creating a co-occurence matrix
Hello R experts, I have a data.frame which has a series of 30 variables that are each coded 1,0--1 if a behavior is engaged in, 0 otherwise. The data.frame looks like this: var1 var2 ...var30 Respondent 1 Respondent 2 etc I would like to create a matrix (or at least a half-matrix) as follows: var1 var2 ...var30 var1 var 2 . . var 30 where the number at each intersection is the number of people who engaged in both behaviors. I could run a whole bunch of tables and input the data by hand into a new matrix, but I was wondering if there is a way to do this via a program/function (I looked at daisy, but concluded this function would not handle this). Any help would be appreciated! Greg Blevins The Market Solutions Group __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] R CMD check
The error was simply a missing end-of-line character in the last line in one of the R files. Thanks to Brian Ripley and Roger Bivand. -- John Bjornar Bremnes Norwegian Meteorological Institute (met.no) Research and Development Department P.O.Box 43 Blindern, N-0313 Oslo, Norway Phone: (+47) 2296 3326. Fax: (+47) 2269 6355 Prof Brian Ripley wrote: You have an error in the R files of your package. Before you even do R CMD check, do try loading the package in R. On Mon, 30 Jun 2003, John Bjørnar Bremnes wrote: when using R CMD check mypkg I get the error message ... * checking R files for library.dynam ... OK * checking generic/method consistency ... WARNING Error in .loadPackageQuietly(package, lib.loc) : Error in parse(file, n, text, prompt) : syntax error on line 95 Execution halted * checking for assignment functions with final arg not named 'value' ... WARNING Error in .loadPackageQuietly(package, lib.loc) : Error in parse(file, n, text, prompt) : syntax error on line 95 Execution halted ... What can I do to avoid this? I use R-1.7.0 on Linux RedHat. Any suggestions are appreciated. -- John Bjornar Bremnes Norwegian Meteorological Institute (met.no) Research and Development Department P.O.Box 43 Blindern, N-0313 Oslo, Norway Phone: (+47) 2296 3326. Fax: (+47) 2269 6355 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Creating a loop that works....
Please don't send messages twice (to [EMAIL PROTECTED] and [EMAIL PROTECTED]). I'm not going to read all your code, understand your problems and write your programs. That's probably the right job for a consultant, or a programmer at your department. Uwe Ligges Michael Rennie wrote: Hi there, First off, thanks to everyone who has helped me so far. Sorry to keep pestering you all. I'm including my code here, and I will comment down it where it is that I am having problems figuring out how to write this damn thing. temper - scan(temp2.dat, na.strings = ., list(Day=0, Temp=0)) Read 366 records Day - temper$Day ; Temp-temper$Temp ; temp- cbind (Day, Temp) #Day = number of days modelled, Temp = daily avg. temp. #temp [,2] p- 0.558626306252032 ACT - 1.66764519286918 Vc-((CTM-temp[,2])/(CTM-CTO)) Vr-((RTM-temp[,2])/(RTM-RTO)) comp- cbind (Day, Temp, Vc, Vr) bio-NULL M- length(Day) #number of days iterated for (i in 1:M) + { + + weight- function(Day) + { + W-NULL + if (Day[i]==1) {W[i] - Wo} + elseif (Day[i]1) {W[i] - ((bio[i-1,1]*bio[i-1,9])/Ef) + } + W + } + + W-weight(Day) The problem, as many of you have already identified, is right here. I hope I finally have the syntax right, but even if the if else is coded properly, I don't think R can find the values in the second condition I list. I need W in each step of the iteration to change slightly, based on the mess of calculations below (which are using parameters that I have already specified). After all the calculations are made, I hope to get values in bio[i,1] and bio [i,9] corresponding to the iteration that just occured, then return to the top of the loop to combine them into the value of W for the next iteration. What I think is happening here is that R is looking for values in the condition before they are actually there- the way I've written it, they can't be there until I get past the conditional step. Which means I am coding this all wrong. That said, I'm not sure how else to do it; the value of W in the next iteration is dependent on the values of Gr and W in the previous iteration, with the exception of the first one (Day=1). I've tried defining bio as bio-matrix(NA, ncol=9, nrow=366) but that doesn't help either. Perhaps my rbind at the end of the file is incorrect? I think maybe I'm getting mixed up between calculating vectors and values-- should I be specifying [i] for everything below where I am now specifying vecotrs? + #W-Wo + + C- p*CA*(W^CB)*((comp[,3]^Xc)*(exp(Xc*(1-comp[,3]*Pc + + ASMR- (ACT*RA*(W^(RB))*((comp[,4]^Xa)*(exp(Xa*(1-comp[,4]) + + SMR- (ASMR/ACT) + + A- (ASMR-SMR) + + F- (FA*(comp[,2]^FB)*(exp(FG*p))*C) + + U- (UA*(comp[,2]^UB)*(exp(UG*p))*(C-F)) + + SDA- (S*(C-F)) + + Gr- (C-(ASMR+F+U+SDA)) + #Day, Temp, Vc, Vr, W, C, ASMR, SMR, A, F, U, SDA, Gr) + + bio- rbind(c(W, C, ASMR, SMR, A, F, U, SDA, Gr)) + + dimnames (bio) -list(NULL, c (W, C, ASMR, SMR, A, F, U, SDA, Gr)) + + } Error: length of dimnames[2] not equal to array extent Execution halted __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] masked objects
On Tue, 1 Jul 2003, ATHANASIA KAMARIOTIS wrote: When opening the software R it appears this message: - Attaching package 'methods': The following object(s) are masked _by_ .GlobalEnv : new -- May you please answer to the following question: How can I restore the object new? Your object `new' is there: the system one is being masked. This does not matter if you are not using formal classes (from package `methods'). To avoid the message, rename your object mynew - new rm(new) -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] namespaces and saved objects
Hi, While saving (function 'save') a 'lmList' object (pack nlme), R issues the warning messages: 1: namespaces may not be available when loading 2: names in persistent strings are currently ignored 3: namespaces may not be available when loading 4: names in persistent strings are currently ignored Any pitfall I should be aware of ? L. PS: I use R.version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status Patched major1 minor7.1 year 2003 month06 day 23 language R __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Fitting inter-arrival time data
On Tuesday 01 July 2003 05:16, M. Edward Borasky wrote: Unfortunately, the data are *non-negative*, not strictly positive. Zero is a valid and frequent inter-arrival time. It is, IIRC, the most likely value of a (negative) exponential distribution. Not really. Zero+ is the value with highest density in a (negative) exponential distribution, which implies that you should have *no* observed zero's from that distribution. If you have a non-negligible fraction of 0 values, then your data are reasonably described as having a mixed distribution: (1) a discrete component at 0, and (2) a continuous positive component. Kernel (or similar) density estimation is appropriate for the continuous component only. Notice that the same remark applies to any procedure (parametric or non-parametric, using mixtures, etc.) which is based on continuous components only. It *looks* that a wise procedure is to separate out the discrete and the continuos component of your data, and handle them separately. At the end you can merge the two parts into Y = p * 0 + (1-p) * X where p is the proportion of 0's, and X represents the continuous component of the random variable. best wishes, Adelchi Azzalini -- Adelchi Azzalini [EMAIL PROTECTED] Dipart.Scienze Statistiche, Università di Padova, Italia http://azzalini.stat.unipd.it/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] namespaces and saved objects
On Tue, 1 Jul 2003, Laurent Gautier wrote: Hi, While saving (function 'save') a 'lmList' object (pack nlme), R issues the warning messages: 1: namespaces may not be available when loading 2: names in persistent strings are currently ignored 3: namespaces may not be available when loading 4: names in persistent strings are currently ignored Any pitfall I should be aware of ? Only that you will need to have package nlme available to re-load the workspace. I think these warnings have been removed in the development version of R. I've removed the cause of such messages with the MASS function glm.nb() recently, and I guess nlme is doing similar things. The cause was that negative.binomial() created a family of functions, which thereby had the body of negative.binomial as their environment and hence the MASS namespace in its environment. As the latter was a minor nuisance, I have manipulated the environments. -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Fitting inter-arrival time data
the two parts into Y = p * 0 + (1-p) * X where p is the proportion of 0's, and X represents the continuous component of the random variable. I must amend myself... what I should have written is Y = I * 0 + (1-I) * X where I is a Bernoulli random variable with probability p of success (i.e. 1) and X represents the continuous component of the random variable. -- Adelchi Azzalini [EMAIL PROTECTED] Dipart.Scienze Statistiche, Università di Padova, Italia http://azzalini.stat.unipd.it/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Deciphering an error message
Hello again, Below is the code I am using which generates the error message. Any comments greatly appreciated, S. # # Function to create a PPP object for all the points in a particular # include. Mark the points with their species name (or a number # indicating it) # # Usage: # x - getBigPPP(year, include, species, number=FALSE) # # Where: # x = ppp object with coordinates and bounds for indicated species # and plots. # year = year(s) to include data for. Either a single number or a #vector of numbers # include = name(s) of plots to include data from. Either a single # character expression or a vector of characters. # species = name(s) of species to include data for. Either a single # species name or a vector of characters. # number = flag indicating whether species names or numbers are used # as marks in ppp object. Species names are default. To # use numbers, set number=TRUE. This argument is not needed # unless numbers are desired. # # Example: # source(spat1.R) # source file to install functions # getBigPPP(1992, G1, apple) # print PPP object (summary of) ## for apple in G1 in 1992. Marks ## will be species name 'apple' # x - getBigPPP(1992, c(P1,P2,P3), c(apple,hawthorn), number=TRUE) ## x is defined as PPP object with ## coordinates and plot information ## for apple and hawthorn species ## in plots P1, P2, and P3, with ## marks set to numbers. # plot(x)# plot locations of species, with ## different marks for each one, and ## plot boundaries. # getBigPPP - function(year=NULL, include=NULL, species=NULL, number=FALSE, spColNam=Species) { # message about usage if(is.null(year) || is.null(include)) { return(ERROR !) } # create species selection if it is now null spCol - t(trees[spColNam]) # print(spCol) if(is.null(species)) { species - as.character(unique(spCol)) } # create the bounds for this object bounds - plotBounds(include) # selection based on include and year select - (trees$Plot %in% include) (trees$Year %in% year) (spCol %in% species) (!is.na(trees$Northing)) (!is.na(trees$Easting)) (trees$Present == 1) # mark with numbers or with species name if(!number) { return(ppp(x=trees$Easting[select], y=trees$Northing[select], marks=as.factor(spCol[select]), poly=bounds)) } specs - unique(spCol[select]) marks - apply(as.matrix(spCol[select]), 1, function(x) { which(specs == x)[1] }) return(ppp(x=trees$Easting[select], y=trees$Northing[select], marks=as.factor(marks), poly=bounds)) } -- Uwe Ligges [EMAIL PROTECTED] wrote: Suzanne E. Blatt wrote: Hello, I'm working in spatstat and having difficulty with the ppp objects. I can get a ppp object for one set of data, but with the same code applied to a second data set (all I am changing is the field identifier), I get the following error message: Error in switch(w$type, rectangle={: internal error: some total scores are neither 0 nor 1 What is a ppp object? Which function has been applied and generated that error message? The error message tells you some values a ought to sum up to 0 or 1 but they don't. I (and perhaps others as well) cannot help when you don't specify some relevant information. Uwe Ligges Any thoughts on what this means and how to correct it would be most appreciated. Thanks, Suzanne __ McAfee VirusScan Online from the Netscape Network. Comprehensive protection for your entire computer. Get your free trial today! http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397 Get AOL Instant Messenger 5.1 free of charge. Download Now! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ McAfee VirusScan Online from the Netscape Network. Comprehensive protection for your entire computer. Get your free trial today! http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397 Get AOL Instant Messenger 5.1 free of charge. Download Now! __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] X-emacs and R for Windows
Is there any way to make XEmacs (or any other editor) the default editor for R so that when I type sample - function(x,y) { + z-x+y + } + edit(sample) the XEmacs (or other editor) is the editor for this function (the default seems to be MS Notepad, blech). Thanks, Neil Chriss DISCLAIMER: This e-mail message and any attachments are inte...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Step - wise
Madame , Monsieur, J'aimerais utiliser la fonction step dans une boucle for pour pouvoir prédire des valeurs (à chaque pas) suivant le modèle proposé par step. Est-il possible de le faire ? Merci d'avance, Cordialement Athanasia __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] X-emacs and R for Windows
Chriss, Neil [EMAIL PROTECTED] wrote: Is there any way to make XEmacs (or any other editor) the default editor for R so that when I type sample - function(x,y) { + z-x+y + } + edit(sample) the XEmacs (or other editor) is the editor for this function (the default seems to be MS Notepad, blech). See ?options options()$editor [1] /usr/bin/vim options(editor=emacs) options()$editor [1] emacs -- Philippe __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Deciphering an error message
Suzanne E. Blatt wrote: Hello again, Below is the code I am using which generates the error message. Any comments greatly appreciated, S. Well, my questions were: - 'What is a ppp object?' Still not answered yet, AFAICS. - 'Which function has been applied and generated that error message?' Still not answered yet, AFAICS. You have send us a self written function, but not a reproducible example that helps to discover the error message. And this function does *not* generate the error message, but perhaps a function called within your function. Further on: - You are using a function ppp() I don't know anything about. - (At least) The line spCol - t(trees[spColNam]) should generate a syntax error ... So, please use the debugging tools to find out which function produces the error message (e.g. via traceback()) and specify *reproducible* examples that are as short as possible. We cannot help as long as you are concealing the relevant information. Uwe # # Function to create a PPP object for all the points in a particular # include. Mark the points with their species name (or a number # indicating it) # # Usage: # x - getBigPPP(year, include, species, number=FALSE) # # Where: # x = ppp object with coordinates and bounds for indicated species # and plots. # year = year(s) to include data for. Either a single number or a #vector of numbers # include = name(s) of plots to include data from. Either a single # character expression or a vector of characters. # species = name(s) of species to include data for. Either a single # species name or a vector of characters. # number = flag indicating whether species names or numbers are used # as marks in ppp object. Species names are default. To # use numbers, set number=TRUE. This argument is not needed # unless numbers are desired. # # Example: # source(spat1.R) # source file to install functions # getBigPPP(1992, G1, apple) # print PPP object (summary of) ## for apple in G1 in 1992. Marks ## will be species name 'apple' # x - getBigPPP(1992, c(P1,P2,P3), c(apple,hawthorn), number=TRUE) ## x is defined as PPP object with ## coordinates and plot information ## for apple and hawthorn species ## in plots P1, P2, and P3, with ## marks set to numbers. # plot(x)# plot locations of species, with ## different marks for each one, and ## plot boundaries. # getBigPPP - function(year=NULL, include=NULL, species=NULL, number=FALSE, spColNam=Species) { # message about usage if(is.null(year) || is.null(include)) { return(ERROR !) } # create species selection if it is now null spCol - t(trees[spColNam]) # print(spCol) if(is.null(species)) { species - as.character(unique(spCol)) } # create the bounds for this object bounds - plotBounds(include) # selection based on include and year select - (trees$Plot %in% include) (trees$Year %in% year) (spCol %in% species) (!is.na(trees$Northing)) (!is.na(trees$Easting)) (trees$Present == 1) # mark with numbers or with species name if(!number) { return(ppp(x=trees$Easting[select], y=trees$Northing[select], marks=as.factor(spCol[select]), poly=bounds)) } specs - unique(spCol[select]) marks - apply(as.matrix(spCol[select]), 1, function(x) { which(specs == x)[1] }) return(ppp(x=trees$Easting[select], y=trees$Northing[select], marks=as.factor(marks), poly=bounds)) } -- Uwe Ligges [EMAIL PROTECTED] wrote: Suzanne E. Blatt wrote: Hello, I'm working in spatstat and having difficulty with the ppp objects. I can get a ppp object for one set of data, but with the same code applied to a second data set (all I am changing is the field identifier), I get the following error message: Error in switch(w$type, rectangle={: internal error: some total scores are neither 0 nor 1 What is a ppp object? Which function has been applied and generated that error message? The error message tells you some values a ought to sum up to 0 or 1 but they don't. I (and perhaps others as well) cannot help when you don't specify some relevant information. Uwe Ligges Any thoughts on what this means and how to correct it would be most appreciated. Thanks, Suzanne __ [EMAIL PROTECTED] mailing list
RE: [R] Creating a co-occurence matrix
From: Greg Blevins [mailto:[EMAIL PROTECTED] Hello R experts, I have a data.frame which has a series of 30 variables that are each coded 1,0--1 if a behavior is engaged in, 0 otherwise. The data.frame looks like this: var1 var2 ...var30 Respondent 1 Respondent 2 etc I would like to create a matrix (or at least a half-matrix) as follows: var1 var2 ...var30 var1 var 2 . . var 30 where the number at each intersection is the number of people who engaged in both behaviors. I could run a whole bunch of tables and input the data by hand into a new matrix, but I was wondering if there is a way to do this via a program/function (I looked at daisy, but concluded this function would not handle this). If I understood you correctly, the cross product of the matrix should do it. If your data frame is named df, then you can do answer - crossprod(data.matrix(df)) Hth, Andy Any help would be appreciated! Greg Blevins The Market Solutions Group __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help -- Notice: This e-mail message, together with any attachments, ...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] help for barchart(lattice)
I'd like to plot coefficients from glm result. with barchart, coefficients are ordered by the names of factors and I'd like to order them by values (or abs(values)). to do that, I've ordered the vector of coefficients but it's plotting the same thing. I'm working R 1.6.2 on win98. Thanks is it possible to do that with standard graphical function? __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] step-wise and prediction
I would like to know how to use the function step with for in order to predict. Id est: Let M , A, B ,C be vectors of length 15 for(i in 1:5) { regrM-lm(M[(1+i):(10+i)]~A[(1+i):(10+i)]+B[(1+i):(10+i)]+C[(1+i): (10+i)]) sregrM-step(regrM) and then I would like to compute the predicted value : M* of M, using the predictors selected by the function step. For example if i=1 and step gives us the model M~A, then in the for, I want to compute M* by the means of A[11], and compare this value to the real value M[11] and so on. Merci d'avance , Cordialement Athanasia __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Computations slow in spite of large amounts of RAM.
Hi all, I am a beginner trying to use R to work with large amounts of oceanographic data, and I find that computations can be VERY slow. In particular, computational speed seems to depend strongly on the number and size of the objects that are loaded (when R starts up). The same computations are significantly faster when all but the essential objects are removed. I am running R on a machine with 16 GB of RAM, and our unix system manager assures me that there is memory available to my R process that has not been used. 1. Is the problem associated with how R uses memory? If so, is there some way to increase the amount of memory used by my R process to get better performance? The computations that are particularly slow involve looping with by(). The data are measurements of vertical profiles of pressure, temperature, and salinity at a number of stations, which are organized into a dataframe p.1 (1925930 rows, 8 columns: id, p, t, and s, etc.), and the objective is to get a much smaller dataframe and the unique values for ID is 1409 with the minimum and maximum pressure for each profile. The slow part is: h.maxmin - by(p.1,p.1$id,function(x){ data.frame(id=x$id[1], maxp=max(x$p), minp=min(x$p))}) 2. Even with unneeded data objects removed, this is very slow. Is there a faster way to get the maximum and minimum values? platform sparc-sun-solaris2.9 arch sparc os solaris2.9 system sparc, solaris2.9 status major1 minor7.0 year 2003 month04 day 16 language R Thank you for your time. Helen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] step-wise and prediction
Have you considered predict(regrM)? J'espere que ces mots vous aideront. Spencer Graves ATHANASIA KAMARIOTIS wrote: I would like to know how to use the function step with for in order to predict. Id est: Let M , A, B ,C be vectors of length 15 for(i in 1:5) { regrM-lm(M[(1+i):(10+i)]~A[(1+i):(10+i)]+B[(1+i):(10+i)]+C[(1+i): (10+i)]) sregrM-step(regrM) and then I would like to compute the predicted value : M* of M, using the predictors selected by the function step. For example if i=1 and step gives us the model M~A, then in the for, I want to compute M* by the means of A[11], and compare this value to the real value M[11] and so on. Merci d'avance , Cordialement Athanasia __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
RE: [R] Computations slow in spite of large amounts of RAM.
From: Huiqin Yang [mailto:[EMAIL PROTECTED] Hi all, I am a beginner trying to use R to work with large amounts of oceanographic data, and I find that computations can be VERY slow. In particular, computational speed seems to depend strongly on the number and size of the objects that are loaded (when R starts up). The same computations are significantly faster when all but the essential objects are removed. I am running R on a machine with 16 GB of RAM, and our unix system manager assures me that there is memory available to my R process that has not been used. 1. Is the problem associated with how R uses memory? If so, is there some way to increase the amount of memory used by my R process to get better performance? Is R compiled as 64-bit? If not, it won't be able to use more than 4GB of RAM (that's my understanding, anyway). R keeps objects in memory, so if you are working with large amount of data, it's a good habit to keep only the absolute essential objects in the workspace, and save() and rm() things you don't need for the computation. The computations that are particularly slow involve looping with by(). The data are measurements of vertical profiles of pressure, temperature, and salinity at a number of stations, which are organized into a dataframe p.1 (1925930 rows, 8 columns: id, p, t, and s, etc.), and the objective is to get a much smaller dataframe and the unique values for ID is 1409 with the minimum and maximum pressure for each profile. The slow part is: h.maxmin - by(p.1,p.1$id,function(x){ data.frame(id=x$id[1], maxp=max(x$p), minp=min(x$p))}) 2. Even with unneeded data objects removed, this is very slow. Is there a faster way to get the maximum and minimum values? Why do you need to use by(), and why have the function return a data frame containing only one row? Here's an experiment on my 900MHz PIII laptop: n - 1e5 dat - data.frame(id = sort(sample(LETTERS, n, replace=TRUE)), + p = rnorm(n)) system.time(h.maxmin - by(dat, dat$id,function(x) { + data.frame(id=x$id[1], maxp=max(x$p), minp=min(x$p))})) [1] 2.75 0.01 2.78 NA NA system.time(junk - tapply(dat$p, dat$id, function(x) range(x))) [1] 0.12 0.01 0.13 NA NA If you want to coerce the result to a data frame with id as row names and min and max as the two variables, you can do: junk.dat - as.data.frame(do.call(rbind, junk)) HTH, Andy platform sparc-sun-solaris2.9 arch sparc os solaris2.9 system sparc, solaris2.9 status major1 minor7.0 year 2003 month04 day 16 language R Thank you for your time. Helen __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo /r-help -- Notice: This e-mail message, together with any attachments, ...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Working memory full
I have a question concerning the working memory used by R. I am running a simulation job (a function which replicates a simulation) which calls several other functions that I have written. Something like this: name1-function(number of replications){ for(i in 1:replication) name2(parameters) name3() # get results and aggregate open.. write(..., append=T) } } name2-function(parameters){ # simulate data ... # save data and parameters write... } name3-function(){ # get data and parameters open... # analyse data ... # save results write.. } name1(100) However, after a couple of replications working memory seems to be full. Error: cannot allocate vector of size ...Kb In addition: Warning message: Reached total allocation of 126Mb: see help(memory.size) This puzzles me, because all arrays (Note: large arrays, i.e., 500x500) are defined locally (within each function) and redefined every replication (the meta-function). So my question is: Why is R eating up my working memory while I think I am redefining the same (local) arrays? Any thoughts on how this can be circumvented? Thanks, Peter. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] X-emacs and R for Windows
Philippe Glaziou [EMAIL PROTECTED] writes: Chriss, Neil [EMAIL PROTECTED] wrote: Is there any way to make XEmacs (or any other editor) the default editor for R so that when I type sample - function(x,y) { + z-x+y + } + edit(sample) the XEmacs (or other editor) is the editor for this function (the default seems to be MS Notepad, blech). See ?options options()$editor [1] /usr/bin/vim options(editor=emacs) options()$editor [1] emacs You might want to consider the emacs client variants (winclient, I think, on XEmacs, not sure what it is on Emacs, gnuclient or emacsclient); they require Emacs to be already running, and simply provide an attached frame to work in. best, -tony -- A.J. Rossini / [EMAIL PROTECTED] / [EMAIL PROTECTED] http://software.biostat.washington.edu/ UNTIL IT MOVES IN JULY. Biomedical and Health Informatics, University of Washington Biostatistics, HVTN/SCHARP, Fred Hutchinson Cancer Research Center. FHCRC: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email CONFIDENTIALITY NOTICE: This e-mail message and any attachme...{{dropped}} __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Computations slow in spite of large amounts of RAM.
Huiqin Yang [EMAIL PROTECTED] writes: Hi all, I am a beginner trying to use R to work with large amounts of oceanographic data, and I find that computations can be VERY slow. In particular, computational speed seems to depend strongly on the number and size of the objects that are loaded (when R starts up). The same computations are significantly faster when all but the essential objects are removed. I am running R on a machine with 16 GB of RAM, and our unix system manager assures me that there is memory available to my R process that has not been used. 1. Is the problem associated with how R uses memory? If so, is there some way to increase the amount of memory used by my R process to get better performance? You could try setting a large nsize and vsize using mem.limits See the description in ?Memory The computations that are particularly slow involve looping with by(). The data are measurements of vertical profiles of pressure, temperature, and salinity at a number of stations, which are organized into a dataframe p.1 (1925930 rows, 8 columns: id, p, t, and s, etc.), and the objective is to get a much smaller dataframe and the unique values for ID is 1409 with the minimum and maximum pressure for each profile. The slow part is: h.maxmin - by(p.1,p.1$id,function(x){ data.frame(id=x$id[1], maxp=max(x$p), minp=min(x$p))}) I think it would be faster to use h.maxmin - tapply(p.1$p, p.1$id, range) In the call to by you are subsetting the entire data frame and that probably means taking at least one copy of that frame. If you use tapply on only the relevant columns you will use much less space. 2. Even with unneeded data objects removed, this is very slow. Is there a faster way to get the maximum and minimum values? See above. -- Douglas Bates[EMAIL PROTECTED] Statistics Department608/262-2598 University of Wisconsin - Madisonhttp://www.stat.wisc.edu/~bates/ __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] crossed random effects
Have you studied Pinhiero and Bates (2000) Mixed Effects Models in S and S-Plus (Springer)? Also, have you tried simplifying your lme call until you get something that works, then start adding back terms in various configurations until it breaks? Have you tried to compute how many coefficients are estimated in both fixed and random terms and evaluate whether all are estimable? For example, with 2 factors at 2 levels each, if you don't have all 4 possible combinations, you can't estimate the interaction -- even if you have thousands of replications of each. Finally, you can always try to read the code. I've learned a lot about S-Plus / R by doing that -- and solved a lot of my own problems that way. hope this helps. spencer graves Sarah Mclean wrote: Hi, if I have posted this twice, please ignore this. I'm not sure if I sent it to the correct e-mail address the first time. I have a data set on germination and plant growth with the following variables: dataset=fm mass (response) sub (fixed effect) moist (fixed effect) pop (fixed effect) mum (random effect nested within population) iheight (covariate) plot (random effect- whole plot factor for split-plot design). I want to see if moist or sub interacts with mum for any of the pops, but I am getting an error message. This is the formula I used: fm$pmu - getGroups(fm, ~1|pop/mum, level=2) fm$grp = as.factor(rep(1,nrow(fm))) fm$pl - getGroups(fm, ~1|plot) fm$mo - getGroups(fm, ~1|moist) fm$su - getGroups(fm, ~1|sub) fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop, data=fm, random=list(grp=pdBlocked(list(pdIdent(~pl - 1), pdIdent(~pmu - 1), pdIdent(~pmu:su - 1), pdIdent(~pmu:mo - 1) Error in chol((value + t(value))/2) : non-positive definite matrix in chol I know the problem is with the random interaction terms, but I don't know how to overcome this. Any advice would be greatly appreciated. I'm new to R and analysis such as this. Thank you, Sarah Mclean [EMAIL PROTECTED] http://mobile.yahoo.com.au - Yahoo! Mobile - Check compose your email via SMS on your Telstra or Vodafone mobile. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] X-emacs and R for Windows
On Tue, 1 Jul 2003, A.J. Rossini wrote: Philippe Glaziou [EMAIL PROTECTED] writes: Chriss, Neil [EMAIL PROTECTED] wrote: Is there any way to make XEmacs (or any other editor) the default editor for R so that when I type sample - function(x,y) { + z-x+y + } + edit(sample) the XEmacs (or other editor) is the editor for this function (the default seems to be MS Notepad, blech). Yes, it is: what other editor can you guarantee to be on all Windows systems? BTW, I think you want to say fix(sample): edit returns a result you may want to assign. See ?options options()$editor [1] /usr/bin/vim options(editor=emacs) options()$editor [1] emacs You might want to consider the emacs client variants (winclient, I think, on XEmacs, not sure what it is on Emacs, gnuclient or emacsclient); they require Emacs to be already running, and simply provide an attached frame to work in. On NTEmacs I use gnuclient, which BTW will start up an emacs if one is not already running, otherwise start a new frame (or, my choice) a new buffer. -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] RE: question about spatial correlation with Xs and Ys
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 01, 2003 3:09 AM To: [EMAIL PROTECTED] Subject: R-help Digest, Vol 5, Issue 1 At 18:48 30/06/2003, Martin Wegmann wrote: hello, I want to do a test for spatial correlation. I tried it with geary.test() but I don't understand the required input. x= a numeric vector the same length as the neighbours list in listw (my sampled data, I assume) listw= a listw object created for example by nb2listw (well when I check nb2listw() I get to neighbours - an object of class nb - but I couldn't figure out, what nb is or how I create such a class with sp.mantel.mc {spdep} I have the same problem: listw created by nb2listw isn't there a more straight forward method ;-) to check for spatial correlation? like x and y coordinates plus my sampled data? Check out the notes from a short course in Spatial Epidemiology by Best et al., at http://stats.ma.ic.ac.uk/~ngb30/. They have S-plus code to run Moran's I and Tango's test for spatial correlation that use disease counts in small areas and their X and Y coordinates. Daniel Smith, Dr.P.H. Environmental Health Investigations Branch California Department of Health Services 1515 Clay Street, Suite 1700 Oakland, CA 94612 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Warning message in scatter.smooth (modreg)
On Tue, 1 Jul 2003, Gavin Simpson wrote: Dear list, In using the scatter.smooth() function (modreg) on a small data set (100 obs) the following error was produced: scatter.smooth(Na, S) Warning message: k-d tree limited by memory. ncmax= 200 I haven't used scatter.smooth much but when I have, I haven't seen this message before. gc() returns gc() used (Mb) gc trigger (Mb) Ncells 417693 11.2 667722 17.9 Vcells 103949 0.8 786432 6.0 This is on a Win XP box with 512 MB RAM, with plenty of space still available (Task Manager Reports 216 MB of RAM and pagefile in use). I have looked through the help files for loess and loess.control but didn't see anything about ncmax. Can someone explain why I might be getting this warning? It's trying to fit a very complicated function, and running out of its own internal storage, which is set in the C routine loess_workspace. However, 200 cells should be ample for 100 obs, so I guess the algorithm is not working properly in your example. -- 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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Matrix to Vector
Hello, I have a matrix of values that I want to convert to a vector, but remove certain entries in the matrix first, i.e. in the vector I want every value in the matrix that is greater than 1000. I would also like to find out how many values are excluded in the transition from matrix to vector. Could someone tell me how this can be done? Thank you in advance Arun Horne __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Matrix to Vector
A matrix is a vector with a dim attribute. The following should do what I understand of you to be asking: sel - (Mat1000) Vec - Mat[sel] n.excl - length(Mat)-length(Vec) hope this helps. spencer graves Arun Horne wrote: Hello, I have a matrix of values that I want to convert to a vector, but remove certain entries in the matrix first, i.e. in the vector I want every value in the matrix that is greater than 1000. I would also like to find out how many values are excluded in the transition from matrix to vector. Could someone tell me how this can be done? Thank you in advance Arun Horne __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] strange error message
Hi, there I have a loop that is producing data, but is also generating an error message that I can't understand. Here's the loop and the error message: bio-matrix(NA, ncol=9, nrow=366) W-NULL M- length(Day) #number of days iterated for (i in 1:M) + { + + + if (Day[i]==1) W[i] - Wo else W[i] - (W[i-1]+(Gr[i]/Ef)) + + + C- p*CA*(W^CB)*(((comp[,3])^Xc)*(exp(Xc*(1-(comp[,3])*Pc + + ASMR- ACT*RA*(W^RB)*(((comp[,4])^Xa)*(exp(Xa*(1-(comp[,4]) + + SMR- (ASMR/ACT) + + A- (ASMR-SMR) + + F- (FA*((comp[,2])^FB)*(exp(FG*p))*C) + + U- (UA*((comp[,2])^UB)*(exp(UG*p))*(C-F)) + + SDA- (S*(C-F)) + + Gr- (C-(ASMR+F+U+SDA)) + + bio- cbind(W, C, ASMR, SMR, A, F, U, SDA, Gr) + + } There were 50 or more warnings (use warnings() to see the first 50) warnings function (...) { if (!(n - length(last.warning))) return() names - names(last.warning) cat(Warning message, if (n 1) s, :\n, sep = ) for (i in 1:n) { out - if (n == 1) names[i] else paste(i, : , names[i], sep = ) if (length(last.warning[[i]])) { temp - deparse(last.warning[[i]]) out - paste(out, in:, temp[1], if (length(temp) 1) ...) } cat(out, ..., fill = TRUE) } } dimnames (bio) -list(NULL, c (W, C, ASMR, SMR, A, F, U, SDA, Gr)) bio WC ASMR SMR AF U [1,] 9.20 233.6647 107.5640 64.50050 43.06345 31.93755 15.840142 Also, does anyone know why I might be getting differences in the same calculation between R and Excel? Is there any way to keep R from rounding your numbers, or to specify the # of decimal places you want for an element? -- Michael Rennie M.Sc. Candidate University of Toronto at Mississauga 3359 Mississauga Rd. N. Mississauga ON L5L 1C6 Ph: 905-828-5452 Fax: 905-828-3792 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] strange error message
Michael Rennie [EMAIL PROTECTED] writes: + } There were 50 or more warnings (use warnings() to see the first 50) warnings function (...) { if (!(n - length(last.warning))) return() names - names(last.warning) cat(Warning message, if (n 1) s, :\n, sep = ) So what were the warnings? We can figure out what the warnings function looks like without your help (Read the message *carefully*!) -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] strange error message
Michael 1) Those are not errors, but warnings. You need to use warnings() (with the brackets) to see what they were. By typing warnings (without the brackets) you are asking R to print out the source code for the warnings() function. 2) try ?options and see option digits in that help file Hope that helps a bit, Gavin Michael Rennie wrote: Hi, there I have a loop that is producing data, but is also generating an error message that I can't understand. Here's the loop and the error message: bio-matrix(NA, ncol=9, nrow=366) W-NULL M- length(Day) #number of days iterated for (i in 1:M) + { + + + if (Day[i]==1) W[i] - Wo else W[i] - (W[i-1]+(Gr[i]/Ef)) + + + C- p*CA*(W^CB)*(((comp[,3])^Xc)*(exp(Xc*(1-(comp[,3])*Pc + + ASMR- ACT*RA*(W^RB)*(((comp[,4])^Xa)*(exp(Xa*(1-(comp[,4]) + + SMR- (ASMR/ACT) + + A- (ASMR-SMR) + + F- (FA*((comp[,2])^FB)*(exp(FG*p))*C) + + U- (UA*((comp[,2])^UB)*(exp(UG*p))*(C-F)) + + SDA- (S*(C-F)) + + Gr- (C-(ASMR+F+U+SDA)) + + bio- cbind(W, C, ASMR, SMR, A, F, U, SDA, Gr) + + } There were 50 or more warnings (use warnings() to see the first 50) warnings function (...) { if (!(n - length(last.warning))) return() names - names(last.warning) cat(Warning message, if (n 1) s, :\n, sep = ) for (i in 1:n) { out - if (n == 1) names[i] else paste(i, : , names[i], sep = ) if (length(last.warning[[i]])) { temp - deparse(last.warning[[i]]) out - paste(out, in:, temp[1], if (length(temp) 1) ...) } cat(out, ..., fill = TRUE) } } dimnames (bio) -list(NULL, c (W, C, ASMR, SMR, A, F, U, SDA, Gr)) bio WC ASMR SMR AF U [1,] 9.20 233.6647 107.5640 64.50050 43.06345 31.93755 15.840142 Also, does anyone know why I might be getting differences in the same calculation between R and Excel? Is there any way to keep R from rounding your numbers, or to specify the # of decimal places you want for an element? -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Gavin Simpson [T] +44 (0)20 7679 5522 ENSIS Research Fellow [F] +44 (0)20 7679 7565 ENSIS Ltd. ECRC [E] [EMAIL PROTECTED] UCL Department of Geography [W] http://www.ucl.ac.uk/~ucfagls/cv/ 26 Bedford Way[W] http://www.ucl.ac.uk/~ucfagls/ London. WC1H 0AP. %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] lines and legend
When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] lines and legend
Yes, I am using plot and then lines. The legend is just not appearing. I am using the coordinates of the legend (150,4) which work on boxplot and plot. I have not looked at the output of par (I don't know how to) to see if they are in the region. I assumed if they worked for plot and boxplot they would also for lines. Anna On Tuesday 01 July 2003 11:16, you wrote: I assume that you are calling 'plot' and then 'lines'. Is the legend just not appearing? what are you using for the coordinates of the legend? Have you looked at the output from par to see if these values are within the plot region? __ James Holtman What is the problem you are trying to solve? Executive Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] (513) 723-2929 Anna H. Pryor [EMAIL PROTECTED]To: R-help mailing list [EMAIL PROTECTED] a.gov cc: Sent by: Subject: [R] lines and legend [EMAIL PROTECTED] ath.ethz.ch 07/01/2003 13:45 When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] lines and legend
Hi Anna, What I often do before calling legend is reset the user-coordinates to the unit square. As in: plot(x = 1:100, y = 1:100, col = red) par(usr = c(0, 1, 0, 1)) # now place legend in upper left hand corner legend(x = 0.02, y = 0.98, legend = test, col = red, pch = 1) Hope this is helpful, Sundar Anna H. Pryor wrote: Yes, I am using plot and then lines. The legend is just not appearing. I am using the coordinates of the legend (150,4) which work on boxplot and plot. I have not looked at the output of par (I don't know how to) to see if they are in the region. I assumed if they worked for plot and boxplot they would also for lines. Anna On Tuesday 01 July 2003 11:16, you wrote: I assume that you are calling 'plot' and then 'lines'. Is the legend just not appearing? what are you using for the coordinates of the legend? Have you looked at the output from par to see if these values are within the plot region? __ James Holtman What is the problem you are trying to solve? Executive Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] (513) 723-2929 Anna H. Pryor [EMAIL PROTECTED]To: R-help mailing list [EMAIL PROTECTED] a.gov cc: Sent by: Subject: [R] lines and legend [EMAIL PROTECTED] ath.ethz.ch 07/01/2003 13:45 When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] lines and legend
Hi, Have you specified the lty and/or col in legend? For example, are the following codes work? plot(1:10, type = n) lines(c(1, 10), c(1, 10)) lines(c(1, 9), c(0, 10), col = red) legend(8, 2, col = c(black, red), lty = 1, legend = c(FOO, FRED)) On Tue, 1 Jul 2003, Anna H. Pryor wrote: Date: Tue, 1 Jul 2003 11:23:55 -0700 From: Anna H. Pryor [EMAIL PROTECTED] To: R-help mailing list [EMAIL PROTECTED] Subject: Re: [R] lines and legend Yes, I am using plot and then lines. The legend is just not appearing. I am using the coordinates of the legend (150,4) which work on boxplot and plot. I have not looked at the output of par (I don't know how to) to see if they are in the region. I assumed if they worked for plot and boxplot they would also for lines. Anna On Tuesday 01 July 2003 11:16, you wrote: I assume that you are calling 'plot' and then 'lines'. Is the legend just not appearing? what are you using for the coordinates of the legend? Have you looked at the output from par to see if these values are within the plot region? __ James Holtman What is the problem you are trying to solve? Executive Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] (513) 723-2929 Anna H. Pryor [EMAIL PROTECTED]To: R-help mailing list [EMAIL PROTECTED] a.gov cc: Sent by: Subject: [R] lines and legend [EMAIL PROTECTED] ath.ethz.ch 07/01/2003 13:45 When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Cheers, Kevin -- On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question. -- Charles Babbage (1791-1871) From Computer Stupidities: http://rinkworks.com/stupid/ -- Ko-Kang Kevin Wang Master of Science (MSc) Student SLC Tutor and Lab Demonstrator Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 Ph: 373-7599 x88475 (City) x88480 (Tamaki) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] upload the data
Dear Sir, I am trying to use the Rweb for the anova. But the first question is how to load the data named with *.xle. You know, all of my data are input to excel. Could you take time to tell me how to load the data from the local excel based file. I am very appreciate for your help. Best wishes Yang Hu * Department of Entomology 219 Hodson Hall, 1980 Folwell Ave University of Minnesota St. Paul, Minnesota 55108 USA (612) 624-3423 e-mail[EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] lines and legend
Anna, I found this quite useful in positioning a legend: plot(1:10, 1:10) legend(locator(1), A legend) Now, go to the plot window and click your left mouse where you want the upper left corner of the legend to appear. Ithink, this should work no matter what your coordinate system is. Hope this helps, Andy __ Andy Jaworski Engineering Systems Technology Center 3M Center, 518-1-01 St. Paul, MN 55144-1000 - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 |-+ | | Anna H. Pryor | | | [EMAIL PROTECTED]| | | a.gov | | | Sent by: | | | [EMAIL PROTECTED]| | | ath.ethz.ch | | || | || | | 07/01/2003 12:45 | | || |-+ -| | | | To: R-help mailing list [EMAIL PROTECTED] | | cc: | | Subject: [R] lines and legend | -| When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] crossed random effects
Hi, thanks for the advice. I have looked at the Pinheiro and Bates book and I've tried simplifying my model. I've narrowed the problem down to having mum nested within pop. If I run the analysis on each population separately, the interaction between mo and su with mum works fine. If I could analyse all of the pops at once this would be preferable because I have multiple responses and pops to test so it would take a bit of time. I'm hoping there is any easier way. Thanks Sarah --- Spencer Graves [EMAIL PROTECTED] wrote: Have you studied Pinhiero and Bates (2000) Mixed Effects Models in S and S-Plus (Springer)? Also, have you tried simplifying your lme call until you get something that works, then start adding back terms in various configurations until it breaks? Have you tried to compute how many coefficients are estimated in both fixed and random terms and evaluate whether all are estimable? For example, with 2 factors at 2 levels each, if you don't have all 4 possible combinations, you can't estimate the interaction -- even if you have thousands of replications of each. Finally, you can always try to read the code. I've learned a lot about S-Plus / R by doing that -- and solved a lot of my own problems that way. hope this helps. spencer graves Sarah Mclean wrote: Hi, if I have posted this twice, please ignore this. I'm not sure if I sent it to the correct e-mail address the first time. I have a data set on germination and plant growth with the following variables: dataset=fm mass (response) sub (fixed effect) moist (fixed effect) pop (fixed effect) mum (random effect nested within population) iheight (covariate) plot (random effect- whole plot factor for split-plot design). I want to see if moist or sub interacts with mum for any of the pops, but I am getting an error message. This is the formula I used: fm$pmu - getGroups(fm, ~1|pop/mum, level=2) fm$grp = as.factor(rep(1,nrow(fm))) fm$pl - getGroups(fm, ~1|plot) fm$mo - getGroups(fm, ~1|moist) fm$su - getGroups(fm, ~1|sub) fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop, data=fm, random=list(grp=pdBlocked(list(pdIdent(~pl - 1), pdIdent(~pmu - 1), pdIdent(~pmu:su - 1), pdIdent(~pmu:mo - 1) Error in chol((value + t(value))/2) : non-positive definite matrix in chol I know the problem is with the random interaction terms, but I don't know how to overcome this. Any advice would be greatly appreciated. I'm new to R and analysis such as this. Thank you, Sarah Mclean [EMAIL PROTECTED] http://mobile.yahoo.com.au - Yahoo! Mobile - Check compose your email via SMS on your Telstra or Vodafone mobile. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help http://mobile.yahoo.com.au - Yahoo! Mobile - Check compose your email via SMS on your Telstra or Vodafone mobile. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] symbol size on a plot
Hi Philippe Hupé wrote: Hi, I would like to get from a plot the size of the symbols plotted. Imagine I have the following plot function : plot(1:2,1:2, pch=15, cex=4) I would like the get the values SIZE1 and SIZE2 so that if I plot the following rectangle : rect(1.5,1.5, 1.5+SIZE1, 1.5+SIZE2) then the size of this square is exactely the same as the one of the symbols that have been plotted. Thanks for any idea. This is a bit tricky. The size of plotting symbols is loosely based on the current cex setting (i.e., the size of text), BUT there are some magic multipliers applied within the C code to determine the exact size so that they look nice. There are some standard calculations you can perform to get close to the symbol size, but you have to do some fiddling to get exact and it will depend on which symbol you are plotting. Here's an example for the default pch=1 circles ... plot(1:10) size1 - (par(cin)[2]/par(pin)[1])* (par(usr)[2] - par(usr)[1]) * 0.5 * par(cex) * 0.375 size2 - (par(cin)[2]/par(pin)[2])* (par(usr)[4] - par(usr)[3]) * 0.5 * par(cex) * 0.375 rect(5 - size1, 5 - size2, 5 + size1, 5 + size2) ... the 0.375 multiplier is an example of a magic multiplier. I got it from the following bits of C code in R/src/main/graphics.c #define RADIUS 0.375 #define CMAG 1.0 #define GSTR_0 Rf_dpptr(dd)-cra[1] * 0.5 * Rf_gpptr(dd)-ipr[0] * Rf_gpptr(dd)-cex case 1: /* S octahedron ( circle) */ xc = CMAG * RADIUS * GSTR_0; Further inspection of the C code would give you similar minor fiddles for the other plotting symbols. Paul -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] crossed random effects
How many mum's and pop's do you have, and how many observations do you have of each mum-pop combination? If you want mum nested within pop, do I infer correctly that each mum has mated with only one pop, but that each pop may have offspring by multiple mums? The table of mum-pop combinations might help explain why you got, Error in chol((value + t(value))/2) : non-positive definite matrix in chol. If you can get an answer ignoring pop, then you might be able to get an answer with pop as a separate random term without specifying mum nested within pop. Also, I'd check very carefully the specification of nesting: I've messed that up more than once, and I'm bald now, because I tore all my hair out before I figured out what I was doing wrong. (Well, there is a slight exageration there.) Have you tried a very simple toy problem (or a published example) with nesting to make sure you can get the correct answer? hope this helps. spencer graves Sarah Mclean wrote: Hi, thanks for the advice. I have looked at the Pinheiro and Bates book and I've tried simplifying my model. I've narrowed the problem down to having mum nested within pop. If I run the analysis on each population separately, the interaction between mo and su with mum works fine. If I could analyse all of the pops at once this would be preferable because I have multiple responses and pops to test so it would take a bit of time. I'm hoping there is any easier way. Thanks Sarah --- Spencer Graves [EMAIL PROTECTED] wrote: Have you studied Pinhiero and Bates (2000) Mixed Effects Models in S and S-Plus (Springer)? Also, have you tried simplifying your lme call until you get something that works, then start adding back terms in various configurations until it breaks? Have you tried to compute how many coefficients are estimated in both fixed and random terms and evaluate whether all are estimable? For example, with 2 factors at 2 levels each, if you don't have all 4 possible combinations, you can't estimate the interaction -- even if you have thousands of replications of each. Finally, you can always try to read the code. I've learned a lot about S-Plus / R by doing that -- and solved a lot of my own problems that way. hope this helps. spencer graves Sarah Mclean wrote: Hi, if I have posted this twice, please ignore this. I'm not sure if I sent it to the correct e-mail address the first time. I have a data set on germination and plant growth with the following variables: dataset=fm mass (response) sub (fixed effect) moist (fixed effect) pop (fixed effect) mum (random effect nested within population) iheight (covariate) plot (random effect- whole plot factor for split-plot design). I want to see if moist or sub interacts with mum for any of the pops, but I am getting an error message. This is the formula I used: fm$pmu - getGroups(fm, ~1|pop/mum, level=2) fm$grp = as.factor(rep(1,nrow(fm))) fm$pl - getGroups(fm, ~1|plot) fm$mo - getGroups(fm, ~1|moist) fm$su - getGroups(fm, ~1|sub) fm1 - lme(sqrt(mass) ~ iheight + moist*sub*pop, data=fm, random=list(grp=pdBlocked(list(pdIdent(~pl - 1), pdIdent(~pmu - 1), pdIdent(~pmu:su - 1), pdIdent(~pmu:mo - 1) Error in chol((value + t(value))/2) : non-positive definite matrix in chol I know the problem is with the random interaction terms, but I don't know how to overcome this. Any advice would be greatly appreciated. I'm new to R and analysis such as this. Thank you, Sarah Mclean [EMAIL PROTECTED] http://mobile.yahoo.com.au - Yahoo! Mobile - Check compose your email via SMS on your Telstra or Vodafone mobile. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help http://mobile.yahoo.com.au - Yahoo! Mobile - Check compose your email via SMS on your Telstra or Vodafone mobile. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] How long is a day?
Why is 19 March, 1947 a little longer than one day? x - as.POSIXct(1947-04-16) julian(x, origin = as.POSIXct(1947-03-20)) Time difference of 27 days julian(x, origin = as.POSIXct(1947-03-19)) Time difference of 28.04167 days julian(x, origin = as.POSIXct(1947-03-18)) Time difference of 29.04167 days I am running R-1.7.1 compiled on RedHat 9.0 Laimonis -- Dr Laimonis Kavalieris Department of Mathematics and Statistics University of Otago PO Box 56 Dunedin New Zealand Tel (64)(3)479 7780 Fax (64)(3)479 8427 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] How long is a day?
Sorry about wasing time - Apparently NZ daylisght saving time finished on March 20, 1947 , and on March 3, 1980, and March 20, 2000 . I'm impressed that R knows all of this Laimonis -- Dr Laimonis Kavalieris Department of Mathematics and Statistics University of Otago PO Box 56 Dunedin New Zealand Tel (64)(3)479 7780 Fax (64)(3)479 8427 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Swedish characters in data frames
Hi I have some data that was prepared while I was Sweden. The columns labelled using ä or å are fine, but for some reason ö is changed to a period. so Blåbär stay the same, but Dödved becomes D.dved I'd like to keep to original variable names the data is read in using vegFreqFull - read.csv(/dat/neil/voles/veg/FrequentFull.csv, header=TRUE) Using R 1.70 on Win 2K SP4 Regards Neil -- Dr Neil A. White Senior Lecturer Department of Biology University of the South Pacific PO Box 1168, Suva Fiji Islands Tel: +679 321 2409 Fax: +679 331 5601 www.usp.ac.fj/biology __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] [ibiblio.org #1674] Mirroring request (fwd)
R users in the southeastern US (and those on the Internet-2 backbone) will be happy to hear of the new CRAN mirror at ibiblio.org aka metalab.unc.edu. -- Andrew J Perrin - http://www.unc.edu/~aperrin Assistant Professor of Sociology, U of North Carolina, Chapel Hill [EMAIL PROTECTED] * andrew_perrin (at) unc.edu -- Forwarded message -- Date: Tue, 1 Jul 2003 17:54:30 -0400 (EDT) From: Nancy via RT [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: [ibiblio.org #1674] Mirroring request Resent-Date: Tue, 1 Jul 2003 19:34:05 -0400 (EDT) Resent-From: Andrew Perrin [EMAIL PROTECTED] Resent-To: [EMAIL PROTECTED] Resent-Subject: [ibiblio.org #1674] Mirroring request Dear Andy, You can find info on R at http://www.us.r-project.org and the CRAN at cran.r-project.org. It's not proprietary in the slightest - GPL all the way. Great! We have set up the new mirror at ftp://ftp.ibiblio.org/pub/languages/R/CRAN/. I am writing them now to have the link added to their list. Thanks for letting us know! Please let us know if you have any other questions. Thank you, Nancy -- Nancy C. Wilson http://www.ibiblio.org __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help