[R] optim with BFGS--what may lead to this, a strange thing happened

2010-09-15 Thread Hey Sky
Dear R Users on a self-written function for calculating maximum likelihood probability (plz check function code at the bottom of this message), one value, wden, suddenly jump to zero. detail info as following: w[11]=2.14 lnw=2.37 2.90 3.76 ... regw=1.96 1.77 1.82

Re: [R] How to uncompress a gz file in R

2010-09-15 Thread steven mosher
Wongsang, Just to be clear R.utils is different than utils As Henrik notes gunzip has been in R.utils ( see http://cran.r-project.org/) for some time. It works like a champ. R.utils is a great package. On Wed, Sep 15, 2010 at 9:30 AM, Wonsang You y...@ifn-magdeburg.de wrote: Dear Henrik,

Re: [R] Creating publication-quality plots for use in Microsoft Word

2010-09-15 Thread Abhijit Dasgupta, PhD
On 9/15/10 10:38 AM, dadrivr wrote: Hi everyone, I am trying to make some publication-quality plots for use in Microsoft Word, but I am having trouble creating high-quality plots that are supported by Microsoft Word. If I use the R plot function to create the figure, the lines are jagged, and

[R] approxfun returning value higher than I would expect

2010-09-15 Thread stephen sefick
Below is the code that I am using in a much larger function. I would expect a bankfull measure at zero to be between 0.6 and 0.8 approxfun is returning 0.8136986. I am sure that I am missing something. measure_bkf - (structure(list(measurment_num = c(0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4, 1.6,

[R] contr.sum, model summaries and `missing' information

2010-09-15 Thread Christophe Rhodes
Hi, I have a dataset with a response variable and multiple factors with more than two levels, which I have been fitting using lm() or glm(). In these fits, I am generally more interested in deviations from the global mean than I am in comparing to a control group, so I use contr.sum() as the

Re: [R] optim with BFGS--what may lead to this, a strange thing happened

2010-09-15 Thread Hey Sky
sorry, a typo. the following code is an example from my computer and the real one just has more variables. the w[11] is the w[5] in the wden equation. the value of wden is calculated based on the ifelse condition. it may equal to 1 when one is working; if not, it will equal to the value

Re: [R] approxfun returning value higher than I would expect

2010-09-15 Thread Duncan Murdoch
On 15/09/2010 3:48 PM, stephen sefick wrote: Below is the code that I am using in a much larger function. I would expect a bankfull measure at zero to be between 0.6 and 0.8 approxfun is returning 0.8136986. I am sure that I am missing something. measure_bkf- (structure(list(measurment_num =

[R] Model fitting

2010-09-15 Thread Diogo B. Provete
I have a data set and I want to procedure to model fitting (e.g., Poisson, Gausian, binomial, quasipoisson etc.). I'd like to know if there is an easier way to do this in R. Thank you in advance. -- Atenciosamente, Diogo Borges Provete == Biólogo Mestre em Biologia

Re: [R] approxfun returning value higher than I would expect

2010-09-15 Thread stephen sefick
Thanks and I'll strip the code down even more in future posts. Stephen On Wed, Sep 15, 2010 at 3:05 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote:  On 15/09/2010 3:48 PM, stephen sefick wrote: Below is the code that I am using in a much larger function.  I would expect a bankfull measure

Re: [R] Model fitting

2010-09-15 Thread Erik Iverson
Diogo B. Provete wrote: I have a data set and I want to procedure to model fitting (e.g., Poisson, Gausian, binomial, quasipoisson etc.). I'd like to know if there is an easier way to do this in R. Easier than what ? There is no shortage of R functions and packages to fit almost any type of

Re: [R] question on optim

2010-09-15 Thread Hey Sky
thanks. Ravi and Nash. I will read the new package and may use it after I am familiar with it. I may bother both of you when I have questions.thanks for that in advance. Nan from Montreal Hi Nan, You can take a look at the optimx package on CRAN. John Nash and I wrote this package to

Re: [R] approxfun returning value higher than I would expect

2010-09-15 Thread stephen sefick
x - c(-0.48,-0.48,-0.42,-0.26,0.58,0.48,0.47,0.54,0.5,0.52,0.52,0.56,0.58,0.61,0.68) y - c(0,0.2,0.4,0.6,0.8,1,1.2,1.4,1.6,1.8,2,2.2,2.4,2.6,2.8) s - approxfun(x[4:5], y[4:5], ties=mean) s(0) #This is the value that I want. The first zero crossing in the order of y. #In other words in

[R] lapack in R 2.11.1 (Ubuntu 10.04.1)

2010-09-15 Thread Matias Salibian-Barrera
Hi there, I'm trying to install the package RcppArmadillo in my R 2.11.1 which I installed and regularly update via Ubuntu's repositories. When I try to install RcppArmadillo from CRAN I get: install.packages('RcppArmadillo', lib='~/myRlibs') [...] g++ -shared -o RcppArmadillo.so

Re: [R] cochran-grubbs tests results

2010-09-15 Thread Greg Snow
The fact that you are asking what a p-value is indicates that you do not have enough of a background for us to be able to help you. It is not that we do not want to help, just that anything we could say in an e-mail would likely do more harm than good at this point. You should either consult

[R] From string to numeric

2010-09-15 Thread Christofer Bogaso
Hi, I have a string like 1,2,5,7,8. From this I want to create a numeric vector of length 5 (total number of numbers in above string), with each element will be the number in above string. Is there any possibility to doing this? Thanks and regards, __

Re: [R] From string to numeric

2010-09-15 Thread Henrique Dallazuanna
Try this: x - scan(textConnection(1,2,5,7,8), sep = ,) On Wed, Sep 15, 2010 at 5:42 PM, Christofer Bogaso bogaso.christo...@gmail.com wrote: Hi, I have a string like 1,2,5,7,8. From this I want to create a numeric vector of length 5 (total number of numbers in above string), with each

[R] Moving non-zero matrix entries to different locations on the matrix

2010-09-15 Thread Juliet Ndukum
I have a matrix: C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 R1 0 0 0 0 0 5 0 0 0 0 0 0 R2 0 0 0 0 0 3 0 0 0 0 0 0 R3 0 0 0 0 0 0 4 0 0 0 0 0 R4 0 0 0 0 0 0 2 0 0 0 0 0 R5 1 0 0 0 0 0 0 0 0 0 0 0 R6 8 0 0 0 0 0

Re: [R] From string to numeric

2010-09-15 Thread Greg Snow
x - 1,2,5,7,8 as.numeric(unlist(strsplit(x, ','))) [1] 1 2 5 7 8 -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf

Re: [R] lapack in R 2.11.1 (Ubuntu 10.04.1)

2010-09-15 Thread Douglas Bates
On Wed, Sep 15, 2010 at 3:48 PM, Matias Salibian-Barrera msalib...@yahoo.ca wrote: Hi there, I'm trying to install the package RcppArmadillo in my R 2.11.1 which I installed and regularly update via Ubuntu's repositories. When I try to install RcppArmadillo from CRAN I get:

Re: [R] lapack in R 2.11.1 (Ubuntu 10.04.1)

2010-09-15 Thread Dirk Eddelbuettel
On 15 September 2010 at 13:48, Matias Salibian-Barrera wrote: | I'm trying to install the package RcppArmadillo in my R 2.11.1 which I installed | and regularly update via Ubuntu's repositories. We welcome questions on Rcpp et al on the rcpp-devel list. There is also the r-sig-debian list

Re: [R] lapack in R 2.11.1 (Ubuntu 10.04.1)

2010-09-15 Thread Matias Salibian-Barrera
Thanks to all that helped. I had not compiled R myself, so it was rather puzzling. I finally decided to re-install R from scratch. First I verified I had the right repositories listed and ran: sudo apt-get update sudo apt-get remove r-base sudo apt-get autoremove sudo apt-get install r-base

[R] loop, list() and non-numeric argument to binary operator

2010-09-15 Thread Chien-Pang Chin
Hi all: I have a problem when I want to do operation a sequence or matrix created by loop and list() or data.frame(). Here is the example. for(i in 1:n) (k[i]=list(c(0:max[i]))) k[1]+1 Error in k[1] + 1 : non-numeric argument to binary operator What should I do to correct this

Re: [R] loop, list() and non-numeric argument to binary operator

2010-09-15 Thread Phil Spector
Chien-Pang - Here's a *reproducible* example that should answer your question: k = list() n = 10 max = 10:19 for(i in 1:n) (k[i]=list(c(0:max[i]))) k[[1]] + 1 [1] 1 2 3 4 5 6 7 8 9 10 11 - Phil Spector

[R] Inconvenient behavior of as.data.frame() for lists without names

2010-09-15 Thread Magnus Thor Torfason
Hi all, I ran into a small issue when converting a list of vectors to a data frame. The Issue I'm having is described by the snippet below: # # Convert a list of vectors into a data.frame strlen = 256 s.long.a = paste(

[R] labeling outliers with subject numberss

2010-09-15 Thread Kevin Burnham
How can I get the outlier in this boxplot of Score to be represented by the corresponding value in SubNo? score=c(6,6,7,14,5,7,6,8) SubNo=1:8 mydata=data.frame(SubNo, score) boxplot(mydata$score) Thanks! Kevin [[alternative HTML version deleted]]

Re: [R] labeling outliers with subject numberss

2010-09-15 Thread Clint Bowman
SubNo[identify(rep(1,8),mydata$score)] -- Clint BowmanINTERNET: cl...@ecy.wa.gov Air Quality Modeler INTERNET: cl...@math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600FAX:(360)

Re: [R] labeling outliers with subject numberss

2010-09-15 Thread Phil Spector
Kevin - Here's one way: z = boxplot(mydata$score,outline=FALSE,ylim=range(mydata$score)) text(1,z$out,SubNo[which(score == z$out)]) - Phil Spector Statistical Computing Facility

Re: [R] From string to numeric

2010-09-15 Thread Jorge Ivan Velez
Hi Cristofer, Try as.numeric(strsplit(x, ,)[[1]]) HTH, Jorge On Wed, Sep 15, 2010 at 4:42 PM, Christofer Bogaso wrote: Hi, I have a string like 1,2,5,7,8. From this I want to create a numeric vector of length 5 (total number of numbers in above string), with each element will be the

[R] aggregate, by, *apply

2010-09-15 Thread Mark Ebbert
Dear R gurus, I regularly come across a situation where I would like to apply a function to a subset of data in a dataframe, but I have not found an R function to facilitate exactly what I need. More specifically, I'd like my function to have a context of where the data it's analyzing came

[R] loop, list() and non-numeric argument to binary operator

2010-09-15 Thread Chien-Pang Chin
Hi all: I have a problem when I want to do operation a sequence or matrix created by loop and list() or data.frame(). Here is the example. for(i in 1:n) (k[i]=list(c(0:max[i]))) k[1]+1 Error in k[1] + 1 : non-numeric argument to binary operator What should I do to correct this

[R] Changing variable class problems

2010-09-15 Thread Richard Barfield
I'm reading in some data from a csv file, and it's reading in some of the columns as character variables instead of numeric. I know I can fix this by doing as.numeric for each of the columns, but the problem is I have a LOT of different quantitative variables that I would have to do this for. I've

Re: [R] aggregate, by, *apply

2010-09-15 Thread Dennis Murphy
Hi: Try this: library(plyr) func - function(x, y) { m - median(x) if(m 2 m mean(y)) ret - TRUE else ret - FALSE ret } ddply(tmp, .(z), summarise, r = func(x, y)) z r 1 a FALSE 2 b TRUE 3 c TRUE HTH, Dennis On Wed, Sep 15, 2010 at 2:45 PM, Mark Ebbert

Re: [R] aggregate, by, *apply

2010-09-15 Thread David Winsemius
On Sep 15, 2010, at 5:45 PM, Mark Ebbert wrote: Dear R gurus, I regularly come across a situation where I would like to apply a function to a subset of data in a dataframe, but I have not found an R function to facilitate exactly what I need. More specifically, I'd like my function to

Re: [R] aggregate, by, *apply

2010-09-15 Thread Abhijit Dasgupta, PhD
I would approach this slightly differently. I would make func a function of x and y. func - function(x,y){ m - median(x) return(m 2 m y) } Now generate tmp just as you have. then: require(plyr) res - daply(tmp, .(z), summarise, res=func(x,y)) I believe this does the trick

Re: [R] Changing variable class problems

2010-09-15 Thread Joshua Wiley
Hi Richard, Something like workf[ , columns] - data.frame(lapply(workf[, columns], as.numeric)) should do what you're after. However, this is really a bit of a work around to the real problem. Can you provide more details on the csv file you are reading in? Perhaps the first couple rows or

Re: [R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread Jorge Ivan Velez
Hi Nicolas, Try (untested): with(pop, table(factor(xloc, levels = 1:20), factor(loc, levels = 1:25))) HTH, Jorge On Wed, Sep 15, 2010 at 7:31 PM, Nicolas Gutierrez wrote: Hi All, I’m trying to superimpose (or add) two matrices: 1. resulting from a table function with frequencies:

Re: [R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread Dennis Murphy
Hi: Try something like this: ind - as.matrix(expand.grid(rownames(U), colnames(U))) Uempty[ind] - U[ind] ind should be a two column matrix of (row, col) indices. Then just replace the values of Uempty associated with those indices with the corresponding entries of U. HTH, Dennis On Wed, Sep

Re: [R] labeling outliers with subject numberss

2010-09-15 Thread Peter Ehlers
Kevin, On 2010-09-15 16:37, Phil Spector wrote: Kevin - Here's one way: z = boxplot(mydata$score,outline=FALSE,ylim=range(mydata$score)) text(1,z$out,SubNo[which(score == z$out)]) - Phil Spector

Re: [R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread David Winsemius
On Sep 15, 2010, at 7:40 PM, Dennis Murphy wrote: Hi: Try something like this: ind - as.matrix(expand.grid(rownames(U), colnames(U))) Uempty[ind] - U[ind] ind should be a two column matrix of (row, col) indices. Then just replace the values of Uempty associated with those indices with the

[R] how to superimpose 2 matrices of different sizes

2010-09-15 Thread Nicolas Gutierrez
Hi All, I’m trying to superimpose (or add) two matrices: 1. resulting from a table function with frequencies: U=table(pop$xloc, pop$yloc)) 14 15 16 17 18 19 20 21 22 5 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0

[R] standard error of difference for mixed effects

2010-09-15 Thread Meissner, Tony (DFW)
I have a dataset relating the effects of engineering works on the level of salinity in a river before and after the works. I have modelled this using linear mixed effects models to determine if the significance and level of the response to the works. I am wanting to calculate the se of

Re: [R] Inconvenient behavior of as.data.frame() for lists without names

2010-09-15 Thread David Winsemius
On Sep 15, 2010, at 6:10 PM, Magnus Thor Torfason wrote: Hi all, I ran into a small issue when converting a list of vectors to a data frame. The Issue I'm having is described by the snippet below: # # Convert a list of vectors into

Re: [R] standard error of difference for mixed effects

2010-09-15 Thread Dennis Murphy
Hi: Why is phase nested within sites? Shouldn't sites and phase be crossed? After all, there is one intervention (works) that purportedly affects the river both upstream and downstream. Moreover, why is log(flow) being treated as both a fixed and random effect? Just curious, Dennis On Wed, Sep

Re: [R] Sweave and graphs

2010-09-15 Thread Katie Surrence
Thanks for your help! My computer died, and I set up Sweave on another computer, on which it is working perfectly. So perhaps I'll never be sure what the problem was on the other machine. On Tue, Sep 14, 2010 at 12:39 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 14/09/2010 1:18 PM,

[R] use same breaks and colors, but the displayed scale are different-image.plot()

2010-09-15 Thread rusers.sh
Hi all, I want to put several figures in a one figure for easy comparison, so i need to use the same methods to plot these figures. The following is an example. I also list my method, but it does not work. #Example data x- 1:10; y- 1:10; z- outer( x,y,+);z2- outer( x,y,-) #Quick view them

Re: [R] approxfun returning value higher than I would expect

2010-09-15 Thread Duncan Murdoch
I think this is fixed now. There were actually two bugs: I fixed an old one a few days ago, but my fix didn't handle the case of unsorted x properly. (I haven't checked whether the old code handled that properly; I'd guess not, but it might have.) Now I've fixed my new bug. *Please* test

Re: [R] use same breaks and colors, but the displayed scale are different-image.plot()

2010-09-15 Thread Dennis Murphy
Hi Jane, Try this: split.screen( rbind(c(0, .8,0,1), c(.8,1,0,1))) # [1] 1 2 # first screen split into a (2, 1) configuration ind - split.screen(c(2,1), screen=1) screen(ind[1]) image(x, y, z, col = cols, zlim = zr) screen(ind[2]) image(x, y, z2, col = cols, zlim = zr) # Place the common,

Re: [R] ggplot bar geom: control the filling in the colour legend

2010-09-15 Thread Paul Murrell
Hi On 13/09/2010 8:03 p.m., Benoit Boulinguiez wrote: Hi all, I'm still seeking for tweaking the appearance of the color legend in a bar goemetry with ggplot2. I can't seem to control the filling of the colour legend squares take this, ggplot(diamonds, aes(clarity, fill=color,colour = cut)) +

[R] finding complex roots in R

2010-09-15 Thread Toros Caglar
I am looking for a way to find the roots of a non-polynomial expression. I know R has a few ways to deal with polynomials, but, I could not find a method that deals with functions involving e^(x) type arguments, that have complex roots as well as real roots. Any ideas? Thanks, Toros

[R] Asking Favor

2010-09-15 Thread chuan zun liang
Dear Prof: My name is Chuan.I from Malaysia.I am a beginner for R.I need favor for Prof. This is my data:

Re: [R] Asking Favor

2010-09-15 Thread Michael Bedward
Hello Chuan, If you just want a matrix with the numbers 1 to 64 arranged by row... m - matrix(1:64, ncol=8, byrow=TRUE) But perhaps I don't understand your question properly ? Michael On 16 September 2010 12:46, chuan zun liang chuan...@yahoo.com.my wrote: Dear Prof: My name is Chuan.I

Re: [R] approxfun returning value higher than I would expect

2010-09-15 Thread stephen sefick
I will get R-dev tomorrow, and give it a try. Where do I check out the svn? thanks, Stephen On Wed, Sep 15, 2010 at 10:00 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: I think this is fixed now.  There were actually two bugs: I fixed an old one a few days ago, but my fix didn't handle

Re: [R] Get File Names in Folder, Read Files, Update, and Write

2010-09-15 Thread steven mosher
you are welcomed. Steve On Wed, Sep 15, 2010 at 6:11 PM, Suphajak Ngamlak supha...@phatrasecurities.com wrote: Thank you so much. It works well Best Regards, Suphajak Ngamlak Equity and Derivatives Trading Phatra Securities Public Company Limited Tel: +662-305-9179 Email:

<    1   2