[R] select Intercept coefficients only

2009-02-27 Thread choonhong ang
Hi friends, Is there a function to select intercept coefficients only ? When I use "coeficients" it shows me all the coefficients, but I only want a specific coefficients. [[alternative HTML version deleted]] __ R-help@r-project.org mailing li

Re: [R] Making tapply code more efficient

2009-02-27 Thread jim holtman
On something the size of your data it took about 30 seconds to determine the number of unique teachers per student. > x <- cbind(sample(326397, 800967, TRUE), sample(20, 800967, TRUE)) > # split the data so you have the number of teachers per student > system.time(t.s <- split(x[,2], x[,1])) us

Re: [R] select Intercept coefficients only

2009-02-27 Thread Uwe Ligges
choonhong ang wrote: Hi friends, Is there a function to select intercept coefficients only ? When I use "coeficients" it shows me all the coefficients, but I only want a specific coefficients. What about indexing, e.g. as in: coefficients(some_lm_object)["(Intercept)"] Uwe Ligges

[R] Optimize for loop / find last record for each person

2009-02-27 Thread Andrew Ziem
I want to find the last record for each person_id in a data frame (from a SQL database) ordered by date. Is there a better way than this for loop? for (i in 2:length(history[,1])) { if (history[i, "person_id"] == history[i - 1, "person_id"]) history[i, "order"] = history[i - 1, "order"]

Re: [R] Inefficiency of SAS Programming

2009-02-27 Thread Greg Snow
But SAS/IML is not part of base SAS, it costs extra, so there is a good chance that a user that has SAS will not be able to run code that uses SAS/IML. I have known of SAS programmers who know IML well that still write matrix/vector tools using macros or proc transpose so that a user without IML

Re: [R] testing two-factor anova effects using model comparison approach with lm() and anova()

2009-02-27 Thread Paul Gribble
Thanks Greg - that makes sense... that the test of the main effect of A is uninteresting if the AxB interaction is in the model - but isn't that exactly what appears in the usual anova(fullmodel) output? A test of the main effect of A, a test of the main effect of B, and then a test of the interac

Re: [R] Download daily weather data

2009-02-27 Thread Chris Stubben
tlevine wrote: > > The NOAA has very promising tabular forecasts > (http://forecast.weather.gov/MapClick.php?CityName=Ithaca&state=NY&site=BGM&textField1=42.4422&textField2=-76.5002&e=0&FcstType=digital), > but I can't figure out how to import them. > Sometimes you can just use gsub to get htm

Re: [R] Optimize for loop / find last record for each person

2009-02-27 Thread Jorge Ivan Velez
Dear Andrew, Here is one way: # Some data set.seed(1) mydata<-data.frame(person_id=rep(1:10,10),x=rnorm(100)) mydata # last register for person_id with(mydata,tapply(x,person_id,function(x) tail(x,1))) # test for person_id=1 mydata[mydata$person_id==1,] # see the last number in column 2 HTH,

Re: [R] testing two-factor anova effects using model comparison approach with lm() and anova()

2009-02-27 Thread Greg Snow
Yes, the output from a summary of lm does include the uninteresting test. Partly at least due to a legacy from when we used to compute a lot of these things by hand. Certain layouts and sequences of calculations were developed to make the hand calculations easier. When we first started having

Re: [R] formula formatting/grammar for regression

2009-02-27 Thread Dieter Menne
BKMooney gmail.com> writes: > > > Also, when I tried to use nls, I get an error: > nls(ypts ~ exp(xpts)) > Error in getInitial.default(func, data, mCall = as.list(match.call(func, : > no 'getInitial' method found for "function" objects > > If someone could please point out what I am doin

[R] Competing risks adjusted for covariates

2009-02-27 Thread Eleni Rapsomaniki
Dear R-users Has anybody implemented a function/package that will compute an individual's risk of an event in the presence of competing risks, adjusted for the individual's covariates? The only thing that seems to come close is the cuminc function from cmprsk package, but I would like to adju

[R] factors to integers preserving value in a dataframe

2009-02-27 Thread Alexy Khrabrov
I want to produce a dataframe with integer columns for elements of string pairs: pairs <- c("10 21","23 45") pairs.split <- lapply(pairs,function(x)strsplit(x," ")) pdf <- as.data.frame(pairs.split) names(pdf) <- c("p","q") -- at this point things look good, except the columns are factors, as

Re: [R] Optimize for loop / find last record for each person

2009-02-27 Thread David Winsemius
"...from an SQL database."How? Structure of the result? You say "ordered by date" but then you don't reference any date variable? And your code creates an "order" column, but that would not appear necessary for the stated purpose and you don't output the last "order" within a "person_i

[R] using a for loop with variable as vectors

2009-02-27 Thread Laura Lucia Prieto Godino
Dear R users, I am completelly lost with the following: I have the following vectors a, b ,c, d and e + a [1] 279.3413 268.0450 266.3062 433.8438 305.4650 317.4712 288.3413 374.6950 > > b [1] 170.4500 254.5675 219.5762 232.3425 200.2738 238.2637 210.6062 262.4825 345.2387 269.3763 [11] 190

Re: [R] factors to integers preserving value in a dataframe

2009-02-27 Thread David Winsemius
R-FAQ 7.10 : http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f -- David Winsemius On Feb 27, 2009, at 2:56 PM, Alexy Khrabrov wrote: I want to produce a dataframe with integer columns for elements of string pairs: pairs <- c("10 21","23 45") pairs.split

Re: [R] factors to integers preserving value in a dataframe

2009-02-27 Thread Dimitris Rizopoulos
have a look at R FAQ 7.10, e.g., try as.numeric(levels(pdf$p))[as.integer(pdf$p)] Best, Dimitris Alexy Khrabrov wrote: I want to produce a dataframe with integer columns for elements of string pairs: pairs <- c("10 21","23 45") pairs.split <- lapply(pairs,function(x)strsplit(x," ")) pdf <-

Re: [R] using a for loop with variable as vectors

2009-02-27 Thread baptiste auguie
Hi, you could do one of the following, 1) combine a, b, c, d, e in a list and use ?lapply my.list <- list(a,b,c,d,e) lapply(my.list, foo) where foo() is a function to be applied to each individual element 2) alternatively, see ?get to retrieve the value of a variable from its name. Your

Re: [R] Optimize for loop / find last record for each person

2009-02-27 Thread Jorge Ivan Velez
Dear Andrew: Here is another way assuming you have an order column in your history data as well as a person_id. Again, your variable of interest is x: # Some data set.seed(1) history<-data.frame( person_id=rep(1:10,each=10), record=rep(sample(10),10), x=rnorm(100)

Re: [R] Optimize for loop / find last record for each person

2009-02-27 Thread William Dunlap
Andrew, it makes it easier to help if you supply a typical input and expected output along with your code. I tried your code with the following input: > history person_id date 1 Mary1 2 Mary2 3Sue3 4 Alex4 5Joe5 6 Alex6 7 Ale

Re: [R] statistical significance of accuracy increase in classification

2009-02-27 Thread Monica Pisica
Hi Stefan, Thanks so much. This will help me i am sure. These past 2 days i was away on a trip so please excuse my delayed answer. Monica > From: stefan.ev...@uos.de > To: pisican...@hotmail.com > Subject: Re: [R] statistical significance of accuracy increase in > classification > Date

Re: [R] statistical significance of accuracy increase in classification

2009-02-27 Thread Monica Pisica
Thanks. I will surely try this as well. Monica > Date: Thu, 26 Feb 2009 08:14:31 -0500 > Subject: Re: [R] statistical significance of accuracy increase in > classification > From: mxk...@gmail.com > To: pisican...@hotmail.com > CC: r-help@r-project.org > > > Do you know about any good refe

Re: [R] Optimize for loop / find last record for each person

2009-02-27 Thread Andrew Ziem
On Fri, Feb 27, 2009 at 2:10 PM, William Dunlap wrote: > Andrew, it makes it easier to help if you supply a typical > input and expected output along with your code.  I tried > your code with the following input: I'll be careful to avoid these mistakes. Also, I should not have used a reserved wo

Re: [R] Competing risks adjusted for covariates

2009-02-27 Thread Ravi Varadhan
Check out the crr() function in the same package: library(cmprsk) ?crr Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2

Re: [R] Optimize for loop / find last record for each person

2009-02-27 Thread Jorge Ivan Velez
Hi Andrew, Just remember that something was bad with the code I sent you (the same you referred to in [1]). This version runs with no problems: # Some data history_ <- data.frame(person_id=c(1,2,2),date_=c("2009-01-01","2009-02-03","2009-02-02"),x=c(0.01,0.05,0.06)) colnames(history_) <- c("perso

[R] Large 3d array manipulation

2009-02-27 Thread Vemuri, Aparna
I have a large 3 dimensional array of size (243,246,768) The first dimension is Rows, second is columns and the third is Time. So for each row and column, I want to calculate the mean of time steps 1:8, 2:9, 3:10 and so on and assign the values to a new array. For this I am using the following s

Re: [R] Inefficiency of SAS Programming

2009-02-27 Thread Frank E Harrell Jr
John Sorkin wrote: Frank, A programming language's efficience is a function of several items, including what you are trying to program. Without using SAS proc IML, I have found that it is more efficient to code algorithms (e.g. a least squares linear regression) using R than SAS; we all know that

[R] While with 2 conditions

2009-02-27 Thread MarcioRibeiro
Hi listers, I check it out at the messages... But I didn't find how do I use the while with 2 conditions... while (a>1 ? b>1){ a<-2 b<-2 } Should I use what... Thanks in advance, Marcio -- View this message in context: http://www.nabble.com/While-with-2-conditions-tp22252945p22252945.html S

Re: [R] While with 2 conditions

2009-02-27 Thread Ted Harding
On 27-Feb-09 19:37:50, MarcioRibeiro wrote: > > Hi listers, > I check it out at the messages... But I didn't find how do I use > the while with 2 conditions... > while (a>1 ? b>1){ > a<-2 > b<-2 > } > Should I use what... > Thanks in advance, > Marcio while((a>1)&(b>1)){ a<-2 b<-2 } is t

Re: [R] Large 3d array manipulation

2009-02-27 Thread Duncan Murdoch
On 27/02/2009 6:15 PM, Vemuri, Aparna wrote: I have a large 3 dimensional array of size (243,246,768) The first dimension is Rows, second is columns and the third is Time. So for each row and column, I want to calculate the mean of time steps 1:8, 2:9, 3:10 and so on and assign the values to

[R] object ".trPaths" not found

2009-02-27 Thread rkevinburton
I am running an R script with Tinn-R (2.2.0.1) and I get the error message Error in source(.trPaths[4], echo = TRUE, max.deparse.length = 150) : object ".trPaths" not found Any solutions? Thank you. Kevin __ R-help@r-project.org mailing list https

Re: [R] Inefficiency of SAS Programming

2009-02-27 Thread Gabor Grothendieck
On Fri, Feb 27, 2009 at 8:53 AM, Frank E Harrell Jr wrote: > Ajay ohri wrote: >> >> Sometimes for the sake of simplicity, SAS coding is created like that. One >> can use the concatenate function and drag and drop in an simple excel sheet >> for creating elaborate SAS code like the one mentioned an

Re: [R] Large 3d array manipulation

2009-02-27 Thread David Winsemius
On Feb 27, 2009, at 7:49 PM, Duncan Murdoch wrote: On 27/02/2009 6:15 PM, Vemuri, Aparna wrote: I have a large 3 dimensional array of size (243,246,768) The first dimension is Rows, second is columns and the third is Time. So for each row and column, I want to calculate the mean of time st

[R] Execute script and go interactive

2009-02-27 Thread Michael Olschimke
Hi, is it possible to execute a script with R and go into interactive mode with the same session? e.g. R < myscript.R >objects() Creating a .Rprofile is not an option for me. Thank you Michael __ R-help@r-project.org mailing list https://stat.ethz.

<    1   2