[R] loop through variable names

2009-11-11 Thread Jacob Wegelin
Often I perform the same task on a series of variables in a dataframe, by looping through a character vector that holds the names and using paste(), eval(), and parse() inside the loop. For instance: thesevars<-names(environmental) environmental$ToyOutcome<-rnorm(nrow(environmental)) tableOf

Re: [R] loop through variable names

2009-11-11 Thread Gabor Grothendieck
Try this: lm(environmental[c("ToyOutcome", thisvar)]) or lm(ToyOutcome ~., environmental[c("ToyOutcome", thisvar)]) On Wed, Nov 11, 2009 at 6:49 PM, Jacob Wegelin wrote: > > Often I perform the same task on a series of variables in a dataframe, by > looping through a character vector that hol

[R] naive "collinear" weighted linear regression

2009-11-11 Thread Mauricio Calvao
Hi there Sorry for what may be a naive or dumb question. I have the following data: > x <- c(1,2,3,4) # predictor vector > y <- c(2,4,6,8) # response vector. Notice that it is an exact, perfect straight line through the origin and slope equal to 2 > error <- c(0.3,0.3,0.3,0.3) # I have (equ

Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread RICHARD M. HEIBERGER
On Wed, Nov 11, 2009 at 8:12 PM, Stavros Macrakis wrote: > Thanks for the suggestion. I'mm familiar with the truncate-lines variable, > but that's not quite what I was looking for. I don't want the padding > spaces displayed, but I do want to see long strings at the end of the line. Then we can

Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Stavros Macrakis
Thanks for the suggestion. I'mm familiar with the truncate-lines variable, but that's not quite what I was looking for. I don't want the padding spaces displayed, but I do want to see long strings at the end of the line. Thanks anyway, -s On Wed, Nov 11, 2009 at 5:40 PM, Richard

Re: [R] Partial correlations and p-values

2009-11-11 Thread Peter Ehlers
dadrivr wrote: I'm trying to write code to calculate partial correlations (along with p-values). I'm new to R, and I don't know how to do this. I have searched and come across different functions, but I haven't been able to get any of them to work (for example, pcor and pcor.test from the ggm

[R] redundant factor levels after subsetting a dataset

2009-11-11 Thread Daniel Malter
#I have a data frame with a numeric and a character variable. x=c(1,2,3,2,0,2,-1,-2,-4) md=c(rep("Miller",3), rep("Richard",3),rep("Smith",3)) data1=data.frame(x,md) #I subset this data.frame in a way such that one level of the character variable does not appear in the new dataset. data2=data1

Re: [R] redundant factor levels after subsetting a dataset

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 9:00 PM, Daniel Malter wrote: #I have a data frame with a numeric and a character variable. x=c(1,2,3,2,0,2,-1,-2,-4) md=c(rep("Miller",3), rep("Richard",3),rep("Smith",3)) data1=data.frame(x,md) #I subset this data.frame in a way such that one level of the character va

Re: [R] naive "collinear" weighted linear regression

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 7:45 PM, Mauricio Calvao wrote: Hi there Sorry for what may be a naive or dumb question. I have the following data: > x <- c(1,2,3,4) # predictor vector > y <- c(2,4,6,8) # response vector. Notice that it is an exact, perfect straight line through the origin and slope

Re: [R] By processing on two variables at once?

2009-11-11 Thread Steve Lianoglou
Hi, On Wed, Nov 11, 2009 at 8:51 PM, zwarren wrote: > > Hello! > > I'm trying to runs stats on two vars at a time in a big data frame.  I knew > how to do this in SAS many years ago, but have half-forgotten that as well! > > I need, for instance, mean(value) by x-y combination: > x   y   z   valu

[R] By processing on two variables at once?

2009-11-11 Thread zwarren
Hello! I'm trying to runs stats on two vars at a time in a big data frame. I knew how to do this in SAS many years ago, but have half-forgotten that as well! I need, for instance, mean(value) by x-y combination: x y z value 1 1 110 1 1 220 1 2 130 with results: x

[R] using R selecte data record?

2009-11-11 Thread chalie epps
I have a database containing all the football tournament, however I want only to filter out all the pairwise events. Briefly: If A matches B & B matches A, we reserve the two tournament, otherwise forsake this tournament. Please help me, thankx. __ R-he

Re: [R] By processing on two variables at once?

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 8:51 PM, zwarren wrote: Hello! I'm trying to runs stats on two vars at a time in a big data frame. I knew how to do this in SAS many years ago, but have half-forgotten that as well! I need, for instance, mean(value) by x-y combination: x y z value 1 1 1

Re: [R] using R selecte data record?

2009-11-11 Thread David Winsemius
On Nov 11, 2009, at 8:53 PM, chalie epps wrote: I have a database containing all the football tournament, however I want only to filter out all the pairwise events. Briefly: If A matches B & B matches A, we reserve the two tournament, otherwise forsake this tournament. Sounds like you might w

Re: [R] Partial correlations and p-values

2009-11-11 Thread dadrivr
Awesome, that's what I was looking for. I have two additional questions: (1) What can I do if the variables are of different lengths? (2) How do I update the formula if I want to control for more than one variable. Let's take the following example: x <- c(1,20,14,7,9) y <- c(5,6,7,9,10,11) z <-

Re: [R] Suppressing final spaces in data.frame printouts

2009-11-11 Thread Stavros Macrakis
<> Thanks! So I guess you're suggesting something like (add-hook 'comint-output-filter-functions (lambda (s) (save-restriction (narrow-to-region comint-last-output-start (+ -1 (process-mark (get-buffer-process (current-buffer) ;; stop o

[R] Finding covariance in a lmer mixed effects model

2009-11-11 Thread Kurt Smith
I am having difficulty finding the covariance for the random effects in a mixed effects model. I fit this model: fm1 <- lmer(fpg ~ 1 + time + (1|ID) + (0+time|ID),fpg_lme) and want to find the covariance between the time and intercept random effects. I tried using VarCorr (see below) but it does

Re: [R] redundant factor levels after subsetting a dataset

2009-11-11 Thread Daniel Malter
Thanks, works a charme. I was not aware that it had been answered just yesterday. The solution previously suggested in this thread did not work for me. Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: David Winsemius [m

[R] Non linear programming optimization (which package to use?)

2009-11-11 Thread Jerome Chong
Hello, 1) Is there any nonlinear programming optmizer that I can user for the following problem? Obj function: (max) revenue = price * volume Constraints: price and volume pair must be from the following variable data set: Variable data set: # price volume 1 10 500 2 20 450 3 30 330 4 40 250 5 5

[R] saving custom functions to existing library

2009-11-11 Thread venkata kirankumar
Hi all, I writen one function in Rgui(R Editor) I saved it as testfunction.R and while I am running that file using source(C:/testfunction.R) its running and it is giving subsequent result insted of this there is any thing like to save my function to save in existing library to reuse it wh

[R] trap window pop up when running 'bugs' in R

2009-11-11 Thread Dongli Zhou
Hi, I'm writing to ask what is the reason that a Trap window always pops up in WinBUGS? I'm tring to run the function 'bugs' in R for a zero-inflated gaussian model. The contents appear in the Trap window is as follows: *incompatible copy BugsCmds.TextError [03A1H] .begINTEGER

[R] Reading a data file one record at a time [SEC=UNCLASSIFIED]

2009-11-11 Thread Justin Peter
Dear r-help, I have a radar data file in the following format: nrays for (1 to n_rays) { some_data_info for (1 to n_gates) { some_data_info} } N_rays=360 and n_gates=950 The data looks something like: Header line1 Ray1 header gate1 var1, var2,.,varN ...

Re: [R] Finding covariance in a lmer mixed effects model

2009-11-11 Thread Viechtbauer Wolfgang (STAT)
The way you have specified the model implies that the covariance is 0. If you actually want to estimate the covariance, you need to use: fm1 <- lmer(fpg ~ 1 + time + (time|ID), fpg_lme) Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and St

[R] How can this code be improved?

2009-11-11 Thread Richard R. Liu
I am running the following code on a MacBook Pro 17" Unibody early 2009 with 8GB RAM, OS X 10.5.8, R 2.10.0 Patch from Nov. 2, 2009, in 64-bit mode. freq.stopwords <- numeric(0) freq.nonstopwords <- numeric(0) token.tables <- list(0) i.ss <- c(0) cat("Beginning at ", date(), ".\n") for (i.d i

<    1   2