Re: [R] help files for a function

2011-03-15 Thread Joshua Wiley
Hi Erin, There is no "appropriate directory" until you have a package. Until the package is built, R will not access and use the help documentation. So I guess the answer is, "wherever it is convenient for you to find and edit as your function develops until the time when you put it in one of yo

[R] help files for a function

2011-03-15 Thread Erin Hodgess
Dear R People: Suppose I have the following function and I generate the documentation for it: > f <- function(x) { + return(x^2) + } > prompt(f) Created file named 'f.Rd'. Edit the file and move it to the appropriate directory. > What would be the appropriate directory if I haven't created my ne

Re: [R] Does R have a "const object"?

2011-03-15 Thread Thomas Lumley
Actually, you can do this using locked bindings. Look at ?lockBinding Locked bindings are how namespaces get const function definitions, and active bindings (on the same help page) are how R CMD check notices that you are using T and F when you mean TRUE and FALSE. -thomas On Wed, Mar 16, 2

Re: [R] Serial Date

2011-03-15 Thread Raoni Rosa Rodrigues
Hello Mr. Grothendieck, thanks for your reply! Text book that I use (Spector, 2008) dind't comment about this feature of chron function... I just don't understand why we have 10957 days of difference between dates (look that date on your mail seems to be 1981, not 2011), and not the 25568 d

Re: [R] (R) transitions in a Markov Chain

2011-03-15 Thread Kjetil Halvorsen
To add to this, I am sure this have been answerted earlier on the list, so you could try to search the archives. On Tue, Mar 15, 2011 at 8:59 PM, Ben Bolker wrote: > Estefania Nares hotmail.com> writes: > >> I have to generate 1000 transitions of a discrete time Markov Chain and >> then give and

Re: [R] File > Save As...

2011-03-15 Thread Duncan Murdoch
On 11-03-15 9:10 PM, Hadley Wickham wrote: Could getSrcFilename() gain a default argument so that getSrcFilename() would by default return the path of the executing script? No, it needs to see a function defined in that script. But I thought default arguments were evaluated in the parent envi

Re: [R] Questions on dividing lists and tapply

2011-03-15 Thread Henrique Dallazuanna
Try this: mapply('/', l1, l2, SIMPLIFY = FALSE) and tapply(1:5, lapply(indxLi, as.numeric), sum) On Tue, Mar 15, 2011 at 6:06 PM, Rohit Pandey wrote: > > Hello R community, > > I have two questions about using R. > > The first is about dividing each element of a list with another similar > si

Re: [R] Matrix building to remove for loops

2011-03-15 Thread Henrique Dallazuanna
Try this: fi_2 <- diag(1, i) fi_2[lower.tri(fi_2)] <- 1 - runif(sum(lower.tri(fi_2))) ^ .5 fi_2[upper.tri(fi_2)] <- fi_2[lower.tri(fi_2)] On Tue, Mar 15, 2011 at 7:51 PM, Brian Pellerin < brianpatrickpelle...@gmail.com> wrote: > Hello R users, > > I would like to reduce the number of for loops i

Re: [R] (R) transitions in a Markov Chain

2011-03-15 Thread Ben Bolker
Estefania Nares hotmail.com> writes: > I have to generate 1000 transitions of a discrete time Markov Chain and > then give and estimation of the equilibrium distribution. > > I know the transition matrix. > > 0.3 0.7 0 > 0.2 0.5 0.3 > 0 0.4 0.6 > Do you know how to do it with R?

Re: [R] Does R have a "const object"?

2011-03-15 Thread rex.dwyer
Cheer up! R is a step closer to that concept than the old FORTRAN compilers that couldn't even guarantee that 37 was a constant if used repeatedly in a subroutine call. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Uwe Ligges Se

Re: [R] File > Save As...

2011-03-15 Thread Hadley Wickham
>> Could getSrcFilename() gain a default argument so that >> getSrcFilename() would by default return the path of the executing >> script? > > No, it needs to see a function defined in that script. But I thought default arguments were evaluated in the parent environment? Does that not follow for

[R] Two issues: WEKA code in R // Probability Estimation Tree algorithms

2011-03-15 Thread Patrick Skorupka
Hi everyone, this email basically pursues two distinct main goals. I appreciate any help! First of all I was wondering if there is any possibility to get WEKA files (coded in Java) to run in R respectively RWeka. I first considered if it was possible with the Weka_interface implemented in RWe

[R] adding linear regression data to plot

2011-03-15 Thread derek
Hello R, I would like to print regression data in graph. I mean the output from: k=lm(formula,data) summary(k) Or somehow extract and print only coefficients and R-squared. -- View this message in context: http://r.789695.n4.nabble.com/adding-linear-regression-data-to-plot-tp3357946p3357946.h

[R] Questions on dividing lists and tapply

2011-03-15 Thread Rohit Pandey
Hello R community, I have two questions about using R. The first is about dividing each element of a list with another similar sized list. So, if the first list has two elements and so does the second, then the result should also be a list with two elements. For example, the inputs are: list(ma

Re: [R] Matching two vectors

2011-03-15 Thread nblarson
Just use vect_2_id as a subsetting index for vect_1, ie: vect_2<-vect_1[vect_2_id] Vincy Pyne wrote: > > Dear R helpers > > Suppose I have a vector as > > vect_1 = c("AAA", "AA", "A", "BBB", "BB", "B", "CCC") > > vect_1_id = c(1:length(vect_1)) > > Through some process I obtain > > vect_2_

[R] Daily to Monthly Cumulative Returns

2011-03-15 Thread Rahul Kaura
I want to do a daily, weekly and monthly regression between InvestmentGrade Credit Spreads (Dependent Variable) and Treasuries (Independent Variable). My starting point is daily spread data and daily prices for US treasuries. Should I convert the US Prices into log returns i.e. log(Pt/Pt-1) or

Re: [R] Finding coordinates for maximum of a function

2011-03-15 Thread derek
I must have mixed it up. Thank you. -- View this message in context: http://r.789695.n4.nabble.com/Finding-coordinates-for-maximum-of-a-function-tp3355369p3357460.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mai

Re: [R] Stepwise Discriminant... in R

2011-03-15 Thread Ty Smith
I have tried this with my actual data, and everything works smoothly, including the monotonically decreasing error rates. e.g.: formula Error 1 Cr 0.4167 2 Cr + Mg 0.1667

[R] (R) transitions in a Markov Chain

2011-03-15 Thread Estefania Nares
Dear experts, I have to generate 1000 transitions of a discrete time Markov Chain and then give and estimation of the equilibrium distribution. I know the transition matrix. 0.3 0.7 0 0.2 0.5 0.3 0 0.4 0.6 Do you know how to do it with R? Thanks a lot! Estefania

[R] how to set the starting value in lme

2011-03-15 Thread jia liu
Hi, When I fit the mixed-effects model by lme, I got the convergence error code = 1 message = iteration limit reached without convergence (9). Even after I increase the iteration numbers, it still did not work. The only way I found to avoid the error message is to increase the number of iteration

Re: [R] File > Save As...

2011-03-15 Thread Gene Leynes
The "getSrcFilename" function is exactly what I was trying to describe, and I'm excited to know that it's on it way! I have tried to create that type of function, but I didn't think it was possible with currently available functions. I would be interested in seeing how the new function works, may

[R] Matrix building to remove for loops

2011-03-15 Thread Brian Pellerin
Hello R users, I would like to reduce the number of for loops in my code. I build these matrices (5 times). The main diagonal are 1s and the two sides along the main diagonal mirror each other as follows: i<-5 fi<-matrix(0,nrow=i,ncol=i)#floral inhibition matrix for(r in 1:i){ for(c in 1:i){

[R] To calculate sample size based on generalized wilcoxon test or Tarone-Ware test

2011-03-15 Thread Zhipeng Wang
Dear all, I am trying to calculate sample size for a clinical research, on the basis of generalized wilcoxon test or Tarone-Ware test. It seems SAS can do this job using it "POWER" procedure, but SAS is not available to me. I would be very grateful if you could let me know if any R package or oth

[R] Comparing parts of strings

2011-03-15 Thread Ben Hunter
Hi, I have a vector of strings (categories), each element of which can be uniquely found in each element of a much longer vector of about 30 or so differeint factors. I would like to define another factor variable (drawn from NewFactorListaccording to which string from "categories" is found in the

Re: [R] File > Save As...

2011-03-15 Thread Duncan Murdoch
On 15/03/2011 4:45 PM, Hadley Wickham wrote: The bigger issue is that R can't tell the location of an open script, which makes it harder to create new versions of existing work But it can. If you open a script and choose save, it will be saved to the same place. Or do you mean an executin

Re: [R] fitting a distribution to a ecdf plot

2011-03-15 Thread Frank Harrell
If you try more than one or two distributions the final estimates, while appearing to have higher precision that the ECDF, will actually have the same precision. That is because of model uncertainty. This would be revealed by bootstrapping. There is little advantage to using a parametric model i

Re: [R] fitting a distribution to a ecdf plot

2011-03-15 Thread Lathouri, Maria
Hallo yes I tried it as well and it works; Thank you a lot Maria From: Dennis Murphy [djmu...@gmail.com] Sent: 15 March 2011 21:36 To: Lathouri, Maria Cc: r-help@r-project.org Subject: Re: [R] fitting a distribution to a ecdf plot Hi: The fitdistrplus package f

Re: [R] applying to dataframe rows

2011-03-15 Thread andrija djurovic
Hi, maybe this: df<-data.frame(a=c(1,2,3,Inf,4,Inf),b=c(Inf,2,3,4,5,8)) df[apply(df,1, function(x) !any(x==Inf)),] df[apply(df,1, function(x) any(x==Inf)),] Andrija On Tue, Mar 15, 2011 at 10:44 PM, Alexy Khrabrov wrote: > How do I apply a function to every row of a dataframe most naturally?

[R] applying to dataframe rows

2011-03-15 Thread Alexy Khrabrov
How do I apply a function to every row of a dataframe most naturally? Specifically, I'd like to filter out any row which contains an Inf in any column. Since all columns are numeric, I guess max should work on a row... -- Alexy __ R-help@r-project.or

Re: [R] fitting a distribution to a ecdf plot

2011-03-15 Thread Dennis Murphy
Hi: The fitdistrplus package from CRAN may be useful. I tried it on your data and the lognormal seemed to fit well, apart from the outlier. I just followed the vignette that accompanies the package. library(fitdistplus) plotdist(NOEccu) # ecdf descdist(NOEccu, boot =

Re: [R] regsubsets() [leaps package] - please share some good examples of use

2011-03-15 Thread Thomas Lumley
On Wed, Mar 16, 2011 at 3:18 AM, agent dunham wrote: > Does it mean that regsubsets doesn't work with categorical variables? No. > It's because I'm trying the following and I don't know what happens. Any > help would be appreciated. > > varin <- data.frame(v1,v2,...,v7, factor1,..., factor4) > >

Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread hihi
Thank you all, it will help :-) Bye, Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, repr

Re: [R] File > Save As...

2011-03-15 Thread Hadley Wickham
>> The bigger issue is that R can't tell the location of an open script, >> which makes it harder to create new versions of existing work > > But it can.  If you open a script and choose save, it will be saved to the > same place.  Or do you mean an executing script?  There are indirect ways to

Re: [R] Does R have a "const object"?

2011-03-15 Thread Duncan Murdoch
On 15/03/2011 2:35 PM, Martin Morgan wrote: On 03/15/2011 11:34 AM, Duncan Murdoch wrote: > On 15/03/2011 2:23 PM, Uwe Ligges wrote: >> >> On 15.03.2011 15:53, xiagao1982 wrote: >> > Hi, all, >> > >> > Does R have a "const object" concept like which is in C++ language? >> I want to set so

Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread Peter Langfelder
On Tue, Mar 15, 2011 at 1:17 PM, hihi wrote: > Hi All, > is there any effiective and dense/compact method to calculate the mean of a > list of - of course coincident - matrices on an element by element basis? The > resulting matrix' [i, j]-th element is the mean of the list's matrices' [i, > j]

Re: [R] File > Save As...

2011-03-15 Thread Duncan Murdoch
On 15/03/2011 2:56 PM, Gene Leynes wrote: The "getSrcFilename" function is exactly what I was trying to describe, and I'm excited to know that it's on it way! I have tried to create that type of function, but I didn't think it was possible with currently available functions. I would be interest

Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread Henrique Dallazuanna
Try this: l <- list(matrix(rnorm(9), 3), matrix(rnorm(9), 3), matrix(rnorm(9), 3)) Reduce('+', l) / length(l) On Tue, Mar 15, 2011 at 5:17 PM, hihi wrote: > Hi All, > is there any effiective and dense/compact method to calculate the mean of a > list of - of course coincident - matrices on an e

Re: [R] Element by element mean of a list of matrices

2011-03-15 Thread Claudia Beleites
Peter, as the matrices in the list have the same shape, you can unlist them into an array and then use rowMeans. HTH Claudia Am 15.03.2011 21:17, schrieb hihi: Hi All, is there any effiective and dense/compact method to calculate the mean of a list of - of course coincident - matrices on a

[R] Element by element mean of a list of matrices

2011-03-15 Thread hihi
Hi All, is there any effiective and dense/compact method to calculate the mean of a list of - of course coincident - matrices on an element by element basis? The resulting matrix' [i, j]-th element is the mean of the list's matrices' [i, j]-th elements respectively... Iterating by for statement

Re: [R] Matching two vectors

2011-03-15 Thread Sarah Goslee
vect_1[vect_2_id] and perhaps a readthrough of some of the very nice intro to R materials available online. Sarah On Tue, Mar 15, 2011 at 3:41 PM, Vincy Pyne wrote: > Dear R helpers > > Suppose I have a vector as > > vect_1 = c("AAA", "AA", "A", "BBB", "BB", "B", "CCC") > > vect_1_id = c(1:leng

[R] Matching two vectors

2011-03-15 Thread Vincy Pyne
Dear R helpers Suppose I have a vector as vect_1 = c("AAA", "AA", "A", "BBB", "BB", "B", "CCC") vect_1_id = c(1:length(vect_1)) Through some process I obtain vect_2_id = c(2, 3, 7), then I need a new vector say vect_2 which will give me vect2 = ("AA", "A", "CCC")  i.e. I need the subset of ve

[R] Bug in lattice auto.key argument

2011-03-15 Thread JLucke
The Lattice auto.key argument has a bug in R.12.2. R version 2.12.2 (2011-02-25) Platform: i386-pc-mingw32/i386 (32-bit) other attached packages: [1] lattice_0.19-17 loaded via a namespace (and not attached): [1] grid_2.12.2 If I set up my plot parameters as require(lattice) superpose.line

Re: [R] Help on 'object(s) are masked from 'package:base"

2011-03-15 Thread David Winsemius
On Mar 15, 2011, at 1:03 PM, YAddo wrote: Dear All: I am a newbie to R. I am trying to use the lmsqreg.fit pack, although I have installed(I think) it I am not able to invoke it when write the code for it. Here's what I got when I installed it. package 'lmsqreg' successfully unpacked

Re: [R] Reporting odds ratios or risk ratios from GLM

2011-03-15 Thread David Winsemius
On Mar 15, 2011, at 1:25 PM, lafadnes wrote: I am a new R user (am using it through the Rcmdr package) and have struggled to find out how to report OR and RR directly when running GLM models (not only reporting coefficients.) Example of the syntax that I have used: GLM.2 <- glm(diarsev ~

Re: [R] Reporting odds ratios or risk ratios from GLM

2011-03-15 Thread Aaron Mackey
OR <- exp(coef(GLM.2)[-1]) OR.ci <- exp(confint(GLM.2)[-1,]) -Aaron On Tue, Mar 15, 2011 at 1:25 PM, lafadnes wrote: > I am a new R user (am using it through the Rcmdr package) and have > struggled > to find out how to report OR and RR directly when running GLM models (not > only reporting coef

Re: [R] Does R have a "const object"?

2011-03-15 Thread Uwe Ligges
On 15.03.2011 19:35, Martin Morgan wrote: On 03/15/2011 11:34 AM, Duncan Murdoch wrote: On 15/03/2011 2:23 PM, Uwe Ligges wrote: On 15.03.2011 15:53, xiagao1982 wrote: > Hi, all, > > Does R have a "const object" concept like which is in C++ language? I want to set some data frames as constan

[R] Reporting odds ratios or risk ratios from GLM

2011-03-15 Thread lafadnes
I am a new R user (am using it through the Rcmdr package) and have struggled to find out how to report OR and RR directly when running GLM models (not only reporting coefficients.) Example of the syntax that I have used: GLM.2 <- glm(diarsev ~ treatmentarm +childage +breastfed, family=binomial(lo

[R] Help on 'object(s) are masked from 'package:base"

2011-03-15 Thread YAddo
Dear All: I am a newbie to R. I am trying to use the lmsqreg.fit pack, although I have installed(I think) it I am not able to invoke it when write the code for it. Here's what I got when I installed it. package 'lmsqreg' successfully unpacked and MD5 sums checked And here is what I got wit

Re: [R] Does R have a "const object"?

2011-03-15 Thread Gabor Grothendieck
On Tue, Mar 15, 2011 at 10:53 AM, xiagao1982 wrote: > Hi, all, > > Does R have a "const object" concept like which is in C++ language? I want to > set some data frames as constant to avoid being modified unintentionally. > Thanks! > > LockBinding will prevent a variable from being modified (but

Re: [R] Does R have a "const object"?

2011-03-15 Thread Martin Morgan
On 03/15/2011 11:34 AM, Duncan Murdoch wrote: On 15/03/2011 2:23 PM, Uwe Ligges wrote: On 15.03.2011 15:53, xiagao1982 wrote: > Hi, all, > > Does R have a "const object" concept like which is in C++ language? I want to set some data frames as constant to avoid being modified unintentionally. Th

Re: [R] Persistent storage between package invocations

2011-03-15 Thread Henrik Bengtsson
It would be nice to have a standard directory where R can write things this way. A semi-standard directory is given by Sys.getenv("R_LIBS_USER"), which defaults to ~/R/.../. Maybe ~/R/ could serve as that convention? That way we (various developers etc) would also not clutter up users home direc

Re: [R] Does R have a "const object"?

2011-03-15 Thread Duncan Murdoch
On 15/03/2011 2:23 PM, Uwe Ligges wrote: On 15.03.2011 15:53, xiagao1982 wrote: > Hi, all, > > Does R have a "const object" concept like which is in C++ language? I want to set some data frames as constant to avoid being modified unintentionally. Thanks! Although there is almost never a "No

Re: [R] Does R have a "const object"?

2011-03-15 Thread Uwe Ligges
On 15.03.2011 15:53, xiagao1982 wrote: Hi, all, Does R have a "const object" concept like which is in C++ language? I want to set some data frames as constant to avoid being modified unintentionally. Thanks! Although there is almost never a "No" in R, the best short answer is: "No". Best,

Re: [R] Calculate monthly means

2011-03-15 Thread KATSCHKE, ADRIAN CIV DFAS
You could use the by() function after a little data manipulation. The first line will create a field just of the date portion of your datetime field. Then you can use the by() function to use the indices you desire to calculate the mean. mSamp$cDT <- chron(unlist(strsplit(as.character(mSamp$Col

Re: [R] How to read only specified columns from a data file

2011-03-15 Thread David Winsemius
On Mar 15, 2011, at 1:11 PM, wrote: I think you need to read an introduction to R. For starters, read.table returns its results as a value, which you are not saving. The probable answer to your question: Read the whole file with read.table, and select columns you need, e.g.: tab <- read.

Re: [R] How to read only specified columns from a data file

2011-03-15 Thread rex.dwyer
I think you need to read an introduction to R. For starters, read.table returns its results as a value, which you are not saving. The probable answer to your question: Read the whole file with read.table, and select columns you need, e.g.: tab <- read.table(myfile, skip=2)[,1:5] -Original Mes

Re: [R] (no subject)

2011-03-15 Thread rex.dwyer
Hi Jon, I read your question differently. Is the answer? - Rex > ch=scan(stdin(),what=character(0),n=1) 1: f Read 1 item > ch [1] "f" > -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Bert Gunter Sent: Tuesday, March 15, 2011 10

Re: [R] fitting a distribution to a ecdf plot

2011-03-15 Thread Carlos Ortega
Hi, One "easy" way to do that is by using the "nls" (nonlinear least square) library. Basically you will test with that if your distribution can be adjusted to the distribution you say it matches (Weibull?) through the adjustment of some parameters. The base package includes the "nls" library, b

Re: [R] fitting a distribution to a ecdf plot

2011-03-15 Thread David Winsemius
On Mar 15, 2011, at 12:23 PM, Lathouri, Maria wrote: Actually I have already done a search on that but it was not much of a help. That is why I posted it in the r-help in case it was much more helpful. There is a tutorial by Ricci with the exact title I suggested looking for. At the Baro

Re: [R] fitting a distribution to a ecdf plot

2011-03-15 Thread Lathouri, Maria
Actually I have already done a search on that but it was not much of a help. That is why I posted it in the r-help in case it was much more helpful. Thank you. Kind regards Maria From: David Winsemius [dwinsem...@comcast.net] Sent: 15 March 2011 16:19 T

Re: [R] Problem with nls.lm function of minpack.lm package.

2011-03-15 Thread Ravi Varadhan
One things you should do, as Kate suggested, is to check whether the Jacobian functiions are correctly code. You can do this with "numDeriv" package: require(numDeriv) ?jacobian Compare the jacobian from numDeriv with your jacobian for a few reasonable parameter vectors. Ravi. _

Re: [R] Calculate monthly means

2011-03-15 Thread Daniel Kaschek
On Tue, 2011-03-15 at 07:24 -0700, Carl Nim wrote: > I am trying to calculate monthly means by year of phosphates and nitrates > from a multi year data set. Can anybody help me out with the most effective > way to do this? > > My data looks like this: > > Collection_Date Test.Name Value > 2000

Re: [R] JAGS/BUGS on gene expression data

2011-03-15 Thread Mark Leeds
hi: you also may want to look at the admit package. it does metropolis hastings using a weighted mixture of t-distributions so you just need to write a function for the likelihood you're trying to get the parameters for. I don't know about it's speed or efficiency for large data sets but you could

Re: [R] fitting a distribution to a ecdf plot

2011-03-15 Thread David Winsemius
On Mar 15, 2011, at 12:00 PM, Lathouri, Maria wrote: Dear all, I need to plot an cumulative distribution plot of a variable and then to fit a distribution to that, probably a weibull or lognormal. I have plotted the ecdf as plot(ecdf(x)) but I haven't managed to fit the distribution. I

[R] fitting a distribution to a ecdf plot

2011-03-15 Thread Lathouri, Maria
Dear all, I need to plot an cumulative distribution plot of a variable and then to fit a distribution to that, probably a weibull or lognormal. I have plotted the ecdf as > plot(ecdf(x)) but I haven't managed to fit the distribution. I have as well attached the data. I would appreciate if you

Re: [R] color under lm line

2011-03-15 Thread Eik Vettorazzi
Hi Keith, how about this: fit<-function(x,coefs) x*coefs[2]+coefs[1] plot(1:10,1:10,type="n") x<-par("usr")[1:2] cf1<-c(a=3,b=.5) #eg coefs from a lm-object cf2<-c(a=1,b=.9) #another line, coloring only intersection polygon(c(x,rev(x)),c(fit(x,cf1),fit(rev(x),cf2)),col="red") setting one of the c

Re: [R] Persistent storage between package invocations

2011-03-15 Thread Prof Brian Ripley
On Tue, 15 Mar 2011, Hadley Wickham wrote: Hi all, Does anyone have any advice or experience storing package settings between R runs? Can I rely on the user's home directory (e.g. tools::file_path_as_absolute("~")) to be available and writeable across platforms? No. First, please use path.e

[R] How to read only specified columns from a data file

2011-03-15 Thread Luis Ridao
R-help, I'm trying to read a data file with plenty of columns. I just need the first 5 but it doe not work by doing something like: > mycols <- rep(NULL, 430) ; mycols[c(1:4)] <- NA > read.table(myfile, skip=2, colClasses=mycols) Any suggestions? Thanks in advance _

Re: [R] Newbie-ish question on iteratively applying function to dataframe

2011-03-15 Thread Ista Zahn
Hi Claus, On Tue, Mar 15, 2011 at 9:33 AM, Claus O'Rourke wrote: > Hi, > I am trying to recursively apply a function to a selection of columns > in a dataframe. I've had a look around and from what I have read, I > should be using some version of the apply function, but I'm really > having some h

Re: [R] create data set from selection of rows

2011-03-15 Thread Francisco Gochez
Hi, What you are after is: datasubset <- dataset[ dataset[,3] == "text3", ] Equivalently, you can use: datasubset <- subset(dataset, subset = dataset[,3] == "text3") HTH, Francisco On Tue, Mar 15, 2011 at 3:09 PM, e-letter wrote: > Readers, > > For a data set: > > text1,23,text2,45 > text1

Re: [R] create data set from selection of rows

2011-03-15 Thread Mohamed Lajnef
Hi, Le 15/03/11 16:09, e-letter a écrit : > Readers, > > For a data set: > > text1,23,text2,45 > text1,23,text3,78 > text1,23,text3,56 > text1,23,text2,45 > > The following command was entered: > > datasubset<-data.frame(dataset[,3]=="text3") datasubset<-subset(dataset,dataset[,3]=="text3") > The

[R] Problem with nls.lm function of minpack.lm package.

2011-03-15 Thread Yann Périard Larrivée
Dear R useRs, I have a problem with nls.lm function of minpackl.lm package. I need to fit the Van Genuchten Model to a set of data of Theta and hydraulic conductivity with nls.lm function of minpack.lm package. For the first fit, the parameter estimates keep changing even after 1000 iteration

Re: [R] create data set from selection of rows

2011-03-15 Thread nblarson
Try using which() Something like data.frame(dataset[which(dataset[,3]=="text3"),]) e-letter wrote: > > Readers, > > For a data set: > > text1,23,text2,45 > text1,23,text3,78 > text1,23,text3,56 > text1,23,text2,45 > > The following command was entered: > > datasubset<-data.frame(dataset[,3]

[R] RE : run a slef-written function

2011-03-15 Thread Wolfgang RAFFELSBERGER
?source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD IGBMC, 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France wolfgang.raffelsberger (at) igbmc.fr De : r-help-boun...@r-project.org [r-help-boun

[R] Fill vector more efficient than element by element?

2011-03-15 Thread beatleb
Dear R useRs, I am a newbie. Currently, my script is quick long, therefor I am trying to improve the efficiency of my script. I use often a version of the following code, the script below is just a simple example, but I especially try to improve the last three lines: matrix1<-diag(100) a=2 try<

[R] Does R have a "const object"?

2011-03-15 Thread xiagao1982
Hi, all, Does R have a "const object" concept like which is in C++ language? I want to set some data frames as constant to avoid being modified unintentionally. Thanks! xiagao1982 2011-03-15 [[alternative HTML version deleted]] __ R-help@

[R] Polynomial regression problem

2011-03-15 Thread Matthew McKinney
I have just started using R so forgive me if this question is very simple. I have a data set (in a data frame called dm) that looks like this x (Cells)y(males) 1 0 2 2 3 7 4 12 5 12 6 19 7 22 8 23 9 25 10 23 11 23 12 11 13

Re: [R] run a slef-written function

2011-03-15 Thread Scott Chamberlain
you could run source(directory/textfilename.txt) [and then you can use it in R] or paste the function into the console, or highlight and pass the function from the built in R text editor, or highlight and pass the function from your external text editor (notepad++, emacs, textwrangler, etc.)

Re: [R] regsubsets() [leaps package] - please share some good examples of use

2011-03-15 Thread agent dunham
Does it mean that regsubsets doesn't work with categorical variables? It's because I'm trying the following and I don't know what happens. Any help would be appreciated. varin <- data.frame(v1,v2,...,v7, factor1,..., factor4) Dependent variable: height Then: eu.subsets <- regsubsets(varinc ,

Re: [R] JAGS/BUGS on gene expression data

2011-03-15 Thread nblarson
64 Bit R w/JAGS seems to be stalling out as well, I ran a test run of 100 iterations and it's been hanging for 8 hours so that doesn't seem to be the solution. I'll take a look at PYMC. That CppBUGS package looks pretty interesting, I'll keep my eye on it. My C programming book arrives today fro

[R] Calculate monthly means

2011-03-15 Thread Carl Nim
I am trying to calculate monthly means by year of phosphates and nitrates from a multi year data set. Can anybody help me out with the most effective way to do this? My data looks like this: Collection_Date   Test.Name  Value 2000-01-24 17:00:00    Phosphate 

Re: [R] sample size of 2 groups of skewed data

2011-03-15 Thread Kjetil Halvorsen
did you try to fit your data with a skew-normal/skew-t distribution? If that works, you can use simulation. Kjetil On Tue, Mar 15, 2011 at 2:31 AM, Lao Meng wrote: > Hi all: > I have a question on sample size calculation of 2 groups of data. If 2 > groups of data are all normal distribution, the

Re: [R] indeterminate for loop

2011-03-15 Thread lm609
Thanks! I've never come across 'while' before and it's perfect. On Mar 15 2011, Jonathan P Daily wrote: ?"while" You don't want a for loop. You need a while loop. -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville

Re: [R] Changing colour of continuous time-series in ggplot2

2011-03-15 Thread Hadley Wickham
You need to specify the group aesthetic - that defines how observations are grouped into instances of a geom. Hadley On Tue, Mar 15, 2011 at 8:37 AM, joeP wrote: > Hi, > > This seems like there should be a simple answer, but having spent most of > the day trying to find it, I'm becoming less con

[R] create data set from selection of rows

2011-03-15 Thread e-letter
Readers, For a data set: text1,23,text2,45 text1,23,text3,78 text1,23,text3,56 text1,23,text2,45 The following command was entered: datasubset<-data.frame(dataset[,3]=="text3") The result of datasubset is TRUE TRUE The required result is text1,23,text3,78 text1,23,text3,56 What is the co

Re: [R] run a slef-written function

2011-03-15 Thread David Winsemius
On Mar 15, 2011, at 9:21 AM, bra86 wrote: How could one get started with a self-written function? I have a function written in .txt format, but can not find the way to import it to the R space. Would be very appreciated for help. It would be more typical to use a file extension of .r but I

Re: [R] run a slef-written function

2011-03-15 Thread Sarah Goslee
source("myfunction.R") is the usual approach. You could also just copy your code and paste it into the R console. Sarah On Tue, Mar 15, 2011 at 9:21 AM, bra86 wrote: > How could one get started with a self-written function? > I have a function written in .txt format, but can not find the way to

Re: [R] Table multiple answers variables

2011-03-15 Thread Orvalho Augusto
This is! Thank you everyone. Caveman On Tue, Mar 15, 2011 at 4:24 PM, Dimitris Rizopoulos < d.rizopou...@erasmusmc.nl> wrote: > try the following: > > DF <- as.data.frame(matrix(sample(2, 120, TRUE), 10, 12)) > > Results <- data.frame( >var = names(DF), >count = colSums(DF == 1), >

Re: [R] Keyboard Input

2011-03-15 Thread Jonathan P Daily
Solved. Thanks. -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when its empty? Does the room, the thing itself have purpose? Or do we, what's the word... imbue it.

Re: [R] indeterminate for loop

2011-03-15 Thread Jonathan P Daily
?"while" You don't want a for loop. You need a while loop. -- Jonathan P. Daily Technician - USGS Leetown Science Center 11649 Leetown Road Kearneysville WV, 25430 (304) 724-4480 "Is the room still a room when its empty? Does the room, the thing itself have purp

Re: [R] Keyboard Input

2011-03-15 Thread Gabor Grothendieck
On Tue, Mar 15, 2011 at 10:29 AM, Jonathan P Daily wrote: > I apologize for being unclear in my original post. What I am trying to > achieve is to capture the stdin() connection and read in a single > keystroke - including arrow keys and the like - without having to have to > use the return key ea

Re: [R] Serial Date

2011-03-15 Thread Gabor Grothendieck
On Tue, Mar 15, 2011 at 10:24 AM, Gabor Grothendieck wrote: > On Sun, Mar 13, 2011 at 10:00 PM, Raoni Rosa Rodrigues > wrote: >> Hello R Help, >> >> I'm working in a project with a software that register date and time data in >> serial time format. This format is used by excel, for exemple. In t

Re: [R] Keyboard Input

2011-03-15 Thread Jonathan P Daily
I apologize for being unclear in my original post. What I am trying to achieve is to capture the stdin() connection and read in a single keystroke - including arrow keys and the like - without having to have to use the return key each time. My goal is to create a small UI for rapidly looking th

Re: [R] Serial Date

2011-03-15 Thread Gabor Grothendieck
On Sun, Mar 13, 2011 at 10:00 PM, Raoni Rosa Rodrigues wrote: > Hello R Help, > > I'm working in a project with a software that register date and time data in > serial time format. This format is used by excel, for exemple. In this > format, 40597.3911423958 is 2011/2/23 09:23:15. First part is

Re: [R] Table multiple answers variables

2011-03-15 Thread Dimitris Rizopoulos
try the following: DF <- as.data.frame(matrix(sample(2, 120, TRUE), 10, 12)) Results <- data.frame( var = names(DF), count = colSums(DF == 1), percentage = colMeans(DF == 1) ) I hope it helps. Best, Dimitris On 3/15/2011 3:13 PM, Orvalho Augusto wrote: I have a dataset like thi

Re: [R] Table multiple answers variables

2011-03-15 Thread Henrique Dallazuanna
Try this: data.frame(count = colSums(x == 1), percentage = colSums(x == 1) / nrow(x)) On Tue, Mar 15, 2011 at 11:13 AM, Orvalho Augusto wrote: > I have a dataset like this: > > q25_1 q25_2 q25_3 q25_4 q25_5 q25_6 q25_7 q25_8 q25_9 q25_10 q25_11 > q25_12 > 1 2 2 1 1 2

[R] Table multiple answers variables

2011-03-15 Thread Orvalho Augusto
I have a dataset like this: q25_1 q25_2 q25_3 q25_4 q25_5 q25_6 q25_7 q25_8 q25_9 q25_10 q25_11 q25_12 1 2 2 1 1 2 1 2 1 1 2 1 3 2 2 2 2 1 2 1 2 1 1 2 1 2 3 2 1 1 1 2

[R] indeterminate for loop

2011-03-15 Thread lm609
Hello, I have written a 'for' loop which on the first run makes nearest neighbour calculations for my dataset 'A' in relation to dataset 'B', then based on these results, some of the rows from A are moved into dataset B, and the calculation is repeated on the remaining rows in A. Therefore a s

Re: [R] Finding coordinates for maximum of a function

2011-03-15 Thread Bert Gunter
Right. ?which.max is what's needed. -- Bert On Tue, Mar 15, 2011 at 6:00 AM, nblarson wrote: > That actually won't work.  max(y) will give a value, not a coordinate, so > x[max(y)] is definitely not what you want. > > -- > View this message in context: > http://r.789695.n4.nabble.com/Finding-

Re: [R] (no subject)

2011-03-15 Thread Bert Gunter
?strsplit x <- "ThisIsaString" y<- strsplit(x,"") This gives a list, which you can convert to a vector by unlist(y) Incidentally, you could have found out about strsplit via R's help.search("character string") (or similar) or even googling "R string function" . Please use R's native Help capabil

  1   2   >