[R] Sorting list elements according to their mean value

2015-03-03 Thread mtb954
Hello R-helpers, I have a list of 999 dataframes and I would like to sort the list by the mean value of one of the columns in the data frames. Here is a small, self-contained example: #begin example iterations-999 d-list() #resampled data f-list() #fitted values r-list() #residuals

[R] Problem using predict() to draw lines() if predictor variable is logged on the fly

2014-10-02 Thread mtb954
Hello, I am plotting glms with logged predictors. I would like to define the logged variables on the fly rather than hard coding them into my dataframe. This code (with hard-coded logged variables) works just fine: xx-seq(-2,.5,by=0.1); lines(xx,predict(power,list(LogArKm00=xx),type=

[R] Clean up biplot resulting from princomp()

2013-02-11 Thread mtb954
Dear R-helpers, The vectors in my biplot are completely obscured by the ~1400 labels R is printing on my biplot. I don't really care about the labels. How can I make the biplot without the annoying labels? See attached, if that helps you see my problem. Many thanks, Mark Na

Re: [R] Clean up biplot resulting from princomp()

2013-02-11 Thread mtb954
Thanks David. ?biplot is not exactly verbose on the issue, but in hindsight I can see how I might have figured that out on my own. In any case, I appreciate the time you took to show me how to do that. Best wishes, Mark Na On Mon, Feb 11, 2013 at 2:56 PM, David L Carlson dcarl...@tamu.edu

[R] Compare each element of a list to a vector

2013-02-03 Thread mtb954
Hello R-helpers, I have a vector x-c(1,2,3) and a list that contains vectors datalist-list(c(1,2,3),c(2,3,4),c(3,4,5),c(4,5,6)) and I would like to identify those list elements that are identical to x. I tried datalist %in% x [1] FALSE FALSE FALSE FALSE but I am obviously using %in%

Re: [R] Compare each element of a list to a vector

2013-02-03 Thread mtb954
Thanks Jim, William and Patrick for your ideas. I appreciate your help. Avoiding a circle of the R Inferno sounds good, so I'm going to use Patrick's 2nd suggestion for now but I learned something from the others too. Cheers, Mark On Sun, Feb 3, 2013 at 12:33 PM, Patrick Burns

[R] Regex for ^ (the caret symbol)?

2013-01-21 Thread mtb954
Hello R-helpers, I am trying to search for string that includes the caret symbol, using the following code: grepl(latitude^2,temp) And R doesn't like that. It gives me: temp-c(latitude^2,latitude and latitude^2,longitude^2,longitude and longitude^2) temp [1] latitude^2

Re: [R] Regex for ^ (the caret symbol)?

2013-01-21 Thread mtb954
Hi Tsjerk, many thanks...that worked perfectly! Mark Na On Mon, Jan 21, 2013 at 9:36 AM, Tsjerk Wassenaar tsje...@gmail.com wrote: Oh, I'm jetlagged. ^ is a control character for 'start of string'. In the context of a character set it means negation: [^a-z]. Ciao, Tsjerk On Mon, Jan

Re: [R] How to convert a string to the column it represents in a dataframe, with a reproducible example

2013-01-18 Thread mtb954
Many thanks to everyone who chimed in on this one. I really appreciate the time you took to help me. Especially Dave W. who made me question what exactly I was after. Dan N.'s solution does exactly what I want, and it helped me learn about the eval() and parse() functions too. Thanks again, and

[R] Object created within a function disappears after the function is run

2013-01-18 Thread mtb954
Dear R-helpers, I have run the code below which I expected to make an object called dd1, but that object does not exist. So, in summary, my problem is that my function is meant to make an object (dd1), and it does indeed make that object (I know that the last line of the function prints it out)

Re: [R] Object created within a function disappears after the function is run

2013-01-18 Thread mtb954
Hi Sarah, that works perfectly, thank you! Mark Na On Fri, Jan 18, 2013 at 5:23 PM, Sarah Goslee sarah.gos...@gmail.comwrote: Hi, You need to assign the result of the function to an object: dd1 - dredgeit(lm1) On Fri, Jan 18, 2013 at 6:17 PM, mtb...@gmail.com wrote: Dear R-helpers,

[R] Naming an object after another object...can it be done?

2013-01-17 Thread mtb954
Hello R-helpers, I have run the following line of code: x-dat$col and now I would like to assign names(x) to be dat$col (e.g., a character string equal to the column name that I assigned to x). What I am trying to do is to assign columns in my dataframe to new objects called x and y. Then I

Re: [R] Naming an object after another object...can it be done?

2013-01-17 Thread mtb954
Hi Liu - I have been trying with assign() but it's not working. I don't think that's what I'm looking forany other ideas? Many thanks, Mark On Thu, Jan 17, 2013 at 1:11 PM, Wensui Liu liuwen...@gmail.com wrote: are you looking for assign()? On Jan 17, 2013 1:56 PM, mtb...@gmail.com

Re: [R] Naming an object after another object...can it be done?

2013-01-17 Thread mtb954
Hi everyone, and thanks for your replies. Let me make this a little simpler. Please forget the plotting, that's not the issue. I have run the following line of code: x-dat.col Now, is there a function (or combination of functions) that will let me assign the character string dat.col to a new

[R] How to convert a string to the column it represents in a dataframe, with a reproducible example

2013-01-17 Thread mtb954
Hello R-helpers, I have run the following lines of code: x-cars$dist y-noquote(x) Now y is a string containing the characters cars$dist My questionis there an R function (or combination of functions) that I can apply to y that will cause y to contain the numbers in cars$dist? Even better,

Re: [R] How to convert a string to the column it represents in a dataframe, with a reproducible example

2013-01-17 Thread mtb954
Hi David, I would like to have two objects, one containing the values in a column and the other containing the column's name. Of course, that's easy to do manually, but I don't want to have to type out the name of the column more than once (thus, below, I have typed it once in quotes, and I am

[R] Using lme, how to specify: (1) repeated measures, and (2) Toeplitz covariance structure?

2008-08-21 Thread mtb954
We are attempting to use nlme to fit a linear mixed model to explain bird abundance as a function of habitat: lme(abundance~habitat-1,data=data,method=ML,random=~1|sampleunit) The data consist of repeated counts of birds in sample units across multiple years, and we have two questions: 1)

[R] cross validation for lme

2008-08-21 Thread mtb954
Hello, We would like to perform a cross validation on a linear mixed model (lme) and wonder if anyone has found something analogous to cv.glm for such models? Thanks, Mark [[alternative HTML version deleted]] __ R-help@r-project.org mailing

[R] How to calculate GLM least square means?

2008-08-05 Thread mtb954
Hello R-helpers, I would like to calculate least square means after having built a GLM with quasipoisson errors. In my model the dependent variable is continuous, I have one continuous independent variable and one categorical independent variable (that is the variable for which I would like to

[R] Combining logical operators to extract columns from a dataframe

2008-03-25 Thread mtb954
Hi R-helpers, I have a dataframe (called data) with 100 columns, the columns of which are named with integers ranging from 1900 to 1999. I wish to extract those columns which names are =1950 and =1970. I tried: data2-subset(data,select=(names(data)=1950 names(data)=1970)) but that doesn't