Re: [R] Sapply for descriptive statistics

2011-03-09 Thread David Winsemius
Sent from my iPhone On Mar 9, 2011, at 5:59 PM, Tomii wrote: > I try to calculate descriptive statistics for one of the variables in the > data frame, however command sapply calculates these statistics for every > value of the variable separately. How to make it calculate range (as well as > o

Re: [R] How to enforce location of installation of downloaded packages

2011-03-09 Thread Gabor Grothendieck
On Wed, Mar 9, 2011 at 6:09 PM, Frank Harrell wrote: > Thanks Uwe.  Too bad there is no system option I can set one time, that will > always take precedence. > You could use the Defaults package to change the default value of the lib argument of install.packages. That is put this in your .Rprofi

Re: [R] Sapply for descriptive statistics

2011-03-09 Thread Dennis Murphy
Hi: Perhaps something like this? m <- matrix(rnorm(100, m = 10, s = 2), ncol = 5) colnames(m) <- paste('V', 1:5, sep = '') # Summary function: summs <- function(x) c(mean = mean(x), sd = sd(x), range = diff(range(x))) # Apply to columns of m and transpose the result: t(apply(m, 2, summs)) For

Re: [R] Help with read.csv

2011-03-09 Thread Gabor Grothendieck
On Wed, Mar 9, 2011 at 5:32 PM, Giovanni Petris wrote: > > Hello, > > I have a file that looks like this: > > Date,Hour,DA_DMD,DMD,DA_RTP,RTP,, > 1/1/2006,1,3393.9,3412,76.65,105.04,, > 1/1/2006,2,3173.3,3202,69.20,67.67,, > 1/1/2006,3,3040.0,3051,69.20,77.67,, > 1/1/2006,4,2998.2,2979,67.32,69.10

Re: [R] Sapply for descriptive statistics

2011-03-09 Thread David Winsemius
Sent from my iPhone On Mar 9, 2011, at 6:13 PM, David Winsemius wrote: > > > Sent from my iPhone > > On Mar 9, 2011, at 5:59 PM, Tomii wrote: > >> I try to calculate descriptive statistics for one of the variables in the >> data frame, however command sapply calculates these statistics fo

[R] extracting half the rows with unique values from data.frame

2011-03-09 Thread Nicolas Gutierrez
hey!! Another data.frame question: I have the following data.frame (pop) pp=textConnection(" + xloc yloc gonad indEneW Agent + 123 20 516.74 1 0.02 20.21 0.25 + 223 20 1143.20 1 0.02 20.21 0.50 + 323 20 250.00 1 0.02 20.21 0.25 + 422 15

Re: [R] Help with read.csv

2011-03-09 Thread Phil Spector
Giovanni - If you change "int" (which has no meaning in R) to "integer" in your second example, it should work. - Phil Spector Statistical Computing Facility Department o

Re: [R] Frailty model -- Conditional or Marginal?

2011-03-09 Thread Thomas Lumley
On Thu, Mar 10, 2011 at 6:33 AM, hongsheng wu wrote: > Dear all, > > When I ran a frailty model like, > > model <- coxph(Surv(Day, Indicator) ~ trt + frailty(group, > distribution="gaussian")) > > The variance of effect estimate of trt was estimated by conditional model or > marginal model? The f

Re: [R] Error: evaluation nested too deeply: infinite recursion / options(expressions=)?

2011-03-09 Thread Duncan Murdoch
On 11-03-09 1:05 PM, rivercode wrote: Hi, I am processing tick data and my code has stopped working as I have increased the size of data being processed. Now I am receiving error for basic tasks in RConsole: a = c(1:1000) Error: evaluation nested too deeply: infinite recursion / options(expr

[R] PROC NLMIXED what package equivalent in R?

2011-03-09 Thread Chris Buddenhagen
To account for likely differences between families in naturalization rates, we fitted a generalized linear mixed model, using PROC NLMIXED in SAS10, with the naturalization rate per genus (that is, the number of naturalized species in a genus as a proportion of the total number of introduced specie

Re: [R] Cleaning date columns

2011-03-09 Thread Bill.Venables
Here is one possible way (I think - untested code) cData <- do.call(rbind, lapply(split(data, data$prochi), function(dat) { dat <- dat[order(dat$date), ] while(any(d <- (diff(dat$date) <= 3))) dat <- dat[-(min(which(d))+1), ]

Re: [R] Extracting only odd columns from a matrix

2011-03-09 Thread Bill.Venables
Xonly <- XY[, grep("^X", dimnames(XY)[[2]])] -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Nixon, Matthew Sent: Thursday, 10 March 2011 12:20 AM To: r-help@R-project.org Subject: [R] Extracting only odd columns from a matrix H

Re: [R] Loop Through Columns to Remove Rows

2011-03-09 Thread Sam Albers
Many thanks for this Jorge. Exactly what I was looking for. I've never encountered any() before. Quite useful. Thanks again! Sam On Wed, Mar 9, 2011 at 1:05 PM, Jorge Ivan Velez wrote: > Hi Sam, > > How about this? > > test[apply(test, 1, function(x) !any(x == '#DIV/0!')), ] > > HTH, > Jorge >

Re: [R] Venn Diagram corresponding to size in R

2011-03-09 Thread Matt Shotwell
Try here: https://stat.ethz.ch/pipermail/r-help/2003-February/029393.html On Tue, 2011-03-08 at 20:25 -0500, Shira Rockowitz wrote: > I was wondering if anyone could help me figure out how to make a Venn > diagram in R where the circles are scaled to the size of each dataset. I > have looked at

[R] confidence intervals when using polr()

2011-03-09 Thread Joe P King
Hello, I am running a model with four categories and want predicted probabilities in each category. Now for this example I wont give a counterfactual just the training data is fine but is there anyway to get a confidence interval around the predicted probabilities in each group? I have tried but it

Re: [R] R console Mac

2011-03-09 Thread Unger, Kristian, Dr.
Thanks Isa. I will post my request to the list that you suggest. Best wishes Kristian Sent from my HTC - Reply message - From: "Ista Zahn" Date: Wed, Mar 9, 2011 22:49 Subject: [R] R console Mac To: "Unger, Kristian, Dr." Cc: "r-help@r-project.org" Hi, The r-sig-mac mailing list is

Re: [R] PROC NLMIXED what package equivalent in R?

2011-03-09 Thread Bert Gunter
Google on "R mixed effects" ! (or you could use R's search tools -- ?help ) -- Bert On Wed, Mar 9, 2011 at 4:58 PM, Chris Buddenhagen wrote: > To account for likely differences between > families in naturalization rates, we fitted a > generalized linear mixed model, using > PROC NLMIXED in SAS

[R] How can I manipulate a data.frame that is just created by assign() while still being in the loop?

2011-03-09 Thread Johann Kim
Hello everyone, I want to use a loop to load many files, each into a seperate variable (data.frames) and then - still in the loop - manipulate the present variable/data.frame. So far this works: for (i in 1:2){ var <- paste("var",i,sep="") fileName <- paste(i,"rating.txt", sep="_

Re: [R] Help with read.csv

2011-03-09 Thread David Wolfskill
On Wed, Mar 09, 2011 at 04:32:29PM -0600, Giovanni Petris wrote: > > Hello, > > I have a file that looks like this: > > Date,Hour,DA_DMD,DMD,DA_RTP,RTP,, > 1/1/2006,1,3393.9,3412,76.65,105.04,, > 1/1/2006,2,3173.3,3202,69.20,67.67,, > 1/1/2006,3,3040.0,3051,69.20,77.67,, > 1/1/2006,4,2998.2,2979

[R] Help writing a Scheffe Contrast function for R

2011-03-09 Thread Tyler Rinker
Hello, As a new user of R (less than a month) I have got my hands on several books and am pouting through the net looking for help in gaining understanding of this powerful tool. I am becoming more proficient with using basic functions to conduct basic statistics. I am now looking t

[R] Theil Kendall line as fit?

2011-03-09 Thread jonbfish
I found some code to compute a Kendall-Theil slope estimate and want to add it to a scatter plot. Is there a way to make it appear like a regression fit instead of a line that extends from the edges of the plot? I would like to have the OLS appear as a dotted line and the KT a solid line but as it

Re: [R] cv.lm syntax error

2011-03-09 Thread agent dunham
Yea, sorry, that's what I mean, and v1,...,v5 and factor have the same length, that's why I don't understand the error > dfmod.1 <- data.frame(v1,v2,v3,v4, v5,factor) > CVlm(df= dfmod.1, form.lm = formula(v1 ~ v2+v3+ v4+ v5+ factor), m=3, > seed=29, plotit=TRUE, printit =TRUE) Error en `[.dat

[R] aggregate by part of a field

2011-03-09 Thread Hui Du
Hi All, I have a data frame like a = data.frame(date = c(20081201, 20081202, 20081201), product = c("a b c d e", "a b c g h t", "d e h a c e h g"), sales = c(1, 2, 3)) Now I want to aggregate the sales by part of the a$product. 'Product' is the product name, a

[R] using lapply

2011-03-09 Thread Kushan Thakkar
I have a function with the follow signare: apply.strategy(instr, strat) where instr and strat are both objects of classes instrument and strategy respectively. I want to apply this function to a list that holds objects of the class instrument. Currently I am doing this by explicit looping: for

Re: [R] still a problem remainingRE: Data lebals xylattice plot: RE: displaying label meeting condition (i.e. significant, i..e p value less than 005) in plot function

2011-03-09 Thread Umesh Rosyara
Lattice-experts: Thank you for those who have responded earlier. I have not got a perfect solution yet but tried several ways, unless anybody really lattice killer steps up, I will leave it and see alternatives. Sorry to send it again. #Data name <- c(paste ("M", 1:1000, sep = "")) xvar <- s

Re: [R] aggregate by part of a field

2011-03-09 Thread Dennis Murphy
Hi: Here's one approach, although I imagine there are more efficient ways. # A function to strip spaces and return the first three non-blank elements of a string keyset <- function(x) substr(gsub(' ', '', x)[1], 1, 3) # Apply the function to the data frame to generate the key: a$key <- sapply(a$

[R] using lapply

2011-03-09 Thread Arun Kumar Saha
On reply to the post http://r.789695.n4.nabble.com/using-lapply-td3345268.html Dear Kushan, this may be a good start: ## assuming 'instr.list' is your list object and you are applying my.strat() function on each element of that list, you can use lapply function as lapply(instr.list, function(x)

Re: [R] A plot similar to violin plot

2011-03-09 Thread Tal Galili
Hello C.H. I've also been curious about this plot a while ago. Your question today inspired me to collect all that I've came by in one post, and I published it here: http://www.r-statistics.com/2011/03/scatter-dot-beeswarm-box-violin-plot-and-plotting-it-with-r/ I hope it might help you or other

<    1   2