Re: [R] using tapply with multiple variables

2011-05-01 Thread Dennis Murphy
Hi: If you have R 2.11.x or later, one can use the formula version of aggregate(): aggregate(Correct ~ Subject + Group, data = ALLDATA, FUN = function(x) sum(x == 'C')) A variety of contributed packages (plyr, data.table, doBy, sqldf and remix, among others) have similar capabilities. If you

Re: [R] indexing into a data.frame using another data.frame that also contains values for replacement

2011-05-01 Thread Dennis Murphy
Hi: Here are two possibilities: df1 - data.frame(rows=c(A,B,C, B, C, A), columns=c(21_2, 22_2, 23_2, 21_2, 22_2, 23_2), values=c(3.3, 2.5, 67.2, 44.3, 53, 66)) with(df1, xtabs(values ~ rows + columns)) columns rows 21_2 22_2 23_2 A 3.3 0.0 66.0 B 44.3 2.5 0.0 C 0.0 53.0

[R] vector file

2011-05-01 Thread azam jaafari
Dear All   I want to import the vector file (   .shp) to R. I could import the file by rgdal package before, by following:   geology-readOGR('C:/geology//saga/geo.geom','finalgeology')   but now there is an error:   Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding =

Re: [R] vector file

2011-05-01 Thread Barry Rowlingson
On Sun, May 1, 2011 at 8:08 AM, azam jaafari azamjaaf...@yahoo.com wrote: Dear All I want to import the vector file (   .shp) to R. I could import the file by rgdal package before, by following: geology-readOGR('C:/geology//saga/geo.geom','finalgeology') but now there is an error: Error

Re: [R] help with a survplot

2011-05-01 Thread David Winsemius
On Apr 30, 2011, at 6:06 PM, Thomas Lumley wrote: On Sun, May 1, 2011 at 4:49 AM, David Winsemius dwinsem...@comcast.net wrote: On Apr 30, 2011, at 10:44 AM, Jabba wrote: Dear useRs, I was asked to produce a survival curve like this:

[R] Different results of coefficients by packages penalized and glmnet

2011-05-01 Thread zhu yao
Dear R users: Recently, I learn to use penalized logistic regression. Two packages (penalized and glmnet) have the function of lasso. So I write these code. However, I got different results of coef. Can someone kindly explain. # lasso using penalized library(penalized)

Re: [R] Question on where samples are grouped in rmvnorm{mvtnorm}

2011-05-01 Thread Petr Savicky
On Sat, Apr 30, 2011 at 11:39:43PM -0400, Chee Chen wrote: Dear All, For function: rmvnorm{mvtnorm} in (library mvtnorm, not splus2R), if I generate 2 bivariate normal samples as follows: rmvnorm(2,mean=rep(0,2),sigma=diag(2)) [,1] [,2] [1,] 2.0749459 1.4932752 [2,]

[R] Longitudinal data with non-randomized subjects

2011-05-01 Thread Ehsan Karim
Dear List, I have a theoretical question related to epidemiological data analysis: If the treatment status (tx = 0,1) changes over time for the patients in a non-randomized cohort, is there a way to estimate the treatment effect? (i.e., after joining the study, some patients may have to wait

Re: [R] QQ plot for normality testing

2011-05-01 Thread Matevž Pavlič
Thanks for the answer and for the link. I was lookin for a search trough the forum posts So the slope of the line is not important as long as the data is approx. on the line? Thanks, m -Original Message- From: Joshua Wiley [mailto:jwiley.ps...@gmail.com] Sent: Saturday, April 30,

Re: [R] create namespace without creating a package?

2011-05-01 Thread Duncan Murdoch
On 30/04/11 10:26 AM, xiagao1982 wrote: Hi all, I am a C++/C# programmer who is new to R. I would like to use something like namespace to organize my functions without creating a package. How can I do this? Thanks! You could do it with the local() function or other explicit use of

Re: [R] Sys.getenv at startup is not working properly

2011-05-01 Thread Duncan Murdoch
Please upgrade to a current release (or R-patched). Version 2.10.1 is quite old. Duncan Murdoch On 30/04/11 3:18 PM, Oliver wrote: Hello, when using Sys.getenv() during startup-phase (.First or .Rprofile) to get the env-variables COLUMNS as well as HOST I get empty strings. After the

Re: [R] create namespace without creating a package?

2011-05-01 Thread Gabor Grothendieck
On Sat, Apr 30, 2011 at 10:26 AM, xiagao1982 xiagao1...@gmail.com wrote: Hi all, I am a C++/C# programmer who is new to R. I would like to use something like namespace to organize my functions without creating a package. How can I do this? Thanks! You can arrange them in classes using

Re: [R] plot several histograms with same y-axes scaling using hist()

2011-05-01 Thread Uwe Ligges
On 29.04.2011 14:39, Jim Lemon wrote: On 04/29/2011 08:35 PM, hck wrote: Dear all Problem: hist()-function, scale = “percent” I want to generate histograms for changing underlying data. In order to make them comparable, I want to fix the y-axis (vertical-axis) to, e.g., 0%, 10%, 20%, 30% as

Re: [R] Question on where samples are grouped in rmvnorm{mvtnorm}

2011-05-01 Thread Uwe Ligges
On 01.05.2011 05:39, Chee Chen wrote: Dear All, For function: rmvnorm{mvtnorm} in (library No, it is a package, not a library! mvtnorm, not splus2R), if I generate 2 bivariate normal samples as follows: rmvnorm(2,mean=rep(0,2),sigma=diag(2)) [,1] [,2] [1,] 2.0749459

Re: [R] Speed up code with for() loop

2011-05-01 Thread Uwe Ligges
On 29.04.2011 22:20, hck wrote: Barth sent me a very good code and I modified it a bit. Have a look: Error-rnorm(1000, mean=0, sd=0.05) estimate-(log(1+0.10)+Error) DCF_korrigiert-(1/(exp(1/(exp(0.5*(-estimate)^2/(0.05^2))*sqrt(2*pi/(0.05^2

Re: [R] Problems downloading statmod cran package

2011-05-01 Thread Uwe Ligges
Hmmm, your subject says you are going to get statmod, On 28.04.2011 04:31, Jim Silverton wrote: Hello all, I keep on getting the following error message when I try downloading statmod: install.packages(statmod) Installing package(s) into ‘C:\Users\Isaac\Documents/R/win-library/2.12’ (as

Re: [R] Element by Element addition of the columns of a Matrix

2011-05-01 Thread Uwe Ligges
On 29.04.2011 15:06, Pete Brecknock wrote: ... is the apply function what you are looking for? A=matrix(1,2,4) apply(A,1,sum) Thanks for providing answers to R-help, but: 1. Please quote the original question for the mailing list readers of us. 2. Please reply also to the original poster

[R] microsecond timestamp support

2011-05-01 Thread Joel Reymont
Does R have support for microseconds in timestamps, e.g. when reading this in Time,Include,Kind,Duration 2011-04-01 14:20:36.368324,Y,U,1.03238296509 2011-04-01 14:20:35.342732,Y,C,0.0252721309662 2011-04-01 14:20:34.337209,Y,R,0.00522899627686 Thanks, Joel

[R] Dummy variables using rfe in caret for variable selection

2011-05-01 Thread Ren
I'm trying to run rfe for variable selection in the caret package, and am getting an error. My data frame includes a dummy variable with 3 levels. x - chlDescr y - chl #crate dummy variable levels(x$State) - c(AL,GA,FL) dummy - model.matrix(~State,x) z - cbind(dummy, x) #remove State category

[R] Mean/SD of Each Position in Table

2011-05-01 Thread Nemergut, Edward *HS
I have 100+ .csv files which have the basic format: test X Substance1 Substance2 Substance3 Substance4 Substance5 1 Time1 10 0 0 0 0 2 Time2 9 5 0 0 0 3 Time3 8 10 1

[R] Tests for the need of cluster analysis

2011-05-01 Thread mary weiss
Does R have the capability to perform tests for the need of clustering analysis (e.g., in prabclus)? I am using panel data with two-way fixed effects but am unsure about whether I should be using a cluster option as well to estimate my model.-- View this message in context:

[R] Urgent: conditional formula for nls

2011-05-01 Thread Andrew Coop
I have data vectors x and y both with 179 observations. I'm trying to fit a nonlinear model with five parameters using nls. The formula is only defined within a range of x-values, it should be zero otherwise, thus my attempted use of ifelse: df-data.frame(x,y)

Re: [R] matrix evaluation using if function

2011-05-01 Thread ivan
Hi, thank you very much, both methods worked perfectly. Regards On Fri, Apr 29, 2011 at 4:17 PM, Berend Hasselman b...@xs4all.nl wrote: David Winsemius wrote: On Apr 29, 2011, at 4:27 AM, ivan wrote: Hi All, I am trying to create a function which evaluates whether the values

Re: [R] microsecond timestamp support

2011-05-01 Thread Rainer Stuetz
On Sun, May 1, 2011 at 15:33, Joel Reymont joe...@gmail.com wrote: Does R have support for microseconds in timestamps, e.g. when reading this in Time,Include,Kind,Duration 2011-04-01 14:20:36.368324,Y,U,1.03238296509 2011-04-01 14:20:35.342732,Y,C,0.0252721309662 2011-04-01

Re: [R] Mean/SD of Each Position in Table

2011-05-01 Thread Dennis Murphy
Hi: I would do something like the following: (1) Create a vector of the file names. (2) Use lapply() to read the files into a list. (3) Use the reshape or reshape2 package to melt the individual files into 'long' form. (4) rbind together the resulting data frames. (5) Use a summarization

Re: [R] Urgent: conditional formula for nls

2011-05-01 Thread Dennis Murphy
Hi: Instead of using ifelse(), you can multiply the logical statement by the rest of the expression. When the logical statement is false, its numerical value is zero. HTH, Dennis On Sun, May 1, 2011 at 9:52 AM, Andrew Coop andrew.e.c...@gmail.com wrote: I have data vectors x and y both with

Re: [R] recommendation on B for validate.lrm () ?

2011-05-01 Thread Frank Harrell
For this case B=200 should work well if using the bootstrap. For cross-val. you can use B=10-fold cross-val and repeat the process 100 times for adequate precision, averaging over the 100 as done in http://biostat.mc.vanderbilt.edu/wiki/pub/Main/RmS/logistic.val.pdf (note this was using the

[R] quick help needed: split a number and find and replace type of function that works like in MS excel

2011-05-01 Thread Ram H. Sharma
Hi R experts I have a couple of quick question: Q1 #my data set.seed(12341) SN - 1:100 pool- c(12,13,14, 23, 24, 34) CT1- sample(pool, 100, replace= TRUE) set.seed(1242) CT2 - sample(pool, 100, replace= TRUE) set.seed(142) CT3 - sample(pool, 100, replace= TRUE) # the number of variables run

Re: [R] Kolmogorov-Smirnov test

2011-05-01 Thread m.marcinmichal
Hi, many thanks for helpful answer. Best Marcin M.-- View this message in context: http://r.789695.n4.nabble.com/Kolmogorov-Smirnov-test-tp3479506p3488364.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing

Re: [R] Longitudinal data with non-randomized subjects

2011-05-01 Thread Ehsan Karim
Apology for reposting, but the format of earlier message got distorted; hopefully this time it will be readable: From: wilds...@hotmail.com To: r-help@r-project.org Subject: Longitudinal data with non-randomized subjects Date: Sun, 1 May 2011 00:34:08 -0700 Dear List, I have a theoretical

[R] bwplot in ascending order

2011-05-01 Thread Doran, Harold
Can anyone point me to examples with R code where bwplot in lattice is used to order the boxes in ascending order? I have found the following discussion and it partly works. But, I have a conditioning variable, so my example is more like bwplot(var1 ~ var2|condition, dat) Th example in the

Re: [R] indexing into a data.frame using another data.frame that also contains values for replacement

2011-05-01 Thread David Winsemius
On Apr 30, 2011, at 4:18 PM, Alice Wines wrote: Hello all, I have a quandry I have been scratching my head about for a while. I've searched the manual and the web and have not been able to find an acceptable result, so I am hoping for some help. I have two data frames and I want to

Re: [R] quick help needed: split a number and find and replace type of function that works like in MS excel

2011-05-01 Thread Steve Lianoglou
Hi, There are a couple of ways to do what you want. I'll provide the fodder and let you finish the implementation. On Sun, May 1, 2011 at 4:26 PM, Ram H. Sharma sharma.ra...@gmail.com wrote: Hi R experts I have a couple of  quick question: Q1 #my data set.seed(12341) SN - 1:100 pool-

[R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
I want to use caret to build a model with an algorithm that actually has no parameters to find. How do I stop it from repeatedly building the same model 25 times? library(caret) data(mdrr) LOGISTIC_model - train(mdrrDescr,mdrrClass ,method='glm'

Re: [R] microsecond timestamp support

2011-05-01 Thread jim holtman
One thing to watch out for using POSIXct is 1us is about the limit of accuracy due to floating point (see FAQ 7.31). Notice that printing out today's date requires about 15 digits with microsecond granularity. Notice in the example that if the time difference between intervals is 0.1 us, you

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread Max Kuhn
It isn't building the same model since each fit is created from different data sets. The resampling is sort of the point of the function, but if you really want to avoid it, supply your own index in trainControl that has every index (eg, index = seq(along = mdrrClass)). In this case, the

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
Hi Max, But in this example, it says the sample size is the same as the total number of samples, so unless the sampling is done by columns, wouldn't you get exactly the same model each time for logistic regression? ps - great package btw. I'm just beginning to explore its potential now.-- View

Re: [R] Bigining with a Program of SVR

2011-05-01 Thread Max Kuhn
When you say variable do you mean predictors or responses? In either case, they do. You can generally tell by reading the help files and looking at the examples. Max On Fri, Apr 29, 2011 at 3:47 PM, ypriverol yprive...@gmail.com wrote: Hi:  I'm starting a research of Support Vector

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread Max Kuhn
No, the sampling is done on rows. The definition of a bootstrap (re)sample is one which is the same size as the original data but taken with replacement. The Accuracy SD and Kappa SD columns give you a sense of how the model performance varied across these bootstrap data sets (i.e. they are not

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
Thanks for the clarification Max - I should have realised that. One final question, I like caret because it lets me pass in data to all functions in the same way. For glm I have only ever used the formula notation and did not see a way to pass in predictors and a target individually. How do I do

Re: [R] using tapply with multiple variables

2011-05-01 Thread Andrew Robinson
This is a nice demonstration of the formula interface to aggregate. A less elegant alternative is to pass lists as arguments. with(dd, aggregate(Correct, by = list(Subject = Subject, Group = Group), FUN = function(x) sum(x == 'C')))

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
glm.fit - answered my own question by reading the manual!-- View this message in context: http://r.789695.n4.nabble.com/caret-prevent-resampling-when-no-parameters-to-find-tp3488761p3488923.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Different results of coefficients by packages penalized and glmnet

2011-05-01 Thread Andrew Robinson
Hi Yao, I can't answer that question, but I offer the following thoughts for your consideration. Generally it's best to approach the package maintainers directly with questions like these. You can find their contact details in the package documentation. Also, you will want to make sure that

[R] multiple mosaic plots layout

2011-05-01 Thread Neuwirth Erich
I would like to display multiple mosaic plots from vcd (not defined by a model but derived from different data sets) side by side. Neither par(mfrow=...) nor layout seem to allow to arrange multiple mosaic plots in a grid. Is there an easy way of arranging mosaics in a grid?

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread Max Kuhn
Not all modeling functions have both the formula and matrix interface. For example, glm() and rpart() only have formula method, enet() has only the matrix interface and ksvm() and others have both. This was one reason I created the package (so we don't have to remember all this). train() lets you

Re: [R] importing and filtering time series data

2011-05-01 Thread jim holtman
Here is one approach. It would be good to provide a reasonable sample of data: x - unclass(Sys.time()) # today's date # create some data # increments by ~ 0.1 seconds len - cumsum(runif(100, 0, 0.1)) dataFile - data.frame(time = x + len, +flag = sample(c(Y, N), 100,

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
Thanks again Max - a great time saver this is. Now just for my sanity, if I use glm.fit to build a model where I have the matrices, how do I then use the predict function without getting an error message? LOGISTIC_model1 - glm.fit(mdrrDescr,mdrrClass, family=binomial(link=logit)) Warning

Re: [R] multiple mosaic plots layout

2011-05-01 Thread baptiste auguie
Unfortunately, it seems that vcd doesn't return grobs but draws directly to the device, which prevents a concise solution. You could try the following, library(gridExtra) library(vcd) data(Titanic) p = grid.grabExpr(mosaic(Titanic)) grid.arrange(p, p, p, ncol=2) Or, more versatile but also more

[R] How to pass objects from local() to GlobalEnv

2011-05-01 Thread xiagao1982
Hi all, I create some objects in local(), and want to pass them to GlobalEnv. How can I do this? Thanks! xiagao1982 2011-05-02 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] How to pass objects from local() to GlobalEnv

2011-05-01 Thread Henrique Dallazuanna
Try this: local(x - 1) On Sun, May 1, 2011 at 9:20 PM, xiagao1982 xiagao1...@gmail.com wrote: Hi all, I create some objects in local(), and want to pass them to GlobalEnv. How can I do this? Thanks! xiagao1982 2011-05-02        [[alternative HTML version deleted]]

Re: [R] How to pass objects from local() to GlobalEnv

2011-05-01 Thread xiagao1982
Thanks a lot! It works! xiagao1982 2011-05-02 发件人: Henrique Dallazuanna 发送时间: 2011-05-02 08:31:02 收件人: xiagao1982 抄送: r-help 主题: Re: [R] How to pass objects from local() to GlobalEnv Try this: local(x - 1) On Sun, May 1, 2011 at 9:20 PM, xiagao1982

Re: [R] Sorting dataframe by number of occurrences of factor

2011-05-01 Thread adigs
That's great - thanks all for your help.-- View this message in context: http://r.789695.n4.nabble.com/Sorting-dataframe-by-number-of-occurrences-of-factor-tp3485443p3488978.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] caret - prevent resampling when no parameters to find

2011-05-01 Thread pdb
Hi Max, I tried your suggestion but cam up with errors: fitControl-trainControl(number=1) LOGISTIC_model - train(mdrrDescr,mdrrClass ,method='glm' ,trControl = fitControl ) Fitting: parameter=none Error in if

Re: [R] quick help needed: split a number and find and replace type of function that works like in MS excel

2011-05-01 Thread Ram H. Sharma
Thank you Steve for the solution: As per your suggestion I spend some time to make it work for 2 variables. nvar = 3 # number of variables ncol- nvar*2 func1- function(x) {sapply( strsplit(as.character(x), ), match, table= c(1,2,3,4,NA))} mydf1 - data.frame(t(