[R] functions with function inputs and optimisation

2013-05-10 Thread Sachinthaka Abeywardana
Hi all, Would be great if you could help me get my head around the further arguemnts in the optim function. Let's say we have f and g as shown: f-function(x,a,b){(x-a)^2+b} optim(100,fn=f,gr=NULL,2,5) #the NULL is annoying g-function(x,a){2*(x-a)} optim(100,fn=f,gr=g,2,5) 1. How does optim

Re: [R] Fwd: NaN-result from fuzzy_inference (package sets) with certain input

2013-05-10 Thread Johannes Radinger
Hi, @David: thank you for your fast response. I changed the universe to cover the at least the total range of the values in the dataframe. However, this does not save the problem for several combination of depth and velocity. I attached the same example as before but with a dataframe of such

[R] Replacing values in a dataframe depending on several conditions

2013-05-10 Thread KatrinH Heimann
Dear all, I would like to replace some values in a dataframe (including the columns Action, Interval and Artificiality) depending on a combination of different conditions the command I tried is for (j in 1:nrow(data)) { if ((data[j,data$Action]==s) (data[j,data$Interval]==l) (data[j,data

Re: [R] Replacing values in a dataframe depending on several conditions

2013-05-10 Thread Berend Hasselman
On 10-05-2013, at 10:59, KatrinH Heimann katrinheim...@gmail.com wrote: Dear all, I would like to replace some values in a dataframe (including the columns Action, Interval and Artificiality) depending on a combination of different conditions the command I tried is for (j in

Re: [R] Replacing values in a dataframe depending on several conditions

2013-05-10 Thread Berend Hasselman
On 10-05-2013, at 10:59, KatrinH Heimann katrinheim...@gmail.com wrote: Dear all, I would like to replace some values in a dataframe (including the columns Action, Interval and Artificiality) depending on a combination of different conditions the command I tried is for (j in

Re: [R] R prints empty group on my figure!!

2013-05-10 Thread Adel ESSAFI
2013/5/9 PIKAL Petr petr.pi...@precheza.cz Hi Thank you, that was the option I look for Use drop=TRUE argument in interaction for removing unused levels. Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Adel

[R] Fwd: binomial glm and sole effect of the treatment

2013-05-10 Thread Katarzyna Kulma
Hiya, I'm using simple glm binomial models to test the effect of treatment (factor, 3 levels) on infection prevalence (infected/uninfected): ad3-glm(Infection~ecs, family=binomial, data=eilb) but summary() function returns for each of the factor-level coefficients against the control treatment:

Re: [R] maxLik: different estimations from different packages

2013-05-10 Thread Arne Henningsen
Dear Alfonso On 10 May 2013 12:51, alfonso.carf...@uniparthenope.it wrote: we are computing maximum likelihood estimations using maxLik package and we realized that the results of the estimation depend on the version of the package installed for example if we try to estimate this function

Re: [R] Fwd: binomial glm and sole effect of the treatment

2013-05-10 Thread Ben Bolker
Katarzyna Kulma katarzyna.kulma at gmail.com writes: Hiya, I'm using simple glm binomial models to test the effect of treatment (factor, 3 levels) on infection prevalence (infected/uninfected): ad3-glm(Infection~ecs, family=binomial, data=eilb) but summary() function returns for each

[R] Isolate polygons unionSpatialPolygons / single polygon instead of multipart polygon

2013-05-10 Thread Alejandro Coca Castro
Hi all, i used the function unionSpatialPolygons to dissolve polygons according to an ID value. However, the results were not that i was expecting. It created a SpatialPolygon and it grouped the objects according to the ID value. i.e. one polygon had about 3 subpolygons with the same value. How is

Re: [R] Time series analysis

2013-05-10 Thread Kai Mx
Awesome, exactly what I was hoping for! Thanks so much! You are right - I put in the wrong end dates for the second day. Best, Kai On Thu, May 9, 2013 at 4:01 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Maybe the following will do it. Note, however, that in your data, for start

[R] How to use character in C code?

2013-05-10 Thread cgenolin
Hi the list, I include some C code in a R function using .C. The argument is a character. I find how to acces to the characters one by one: --- 8 --- C void dealWithCharacter(char **chaine, int *size){ int i=0; for(i=0;i*size;i++){ Rprintf(Le caractere %i est

Re: [R] Return a vector in Fibonacci sequence function

2013-05-10 Thread arun
Hi, May be this helps: fibv =function(n) { f1 = f2 = 1 f3- c(f1,f2) for(i in seq(2, n-1)) { if(n == 0 || n == 1) return(n) if(n == 2) return(1) f = f1 + f2 f2 = f1 f1 = f f3- c(f3,f) } f3 } fibv(0) #[1] 0  fibv(1) #[1] 1  fibv(3) #[1] 1 1 2  fibv(10) # [1]  1  1  2  3  5  8 13 21 34 55 A.K.

[R] Weird RefClass running time

2013-05-10 Thread David Kulp
Anyone have a clue why assigning to a list field in a RefClass is so much slower than assigning to a plain old list? For example, given a list of length N, if I want to assign a value to each entry, then the running time is quadratic in N. That is, refclass$a.list[[i]] - value is much much

Re: [R] attr vs attributes

2013-05-10 Thread Rui Barradas
Hello, There's at least one example where only the form attr(x, foo) - bar would work, not the other form. If you want to set attributes programatically, use the first form, like in the function below. Note that the example is artificial. setAttr - function(x, attrib, value){

Re: [R] attr vs attributes

2013-05-10 Thread Duncan Murdoch
On 10/05/2013 10:50 AM, Rui Barradas wrote: Hello, There's at least one example where only the form attr(x, foo) - bar would work, not the other form. If you want to set attributes programatically, use the first form, like in the function below. Note that the example is artificial. setAttr -

[R] helper function to pluck dendrogram attributes

2013-05-10 Thread Murat Tasan
hi all -- i've written a series of procedures to annotate nodes in a dendrogram object. i'd like to be able to easily pluck out some of these attributes and view them in tree form. in a regular list, i'd do something like: sapply(my_list, function(x) x$my_entry) and in a dendrogram, i can use

Re: [R] attr vs attributes

2013-05-10 Thread Murat Tasan
thanks, both. the only real difference between the two approaches that i can see is when assigning _new_ attributes to an object where the attribute name is itself variable. something like this: attributes(my_obj)[[my_attr_name]] - my_attr_value ...fails when my_obj doesn't already have an

[R] rlnorm(n, meanlog = 0, sdlog = 1)

2013-05-10 Thread Dr. Alireza Zolfaghari
Hi list, Does anyone know the code behind rlnorm(n, meanlog = 0, sdlog = 1)? I am going to write it in c#. thanks Alireza [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] rlnorm(n, meanlog = 0, sdlog = 1)

2013-05-10 Thread Rui Barradas
Hello, R is open source, you can download the sources and then grep rlnorm to see file: src/library/stats/distn.R rlnorm - function(n, meanlog=0, sdlog=1) .External(C_rlnorm, n, meanlog, sdlog) And file rlnorm.c is in src/nmath. It returns exp(rnorm(meanlog, sdlog)) So you'll have to

Re: [R] Can DEoptim trace output be customized?

2013-05-10 Thread David Reiner
Katharine, Thank you for the pointer, and thanks to Josh Ulrich and William Dunlap for good suggestions. (Also thanks to Dirk Eddelbuettel for shaming me into modifying the code.) William's fnTracer wrapper technique doesn't require rebuilding the package, so it's easier in some ways, especially

Re: [R] attr vs attributes

2013-05-10 Thread William Dunlap
attributes(my_obj)[[my_attr_name]] - my_attr_value ...fails when my_obj doesn't already have an attribute named my_attr_name. Do you have an example of this? In R-2.15.3 I don't see that problem: my_obj - 37:41 my_attr_name - myAttr my_attr_value - as.roman(2012:2013)

[R] Automatic way to embed fonts into all pdf output?

2013-05-10 Thread Paul Johnson
This is a feature request. Or else a howto request. Can there be some simple, automatic way to make fonts embed into pdf output? Could this be in options() or par()? Why? I recently wanted to create a paper for a conference in a format called AAAI (which I had never heard of before because I

[R] maxLik: different estimations from different packages

2013-05-10 Thread alfonso . carfora
Dear all, we are computing maximum likelihood estimations using maxLik package and we realized that the results of the estimation depend on the version of the package installed for example if we try to estimate this function with an old version of maxLik under R 2.13.1 (32 bit version

[R] compare vector with selected element from a matrix

2013-05-10 Thread Ran Gu
Dear all, I want to compare a huge vector with selected element from a matrix. A is a matrix and B is a vector. I want to compare each element of B with selected element from A. C and D are selection criteria. They are vectors of same length as B. C specifies the row number of A, and D specifies

Re: [R] maxLik: different estimations from different packages

2013-05-10 Thread Ott Toomet
Hi, maybe we changed the convergence criteria a little bit? I cannot remember, but we have played around with those a few times. You may try those, perhaps it helps a bit. Another recommendation---as you do not supply analytic gradient, you may want use BHHH method instead (if this applies to

Re: [R] R installation error

2013-05-10 Thread Meenu Chopra
Thanks to all The main problem with ma linux system is that its not able to install any software using sudo command. like i used command yum search libX11 , it shown that yum is not installed and when i use sudo apt-get install yum its giving error E: Unable to locate package yum same problem

[R] PGLM Package: Starting Values for Within-Model

2013-05-10 Thread MaxFranke
I am currently using the PGLM package and I would like to implement a within-model. Unfortunately, I do not succeed as I am not a big expert in panel regression. I am using the example data set from the PGLM package: library(pglm) data('Unions', package = 'pglm') anb -

[R] Package Seqminer: Fundamental usage question

2013-05-10 Thread Darren Obbard
Hi, I am trying to use the package 'SeqMiner zhanxw.com/seqminer/, and I would like to use any of the functions readVCFToMatrixByRange() readVCFToMatrixByGene() readVCFToListByGene() or readVCFToListByRange() I have run the example code on the test datasets, and have got the expected output.

[R] irt model estimation with constrained parameters

2013-05-10 Thread Fischer, Felix
hi, is there a way to estimate the parameters of an IRT model (in my case, the graded response model), when some item parameter are already known? what i have heard is that other irt programs such as parscale allow to prespecify some of the item difficulty and location parameters and estimate

Re: [R] duplicate rows with new time series

2013-05-10 Thread Ye Lin
Thanks, this one works! On Thu, May 9, 2013 at 5:09 PM, Gabor Grothendieck ggrothendi...@gmail.comwrote: On Thu, May 9, 2013 at 8:09 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Thu, May 9, 2013 at 7:24 PM, Ye Lin ye...@lbl.gov wrote: Hey All, I want to duplicate the

[R] Allocating outputs from code using foreach and doPar

2013-05-10 Thread Chris Hergarten
Dear R-users, I am looking for a solution to parallelize my PLSR predictions in order to save processing time. I was trying to use the foreach construct with doPar (cf. 2nd part of code below), but I was unable to allocate the predicted values and the model performance parameters (RMSEP) to the

Re: [R] compare vector with selected element from a matrix

2013-05-10 Thread William Dunlap
Try using a 2-column matrix, with columns formed from C and D, to subscript A. E.g., A - matrix(101:132, nrow=8, ncol=4) C - seq_len(nrow(A))^2 %% nrow(A) + 1 D - seq_len(nrow(A))^3 %% ncol(A) + 1 for(j in seq_len(nrow(A))) print(A[C[j], D[j]]) [1] 110 [1] 105 [1] 126

Re: [R] R installation error

2013-05-10 Thread Paul Johnson
Meenu: You have an elementary Linux setup and configuration problem to understand first, before you worry about configuring and compiling your own R. I agree strongly that this is something that all linux users should learn to do, but compiling R itself is like climbing Mt Everest as your first

[R] date and time coding question

2013-05-10 Thread Andras Farkas
Dear All   I have the following code:   datetime -c(1/1/13 00:00,1/1/13 12:00,1/2/13 00:00,1/2/13 12:00) datetime -as.POSIXct(datetime,format='%m/%d/%Y %H:%M') times

Re: [R] maxLik: different estimations from different packages

2013-05-10 Thread Spencer Graves
On 5/10/2013 5:22 AM, Ott Toomet wrote: Hi, maybe we changed the convergence criteria a little bit? I cannot remember, but we have played around with those a few times. You may try those, perhaps it helps a bit. Another recommendation---as you do not supply analytic gradient, you may want use

Re: [R] attr vs attributes

2013-05-10 Thread Murat Tasan
sure, here's a series of commands/outputs (using R 3.0.0): x - letters[1:4] y - foo attributes(x) NULL attributes(x)[[y]] - bar Error in attributes(x)[[y]] - bar : attributes must be a list or NULL attr(x, y) - bar attributes(x) $foo [1] bar attributes(x)[[y]] - newbar

Re: [R] date and time coding question

2013-05-10 Thread Jeff Newmiller
a) Please read the Posting Guide and post in plain text as it says to do. This is an adjustment you must make in your email client software, we cannot advise you how to do it here. b) Not clear why you want a matrix. A vector is more typical in R; most of the time using n*1 matrices is an

Re: [R] attr vs attributes

2013-05-10 Thread William Dunlap
Thanks. I looks like my example worked because the value of the new attribute had a length greater than 1. That difference in behavior smells like a bug. { x - 1 ; attributes(x)[[attrName]] - 2012 ; str(x) } Error in attributes(x)[[attrName]] - 2012 : attributes must be a list or NULL

Re: [R] NMDS with missing data?

2013-05-10 Thread Elizabeth Beck
Hi David, You are right in that Bray-Curtis is not suitable for my dataset, and that my variables are very different. Given your suggestions, I am struggling with how to transform or standardize my data given that they vary so much. Additionally, looking at the dist() package I am not sure which

Re: [R] R installation error

2013-05-10 Thread Emre Sahin
On Fri, May 10, 2013 at 01:33:34PM +0100, Meenu Chopra wrote: Thanks to all The main problem with ma linux system is that its not able to install any software using sudo command. like i used command yum search libX11 , it shown that yum is not installed and when i use sudo apt-get install

Re: [R] Tranfer data from exel into R

2013-05-10 Thread iembry
Hi, you are very welcome! I'm glad that it works now. Irucka Embry -Original Message- From: Hiep [via R] [ml-node+s789695n4666747...@n4.nabble.com] Sent: 5/10/2013 6:27:23 AM To: iruc...@mail2world.com Subject: Re: Re: Tranfer data from exel into R Hi Irucka it works now, thank you

[R] Distributing R byte code

2013-05-10 Thread Paul A. Steckler
Hi, I've used R just a little bit, and I couldn't find an answer to my questions via Web search. I'm aware of Luke Tierney's byte code compiler for R, and the compile package, and I have some questions about its use. I want to take some R code, create byte code for it, and distribute it,

[R] need an assistance

2013-05-10 Thread Iut Tri Utami
Hi, i am tryng to run Bagging SVM but I have a problem. I do Bagging SVM based on algoritm bagging Trees by Breiman. I get the following error and I think I am wrong in calculating err.mean and err.vote. I also have difficulty in making the plot. library(e1071) gendata -

Re: [R] NMDS with missing data?

2013-05-10 Thread David Winsemius
On May 10, 2013, at 11:20 AM, Elizabeth Beck wrote: This. SODIUM K CL HCO3 ANION CA P GLUCOSE CHOLESTGGTGLDH CK AST PROTEIN ALBUMIN GLOBULIN A_G UA BA CORTICO T3 T4 THYROID 145 3.3 102 24 22 2.9 2.45 9.8 5.7 3 3 678 5 34 15 19 0.79 180 6 70.97 1.31 12.77 0.102376 146 3.2

Re: [R] Return a vector in Fibonacci sequence function

2013-05-10 Thread Tomos_D
That's great thanks --- Original Message --- From: arun kirshna [via R] ml-node+s789695n4666758...@n4.nabble.com Sent: May 10, 2013 3:34 PM To: Tomos_D vampire_l...@hotmail.co.uk Subject: Re: Return a vector in Fibonacci sequence function Hi, May be this helps: fibv =function(n) { f1 = f2 = 1

Re: [R] How to generate factor levels with unequal numbers?

2013-05-10 Thread arun
Hi, vec1-factor(rep(c(A,B,C),c(19,8,11)),levels=c(A,B,C)) sapply(split(vec1,vec1),length) # A  B  C #19  8 11 #or you could change gl() function gl.new-function (n, k, labels = 1:n, ordered = FALSE) {   out- numeric()    for(i in 1:n){    out- append(out,rep(i,length.out=k[i]))    }   

[R] R's basic lm() and summary.lm functions

2013-05-10 Thread ivo welch
dear R experts: I am contemplating the logic in R's lm() and summary(lm()) statements. the reason is that I want to extend the functionality of lm to give me both standardized coefficients and newey-west standard errors and Ts. I have the code and can stick it at the end of the lm() function

Re: [R] Distributing R byte code

2013-05-10 Thread Duncan Murdoch
On 13-05-10 1:21 PM, Paul A. Steckler wrote: Hi, I've used R just a little bit, and I couldn't find an answer to my questions via Web search. I'm aware of Luke Tierney's byte code compiler for R, and the compile package, and I have some questions about its use. I want to take some R

Re: [R] attr vs attributes

2013-05-10 Thread Duncan Murdoch
On 13-05-10 2:06 PM, William Dunlap wrote: Thanks. I looks like my example worked because the value of the new attribute had a length greater than 1. That difference in behavior smells like a bug. Yes, definitely looks like one. I'll submit the bug report; I hope someone else will fix it.

Re: [R] R's basic lm() and summary.lm functions

2013-05-10 Thread ivo welch
I ended up wrapping my own new ols() function in the end. it is my replacement for lm() and summary.lm. this way, I don't need to alter internals. in case someone else needs it, it is included. of course, feel free to ignore. docs[[ols]] - c(Rd= ' @TITLE ols.R @AUTHOR ivo.we...@gmail.com

Re: [R] How to use character in C code?

2013-05-10 Thread Suzen, Mehmet
You may want to use C++ instead using Rcpp which string handling would be easier: http://gallery.rcpp.org/articles/strings_with_rcpp/ On 10 May 2013 15:51, cgenolin cgeno...@u-paris10.fr wrote: Hi the list, I include some C code in a R function using .C. The argument is a character. I find

[R] (no subject)

2013-05-10 Thread Smith Freeman
Hello, I am attempting to use the classInt package in conjunction with rworldmap package in R to construct a chloropleth. I want to use the fixedBreaks argument to specify given breaks. My data look like this: head(Maji) Country waterused CC 1 Afghanistan 36

Re: [R] (no subject)

2013-05-10 Thread Michael Sumner
What does ww[[waterused]] have to do with Maji? On Sat, May 11, 2013 at 10:07 AM, Smith Freeman smithifree...@gmail.com wrote: Hello, I am attempting to use the classInt package in conjunction with rworldmap package in R to construct a chloropleth. I want to use the fixedBreaks argument to

Re: [R] generating new vector based on criteria from other vectors

2013-05-10 Thread arun
Hi, dat1- read.table(text= x1  x2  x3 a1 b2   2 a1 b4   4 a2 NA  3 NA b2  6 a3  b1   NA a1 b2   9 a1 b2   NA a1 b4   2 ,sep=,header=TRUE,stringsAsFactors=FALSE)    dat2- dat1