Re: [R] shading line plot
First, you need to follow the posting guide ... compose a self-contained example R code including sample data that is at least representative of your actual data. This will eliminate many possible misunderstandings and most likely will lead to a more rapid response to your query. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Akhil dua akhil.dua...@gmail.com wrote: Hi everyone, I have a time series data set and I want to fill my line plot of this time series with different colors e.g I want to fill portion related to 1995-1996 with blue , portion related to 1996-1997 with orange and then portion related to 1997-1998 with red can anyone please help me. [[alternative HTML version deleted]] __ 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, reproducible code. __ 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, reproducible code.
[R] how to write out a tree file with bootstrap from phangorn package
Dear R-helpers and Klaus, I would like to know how to write out a tree file with bootstrap from phangorn package. That tree file could be in newick format or others. I am new for phylogenetic operation in R. Could you please give me any directions on that? Thanks in advance. Best wishes, Jian-Feng, # as a example # I accomplished 1000 bootstrap simulation on a fit object (a maximum likelihood tree object) # how could I output a tree in newick format for tuning outside R? bs - bootstrap.pml(fit, bs=1000, optNni=T, optInv=T, multicore=T) [[alternative HTML version deleted]] __ 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, reproducible code.
[R] OO code organization
Greetings, I found the mistake. As this may be useful to others the details are as follows: In the source file derived_j/derived_j.R of every derived class the source of the base source(..base/base.R) was included (as you would in C or C++). This file contains the statement setGeneric(showsSelf,...) However when doing in file tests/test.R source(../base/base.R)source(../derived_1/derived_1.R)source(../derived_2/derived_1.R) source(../derived_n/derived_1.R) the repeated evaluation ofsetGeneric(showsSelf,...) is triggered. Apparently after each such call to setGeneric the slate is wiped clean and the previous definitions for methods of the generic deleted. Thus only the last definition in source(../derived_n/derived_1.R) survives. The inclusion of source(..base/base.R) is not needed and removal cures the problem. [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] How to convert data to 'normal' if they are in the form of standard scientific notations?
Hi Dear Jean Thanks a lot for your help. The reason I did not provide producible code is that my work started with reading in some large csv files, e.g. the data is not created by myself. But the data is from the same data provider so I would expect to receive data in exactly same data format. I use read.csv to read the data in. My major curious is that by using exactly same code as I provided in my email, e.g. 'as.factor' why one of them work (e.g. convert the numerical data to factor) but the other one remains numerical with scientific notation? So, in R, how do I check if the data format are different for these two files in their original csv files, which might cause the different results..? Also I tried your code and created some reproducible examples, but still can not make it work as in your example a-c(2.0e+9,2.1e+9) is.numeric(a) [1] TRUE a.f-factor(a) is.numeric(a.f) [1] FALSE is.factor(a.f) [1] TRUE so factor comes correctly print(a,digits=12) [1] 2.0e+09 2.1e+09 print(a, digits=21) [1] 20.000 21.000 b-c(3000,3100) print(b,digits=5) [1] 3.0e+07 3.1e+07 So the printed result depends probably on your local setting. See also ?options help page. And maybe also ?format and ?sprintf Regards Petr a-c(2.0e+9,2.1e+9) print(a,digits=4)[1] 20 21 # I expected to see 2.0e+9 here...? print(a,digits=7)[1] 20 21 # Think here I should expect same 2.0e+9? getOption(digits) # Checking my default number of digits now..[1] 7 b-c(3000, 3100) print(b)[1] 3000 3100 # This is what I expected to see print(b,digits=5)[1] 3000 3100 # I'm so confused why it is not working, e.g. printing 3.0e+9! getOption(digits) # checking again, but now I would expect it has being changed to 5[1] 7 Any thoughts please...? Thanks HJ On Mon, Aug 6, 2012 at 7:04 PM, Jean V Adams jvad...@usgs.gov wrote: HJ, You don't provide any reproducible code, so I had to make up my own. dat - data.frame(a=letters[1:5], x=c(20110911001084, 20110911001084, 20110911001084, 20110911001084, 20110911001084), y=c(2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12)) In my example, the long numbers print out without scientific notation. dat a x y 1 a 20110911001084 210004000 2 b 20110911001084 210004000 3 c 20110911001084 210004000 4 d 20110911001084 210004000 5 e 20110911001084 210004000 I can make it print with scientific notation using the digits argument to the print() function. print(dat, digits=3) ax y 1 a 2.01e+13 2.1e+12 2 b 2.01e+13 2.1e+12 3 c 2.01e+13 2.1e+12 4 d 2.01e+13 2.1e+12 5 e 2.01e+13 2.1e+12 What is your default number of digits? getOption(digits) Jean HJ YAN yhj...@googlemail.com wrote on 08/06/2012 11:14:17 AM: Dear R users I read two csv data files into R and called them Tem1 and Tem5. For the first column, data in Tem1 has 13 digits where in Tem5 there are 14 digits for each observation. Originally there are 'numerical' as can be seen in my code below. But how can I display/convert them using other form rather than scientific notations which seems a standard/default? I want them to be in the form like '20110911001084', but I'm very confused why when I used 'as.factor' call it works for my 'Tem1' but not for 'Tem5'...?? Many thanks! HJ Tem1[1:5,1][1] 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 2. 10004e+12 Tem5[1:5,1][1] 2.011091e+13 2.011091e+13 2.011091e+13 2. 011091e+13 2.011091e+13 class(Tem1[1:5,1])[1] numeric class(Tem5 [1:5,1])[1] numeric as.factor(Tem1[1:5,1])[1] 2.10004e+12 2. 10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 Levels: 2.10004e+12 as.factor(Tem5[1:5,1])[1] 20110911001084 20110911001084 20110911001084 20110911001084 20110911001084 Levels: 20110911001084 [[alternative HTML version deleted]] __ 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, reproducible code. __ 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, reproducible code.
[R] process evaluation packages (slightly off topic)
Dear all I need to perform some process evaluation. Sorry for not posting data and code - I do not have any, I ask only for pointing me to correct direction. Suppose I have several connected processes P1, P2, ..., Pn. Each process takes some time and have some capacity (let say like preparing a dinner for several persons - only one stove, limited capacity of utensils, heating and cooling takes some time) and some processes can by cyclic (fry onion in pan, put it aside, in the same pan fry meat, put an onion and some water and simmer for a while...). I can prepare some oriented graph (paper/pencil) or Word or drawing programme, I can also evaluate whole process by shading spreadsheet cells but those two tasks are not connected. Is there any R package/other software suitable for simplifying or helping in such tasks? E.g. When I prepare oriented graph with capacity and time for each node is there any automatic way to transfer this graph to timeline to see how long whole process will take, where are bottlenecks or so? Thank you Petr __ 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, reproducible code.
[R] Passing arguments to a function within a function ...
Hallo Everybody How do you specify arguments for a function used within another function? Here is my problem: I am reconstructing a calculator for the burden of disease due to air pollution from publications and tools published by the WHO. The calculations make use of published dose-response relationships for particular health end-points. This is then applied to populations with known or estimated levels of exposure and incidence rates to calcute the number of cases of each end-point attributable to each pollutant. I have functions that work on their own but when is have to use the one within the other, I don't know how to specify its arguments Here are example data and the functions: ## Example data frame with population, concentration and cases ## x = data.frame(Name = LETTERS[1:10], pop=sample(x=1000:1,size=10), Xbabies = 0.106, Xkids = 0.232, Xteens = 0.375, Xadults = 0.235, Xaged = 0.52, cases = sample(x=100:500,size=10), conc = sample(x=20:125,size=10) ) ## Two of the published dose-response relationships adult.CP.mortality = list(end.point = Cardiopulmanory mortality in adults over 30, pollutant = PM10, relationship = log-linear, beta = c(0.0562,0.1551,0.2541), Xpop = c(Xbabies,Xkids,Xteens,Xadults,Xaged)[4:5]) adult.LC.mortality = list(end.point = Lung Cancer mortality in adults over 30, pollutant = PM10, relationship = log-linear, beta = c(0.0856, 0.2322,0.3787), Xpop = c(Xbabies,Xkids,Xteens,Xadults,Xaged)[4:5]) ## Generic function to calculculate the Attributable cases for a pollutant in a population dose.response - function(pop, Xpop = 1, conc, base.conc=7.5, relationship = c(linear,log-linear)[1], beta=c(0.0006,0.0008,0.0010), cases=NULL, incidence.rate=NULL, par = c(low estimate,cental estimate,high estimate), verbose = FALSE ){ # Turn case rate into case number d - cases if(verbose==TRUE) message(d = , d) if(verbose==TRUE) message(pop = , pop) if(verbose==TRUE) message(beta = , beta) if(verbose==TRUE) message(conc = , conc) if(verbose==TRUE) message(base.coc = , base.conc) if(verbose==TRUE) message(relationship = , relationship) if(is.null(cases)==TRUE) {d - incidence.rate*pop} # use incidence rate if cases are not available if(relationship == linear) {RR = exp(beta*(conc-base.conc))} #RR=exp[beta(X-Xo)] if(relationship == log-linear) {RR = ((conc+1)/(base.conc+1))^beta} if(verbose==TRUE) message(RR = , RR) AF = (RR-1)/RR #AF=(RR-1)/RR if(verbose==TRUE) message(AF = , AF) AM = AF * d #AM = AF * cases if(verbose==TRUE) message(AM = , AM) out = data.frame(beta=beta,cases=d, RelativeRisk=RR,AttributableFraction=AF, AttributableInsidence=AM) rownames(out) = c(low estimate,cental estimate,high estimate) if(verbose==TRUE) message(dimentions of out = , dim(out)) out.idx = na.omit(match(par,rownames(out))) out[out.idx,] } ## Function using the published dose-response relationships with the generic function drep - function(pop.conc=x,sicklist=adult.CP.mortality,...){ dr.out=by(x,x$Name,function(x){z=as.data.frame((x)) dose.response(pop=z$pop*sum(z[,adult.CP.mortality$Xpop]), conc=z$conc, cases=z$cases, relationship = sicklist$relationship, beta = sicklist$beta, Xpop = sicklist$Xpop, par = c(low estimate,cental estimate,high estimate)[2] , verbose=FALSE ) } ) names(dr.out) - paste(sicklist$end.point,: , names(dr.out),sep=) dr.out } # This is where the trouble starts: What do I do if I need to pass the argument base.conc=10 or a different option for par= to dose.response() ? At the moment it works becuase it uses the default, which will not be valid in all cases. Thanks in advance Christiaan -- Christiaan Pauw Nova Institute www.nova.org.za __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
Re: [R] how to write out a tree file with bootstrap from phangorn package
Dear Klaus, Thanks a lot for your kind reply. That is really valuable for me. Best wishes, Jian-Feng, 2012/8/7 Klaus Schliep klaus.schl...@gmail.com Dear Jian-Feng, you can use the function plotBS. plotBS plots a tree and adds the support values (in %). This function also silently returns this tree: tree - plotBS(fit$tree, bs) # You can export than this tree using write.tree or write.nexus, e.g. write.tree(tree) Regards, Klaus On 8/7/12, Mao Jianfeng jianfeng@gmail.com wrote: Dear R-helpers and Klaus, I would like to know how to write out a tree file with bootstrap from phangorn package. That tree file could be in newick format or others. I am new for phylogenetic operation in R. Could you please give me any directions on that? Thanks in advance. Best wishes, Jian-Feng, # as a example # I accomplished 1000 bootstrap simulation on a fit object (a maximum likelihood tree object) # how could I output a tree in newick format for tuning outside R? bs - bootstrap.pml(fit, bs=1000, optNni=T, optInv=T, multicore=T) -- Jian-Feng, Mao Post doc Dept. of Molecular Biology Max Planck Institute for Developmental Biology Spemannstrasse 37-39 72076 Tuebingen Germany Blog: http://maojf.blogspot.com/ [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] test if elements of a character vector contain letters
On Mon, Aug 6, 2012 at 7:35 PM, Marc Schwartz marc_schwa...@me.com wrote: is.letter - function(x) grepl([[:alpha:]], x) is.number - function(x) grepl([[:digit:]], x) Quick follow-up question. I'm always reluctant to create functions that would resemble the method of a function (here, is() ), but would in fact not be a genuine method. So would there be any incompatibility between is() and is.letter(), given that the latter is not a method of the former? Is it good (or acceptable) practice to define is.letter() as above? Would is_letter() be better? Regards Liviu __ 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, reproducible code.
Re: [R] Passing arguments to a function within a function ...
Hello, Your problem seems simple, if I understand it correctly. Just add an extra argument to the caller function, drep(). drep - function(pop.conc = x, sicklist = adult.CP.mortality, par = cental estimate, ...) { # This extra argument dr.out = by(x, x$Name, function(x) { z = as.data.frame((x)) dose.response(pop = z$pop * sum(z[, adult.CP.mortality$Xpop]), conc = z$conc, cases = z$cases, relationship = sicklist$relationship, beta = sicklist$beta, Xpop = sicklist$Xpop, par = par, # Note the difference (!) verbose = FALSE) }) names(dr.out) - paste(sicklist$end.point, : , names(dr.out), sep = ) dr.out } In this case, the new argument has a default value.When the callee dose.response() is called, the first 'par' is the name one of it's arguments, the second 'par' is a value, the passed to value. The first is a name, it does not have a value and can not, for instance, be printed, only the second can. They are completely different in nature. And the same for other arguments, like 'base.conc'. Hope this helps, Rui Barradas Em 07-08-2012 09:52, christiaan pauw escreveu: Hallo Everybody How do you specify arguments for a function used within another function? Here is my problem: I am reconstructing a calculator for the burden of disease due to air pollution from publications and tools published by the WHO. The calculations make use of published dose-response relationships for particular health end-points. This is then applied to populations with known or estimated levels of exposure and incidence rates to calcute the number of cases of each end-point attributable to each pollutant. I have functions that work on their own but when is have to use the one within the other, I don't know how to specify its arguments Here are example data and the functions: ## Example data frame with population, concentration and cases ## x = data.frame(Name = LETTERS[1:10], pop=sample(x=1000:1,size=10), Xbabies = 0.106, Xkids = 0.232, Xteens = 0.375, Xadults = 0.235, Xaged = 0.52, cases = sample(x=100:500,size=10), conc = sample(x=20:125,size=10) ) ## Two of the published dose-response relationships adult.CP.mortality = list(end.point = Cardiopulmanory mortality in adults over 30, pollutant = PM10, relationship = log-linear, beta = c(0.0562,0.1551,0.2541), Xpop = c(Xbabies,Xkids,Xteens,Xadults,Xaged)[4:5]) adult.LC.mortality = list(end.point = Lung Cancer mortality in adults over 30, pollutant = PM10, relationship = log-linear, beta = c(0.0856, 0.2322,0.3787), Xpop = c(Xbabies,Xkids,Xteens,Xadults,Xaged)[4:5]) ## Generic function to calculculate the Attributable cases for a pollutant in a population dose.response - function(pop, Xpop = 1, conc, base.conc=7.5, relationship = c(linear,log-linear)[1], beta=c(0.0006,0.0008,0.0010), cases=NULL, incidence.rate=NULL, par = c(low estimate,cental estimate,high estimate), verbose = FALSE ){ # Turn case rate into case number d - cases if(verbose==TRUE) message(d = , d) if(verbose==TRUE) message(pop = , pop) if(verbose==TRUE) message(beta = , beta) if(verbose==TRUE) message(conc = , conc) if(verbose==TRUE) message(base.coc = , base.conc) if(verbose==TRUE) message(relationship = , relationship) if(is.null(cases)==TRUE) {d - incidence.rate*pop} # use incidence rate if cases are not available if(relationship == linear) {RR = exp(beta*(conc-base.conc))} #RR=exp[beta(X-Xo)] if(relationship == log-linear) {RR = ((conc+1)/(base.conc+1))^beta} if(verbose==TRUE) message(RR = , RR) AF = (RR-1)/RR #AF=(RR-1)/RR if(verbose==TRUE) message(AF = , AF) AM = AF * d #AM = AF * cases if(verbose==TRUE) message(AM = , AM) out = data.frame(beta=beta,cases=d, RelativeRisk=RR,AttributableFraction=AF, AttributableInsidence=AM) rownames(out) = c(low estimate,cental estimate,high estimate) if(verbose==TRUE) message(dimentions of out = , dim(out)) out.idx = na.omit(match(par,rownames(out))) out[out.idx,] } ## Function using the published dose-response relationships with the generic function drep - function(pop.conc=x,sicklist=adult.CP.mortality,...){
Re: [R] How to convert data to 'normal' if they are in the form of standard scientific notations?
Try: options(scipen = 9) Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Tue, Aug 7, 2012 at 11:11 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Hi Dear Jean Thanks a lot for your help. The reason I did not provide producible code is that my work started with reading in some large csv files, e.g. the data is not created by myself. But the data is from the same data provider so I would expect to receive data in exactly same data format. I use read.csv to read the data in. My major curious is that by using exactly same code as I provided in my email, e.g. 'as.factor' why one of them work (e.g. convert the numerical data to factor) but the other one remains numerical with scientific notation? So, in R, how do I check if the data format are different for these two files in their original csv files, which might cause the different results..? Also I tried your code and created some reproducible examples, but still can not make it work as in your example a-c(2.0e+9,2.1e+9) is.numeric(a) [1] TRUE a.f-factor(a) is.numeric(a.f) [1] FALSE is.factor(a.f) [1] TRUE so factor comes correctly print(a,digits=12) [1] 2.0e+09 2.1e+09 print(a, digits=21) [1] 20.000 21.000 b-c(3000,3100) print(b,digits=5) [1] 3.0e+07 3.1e+07 So the printed result depends probably on your local setting. See also ?options help page. And maybe also ?format and ?sprintf Regards Petr a-c(2.0e+9,2.1e+9) print(a,digits=4)[1] 20 21 # I expected to see 2.0e+9 here...? print(a,digits=7)[1] 20 21 # Think here I should expect same 2.0e+9? getOption(digits) # Checking my default number of digits now..[1] 7 b-c(3000, 3100) print(b)[1] 3000 3100 # This is what I expected to see print(b,digits=5)[1] 3000 3100 # I'm so confused why it is not working, e.g. printing 3.0e+9! getOption(digits) # checking again, but now I would expect it has being changed to 5[1] 7 Any thoughts please...? Thanks HJ On Mon, Aug 6, 2012 at 7:04 PM, Jean V Adams jvad...@usgs.gov wrote: HJ, You don't provide any reproducible code, so I had to make up my own. dat - data.frame(a=letters[1:5], x=c(20110911001084, 20110911001084, 20110911001084, 20110911001084, 20110911001084), y=c(2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12)) In my example, the long numbers print out without scientific notation. dat a x y 1 a 20110911001084 210004000 2 b 20110911001084 210004000 3 c 20110911001084 210004000 4 d 20110911001084 210004000 5 e 20110911001084 210004000 I can make it print with scientific notation using the digits argument to the print() function. print(dat, digits=3) ax y 1 a 2.01e+13 2.1e+12 2 b 2.01e+13 2.1e+12 3 c 2.01e+13 2.1e+12 4 d 2.01e+13 2.1e+12 5 e 2.01e+13 2.1e+12 What is your default number of digits? getOption(digits) Jean HJ YAN yhj...@googlemail.com wrote on 08/06/2012 11:14:17 AM: Dear R users I read two csv data files into R and called them Tem1 and Tem5. For the first column, data in Tem1 has 13 digits where in Tem5 there are 14 digits for each observation. Originally there are 'numerical' as can be seen in my code below. But how can I display/convert them using other form rather than scientific notations which seems a standard/default? I want them to be in the form like '20110911001084', but I'm very confused why when I used 'as.factor' call it works for my 'Tem1' but not for 'Tem5'...?? Many thanks! HJ Tem1[1:5,1][1] 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 2. 10004e+12 Tem5[1:5,1][1] 2.011091e+13 2.011091e+13 2.011091e+13 2. 011091e+13 2.011091e+13 class(Tem1[1:5,1])[1] numeric class(Tem5 [1:5,1])[1] numeric as.factor(Tem1[1:5,1])[1] 2.10004e+12 2. 10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 Levels: 2.10004e+12 as.factor(Tem5[1:5,1])[1] 20110911001084 20110911001084 20110911001084 20110911001084 20110911001084 Levels: 20110911001084 [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] Passing arguments to a function within a function ...
Thanks Rui It works. On 7 August 2012 11:34, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Your problem seems simple, if I understand it correctly. Just add an extra argument to the caller function, drep(). Christiaan Pauw Nova Institute www.nova.org.za __ 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, reproducible code.
Re: [R] Force evaluation of a symbol when a function is created
Here's one more way. It seems to me this is the most R-like way to do what you want: multiply_by_Y - function(Y) { force(Y) function(x) x*Y } F - multiply_by_Y(3) The force call forces Y to be evaluated at that point, so its value is fixed from that point forward. Duncan Murdoch On 12-08-06 5:07 PM, Schoenfeld, David Alan,Ph.D.,Biostatistics wrote: I am porting a program in matlab to R, The problem is that Matlab has a feature where symbols that aren't arguments are evaluated immediately. That is: Y=3 F=@(x) x*Y Will yield a function such that F(2)=6. If later say. Y=4 then F(2) will still equal 6. R on the other hand has lazy evaluation. F-function(x){x*Y} Will do the following Y=3 F(2)=6 Y=4 F(2)=8. Does anyone know of away to defeat lazy evaluation in R so that I can easily simulate the Matlab behavior. I know that I can live without this in ordinary programming but it would make my port much easier. Thanks. The information in this e-mail is intended only for the ...{{dropped:14}} __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Overlay Histogram
Thanks a lot. Hannah 2012/8/6 R. Michael Weylandt michael.weyla...@gmail.com See example(layout) for one idea. I think you might also want to look into rug plots. Best, Michael On Mon, Aug 6, 2012 at 2:40 PM, li li hannah@gmail.com wrote: Dear all, For two sets of random variables, say, x - rnorm(1000, 10, 10) and y - rnorm(1000. 3, 20). Is there any way to overlay the histograms (and density curves) of x and y on the plot of y vs. x? The histogram of x is on the x axis and that of y is on the y axis. The density curve here is to approximate the shape of the distribution and does not have to have area 1. Thank you in advance. Hannah [[alternative HTML version deleted]] __ 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, reproducible code. [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] add leading zeros
Hello On Fri, Jul 27, 2012 at 6:54 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Much easier than you think: x - c(1L, 9000L) sprintf(%05i,x) For anyone interested, I came up with a small wrapper for the above: add.lead - function(x, width=max(nchar(x))){ sprintf(paste('%0', width, 'i', sep=''), x) } x - c(1L, 15L, 234L, 9000L) (xa - add.lead(x)) [1] 0001 0015 0234 9000 nchar(xa) [1] 4 4 4 4 (xb - add.lead(x, 5)) [1] 1 00015 00234 09000 nchar(xb) [1] 5 5 5 5 (xc - add.lead(x, 15)) [1] 001 015 234 0009000 nchar(xc) [1] 15 15 15 15 Regards Liviu __ 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, reproducible code.
[R] Error with convUL (PBSmapping)
Hi all, I'm trying to use the function convUL from the Package PBSmapping but i get i weird error with my data but also with the example in the convUL's help. Here is the example script with the error message: data(nepacLL, package=PBSmapping) #--- set the zone attribute #--- use a zone that is most central to the mapped region attr(nepacLL, zone) - 6 #--- convert and plot the result nepacUTM - convUL(nepacLL) Error in .C(convUL, inXY = as.double(inXY), inVerts = as.integer(inVerts), : C symbol name convUL not in DLL for package PBSmapping someone can help me? Thanks [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] Parallel runs of an external executable with snow in local
On 06.08.2012 17:07, Xavier Portell/UPC wrote: Thanks Uwe but, actually, I did so. Since #8220;filetorun.exe#8221; looks in the current folder for #8220;input.txt#8221;, I tried moving all needed files to a newly created temporary folder #8220;tmp.id#8221; (say, tmp.1) and running the executable. This works fine by doing it directly from the windows command line but not by doing it from R, since using: # System(#8220;C:/Users/#8230;/currentworkdirectory/temp.1/filetorun.exe#8221;) # Causes #8220;filetorun.exe#8221; to look for #8220;input.txt#8221; in #8220;C:/Users/#8230;/currentworkdirectory#8221;. So there#8217;s no point on moving files to a folder, it seems that input file must be situated in the current R work directory. Does anybody know how to avoid this behaviour? Errr, you mean you cannot specify an input for filetorun.exe? If so, you can ask R to switch to use another working directory for each instance. Best, Uwe Ligges I hope I#8217;ve explained that clearly, Xavier Portell Canal, PhD candidate. Department of Agri-food Engineering, Universitat Politècnica de Catalunya -Uwe Ligges lig...@statistik.tu-dortmund.de ha escrit: - Per a: Xavier Portell/UPC xavier.port...@upc.edu De: Uwe Ligges lig...@statistik.tu-dortmund.de Data: 05/08/2012 07:46PM a/c: r-help@r-project.org Assumpte: Re: [R] Parallel runs of an external executable with snow in local On 03.08.2012 19:21, Xavier Portell/UPC wrote: Hi everyone, I'm aiming to run an external executable (say filetorun.EXE) in parallel. The external executable collect needed data from a file, say input.txt and, in turn,generates several output files, say output.txt. I need to generate input.txt, run the executable and keep input.txt and output.txt. I'm using Windows 7, R version 2.15.1 (2012-06-22) on RStudio and platform: i386.pc.mingw32/i386 (32-bit). My first attempt was a R code which, by using System(filetorun.EXE, intern = F, ignore.stdout = F, ignore.stderr = F, wait = T, input = NULL, show.output.on.console = T, minimized = F, invisible = T)) , ran the executable and kept required files to a conveniently named folder. After that I changed my previous R script so I could use the function lapply().This script apparently worked fine. Finally, I tried to parallelize the problem by using snow and parLapply(). The resulting script looks like this: ## Not run # library(snow)cl - makeCluster(3, type = SOCK) clusterExport(cl,list('param.esp','copy.files','for12.template','program.executor')) parLapply(cl,a.list,a.function))stopCluster(cl) # ##End not run Although it runs, the parallelized version is messing up the input parameters to pass to the executable (see table below, where parameters P1 and P2 are considered. .s comes from the serial code and .p from the parallelized one): s r P1.s P2.s P1.p P2.p 1 1 1 1.0 3.00 2.0 3.00 2 2 1 1.5 3.00 2.0 3.75 3 3 1 2.0 3.00 2.0 3.00 4 4 1 1.0 3.75 1.5 3.00 5 5 1 1.5 3.75 1.5 3.00 6 6 1 2.0 3.75 2.0 3.75 My first thought to avoid the described behaviour was creating a temporary file, say tmp.id with id being an identification run number, and copying filetorun.EXE and Input.txt to tmp.id. However, while doing so, I realised that although running the correct filetorun.EXE copy (i.e., the one in tmp.id) R looks for input.txt in the work directory. Not sure about the real setup, but you can actually specify the path, not only filenames. Uwe Ligges I've been looking thoroughly for a solution but I got nothing. Thanks for any help in advance, Xavier Portell Canal PhD candidate Department of Agri-food engineering, Universitat Politècnica de Catalunya __ 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, reproducible code. __ 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, reproducible code.
Re: [R] process evaluation packages (slightly off topic)
Search on R package Gantt, where you will find, among others, http://cran.r-project.org/web/packages/plan/plan.pdf -- Bert On Tue, Aug 7, 2012 at 1:28 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Dear all I need to perform some process evaluation. Sorry for not posting data and code - I do not have any, I ask only for pointing me to correct direction. Suppose I have several connected processes P1, P2, ..., Pn. Each process takes some time and have some capacity (let say like preparing a dinner for several persons - only one stove, limited capacity of utensils, heating and cooling takes some time) and some processes can by cyclic (fry onion in pan, put it aside, in the same pan fry meat, put an onion and some water and simmer for a while...). I can prepare some oriented graph (paper/pencil) or Word or drawing programme, I can also evaluate whole process by shading spreadsheet cells but those two tasks are not connected. Is there any R package/other software suitable for simplifying or helping in such tasks? E.g. When I prepare oriented graph with capacity and time for each node is there any automatic way to transfer this graph to timeline to see how long whole process will take, where are bottlenecks or so? Thank you Petr __ 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, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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, reproducible code.
Re: [R] Force evaluation of a symbol when a function is created
Duncan, et.al: Many thanks: let the closure do the work automatically rather than manually manipulating it. However, in the spirit of the OP's original request, I believe the call would be: Y - 3 ## That is, Y gets a value at some prior point, perhaps programmatically. F - multiply_by_Y(Y) # ... F picks up this value implicitly -- no need for explicit assignment. But then there is no need for force(), is there? fy - function(Y)function(x) x*Y Y - 2 F - fy(Y) F(5) [1] 10 Y - 3 F(5) [1] 10 G - fy(Y) G(5) [1] 15 That is, one simply relies on lexical scoping/closures to retain the value of Y used as a free variable in function(x)x*Y when it is defined. No need to explicitly force() it. If wrong, I would be grateful for correction. This appears to me to duplicate the Matlab behavior rather closely. -- Bert On Tue, Aug 7, 2012 at 3:48 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote: Here's one more way. It seems to me this is the most R-like way to do what you want: multiply_by_Y - function(Y) { force(Y) function(x) x*Y } F - multiply_by_Y(3) The force call forces Y to be evaluated at that point, so its value is fixed from that point forward. Duncan Murdoch On 12-08-06 5:07 PM, Schoenfeld, David Alan,Ph.D.,Biostatistics wrote: I am porting a program in matlab to R, The problem is that Matlab has a feature where symbols that aren't arguments are evaluated immediately. That is: Y=3 F=@(x) x*Y Will yield a function such that F(2)=6. If later say. Y=4 then F(2) will still equal 6. R on the other hand has lazy evaluation. F-function(x){x*Y} Will do the following Y=3 F(2)=6 Y=4 F(2)=8. Does anyone know of away to defeat lazy evaluation in R so that I can easily simulate the Matlab behavior. I know that I can live without this in ordinary programming but it would make my port much easier. Thanks. The information in this e-mail is intended only for the ...{{dropped:14}} __ 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, reproducible code. __ 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, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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, reproducible code.
Re: [R] Overlay Histogram
I cannot see any obvious way to do this. Ben Gunter's suggestion re layout makes sense. Here is a version using grid and ggplot2. Note I shamelessly stole code to due it. library(ggplot2) library(grid) dd - data.frame(x = rnorm(1000, 10, 10), y = rnorm(1000, 3, 20)) # From https://stat.ethz.ch/pipermail/r-help/2011-June/280588.html p1 - ggplot(dd, aes(x=x)) + geom_histogram(aes(y=..density..), fill=red, colour=black)+ geom_density(colour=black, adjust=4) + opts(title=Normal Random Sample) p2 - ggplot(dd, aes(x=y)) + geom_histogram(aes(y=..density..), fill=blue, colour=black)+ geom_density(colour=black, adjust=4) + opts(title=Normal Random Sample) + coord_flip() # From StackOverflow http://stackoverflow.com/questions/9490482/combined-plot-of-ggplot2-not-in-a-single-plot-using-par-or-layout-functio # this simplifies the vp statement # otherwise we would have to use something like # print(plot5 , vp = viewport(layout.pos.row = 2, layout.pos.col = 1:2)) # and so on for the rest of the plots. vplayout - function(x, y) viewport(layout.pos.row = x, layout.pos.col = y) grid.newpage() pushViewport(viewport(layout = grid.layout(2, 1))) print(p1, vp = vplayout(1, 1)) print(p2, vp = vplayout(2, 1)) John Kane Kingston ON Canada -Original Message- From: hannah@gmail.com Sent: Mon, 6 Aug 2012 15:40:55 -0400 To: r-help@r-project.org Subject: [R] Overlay Histogram Dear all, For two sets of random variables, say, x - rnorm(1000, 10, 10) and y - rnorm(1000. 3, 20). Is there any way to overlay the histograms (and density curves) of x and y on the plot of y vs. x? The histogram of x is on the x axis and that of y is on the y axis. The density curve here is to approximate the shape of the distribution and does not have to have area 1. Thank you in advance. Hannah [[alternative HTML version deleted]] __ 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, reproducible code. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ 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, reproducible code.
Re: [R] Plotting Where People Live on a U.S. Map
Hi Ricardo, I wonder if this is like the other site I found recently on the web: http://www.gpsvisualizer.com/geocoder/ Thanks for sending me this resource. I will check it out. Dan From: Ricardo Pietrobon [mailto:rpie...@duke.edu] Sent: Monday, August 06, 2012 10:44 PM To: Lopez, Dan Cc: Sarah Goslee; R help (r-help@r-project.org) Subject: Re: [R] Plotting Where People Live on a U.S. Map Dan, google refine http://goo.gl/AeKml can actually transform zip codes into longitude/latitude - http://goo.gl/1HDWb will show you how to do this from street adresses, but it should also work from city names -- i think it will allocate a default long/lat for a city, but not sure of the exact mechanism On Fri, Aug 3, 2012 at 1:10 PM, Lopez, Dan lopez...@llnl.govmailto:lopez...@llnl.gov wrote: Thank you! Dan From: Sarah Goslee [mailto:sarah.gos...@gmail.commailto:sarah.gos...@gmail.com] Sent: Thursday, August 02, 2012 5:51 PM To: Lopez, Dan Cc: R help (r-help@r-project.orgmailto:r-help@r-project.org) Subject: Re: [R] Plotting Where People Live on a U.S. Map Hi Dan, For question 1, yes you'll need geographic coordinates. I thinknit's possible to get a shapefile of zip codes, but maybe someone else will know the details. For #2, you probably want maps instead of map, and you need to load a package before you can use it: install.packages(maps) library(maps) and then your code. Sarah On Thursday, August 2, 2012, Lopez, Dan wrote: Hi, QUESTION TOPIC #1 I have some data I want to plot on a map. But what I have are home addresses: street, City, State, complete postal code--i.e 95377-1234. Is there a way to plot this data or do I need latitudinal and longitude coordinates? If so how do I convert them? Is there a package that will do the conversion in R? QUESTION TOPIC #2 I was trying to experiment with this code that I found at the site below but got a message that indicated that the map function is not found. So I tried installing the maps package but got the below message. Is there an alternative way of doing this (please refer to URL below)? # The message I got: install.packages(map) Warning message: package 'map' is not available (for R version 2.15.0) # The code I tried to run: states - data.frame(map(state, plot=FALSE)[c(x,y)]) colnames(states) - c(Lon,Lat) ggplot(states, aes(x=Lon, y=Lat)) + geom_path() + geom_point(alpha=0.6,size=0.3,data=subway) # Where I got the code from and also an image of what I am attempting to do (please enter this in your URL) http://www.google.com/imgres?um=1hl=enbiw=1790bih=845tbm=ischtbnid=4rMjXYA_w1qDiM:imgrefurl=http://www.informaniac.net/docid=SJqcsPghztrj0Mimgurl=http://lh5.ggpht.com/_yBbodrC25kU/Ta6Ifqr0ZLI/AAABRCg/98rIF-kMMns/map%25255B7%25255D.pngw=512h=319ei=mgsbUIzqJuKbiAL5v4DQDgzoom=1iact=hcvpx=176vpy=477dur=5741hovh=177hovw=285tx=110ty=113sig=117496213270544868088page=2tbnh=125tbnw=200start=32ndsp=40ved=1t:429,r:0,s:32,i:175 Dan [[alternative HTML version deleted]] __ R-help@r-project.orgmailto:R-help@r-project.orgjavascript:; 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, reproducible code. -- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org [[alternative HTML version deleted]] __ R-help@r-project.orgmailto: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, reproducible code. [[alternative HTML version deleted]] __ 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, reproducible code.
[R] Styling gridExtra's title and left labels
Hi, I'm using the gridExtra package to combine some graphs like in the arrangeGrob example. Each of the graphs has a title but they appear much larger than the overall combined plot title and left axis label. Does anyone know how I can control the style / size of the gridExtra labels? library(gridExtra) library(ggplot2) dsamp - diamonds[sample(nrow(diamonds), 1000), ] p1 - qplot(carat, price, data=dsamp, colour=clarity) p2 - qplot(carat, price, data=dsamp, colour=clarity, geom=path) tmp - ggplot_gtable(ggplot_build(p1)) leg - which(sapply(tmp$grobs, function(x) x$name) == guide-box) legend - tmp$grobs[[leg]] grid.arrange(arrangeGrob(p1 + theme(legend.position=none) + ggtitle(Scatter Plot), p2 + theme(legend.position=none) + ggtitle(Line Plot), main =this is a title, left = This is my global Y-axis title), legend, widths=unit.c(unit(1, npc) - legend$width, legend$width), nrow=1) -- View this message in context: http://r.789695.n4.nabble.com/Styling-gridExtra-s-title-and-left-labels-tp4639388.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] Overlapping a Plot with Dataframe
Hello Everyone, I am trying to overlap a plot with a data set in the form of a data frame. Its very easy to overlap the data using points function. But the only problem I am facing is Standard deviation bar on the plot. data - data.frame( x = c(3.00,2.00,3.80,2.40,2.00), error = c(0.0,0.4,1.1,0.7,0.5) ) I tried plotrix, segments but they are making a new plot with data points n error bar. I want to Overlap this data sets on a plot with its Error bar. Can anyone help me with it. Many Thanks, Himanshu -- View this message in context: http://r.789695.n4.nabble.com/Overlapping-a-Plot-with-Dataframe-tp4639396.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] time plot
hi, i am new to using R if someone can please tell me how to change the angel of the graph to a 45 degree angel. [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] ERROR : cannot allocate vector of size (in MB GB)
How is possible to split a .csv file in terms of size (in KiloByte) ? -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Tuesday, July 24, 2012 11:30 PM To: Akkara, Antony (GE Energy, Non-GE) Cc: r-help@r-project.org Subject: Re: [R] ERROR : cannot allocate vector of size (in MB GB) try this: input - file(yourLargeCSV, r) fileNo - 1 repeat{ myLines - readLines(input, n=10) # 100K lines / file if (length(myLines) == 0) break writeLines(myLines, sprintf(output%03d.csv, fileNo)) fileNo - fileNo + 1 } close(input) On Tue, Jul 24, 2012 at 9:45 AM, Rantony antony.akk...@ge.com wrote: Hi, Here in R, I need to load a huge file(.csv) , its size is 200MB. [may come more than 1GB sometimes]. When i tried to load into a variable it taking too much of time and after that when i do cbind by groups, getting an error like this Error: cannot allocate vector of size 82.4 Mb My requirement is, spilt data from Huge-size-file(.csv) to no. of small csv files. Here i will give no of lines to be 'split by' as input. Below i give my code --- SplitLargeCSVToMany - function(DataMatrix,Destination,NoOfLineToGroup) { test - data.frame(read.csv(DataMatrix)) # create groups No.of rows group - rep(1:NROW(test), each=NoOfLineToGroup) new.test - cbind(test, group=group) new.test2 - new.test new.test2[,ncol(new.test2)] - NULL # now get indices to write out indices - split(seq(nrow(test)), new.test[, 'group']) # now write out the files for (i in names(indices)) { write.csv(new.test2[indices[[i]],], file=paste(Destination,data., i, .csv, sep=),row.names=FALSE) } } - My system Configuration is, Intel Core2 Duo speed : 3GHz 2 GB RAM OS: Windows-XP [ServicePack-3] --- Any hope to solve this issue ? Thanks in advance, Antony. -- View this message in context: http://r.789695.n4.nabble.com/ERROR-cannot-allocate-vector-of-size-in- MB-GB-tp4637597.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. __ 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, reproducible code.
[R] Problem with global variable building a package
Hi,  My name is Eva and this is my first message here. My English is not very good, but I hope you can understand my question, in the context of an academic project.  I have developed several functions in R and the idea is that the user can access functions in order to:  1)     Alter parameters in relation with data and type of analysis. 2)     Run statistical analysis (Text and pdf files with results will be generated). 3)     View the value of the most important parameters.  All the parameters I need are stored in a list object, and this list is used in all the functions along the cycle performed by the user, but I would like the user does not need to pass the name of the list as argument when he/she runs the different functions, so I think I need to treat the list as a global variable.  Firstly, I used the global assignment operator (â-â); secondly, I used âgetâ and âassignâ functions and even I used a new.env() in order to use a new environment exclusively for my list. However, when I try to build a package with all my functions I donât reach this end, because of an error in parse process.  My question for you is the following: taking into account that my end is to build a package, what can I do with this âglobalâ list?. How can I treat it?.  Thanks in advance.  Regards, Eva  [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] label_wrap_gen question
On 8/6/2012 9:07 PM, vd3000 wrote: Hi, all I am trying to use the label_wrap_gen function in this website. https://github.com/hadley/ggplot2/wiki/labeller I tried to make a long name like this Light and heavy good vehicles (diesel) -\nGVX f2 = facet_grid(vehicle ~ ., labeller=label_wrap_gen(width=15)) eventually, I got something like this in my label... *Light and heavy good vehicles (diesel) - GVX* I suppose the -n could break GVX to the next row but it failed... Is it a bug? or it has been overpowered by width=15?? so -n could not function well? Eventually I tried f2 = facet_grid(vehicle ~.) The -n did work and I got *Light and heavy good vehicles (diesel) - GVX* But it also failed because I could not show all the label properly... Anyone has idea about this? It is freaking me out~ I am sorry I am stupid on R Thanks in advance. VD label_wrap_gen uses strwrap to do the heavy lifting of figuring out how to actually split the text into lines. From the help page of strwrap, Whitespace (space, tab or newline characters) in the input is destroyed., so this is documented behavior. I don't see an option to strwrap to suppress this behavior. -- View this message in context: http://r.789695.n4.nabble.com/label-wrap-gen-question-tp4639364.html Sent from the R help mailing list archive at Nabble.com. -- Brian S. Diggs, PhD Senior Research Associate, Department of Surgery Oregon Health Science University __ 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, reproducible code.
[R] R enquire
Dear Madam or Mister, My name is Manuel Montesino and I am a PhD student at the University of Copenhagen. I am not a programmer myself, but my thesis requires the combined use of R and a model. I would be very grateful if you help me with the following issue; I am trying to combine a small piece of code written in Fortran 77 with R. The F77 code aims to select data from a library and write it into a new file (1) The F77 code has being compiled using gFortran and the statements declared at (2). Once everything is done, the dynamic library is loaded and run in R using the piece of code showed at (3).Then, a runtime error appears when R is asked to run the subroutine (weathersel), R closes down and the selected weather data file is created. Exploring the error a bit further shows that the loop stops at the line 1917. The subroutine works for lower number of lines and the subroutine works if only the last lines of the weather library are explored. This seems to me that there is a limit in the number of iterations that R can handle depending on the memory available at the computer. However, I am not sure. Why appears the runtime error? Is it true that there is a limitation in the loops that R can handle? Is it because a piece of F77! code? Thank you very much in advance for your help and I hope to hear from you soon. Best wishes, Manuel. (1)F77 code subroutine weathersel(GRD,YR,SWJD,HRVJD) C== C -- C -- C INTEGER :: GRID,YEAR,JDAY,A,B,C,D REAL :: LAT,LONG,MINT,MAXT,TEMP REAL :: PREC,WIND,RAD,RH,DELTA,ET C--- C ** Identifying the variables C A=GRD B=YR C=SWJD D=HRVJD C C- C ** Opening the files C open(unit=16,file='Weather library\weather.dat',status='old') Open the file with the weather data. open(unit=18,file='weathersel.dat') Create a new file. C C- C ** Crating the library C DO I=1,12922 From the first to the last row in the weather data... READ(16,*)GRID,LAT,LONG,YEAR,JDAY,MINT,MAXT, ...read the weather variables in the row... TEMP,PREC,WIND,RAD,RH,DELTA,ET IF(GRID.EQ.A)THEN ...if the read location equals to the solicited location... IF(YEAR.EQ.B.AND.JDAY.GT.C.AND.JDAY.LT.D)THEN (and other options) WRITE(18,*)JDAY,MAXT,MINT,TEMP,RH,PREC,WIND,RAD ...then write the data in the new file in that order... END IF END IF ENDDO C END ...end the program (2)gFortran compilation: gfortran -c -fdefault-real-8 -Wall weathrsel.for gfortran -shared -o WEATHRSEL.DLL weathrsel.o del *.o pause (3)R code calling the dynamic library #Load the library dyn.load(WEATHRSEL.DLL) # Define the parameters GRD-23 # Grid YR-1992 # Year SWJD-210 # Showing julian day HRVJD-260 # Harvesting julian day # Run the code .Fortran('weathersel',GRD,YR,SWJD,HRVJD) # Stop using the library dyn.unload(WEATHRSEL.DLL) [[alternative HTML version deleted]] __ 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, reproducible code.
[R] Unable to download R package
Hi, I'm new to R. I'm using the R Gui and have tried to install additional packeges. When I choose Packages/Install package(s) I get the following error... utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified Can someone -- ** Irish Life Investment Managers Limited is regulated by the Central Bank of Ireland. Irish Life Investment Managers Limited Registered Office: Beresford Court, Beresford Place, Dublin 1. Registered in Ireland Number 116000 While Irish Life Investment Managers uses reasonable efforts to ensure that the information contained in this email is current, accurate and complete at the date of publication, no representations or warranties are made (express or implied) as to the reliability, accuracy or completeness of such information. Irish Life Investment Managers therefore cannot be held liable for any loss arising directly or indirectly from the use of, or any action taken in reliance on, any information contained in this email. This material is for information only and does not constitute an offer or recommendation to buy or sell any investment, or subscribe to any investment management or advisory service. It is intended for the use of institutional and other professional investors. Past performance is not indicative of future results. The value of funds we manage may fall as well as rise. This email and any files transmitted with it are confide...{{dropped:16}} __ 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, reproducible code.
Re: [R] how to write out a tree file with bootstrap from phangorn package
Dear Jian-Feng, you can use the function plotBS. plotBS plots a tree and adds the support values (in %). This function also silently returns this tree: tree - plotBS(fit$tree, bs) # You can export than this tree using write.tree or write.nexus, e.g. write.tree(tree) Regards, Klaus On 8/7/12, Mao Jianfeng jianfeng@gmail.com wrote: Dear R-helpers and Klaus, I would like to know how to write out a tree file with bootstrap from phangorn package. That tree file could be in newick format or others. I am new for phylogenetic operation in R. Could you please give me any directions on that? Thanks in advance. Best wishes, Jian-Feng, # as a example # I accomplished 1000 bootstrap simulation on a fit object (a maximum likelihood tree object) # how could I output a tree in newick format for tuning outside R? bs - bootstrap.pml(fit, bs=1000, optNni=T, optInv=T, multicore=T) __ 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, reproducible code.
[R] Hist function
Hello everyone, First i explain my aim. I would like to calculate the frecuency of temperature (datos.mx1, columns 3-6) for each month with the thresholds of table lf.med and lc.med. numero1 - hist(subset(datos.mx1[,3], datos.mx1$Mes==1),plot=FALSE,breaks=c(min(datos.mx1[,3]),lf.med[1,2],lc.med[1,2],max(datos.mx1[,3]))) # First month and only the first weather station (column 3) I now have to apply the above command for all 12 months at all the weather stations. I've been trying to get with a for-loop, but without success. How can i do it the best way? After this command, i'm only interested in the part of $counts. I hope someone can help me. Any help is greatly appreciated!!! Thank you, everybody`!! datos.mx1 Fecha Mes Serra.da.Foladoira Santiago Sergude Rio.Do.Sol 101.01.2006 14.1 14.4 9.35.7 202.01.2006 15.5 9.811.07.6 303.01.2006 19.9 13.012.79.9 404.01.2006 19.7 13.312.79.7 505.01.2006 1 10.2 12.213.18.0 606.01.2006 14.2 14.210.25.4 707.01.2006 11.0 6.9 3.23.2 . . ...etc. lf.med Mes Serra.da.Foladoira Santiago Sergude Rio.Do.Sol 11 7.833702 8.811945 8.122162 7.899513 22 7.766978 8.592693 8.041483 7.887327 33 7.864609 8.861457 8.385405 8.080646 44 8.204098 8.986149 8.803744 8.438141 55 8.716766 9.317366 9.385637 8.977087 66 9.377651 9.874497 10.194340 9.686213 77 9.838470 10.055430 10.447219 9.991618 88 10.046204 10.099868 10.520872 10.098330 99 9.780911 10.038629 10.156048 9.851299 10 10 9.425308 9.779886 9.646881 9.496192 11 11 8.417168 9.346191 8.791033 8.549046 12 12 7.968706 8.795800 8.038208 8.017603 lc.med Mes Serra.da.Foladoira Santiago Sergude Rio.Do.Sol 11 21.29353 26.62562 23.71784 22.04786 22 21.97787 27.07213 25.68340 23.39020 33 22.69749 27.42612 26.97889 24.33741 44 24.49683 29.21054 29.76726 26.59280 55 25.24233 29.83056 30.75132 27.28277 66 26.46742 30.70485 33.02328 28.77892 77 27.72731 30.24450 34.28162 29.97767 88 27.64356 30.84850 34.52161 30.00666 99 27.21998 31.18390 33.19776 29.54618 10 10 25.35830 28.83195 29.63192 26.42831 11 11 22.37895 26.38226 25.69239 23.47575 12 12 21.44064 26.09142 23.99676 22.26208 [[alternative HTML version deleted]] __ 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, reproducible code.
[R] What is the difference between probe level data and summarized data
Hi all, What is the difference between probe level data and summarized data. Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/What-is-the-difference-between-probe-level-data-and-summarized-data-tp4639376.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] (no subject)
hi, I'm working on a research project where we're looking at the changing resonances in femur bones during hip replacement operations. basically, I've got a spreadsheet with one column listing frequencies in 5Hz bands and 3 columns showing the amplitude of that frequency when the bone is loose, medium to tight (referring to the tension of the reamer/chisel creating a cavity for the hip replacement). I'm coming at this more from a sound perspective so I would really appreciate some advice from anyone with a handle on stats, could correlograms be used in presenting this data? When working with a large number of bone samples, can anyone recommend a good method of recognizing and mapping these changes? All the best, Bob__ 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, reproducible code.
[R] predicting test dataset response from training dataset with randomForest
Hi I am new to R so I apologize if this is trivial. I am trying to predict the resistance or susceptibility of my sequences to a certain drug with a randomForest function from a file with amino acids on each of the positions in the protein. I ran the following: library(randomForest) path - C:\\... path2 - ... name - ... actualFileName - paste(path, path2, name, .txt, sep=) # reading in the training dataset dat1 - read.table(actualFileName, header=TRUE, sep=\t, colClasses=character) head(dat1) X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 ... SR 1 M K V K L L V L L C T F T A T Y A ... suscep 2 M K V K L L V L L C T F A A T Y A ... suscep 3 M K V K L L V L L C T F T A T Y A ... resist ... # some of the important sites identified by fisher test dat1$X13 - as.factor(dat1$X13) dat1$X52 - as.factor(dat1$X52) dat1$X53 - as.factor(dat1$X53) dat1$X64 - as.factor(dat1$X64) dat1$X85 - as.factor(dat1$X85) dat1$X99 - as.factor(dat1$X99) dat1$X111 - as.factor(dat1$X111) dat1$X142 - as.factor(dat1$X142) dat1$X157 - as.factor(dat1$X157) dat1$X158 - as.factor(dat1$X158) dat1$X162 - as.factor(dat1$X162) dat1$X169 - as.factor(dat1$X169) dat1$X200 - as.factor(dat1$X200) dat1$X202 - as.factor(dat1$X202) dat1$X203 - as.factor(dat1$X203) dat1$X205 - as.factor(dat1$X205) dat1$X206 - as.factor(dat1$X206) dat1$X209 - as.factor(dat1$X209) dat1$X210 - as.factor(dat1$X210) dat1$X225 - as.factor(dat1$X225) dat1$X269 - as.factor(dat1$X269) dat1$X283 - as.factor(dat1$X283) dat1$X290 - as.factor(dat1$X290) dat1$X432 - as.factor(dat1$X432) dat1$X434 - as.factor(dat1$X434) dat1$X455 - as.factor(dat1$X455) dat1$X467 - as.factor(dat1$X467) dat1$X512 - as.factor(dat1$X512) dat1$SR - as.factor(dat1$SR) dat1.rf -randomForest(SR ~ X13+ X52+ X53+ X64+ X85+ X99+ X111+ X142+ X157+ X158+ X162+ X169+ X200+ + X202+ X203+ X205+ X206+ X209+ X210+ X225+ X269+ X283+ X290+ X432+ X434+ X455+ X467+ X512, data=dat1, importance=TRUE, + proximity=TRUE, varUsed=TRUE, ntree=5000, varImpPlot=TRUE) print(dat1.rf) varImpPlot(dat1.rf) varUsed(dat1.rf, by.tree=FALSE, count=TRUE) MDSplot(dat1.rf, dat1$SR, palette=rep(1, 2), + pch=as.numeric(dat1$SR)) path3 - C:\\Users... path4 - ... name2 - ... # reading in the test dataset actualFileName2 - paste(path3, path4, name2, .txt, sep=) dat2 - read.table(actualFileName2, header=TRUE, sep=\t, colClasses=character) dat2$X13 - as.factor(dat2$X13) dat2$X52 - as.factor(dat2$X52) dat2$X53 - as.factor(dat2$X53) dat2$X64 - as.factor(dat2$X64) dat2$X85 - as.factor(dat2$X85) dat2$X99 - as.factor(dat2$X99) dat2$X111 - as.factor(dat2$X111) dat2$X142 - as.factor(dat2$X142) dat2$X157 - as.factor(dat2$X157) dat2$X158 - as.factor(dat2$X158) dat2$X162 - as.factor(dat2$X162) dat2$X169 - as.factor(dat2$X169) dat2$X200 - as.factor(dat2$X200) dat2$X202 - as.factor(dat2$X202) dat2$X203 - as.factor(dat2$X203) dat2$X205 - as.factor(dat2$X205) dat2$X206 - as.factor(dat2$X206) dat2$X209 - as.factor(dat2$X209) dat2$X210 - as.factor(dat2$X210) dat2$X225 - as.factor(dat2$X225) dat2$X269 - as.factor(dat2$X269) dat2$X283 - as.factor(dat2$X283) dat2$X290 - as.factor(dat2$X290) dat2$X432 - as.factor(dat2$X432) dat2$X434 - as.factor(dat2$X434) dat2$X455 - as.factor(dat2$X455) dat2$X467 - as.factor(dat2$X467) dat2$X512 - as.factor(dat2$X512) dat2$SR - as.factor(dat2$SR) dat2.pred-predict(dat1.rf, dat2, type=response, norm.votes=TRUE, predict.all=FALSE, proximity=FALSE, nodes=FALSE) Error in predict.randomForest(dat1.rf, dat2, type = response, norm.votes = TRUE, : New factor levels not present in the training data The thing is that each of the amino acid positions in the training dataset is present also in the training dataset. So I don't know how to deal with the error. Thank you very much. Kind regards, Mojca Zelnikar -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. __ 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, reproducible code.
Re: [R] How to convert data to 'normal' if they are in the form of standard scientific notations?
Hi, This might also helps. a-c(2.0e+9,2.1e+9) is.numeric(a) #[1] TRUE format(a,sci=FALSE) #[1] 20 21 A.K. - Original Message - From: Petr PIKAL petr.pi...@precheza.cz To: HJ YAN yhj...@googlemail.com Cc: r-help@r-project.org Sent: Tuesday, August 7, 2012 4:11 AM Subject: Re: [R] How to convert data to 'normal' if they are in the form of standard scientific notations? Hi Dear Jean Thanks a lot for your help. The reason I did not provide producible code is that my work started with reading in some large csv files, e.g. the data is not created by myself. But the data is from the same data provider so I would expect to receive data in exactly same data format. I use read.csv to read the data in. My major curious is that by using exactly same code as I provided in my email, e.g. 'as.factor' why one of them work (e.g. convert the numerical data to factor) but the other one remains numerical with scientific notation? So, in R, how do I check if the data format are different for these two files in their original csv files, which might cause the different results..? Also I tried your code and created some reproducible examples, but still can not make it work as in your example a-c(2.0e+9,2.1e+9) is.numeric(a) [1] TRUE a.f-factor(a) is.numeric(a.f) [1] FALSE is.factor(a.f) [1] TRUE so factor comes correctly print(a,digits=12) [1] 2.0e+09 2.1e+09 print(a, digits=21) [1] 20.000 21.000 b-c(3000,3100) print(b,digits=5) [1] 3.0e+07 3.1e+07 So the printed result depends probably on your local setting. See also ?options help page. And maybe also ?format and ?sprintf Regards Petr a-c(2.0e+9,2.1e+9) print(a,digits=4)[1] 20 21 # I expected to see 2.0e+9 here...? print(a,digits=7)[1] 20 21 # Think here I should expect same 2.0e+9? getOption(digits) # Checking my default number of digits now..[1] 7 b-c(3000, 3100) print(b)[1] 3000 3100 # This is what I expected to see print(b,digits=5)[1] 3000 3100 # I'm so confused why it is not working, e.g. printing 3.0e+9! getOption(digits) # checking again, but now I would expect it has being changed to 5[1] 7 Any thoughts please...? Thanks HJ On Mon, Aug 6, 2012 at 7:04 PM, Jean V Adams jvad...@usgs.gov wrote: HJ, You don't provide any reproducible code, so I had to make up my own. dat - data.frame(a=letters[1:5], x=c(20110911001084, 20110911001084, 20110911001084, 20110911001084, 20110911001084), y=c(2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12)) In my example, the long numbers print out without scientific notation. dat a x y 1 a 20110911001084 210004000 2 b 20110911001084 210004000 3 c 20110911001084 210004000 4 d 20110911001084 210004000 5 e 20110911001084 210004000 I can make it print with scientific notation using the digits argument to the print() function. print(dat, digits=3) a x y 1 a 2.01e+13 2.1e+12 2 b 2.01e+13 2.1e+12 3 c 2.01e+13 2.1e+12 4 d 2.01e+13 2.1e+12 5 e 2.01e+13 2.1e+12 What is your default number of digits? getOption(digits) Jean HJ YAN yhj...@googlemail.com wrote on 08/06/2012 11:14:17 AM: Dear R users I read two csv data files into R and called them Tem1 and Tem5. For the first column, data in Tem1 has 13 digits where in Tem5 there are 14 digits for each observation. Originally there are 'numerical' as can be seen in my code below. But how can I display/convert them using other form rather than scientific notations which seems a standard/default? I want them to be in the form like '20110911001084', but I'm very confused why when I used 'as.factor' call it works for my 'Tem1' but not for 'Tem5'...?? Many thanks! HJ Tem1[1:5,1][1] 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 2. 10004e+12 Tem5[1:5,1][1] 2.011091e+13 2.011091e+13 2.011091e+13 2. 011091e+13 2.011091e+13 class(Tem1[1:5,1])[1] numeric class(Tem5 [1:5,1])[1] numeric as.factor(Tem1[1:5,1])[1] 2.10004e+12 2. 10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 Levels: 2.10004e+12 as.factor(Tem5[1:5,1])[1] 20110911001084 20110911001084 20110911001084 20110911001084 20110911001084 Levels: 20110911001084 [[alternative HTML version deleted]] __ 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, reproducible code. __ 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
[R] Save reload list objects
Hi, I think this is probably ( hopefully) very easy but I the ideas I have tried don't work. Simply, I have 2 very large lists in my workspace which take an awfully long time to make, each containing the information from 12500+ lmer models. I would like to now save these lists as files (txt, csv... whatever suits best) on to my computer/usb. Then I would like to be able to reload them in to the workspace on another computer (the second computer will not be able to run the script which makes the list m1- lapply(split(narrow,narrow$gene),function(x)lmer(value~sex+(1|line:sex)+(1|line),data=x)) ) in exactly the same layout,/state/condition as they were when they were made (exact replicas basically) so that it does not affect subsequent code in my script . Then I can just silence the original script line which makes the list and just have a couple of lines which save and load each one to the same object name as the original lists. So the commands I need help for should able to *save the lists *rg.lmer and rg.lmer2 separately And then *load the lists as lists, /not a df/,* in to another workspace Possibly looking towards sink() but not sure and couldn't figure out how this works... Thanks in advance Rob -- View this message in context: http://r.789695.n4.nabble.com/Save-reload-list-objects-tp4639397.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] Sum of vector elements
Hi, Is it possible to avoid using do and while loops to calculate the sum of the elements of a vector until the appearance of the first positive element. -- View this message in context: http://r.789695.n4.nabble.com/Sum-of-vector-elements-tp4639395.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] Interpreting predictions of svm
Hi, I have some difficulties in interpreting the prediction of a svm model using the package e1071. y1 is the variable I want to predict. It is of type factor and has got two levels: 50% and 50%. z is the dataset. model - svm(y1 ~ ., data = z,type=C-classification, cross=10) model Call: svm(formula = y1 ~ ., data = z, type = C-classification, cross = 10) Parameters: SVM-Type: C-classification SVM-Kernel: radial cost: 1 gamma: 0.07142857 Number of Support Vectors: 68 pred - predict(model,newdata=z,probability=TRUE,decision.values = TRUE) table(pred) pred 50% 50% 414 0 The results of pred is not what I intended to get as, I expected this type of result: 50% 50% 50%8925 50% 38262 What should I do? -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-predictions-of-svm-tp4639405.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] trouble with looping for effect of sampling interval increase
My apologies, here is a sample dataset generator: #Running sum Test Data Coin - c(-1,1) flips=sample(Coin, 1000, replace=T) Runningsum -cumsum (flips) #A deactivated plot #plot (Runningsum) Test - cbind (Runningsum) datasetORIGINAL - cbind (Runningsum) From: Jean V Adams [jvad...@usgs.gov] Sent: Monday, August 06, 2012 1:33 PM To: White, William Patrick Cc: r-help@r-project.org Subject: Re: [R] trouble with looping for effect of sampling interval increase You would make it much easier for R-help readers to solve your problem if you provided a small example data set with your code, so that we could reproduce your results and troubleshoot the issues. Jean Naidraug white@wright.edu wrote on 08/05/2012 09:08:25 AM: I've looked everywhere and tinkered for three days now, so I figure asking might be good. So here's a general rundown of what I am trying to get my code to do I am giving you the whole rundown because I need a solution that retain certain ways of doing things because they give me the information i need. I want to examine the effect of increasing my sampling interval on my data. Example: what if instead of sampling every hour I sampled every two, oh yeah, how about every three?.. etc ad nausea. How I want to do this is to take the data I have now, add an index to it, that contains counters. Those counters will look something like 1,2,1,2,.. for the first one, 1,2,3,1,2,3.. for the next one. I have a lot of them, like say a thousand... Then for each column in the index my loops should start in the first column, run only the ones, store that, then run the twos, and store that in the same column of output in a different row. Then move to the next column run the ones, store in the next column of output, run the twos, store in the next row of that column, run the threes, etc on out until there is no more. I want to use this index for a number of reasons. The first is that after this I will be going back through and using a different method for sub-sampling but keeping all else the same. So all I have to do there is change the way I generate the index. The second is that it allows me to run many subsamples and see their range. So the code I have made, generates my index, and does the heavy lifting all correctly, as well as my averages, and quartiles, but a look at the head () of my key output (IntervalBetas) shows that something has gone a miss. You have to look close to catch it. The values generated for each row of output are identical, this should not be the case, as row one of the first output column should be generated from all values indexed by a one in the first column, whereas in column two there are different values indexed by the number one. I've checked about everything I can think of, done print() on my loop sequence things (those little i and j) and wiggled about everything. I am flummoxed. I think the bit that is messing up is in here : #Here is the loop for betas from sampling interval increase c - WHOLESIZE[2]-1 for (i in 1:c) { x - length(unique(index[,i])) for (j in 1:x) { data - WHOLE [WHOLE[,x]==j,1] But also here is the whole code in case I am wrong that that is the problem area: #loop for making index #clean dataset of empty cells dataset - na.omit (datasetORIGINAL) #how messed up was the data? holeyDATA - datasetORIGINAL - dataset D - dim(dataset) #what is the smallest sample? tinysample - 100 #how long is the dataset? datalength - length (dataset) #MD - how many divisions MD - datalength/tinysample #clear things up for the index loop WHOLE - NULL index - NULL #do the index loop for (a in 1:MD) { index - cbind (index, rep (1:a, length = D[1])) } index - subset(index, select = -c(1) ) #merge dataset and index loop WHOLE - cbind (dataset, index) WHOLESIZE - dim (WHOLE) #Housekeeping before loops IntervalBetas - NULL IntervalBetas - c(NA,NA) IntervalBetas - as.data.frame (IntervalBetas) IntervalLowerQ - NULL IntervalUpperQ - NULL IntervalMean - NULL IntervalMedian - NULL #Here is the loop for betas from sampling interval increase c - WHOLESIZE[2]-1 for (i in 1:c) { x - length(unique(index[,i])) for (j in 1:x) { data - WHOLE [WHOLE[,x]==j,1] #get power spectral density PSDPLOT - spectrum (data, detrend = TRUE, plot = FALSE) frequency - PSDPLOT$freq PSD - PSDPLOT$spec #log transform the power spectral density Logfrequency - log(frequency) LogPSD- log(PSD) #fit my line to the data Line - lm (LogPSD ~ Logfrequency) #store the slope of the line Betas - rbind (Betas, -coef(Line)[2]) #Get values on the curve shape BSkew - skew (Betas) BMean - mean (Betas) BMedian - median (Betas) Q - quantile (Betas) #store curve shape values IntervalLowerQ - rbind (IntervalLowerQ , Q[2]) IntervalUpperQ - rbind (IntervalUpperQ , Q[4]) IntervalSkew - rbind (IntervalSkew ,
Re: [R] time plot
What graph? Please read the posting guidelines and provide some example data and some code showing what you are doing. John Kane Kingston ON Canada -Original Message- From: anand.kara...@gmail.com Sent: Tue, 7 Aug 2012 12:24:50 +0530 To: r-help@r-project.org Subject: [R] time plot hi, i am new to using R if someone can please tell me how to change the angel of the graph to a 45 degree angel. [[alternative HTML version deleted]] __ 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, reproducible code. FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks orcas on your desktop! __ 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, reproducible code.
Re: [R] What is the difference between probe level data and summarized data
No idea. What are you doing? What packages are you using? What function is (presumably) giving you these results? John Kane Kingston ON Canada -Original Message- From: mohammadianalimohammad...@gmail.com Sent: Tue, 7 Aug 2012 01:12:08 -0700 (PDT) To: r-help@r-project.org Subject: [R] What is the difference between probe level data and summarized data Hi all, What is the difference between probe level data and summarized data. Thanks in advance. -- View this message in context: http://r.789695.n4.nabble.com/What-is-the-difference-between-probe-level-data-and-summarized-data-tp4639376.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family! Visit http://www.inbox.com/photosharing to find out more! __ 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, reproducible code.
Re: [R] Save reload list objects
Hi Rob, Unless I've missed something you are just looking for ?save and ?load. Best, Ista On Tue, Aug 7, 2012 at 9:20 AM, robgriffin247 rg.rfo...@hotmail.co.uk wrote: Hi, I think this is probably ( hopefully) very easy but I the ideas I have tried don't work. Simply, I have 2 very large lists in my workspace which take an awfully long time to make, each containing the information from 12500+ lmer models. I would like to now save these lists as files (txt, csv... whatever suits best) on to my computer/usb. Then I would like to be able to reload them in to the workspace on another computer (the second computer will not be able to run the script which makes the list m1- lapply(split(narrow,narrow$gene),function(x)lmer(value~sex+(1|line:sex)+(1|line),data=x)) ) in exactly the same layout,/state/condition as they were when they were made (exact replicas basically) so that it does not affect subsequent code in my script . Then I can just silence the original script line which makes the list and just have a couple of lines which save and load each one to the same object name as the original lists. So the commands I need help for should able to *save the lists *rg.lmer and rg.lmer2 separately And then *load the lists as lists, /not a df/,* in to another workspace Possibly looking towards sink() but not sure and couldn't figure out how this works... Thanks in advance Rob -- View this message in context: http://r.789695.n4.nabble.com/Save-reload-list-objects-tp4639397.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Overlapping a Plot with Dataframe
What are you actually plotting? John Kane Kingston ON Canada -Original Message- From: bioinfo.himan...@gmail.com Sent: Tue, 7 Aug 2012 05:57:06 -0700 (PDT) To: r-help@r-project.org Subject: [R] Overlapping a Plot with Dataframe Hello Everyone, I am trying to overlap a plot with a data set in the form of a data frame. Its very easy to overlap the data using points function. But the only problem I am facing is Standard deviation bar on the plot. data - data.frame( x = c(3.00,2.00,3.80,2.40,2.00), error = c(0.0,0.4,1.1,0.7,0.5) ) I tried plotrix, segments but they are making a new plot with data points n error bar. I want to Overlap this data sets on a plot with its Error bar. Can anyone help me with it. Many Thanks, Himanshu -- View this message in context: http://r.789695.n4.nabble.com/Overlapping-a-Plot-with-Dataframe-tp4639396.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. Receive Notifications of Incoming Messages Easily monitor multiple email accounts access them with a click. Visit http://www.inbox.com/notifier and check it out! __ 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, reproducible code.
Re: [R] Unable to download R package
Try a different repository? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. ODowd, Darragh darragh.od...@ilim.com wrote: Hi, I'm new to R. I'm using the R Gui and have tried to install additional packeges. When I choose Packages/Install package(s) I get the following error... utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified Can someone -- ** Irish Life Investment Managers Limited is regulated by the Central Bank of Ireland. Irish Life Investment Managers Limited Registered Office: Beresford Court, Beresford Place, Dublin 1. Registered in Ireland Number 116000 While Irish Life Investment Managers uses reasonable efforts to ensure that the information contained in this email is current, accurate and complete at the date of publication, no representations or warranties are made (express or implied) as to the reliability, accuracy or completeness of such information. Irish Life Investment Managers therefore cannot be held liable for any loss arising directly or indirectly from the use of, or any action taken in reliance on, any information contained in this email. This material is for information only and does not constitute an offer or recommendation to buy or sell any investment, or subscribe to any investment management or advisory service. It is intended for the use of institutional and other professional investors. Past performance is not indicative of future results. The value of funds we manage may fall as well as rise. This email and any files transmitted with it are confide...{{dropped:16}} __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Sum of vector elements
I'd do something like this: x - sample(seq(-10, 10)) sum(x[seq_len(which.max(x 0)]) Though others might have more direct solutions. which.max() gets you the index of the first time x 0 -- seq_len gives you numbers 1 to that index -- then just subset and sum like normal. Best, Michael On Tue, Aug 7, 2012 at 7:37 AM, number10 havana_dr...@ymail.com wrote: Hi, Is it possible to avoid using do and while loops to calculate the sum of the elements of a vector until the appearance of the first positive element. -- View this message in context: http://r.789695.n4.nabble.com/Sum-of-vector-elements-tp4639395.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Unable to download R package
I can access the Mac tree of the ICL repos and it seems unlikely that both ICL and Prof Ripley's site would be down at the same time. OP: are you having firewall issues? Michael On Tue, Aug 7, 2012 at 10:58 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Try a different repository? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. ODowd, Darragh darragh.od...@ilim.com wrote: Hi, I'm new to R. I'm using the R Gui and have tried to install additional packeges. When I choose Packages/Install package(s) I get the following error... utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified Can someone -- ** Irish Life Investment Managers Limited is regulated by the Central Bank of Ireland. Irish Life Investment Managers Limited Registered Office: Beresford Court, Beresford Place, Dublin 1. Registered in Ireland Number 116000 While Irish Life Investment Managers uses reasonable efforts to ensure that the information contained in this email is current, accurate and complete at the date of publication, no representations or warranties are made (express or implied) as to the reliability, accuracy or completeness of such information. Irish Life Investment Managers therefore cannot be held liable for any loss arising directly or indirectly from the use of, or any action taken in reliance on, any information contained in this email. This material is for information only and does not constitute an offer or recommendation to buy or sell any investment, or subscribe to any investment management or advisory service. It is intended for the use of institutional and other professional investors. Past performance is not indicative of future results. The value of funds we manage may fall as well as rise. This email and any files transmitted with it are confide...{{dropped:16}} __ 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, reproducible code. __ 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, reproducible code. __ 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, reproducible code.
Re: [R] (no subject)
1. This is completely off topic. This is an R help list, not a statistical advice list like stats.stackexchange.com. 2. I would strongly recommend that you abandon internet statistical advice lists and seek local statistical help. You simply do not appear to have sufficient statistical background to formulate an appropriate analysis for what appears to be complex data. That you think you can do so appears, itself, to be a measure of your statistical ignorance.* Of course, that's just my perception... Cheers, Bert * Note: This is not meant in any sense as an insult, merely my perception of the state of your statistical knowledge based on your post. I am, for example, ignorant of audio physics, dentistry, plumbing, JAVA, ... On Tue, Aug 7, 2012 at 4:15 AM, bob jackson jackbob...@yahoo.com wrote: hi, I'm working on a research project where we're looking at the changing resonances in femur bones during hip replacement operations. basically, I've got a spreadsheet with one column listing frequencies in 5Hz bands and 3 columns showing the amplitude of that frequency when the bone is loose, medium to tight (referring to the tension of the reamer/chisel creating a cavity for the hip replacement). I'm coming at this more from a sound perspective so I would really appreciate some advice from anyone with a handle on stats, could correlograms be used in presenting this data? When working with a large number of bone samples, can anyone recommend a good method of recognizing and mapping these changes? All the best, Bob __ 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, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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, reproducible code.
Re: [R] Unable to download R package
Olympics--they are all off partying? John Kane Kingston ON Canada -Original Message- From: michael.weyla...@gmail.com Sent: Tue, 7 Aug 2012 11:03:19 -0500 To: jdnew...@dcn.davis.ca.us Subject: Re: [R] Unable to download R package I can access the Mac tree of the ICL repos and it seems unlikely that both ICL and Prof Ripley's site would be down at the same time. OP: are you having firewall issues? Michael On Tue, Aug 7, 2012 at 10:58 AM, Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Try a different repository? --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. ODowd, Darragh darragh.od...@ilim.com wrote: Hi, I'm new to R. I'm using the R Gui and have tried to install additional packeges. When I choose Packages/Install package(s) I get the following error... utils:::menuInstallPkgs() Warning: unable to access index for repository http://cran.ma.imperial.ac.uk/bin/windows/contrib/2.15 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15 Error in install.packages(NULL, .libPaths()[1L], dependencies = NA, type = type) : no packages were specified Can someone -- ** Irish Life Investment Managers Limited is regulated by the Central Bank of Ireland. Irish Life Investment Managers Limited Registered Office: Beresford Court, Beresford Place, Dublin 1. Registered in Ireland Number 116000 While Irish Life Investment Managers uses reasonable efforts to ensure that the information contained in this email is current, accurate and complete at the date of publication, no representations or warranties are made (express or implied) as to the reliability, accuracy or completeness of such information. Irish Life Investment Managers therefore cannot be held liable for any loss arising directly or indirectly from the use of, or any action taken in reliance on, any information contained in this email. This material is for information only and does not constitute an offer or recommendation to buy or sell any investment, or subscribe to any investment management or advisory service. It is intended for the use of institutional and other professional investors. Past performance is not indicative of future results. The value of funds we manage may fall as well as rise. This email and any files transmitted with it are confide...{{dropped:16}} __ 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, reproducible code. __ 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, reproducible code. __ 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, reproducible code. GET FREE SMILEYS FOR YOUR IM EMAIL - Learn more at http://www.inbox.com/smileys Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails __ 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, reproducible code.
Re: [R] What is the difference between probe level data and summarized data
On 08/07/2012 01:12 AM, ali_protocol wrote: Hi all, What is the difference between probe level data and summarized data. Thanks in advance. sounds like microarrays, for which http://biostars.org *or* the Bioconductor mailing list http://bioconductor.org/help/mailing-list might be appropriate. Martin -- View this message in context: http://r.789695.n4.nabble.com/What-is-the-difference-between-probe-level-data-and-summarized-data-tp4639376.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. -- Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M1 B861 Phone: (206) 667-2793 __ 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, reproducible code.
[R] NADA Package: Referencing Data Frame Columns
The sample data sets that come with the NADA package are limited to one or two variables and a censored measurement indicator column. I try to mimic examples using my data but keep missing the target. My water chemistry data is available in two formats: long (as seen in a database table) and wide (as seen in a spreadsheet). The two structures are: str(chem) 'data.frame': 65349 obs. of 8 variables: $ site: Factor w/ 64 levels D-1,D-2,D-3,..: 1 1 1 1 1 1 1 ... $ sampdate: Date, format: 2007-12-12 2007-12-12 ... $ era : Factor w/ 2 levels Post,Pre: 1 1 1 1 1 1 1 1 1 1 ... $ param : Factor w/ 64 levels AgDis,AgTot,..: 2 4 5 7 11 15 25 ... $ quant : num 1.30e-04 1.06e-01 2.31e+02 1.13e-02 5.00e-03 ... $ ceneq1 : logi TRUE FALSE FALSE FALSE TRUE FALSE ... $ floor : num 0 0.106 231 0.0113 0 100 0 1.43 0 0.0239 ... $ ceiling : num 1.30e-04 1.06e-01 2.31e+02 1.13e-02 5.00e-03 2.39e-02 ... and str(chem.cast) 'data.frame': 56938 obs. of 70 variables: $ site : Factor w/ 64 levels D-1,D-2,D-3,..: 1 1 1 1 1 ... $ sampdate : Date, format: 2007-12-12 2007-12-12 ... $ era : Factor w/ 2 levels Post,Pre: 1 1 1 1 1 1 1 1 1 1 ... $ ceneq1 : logi TRUE FALSE FALSE FALSE TRUE FALSE ... $ floor: num 0 0.106 231 0.0113 0 100 0 1.43 0 0.0239 ... $ ceiling : num 1.30e-04 1.06e-01 2.31e+02 1.13e-02 5.00e-03 ... $ AgDis: num NA NA NA NA NA NA NA NA NA NA ... $ AgTot: num 0.00013 NA NA NA NA NA NA NA NA NA ... $ AlDis: num NA NA NA NA NA NA NA NA NA NA ... $ AlTot: num NA 0.106 NA NA NA NA NA NA NA NA ... $ Alk : num NA NA 231 NA NA NA NA NA NA NA ... $ AsDis: num NA NA NA NA NA NA NA NA NA NA ... and so on. I do not know if the latter is appropriate; that is, that the ceneq1, floor, and ceiling values are available for each site, sampdate, and chemical. Is the appropriate way to use the NADA methods for analyses and plotting to subset each chemical separately from the 'chem' data frame? Or, is there a syntax other than, for example, cenboxplot(chemVdis, chem$ceneq1, chem$era) Error in cenros(obs[group == i], cen[group == i]) : error in evaluating the argument 'obs' in selecting a method for function 'ros': Error: object 'Vdis' not found I get the same error when trying to use the 'chem.cast' data frame. Rich __ 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, reproducible code.
Re: [R] Multiple Comparisons-Kruskal-Wallis-Test: kruskal{agricolae} and kruskalmc{pgirmess} don't yield the same results although they should do (?)
I see.. So apparently the different functions are doing the same thing! :-) Besides I didn't know the groups should have about the same size. Thank you four your time Mr. Dalgaard. -- View this message in context: http://r.789695.n4.nabble.com/Multiple-Comparisons-Kruskal-Wallis-Test-kruskal-agricolae-and-kruskalmc-pgirmess-don-t-yield-the-sa-tp4639004p4639431.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] Rcolorbrewer Package
Hi all, I am trying to download the Rcolorbrewer package from Cran http://cran.r-project.org/web/packages/RColorBrewer//index.html It seems the files have been removed. Does anyone know where can I download the package? Thanks. Hannah [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] Rcolorbrewer Package
The link works just fine for me and I can download the package if I take out one of the repeated slashes. Best, Michael On Tue, Aug 7, 2012 at 12:08 PM, li li hannah@gmail.com wrote: Hi all, I am trying to download the Rcolorbrewer package from Cran http://cran.r-project.org/web/packages/RColorBrewer//index.html It seems the files have been removed. Does anyone know where can I download the package? Thanks. Hannah [[alternative HTML version deleted]] __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Sum of vector elements
Another approach... not exactly more direct, but perhaps more robust and more general: tmp - aggregate(x,list(lvl=cumsum(abs(diff(c(FALSE,x0), FUN=sum) ans - tmp[0==tmp$lvl,x] abs(diff()) finds transitions, FALSE forces level zero to represent negative numbers cumsum marks levels (groups of positive and not-positive numbers) aggregate does the summation ans may be empty if x started with positive numbers. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. R. Michael Weylandt michael.weyla...@gmail.com wrote: I'd do something like this: x - sample(seq(-10, 10)) sum(x[seq_len(which.max(x 0)]) Though others might have more direct solutions. which.max() gets you the index of the first time x 0 -- seq_len gives you numbers 1 to that index -- then just subset and sum like normal. Best, Michael On Tue, Aug 7, 2012 at 7:37 AM, number10 havana_dr...@ymail.com wrote: Hi, Is it possible to avoid using do and while loops to calculate the sum of the elements of a vector until the appearance of the first positive element. -- View this message in context: http://r.789695.n4.nabble.com/Sum-of-vector-elements-tp4639395.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Rcolorbrewer Package
install.packages(RColorBrewer) seems to work for me. John Kane Kingston ON Canada -Original Message- From: hannah@gmail.com Sent: Tue, 7 Aug 2012 13:08:11 -0400 To: r-help@r-project.org Subject: [R] Rcolorbrewer Package Hi all, I am trying to download the Rcolorbrewer package from Cran http://cran.r-project.org/web/packages/RColorBrewer//index.html It seems the files have been removed. Does anyone know where can I download the package? Thanks. Hannah [[alternative HTML version deleted]] __ 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, reproducible code. FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop! __ 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, reproducible code.
Re: [R] Sum of vector elements
I'll add my suggestion, which first extracts from x the elements up to but not including the first positive one and then sums them: f3 - function(x) { sum(x[cumsum(x0) == 0]) } Michaels suggestion was sum(x[seq_len(which.max(x 0)]) but that includes the first positive element so I think it should be at least f1 - function(x) sum(x[seq_len(which.max(x0)-1)]) (but that still fails in some cases). Jeff's was f2 - function (x) { tmp - aggregate(x, list(lvl = cumsum(abs(diff(c(FALSE, x 0), FUN = sum) tmp[0 == tmp$lvl, x] } To test them, make a list of datasets xs - list(allNeg=c(-1, -3, -9), allPos=c(1,3,9), firstPos=c(1,-3,-9), firstNeg=c(-1,-3,+9), misc=c(-1,-3,9,-27,-81)) sapply(xs, function(x)try(f1(x))) allNeg allPos firstPos firstNeg misc 000 -4 -4 sapply(xs, function(x)try(f2(x))) $allNeg [1] -13 $allPos numeric(0) $firstPos numeric(0) $firstNeg [1] -4 $misc [1] -4 sapply(xs, function(x)try(f3(x))) allNeg allPos firstPos firstNeg misc -1300 -4 -4 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Newmiller Sent: Tuesday, August 07, 2012 10:25 AM To: R. Michael Weylandt; number10 Cc: r-help@r-project.org Subject: Re: [R] Sum of vector elements Another approach... not exactly more direct, but perhaps more robust and more general: tmp - aggregate(x,list(lvl=cumsum(abs(diff(c(FALSE,x0), FUN=sum) ans - tmp[0==tmp$lvl,x] abs(diff()) finds transitions, FALSE forces level zero to represent negative numbers cumsum marks levels (groups of positive and not-positive numbers) aggregate does the summation ans may be empty if x started with positive numbers. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. R. Michael Weylandt michael.weyla...@gmail.com wrote: I'd do something like this: x - sample(seq(-10, 10)) sum(x[seq_len(which.max(x 0)]) Though others might have more direct solutions. which.max() gets you the index of the first time x 0 -- seq_len gives you numbers 1 to that index -- then just subset and sum like normal. Best, Michael On Tue, Aug 7, 2012 at 7:37 AM, number10 havana_dr...@ymail.com wrote: Hi, Is it possible to avoid using do and while loops to calculate the sum of the elements of a vector until the appearance of the first positive element. -- View this message in context: http://r.789695.n4.nabble.com/Sum-of-vector-elements-tp4639395.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code. __ 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, reproducible code. __ 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, reproducible code.
Re: [R] NADA Package: Referencing Data Frame Columns
On Tue, Aug 7, 2012 at 11:26 AM, Rich Shepard rshep...@appl-ecosys.com wrote: The sample data sets that come with the NADA package are limited to one or two variables and a censored measurement indicator column. I try to mimic examples using my data but keep missing the target. My water chemistry data is available in two formats: long (as seen in a database table) and wide (as seen in a spreadsheet). The two structures are: str(chem) 'data.frame': 65349 obs. of 8 variables: $ site: Factor w/ 64 levels D-1,D-2,D-3,..: 1 1 1 1 1 1 1 ... $ sampdate: Date, format: 2007-12-12 2007-12-12 ... $ era : Factor w/ 2 levels Post,Pre: 1 1 1 1 1 1 1 1 1 1 ... $ param : Factor w/ 64 levels AgDis,AgTot,..: 2 4 5 7 11 15 25 ... $ quant : num 1.30e-04 1.06e-01 2.31e+02 1.13e-02 5.00e-03 ... $ ceneq1 : logi TRUE FALSE FALSE FALSE TRUE FALSE ... $ floor : num 0 0.106 231 0.0113 0 100 0 1.43 0 0.0239 ... $ ceiling : num 1.30e-04 1.06e-01 2.31e+02 1.13e-02 5.00e-03 2.39e-02 ... and str(chem.cast) 'data.frame': 56938 obs. of 70 variables: $ site : Factor w/ 64 levels D-1,D-2,D-3,..: 1 1 1 1 1 ... $ sampdate : Date, format: 2007-12-12 2007-12-12 ... $ era : Factor w/ 2 levels Post,Pre: 1 1 1 1 1 1 1 1 1 1 ... $ ceneq1 : logi TRUE FALSE FALSE FALSE TRUE FALSE ... $ floor: num 0 0.106 231 0.0113 0 100 0 1.43 0 0.0239 ... $ ceiling : num 1.30e-04 1.06e-01 2.31e+02 1.13e-02 5.00e-03 ... $ AgDis: num NA NA NA NA NA NA NA NA NA NA ... $ AgTot: num 0.00013 NA NA NA NA NA NA NA NA NA ... $ AlDis: num NA NA NA NA NA NA NA NA NA NA ... $ AlTot: num NA 0.106 NA NA NA NA NA NA NA NA ... $ Alk : num NA NA 231 NA NA NA NA NA NA NA ... $ AsDis: num NA NA NA NA NA NA NA NA NA NA ... and so on. I do not know if the latter is appropriate; that is, that the ceneq1, floor, and ceiling values are available for each site, sampdate, and chemical. Is the appropriate way to use the NADA methods for analyses and plotting to subset each chemical separately from the 'chem' data frame? Or, is there a syntax other than, for example, cenboxplot(chemVdis, chem$ceneq1, chem$era) Error in cenros(obs[group == i], cen[group == i]) : error in evaluating the argument 'obs' in selecting a method for function 'ros': Error: object 'Vdis' not found I get the same error when trying to use the 'chem.cast' data frame. Take a look at with() Michael Rich __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Problem with global variable building a package
On Tue, Aug 7, 2012 at 2:09 AM, Eva Prieto Castro evapcas...@yahoo.es wrote: Hi, My name is Eva and this is my first message here. My English is not very good, but I hope you can understand my question, in the context of an academic project. I have developed several functions in R and the idea is that the user can access functions in order to: 1) Alter parameters in relation with data and type of analysis. 2) Run statistical analysis (Text and pdf files with results will be generated). 3) View the value of the most important parameters. All the parameters I need are stored in a list object, and this list is used in all the functions along the cycle performed by the user, but I would like the user does not need to pass the name of the list as argument when he/she runs the different functions, so I think I need to treat the list as a global variable. Firstly, I used the global assignment operator (“-“); secondly, I used “get” and “assign” functions and even I used a new.env() in order to use a new environment exclusively for my list. However, when I try to build a package with all my functions I don’t reach this end, because of an error in parse process. My question for you is the following: taking into account that my end is to build a package, what can I do with this “global” list?. How can I treat it?. Hi Eva, I was actually doing something similar just the other day -- for a quick and dirty solution, you can use assignInNamespace() or assignInMyNamespace() but the help pages suggest CRAN won't look kindly thereupon. To avoid that, I simply used a hidden [starting with a dot] variable in the user's global environment (i.e., I defined it on package load with the .onAttach() function and then just referenced it when needed) but the best practices solution is probably to use options() or something similar. See, e.g., setCompilerOptions() of the compiler package or setRmetricsOptions() of the Rmetrics bundle. Best, Michael Thanks in advance. Regards, Eva [[alternative HTML version deleted]] __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Error with convUL (PBSmapping)
This looks like a fairly low level problem that you might need the maintainer to look at. To get contact information, type maintainer(PBSmapping) at the R prompt. Best, Michael On Tue, Aug 7, 2012 at 7:21 AM, niandra rmaill...@yahoo.it wrote: Hi all, I'm trying to use the function convUL from the Package PBSmapping but i get i weird error with my data but also with the example in the convUL's help. Here is the example script with the error message: data(nepacLL, package=PBSmapping) #--- set the zone attribute #--- use a zone that is most central to the mapped region attr(nepacLL, zone) - 6 #--- convert and plot the result nepacUTM - convUL(nepacLL) Error in .C(convUL, inXY = as.double(inXY), inVerts = as.integer(inVerts), : C symbol name convUL not in DLL for package PBSmapping someone can help me? Thanks [[alternative HTML version deleted]] __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Hist function
On Tue, Aug 7, 2012 at 8:05 AM, Dominic Roye dominic.r...@gmail.com wrote: Hello everyone, First i explain my aim. I would like to calculate the frecuency of temperature (datos.mx1, columns 3-6) for each month with the thresholds of table lf.med and lc.med. numero1 - hist(subset(datos.mx1[,3], datos.mx1$Mes==1),plot=FALSE,breaks=c(min(datos.mx1[,3]),lf.med[1,2],lc.med[1,2],max(datos.mx1[,3]))) # First month and only the first weather station (column 3) I now have to apply the above command for all 12 months at all the weather stations. I've been trying to get with a for-loop, but without success. How can i do it the best way? I'd suggest the tapply() function. If you could use dput() to make a small reproducible example of your data, I'll help you set up the exact syntax, but I think it's something like this: tapply(datos.mx1, datos.mx1$Mes, function(x) hist(x[,3], plot = FALSE, breaks = c(min(x[,3], lf.med[1,2], lc.med[1,2], max(x[,3] Best, Michael After this command, i'm only interested in the part of $counts. I hope someone can help me. Any help is greatly appreciated!!! Thank you, everybody`!! datos.mx1 Fecha Mes Serra.da.Foladoira Santiago Sergude Rio.Do.Sol 101.01.2006 14.1 14.4 9.35.7 202.01.2006 15.5 9.811.07.6 303.01.2006 19.9 13.012.79.9 404.01.2006 19.7 13.312.79.7 505.01.2006 1 10.2 12.213.18.0 606.01.2006 14.2 14.210.25.4 707.01.2006 11.0 6.9 3.23.2 . . ...etc. lf.med Mes Serra.da.Foladoira Santiago Sergude Rio.Do.Sol 11 7.833702 8.811945 8.122162 7.899513 22 7.766978 8.592693 8.041483 7.887327 33 7.864609 8.861457 8.385405 8.080646 44 8.204098 8.986149 8.803744 8.438141 55 8.716766 9.317366 9.385637 8.977087 66 9.377651 9.874497 10.194340 9.686213 77 9.838470 10.055430 10.447219 9.991618 88 10.046204 10.099868 10.520872 10.098330 99 9.780911 10.038629 10.156048 9.851299 10 10 9.425308 9.779886 9.646881 9.496192 11 11 8.417168 9.346191 8.791033 8.549046 12 12 7.968706 8.795800 8.038208 8.017603 lc.med Mes Serra.da.Foladoira Santiago Sergude Rio.Do.Sol 11 21.29353 26.62562 23.71784 22.04786 22 21.97787 27.07213 25.68340 23.39020 33 22.69749 27.42612 26.97889 24.33741 44 24.49683 29.21054 29.76726 26.59280 55 25.24233 29.83056 30.75132 27.28277 66 26.46742 30.70485 33.02328 28.77892 77 27.72731 30.24450 34.28162 29.97767 88 27.64356 30.84850 34.52161 30.00666 99 27.21998 31.18390 33.19776 29.54618 10 10 25.35830 28.83195 29.63192 26.42831 11 11 22.37895 26.38226 25.69239 23.47575 12 12 21.44064 26.09142 23.99676 22.26208 [[alternative HTML version deleted]] __ 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, reproducible code. __ 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, reproducible code.
Re: [R] How to convert data to 'normal' if they are in the form of standard scientific notations?
Hi, Try these also: a-c(2.0e+9,2.1e+9) is.numeric(a) [1] TRUE formatC(a,format=fg) #[1] 20 21 formatC(a,format=f) #[1] 20. 21. formatC(a,format=f,digits=0) #[1] 20 21 A.K. - Original Message - From: HJ YAN yhj...@googlemail.com To: Jean V Adams jvad...@usgs.gov Cc: r-help@r-project.org Sent: Monday, August 6, 2012 7:05 PM Subject: Re: [R] How to convert data to 'normal' if they are in the form of standard scientific notations? Dear Jean Thanks a lot for your help. The reason I did not provide producible code is that my work started with reading in some large csv files, e.g. the data is not created by myself. But the data is from the same data provider so I would expect to receive data in exactly same data format. I use read.csv to read the data in. My major curious is that by using exactly same code as I provided in my email, e.g. 'as.factor' why one of them work (e.g. convert the numerical data to factor) but the other one remains numerical with scientific notation? So, in R, how do I check if the data format are different for these two files in their original csv files, which might cause the different results..? Also I tried your code and created some reproducible examples, but still can not make it work as in your example a-c(2.0e+9,2.1e+9) print(a,digits=4)[1] 20 21 # I expected to see 2.0e+9 here...? print(a,digits=7)[1] 20 21 # Think here I should expect same 2.0e+9? getOption(digits) # Checking my default number of digits now..[1] 7 b-c(3000,3100) print(b)[1] 3000 3100 # This is what I expected to see print(b,digits=5)[1] 3000 3100 # I'm so confused why it is not working, e.g. printing 3.0e+9! getOption(digits) # checking again, but now I would expect it has being changed to 5[1] 7 Any thoughts please...? Thanks HJ On Mon, Aug 6, 2012 at 7:04 PM, Jean V Adams jvad...@usgs.gov wrote: HJ, You don't provide any reproducible code, so I had to make up my own. dat - data.frame(a=letters[1:5], x=c(20110911001084, 20110911001084, 20110911001084, 20110911001084, 20110911001084), y=c(2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12, 2.10004e+12)) In my example, the long numbers print out without scientific notation. dat a x y 1 a 20110911001084 210004000 2 b 20110911001084 210004000 3 c 20110911001084 210004000 4 d 20110911001084 210004000 5 e 20110911001084 210004000 I can make it print with scientific notation using the digits argument to the print() function. print(dat, digits=3) a x y 1 a 2.01e+13 2.1e+12 2 b 2.01e+13 2.1e+12 3 c 2.01e+13 2.1e+12 4 d 2.01e+13 2.1e+12 5 e 2.01e+13 2.1e+12 What is your default number of digits? getOption(digits) Jean HJ YAN yhj...@googlemail.com wrote on 08/06/2012 11:14:17 AM: Dear R users I read two csv data files into R and called them Tem1 and Tem5. For the first column, data in Tem1 has 13 digits where in Tem5 there are 14 digits for each observation. Originally there are 'numerical' as can be seen in my code below. But how can I display/convert them using other form rather than scientific notations which seems a standard/default? I want them to be in the form like '20110911001084', but I'm very confused why when I used 'as.factor' call it works for my 'Tem1' but not for 'Tem5'...?? Many thanks! HJ Tem1[1:5,1][1] 2.10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 2. 10004e+12 Tem5[1:5,1][1] 2.011091e+13 2.011091e+13 2.011091e+13 2. 011091e+13 2.011091e+13 class(Tem1[1:5,1])[1] numeric class(Tem5 [1:5,1])[1] numeric as.factor(Tem1[1:5,1])[1] 2.10004e+12 2. 10004e+12 2.10004e+12 2.10004e+12 2.10004e+12 Levels: 2.10004e+12 as.factor(Tem5[1:5,1])[1] 20110911001084 20110911001084 20110911001084 20110911001084 20110911001084 Levels: 20110911001084 [[alternative HTML version deleted]] __ 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, reproducible code. __ 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, reproducible code.
Re: [R] multiple comparisons for GAMs
I have looked into using glht (‘multcomp’ package) to do multiple comparisons for a model fit with GAM {mgcv} but after reading the description of the ‘multcomp’ package, I believe this method only applies to parametric models and linear hypotheses. When I ran the code glht(model,linfct….) I got an error message (see below), but I am not sure if that was the result of my data being input in the incorrect format or the result of the test not working on the type of model I used. Does anyone know if there is an equivalent procedure for non-parametric models, or one that can be used to test for significant differences in curves modeled using GAMs? I have included a highly simplified, mini dataset that approximates the shape of the relationships exhibited by my own much larger data set, as well as the code I used. In a nutshell, I would like to test whether the shape of the relationship between light and log_abundance at a height of 200m is significantly different from the relationship between light and log_abundance at a height of 400m. require (lattice) require (mgcv) require(multcomp) species=read.csv(Book1.csv, header=TRUE, sep=,, quote=\,fill=TRUE) attach(species) names(species) species height light log_abundance 1200m 0.15 0.20 2200m 0.23 0.28 3200m 0.38 0.30 4200m 0.41 0.47 5200m 0.52 0.48 6200m 0.63 0.42 7200m 0.71 0.37 8200m 0.85 0.35 9200m 0.96 0.40 10 200m 1.05 0.45 11 200m 1.16 0.37 12 200m 1.23 0.30 13 200m 1.39 0.26 14 200m 1.47 0.15 15 400m 0.12 0.10 16 400m 0.25 0.09 17 400m 0.36 0.12 18 400m 0.42 0.14 19 400m 0.60 0.24 20 400m 0.65 0.28 21 400m 0.74 0.37 22 400m 0.86 0.40 23 400m 0.93 0.35 24 400m 1.06 0.25 25 400m 1.15 0.15 26 400m 1.24 0.18 27 400m 1.37 0.40 28 400m 1.48 0.57 coplot(log_abundance~light|height) model1=gam(log_abundance~s(light)+height+te(light,by=height,k=6)) plot(model1,trans=function(x)exp(x)/(1+exp(x)),shade=T,pages=1) summary (model1) glht(model1,linfct=mcp(height=Tukey)) Error in linfct[[nm]] %*% C : requires numeric/complex matrix/vector arguments -- View this message in context: http://r.789695.n4.nabble.com/multiple-comparisons-for-GAMs-tp4638935p4639429.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
Re: [R] NADA Package: Referencing Data Frame Columns
On Tue, 7 Aug 2012, R. Michael Weylandt wrote: Take a look at with() Michael, Thank you. I will. Rich -- Richard B. Shepard, Ph.D. | Integrity - Credibility - Innovation Applied Ecosystem Services, Inc. |Helping Ensure Our Clients' Futures http://www.appl-ecosys.com Voice: 503-667-4517 Fax: 503-667-8863 __ 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, reproducible code.
Re: [R] Package to remove collinear variables
For background have a look at http://en.wikipedia.org/wiki/Multicollinearity. I have also used Regression Diagnostics: Identifying Influential Data and Sources of Collinearity (Wiley Series in Probability and Statistics) by David A. Belsley, Edwin Kuh and Roy E. Welsch Sections 1.9 to 1.12 of Hands-On Intermediate Econometrics Using R: Templates for Extending Dozens of Practical Examples [With CDROM] by Hrishikesh D. Vinod (2008) Basically how you proceed depends a lot on what you are trying to achieve. Best Regards John On 5 August 2012 23:04, Roberto Moscetti rmosce...@unitus.it wrote: Hi, thank you for your help. I know, I need to learn enough statistics to understand how to process my data. The reason because of I write on this forum is to ask to people a way to learn. I am a postharvest researcher and statistic is not my main field, so I try to do my best. Do you know a book (or literature) than can help me? Thank you very much for your time and suggestions. Best regards, Roberto Il 05/08/2012 12:55, Jeff Newmiller ha scritto: There is no magic bullet (package) for your problem. You must either learn enough statistics to understand how to analyze your data, or consult with someone who does. FWIW collinearity is not in general amenable to automatic removal. However, you can identify which inputs are collinear with each other, and omit the redundant ones next iteration of your analysis, using (for example) the approach suggested by Uwe. Deciding WHICH of the redundant inputs is most appropriate to keep is the part computers are not so good at... that is where you must be smarter or more creative than the computer. Also, it would help you get responses if you included the context (earlier discussion) in your replies.. most people do not use Nabble here. Reading and following the requests in the footer of every message will also help. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Roberto rmosce...@unitus.it wrote: I do not know, because I tried to use rfe function (Backwards Feature Selection, Caret Package) to select wavelengths useful for a prediction model. Otherwise, rfe function give me back a lot of warning messages about collinearity between variables. So, I do not know if your script can be useful. I tried to use VIF-Regression to select variables, but rfe function advise me with the same warning messages again. What do you think about that? Thank you very much for your help. Best, Roberto -- View this message in context: http://r.789695.n4.nabble.com/Package-to-remove-collinear-variables-tp4639200p4639226.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code. -- John C Frain Economics Department Trinity College Dublin Dublin 2 Ireland www.tcd.ie/Economics/staff/frainj/home.html mailto:fra...@tcd.ie mailto:fra...@gmail.com __ 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, reproducible code.
Re: [R] NADA Package: Referencing Data Frame Columns
On Tue, 7 Aug 2012, David Winsemius wrote: cenboxplot(chemVdis, chem$ceneq1, chem$era) ___^ Incorrect use of '' when '$' was intended. Mea culpa, David! Thanks for catching my typo. Rich __ 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, reproducible code.
Re: [R] issue with nzchar() ?
On Mon, Aug 6, 2012 at 5:27 PM, R. Michael Weylandt michael.weyla...@gmail.com wrote: On Mon, Aug 6, 2012 at 9:53 AM, Liviu Andronic landronim...@gmail.com wrote: On Mon, Aug 6, 2012 at 4:48 PM, Liviu Andronic landronim...@gmail.com wrote: string, something that I find strange. At best NA is the equivalent of an empty string. Certainly not to my mind, unless you think that zero and NA should be the same for integers and doubles as well. NA (in whatever form) is, to my mind, _unknown_ which is very different than knowing 0. This is a tricky question and I don't have a strong opinion yet. I'm not sure why that's the case, but it's documented on the help page (under value): For ‘nchar’, an integer vector giving the sizes of each element, currently always ‘2’ for missing values (for ‘NA’). I most certainly missed this bit in the help page. My guess is that it's this way for back-compatability from a time when there probably wasn't a proper NA_character_ (that's the parser literal for a character NA) and they really were just NA (the string) -- perhaps in some far distant R 3.0 we'll see nchar(NA_character_) = NA_integer_ As David has also suggested (and Bert alluded), it may be worth having a nchar(..., returnNA=FALSE) argument, which if TRUE would return NA when it encounters NA values in the original vector. Thank you all for the comments. Regards Liviu __ 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, reproducible code.
[R] Bayesian estimates for the 1st-order Spatial Autoregressive model
Greetings: I am a relatively new user to R. I was wondering if anyone is familiar with MATLAB's far_g() function. If yes, is there an R equivalent to this? I would like to have the ability to input as my observation vector continuous values. I noticed that there was something close in R, sar_probit_mcmc(), but I can only use a binary vector as my observation vector. If my question sounds a bit confusing I am pasting below the MATLAB description of the function so you can see what it is that I am looking for. function results = far_g(y,W,ndraw,nomit,prior) % PURPOSE: Bayesian estimates for the 1st-order Spatial autoregressive model % y = rho*W*y + e,e = N(0,sige*V), % V = diag(v1,v2,...vn), r/vi = ID chi(r)/r, r = Gamma(m,k) % sige = gamma(nu,d0) % rho = Uniform(rmin,rmax), or rho = beta(a1,a2); Thanks in advance, __ This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited. All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto, including its subsidiaries. The recipient of this e-mail is solely responsible for checking for the presence of Viruses or other Malware. Monsanto, along with its subsidiaries, accepts no liability for any damage caused by any such code transmitted by or accompanying this e-mail or any attachment. The information contained in this email may be subject to the export control laws and regulations of the United States, potentially including but not limited to the Export Administration Regulations (EAR) and sanctions regulations issued by the U.S. Department of Treasury, Office of Foreign Asset Controls (OFAC). As a recipient of this information you are obligated to comply with all applicable U.S. export laws and regulations. [[alternative HTML version deleted]] __ 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, reproducible code.
[R] Decimal number
HI i have a little problem please help me to solve it this is the code in R: beta0 [1] 64.90614 beta1 [1] 17.7025 beta [1] 17 64 her beta- c(beta0, beta1) thank you in advance hafida -- View this message in context: http://r.789695.n4.nabble.com/Decimal-number-tp4639428.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
Re: [R] Styling gridExtra's title and left labels
Hi, You can use a grob instead of a text string, e.g main = textGrob(Title goes here, gp=gpar(fontsize=24)) HTH, b. On 7 August 2012 03:49, Alastair alastair.and...@gmail.com wrote: Hi, I'm using the gridExtra package to combine some graphs like in the arrangeGrob example. Each of the graphs has a title but they appear much larger than the overall combined plot title and left axis label. Does anyone know how I can control the style / size of the gridExtra labels? library(gridExtra) library(ggplot2) dsamp - diamonds[sample(nrow(diamonds), 1000), ] p1 - qplot(carat, price, data=dsamp, colour=clarity) p2 - qplot(carat, price, data=dsamp, colour=clarity, geom=path) tmp - ggplot_gtable(ggplot_build(p1)) leg - which(sapply(tmp$grobs, function(x) x$name) == guide-box) legend - tmp$grobs[[leg]] grid.arrange(arrangeGrob(p1 + theme(legend.position=none) + ggtitle(Scatter Plot), p2 + theme(legend.position=none) + ggtitle(Line Plot), main =this is a title, left = This is my global Y-axis title), legend, widths=unit.c(unit(1, npc) - legend$width, legend$width), nrow=1) -- View this message in context: http://r.789695.n4.nabble.com/Styling-gridExtra-s-title-and-left-labels-tp4639388.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code.
Re: [R] NADA Package: Referencing Data Frame Columns
On Tue, 7 Aug 2012, R. Michael Weylandt wrote: Take a look at with() Michael, Works like a charm! Thanks again for the pointer. Rich __ 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, reproducible code.
Re: [R] test if elements of a character vector contain letters
On Mon, Aug 6, 2012 at 7:35 PM, Marc Schwartz marc_schwa...@me.com wrote: is.letter - function(x) grepl([[:alpha:]], x) is.number - function(x) grepl([[:digit:]], x) Another follow-up. To test for (non-)alphanumeric one would do the following: x - c(letters, 1:26, '+', '-', '%^') x[1:10] - paste(x[1:10], 1:10, sep='') x [1] a1 b2 c3 d4 e5 f6 g7 h8 i9 j10 k l m n [15] o p q r s t u v w x y z 1 2 [29] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [43] 17 18 19 20 21 22 23 24 25 26 + - %^ xb - grepl([[:alnum:]],x) ##test for alphanumeric chars x[xb] [1] a1 b2 c3 d4 e5 f6 g7 h8 i9 j10 k l m n [15] o p q r s t u v w x y z 1 2 [29] 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [43] 17 18 19 20 21 22 23 24 25 26 xb - grepl([[:punct:]],x) ##test for non-alphanumeric chars x[xb] [1] + - %^ More regex rules are available on the Wiki [1]. Regards Liviu [1] http://en.wikipedia.org/wiki/Regular_expression __ 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, reproducible code.
Re: [R] Decimal number
hello arun her beta can be considered simply as an object. when i wrote beta I want to get the number of beta and beta with the full part after the comma hafida -- View this message in context: http://r.789695.n4.nabble.com/Decimal-number-tp4639428p4639452.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] Trying to build up a user interface with the R tcltk package
I'm trying to build up a user inteface using the R tcltk component. Since the documentation for this R library is scarce and poor, I have decided to use only the .Tcl function to pass commands to the tcl interpreter. So I wrote my first very simple tcltk program, hoping to run it from inside R and get the nice Tk window, with the following R instruction: - .Tcl('source smalltst.tcl') - Tcl Eventhough, neither R nor tcl complain about the instruction, I don't get the tk window. The tcltk program, stored in smalltst.tcl, which, by the way displays a simple tk window when run from tclsh, is as follows: #! /usr/bin/tclsh package require Tk ttk::frame .c -padding 3 3 12 12 ttk::frame .c.f -borderwidth 5 -relief sunken -width 200 -height 100 ttk::label .c.namelbl -text Name grid .c -column 0 -row 0 -sticky nsew grid .c.f -column 0 -row 0 -columnspan 3 -rowspan 2 -sticky nsew grid .c.namelbl -column 3 -row 0 -columnspan 2 -sticky nw -padx 5 Do you have any comments on this? Thanks, --Sergio. -- View this message in context: http://r.789695.n4.nabble.com/Trying-to-build-up-a-user-interface-with-the-R-tcltk-package-tp4639426.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
Re: [R] add leading zeros
On Aug 7, 2012, at 3:55 AM, Liviu Andronic wrote: Hello On Fri, Jul 27, 2012 at 6:54 AM, R. Michael Weylandt michael.weyla...@gmail.com wrote: Much easier than you think: x - c(1L, 9000L) sprintf(%05i,x) For anyone interested, I came up with a small wrapper for the above: add.lead - function(x, width=max(nchar(x))){ sprintf(paste('%0', width, 'i', sep=''), x) } Thanks, Liviu; Your post prompted me to add a variant in my .Rprofile that adds leading zeros to numeric-date values in ddmm format which lost them because they were imported as integers (because I forgot to use colClasses.) add.dt0 - function(x, width=8 ){ sprintf(paste('%0', width, switch(is.numeric(x)+1, 's', 'i'), sep=''), x) } Can also be used for Excel (character) output that omits the leading 0 in date fields that were output in csv-format as m/dd/yy. #character input dts - (7/12/08, 11/11/11) as.Date(add.dt0(dts), format=%d/%m/%y, origin=1970-01-01) #[1] 2008-12-07 2011-11-11 # numeric input as.Date(add.dt0(1122011), format=%d%m%Y, origin=1970-01-01) #[1] 2011-12-01 as.Date(1122011, format=%d%m%Y, origin=1970-01-01) [1] NA as.Date(add.dt0(1122011), format=%d%m%Y, origin=1970-01-01) [1] 2011-12-01 as.Date(01122011, format=%d%m%Y, origin=1970-01-01) [1] NA as.Date(add.dt0(01122011), format=%d%m%Y, origin=1970-01-01) [1] 2011-12-01 -- David. x - c(1L, 15L, 234L, 9000L) (xa - add.lead(x)) [1] 0001 0015 0234 9000 nchar(xa) [1] 4 4 4 4 (xb - add.lead(x, 5)) [1] 1 00015 00234 09000 nchar(xb) [1] 5 5 5 5 (xc - add.lead(x, 15)) [1] 001 015 234 0009000 nchar(xc) [1] 15 15 15 15 Regards Liviu David Winsemius, MD Alameda, CA, USA __ 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, reproducible code.
[R] looking for accessibility help (blind student)
I will have a blind student in my AP Statistics class this year. I'm thinking about using R as his calculator. It seems like it's core text-in text-out nature may match screen reading software well. And I'd like to explore directing visualizations to tactile graphics output. I'm wondering if anyone could give me suggestions (people, websites, organizations) where I could discover anything that could help me help him. Thanks so much. Peter++ === Peter Petto ppe...@ppetto.com Lakewood High School Math cell: 440.249.4289 [[alternative HTML version deleted]] __ 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, reproducible code.
[R] summing and combining rows
Hello, I have a data set that needs to be combined so that rows are summed by a group based on a certain variable. I'm pretty sure rowsum() or rowsums() can do this but it's difficult for me to figure out how it will work for my data based on the examples I've read. My data are structured like this: PlotSizeClassStems 12 Class31 12 Class43 17 Class35 17 Class42 I simply want to sum the size classes by plot and create a new data frame with a size class called Class34 or with the SizeClass variable removed. I actually do have other size classes that I want to leave alone, but combine 3 and 4, so if I could figure out how to do this by creating a new class, that would be preferable. I've also attached a more detailed sample of data. Thanks, Chris Dolanc -- Christopher R. Dolanc Post-doctoral Researcher University of Montana and UC-Davis Data Plot Lat LatCat Elevation ElevCatType SizeClass Stems Area Density 5171 VTM 39C16 39.76282 Lat6 1500 Elev1 ConiferClass3 0 751.5347 0.0 5172 VTM 39C16 39.76282 Lat6 1500 Elev1 ConiferClass4 1 751.5347 13.30611 5771 VTM 39F11 39.57721 Lat6 500 Elev1 ConiferClass3 0 751.5347 0.0 5772 VTM 39F11 39.57721 Lat6 500 Elev1 ConiferClass4 0 751.5347 0.0 5787 VTM 39F13 39.56214 Lat6 1500 Elev1 ConiferClass3 3 694.0784 0.0 5788 VTM 39F13 39.56214 Lat6 1500 Elev1 ConiferClass4 1 694.0784 0.0 5795 VTM 39F14 39.54522 Lat6 900 Elev1 ConiferClass3 1 763.9850 13.08926 5796 VTM 39F14 39.54522 Lat6 900 Elev1 ConiferClass4 2 763.9850 0.0 __ 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, reproducible code.
[R] Error using ddply inside user-defined function
Hi All, I *think* it's ddply because the function recognizes vr1, etc, in other parts of the function. Here's some code: # create dataset PROV.PM.FBCTS - c(0.00 ,0.00, 33205.19, 25994.56, 23351.37, 26959.56 ,27632.58, 26076.24, 0.00, 0.00 , 6741.42, 18665.09 ,18129.59 ,21468.39 ,21294.60 ,22764.82, 26076.73) FBCTS.INV.TOT - c(0 , 0, 958612, 487990, 413344, 573347, 870307, 552681 , 0, 0 , 163831 , 400161 , 353000, 358322 , 489969, 147379, 1022769) FBCTS.REC.TOT - c(0 ,0, 1638818 ,297119 , 299436 ,414164 , 515735, 529001 ,0, 0 , 427341 , 625893 ,437854 , 407091, 425119 , 8663, 0) MECH.NAME - c(Mechanism A,Mechanism A,Mechanism A,Mechanism A,Mechanism A,Mechanism A,Mechanism A,Mechanism A, Mechanism B,Mechanism B,Mechanism B,Mechanism B,Mechanism B,Mechanism B,Mechanism B,Mechanism B,Mechanism B,) vn - data.frame(MECH.NAME, PROV.PM.FBCTS, FBCTS.INV.TOT, FBCTS.REC.TOT) # create function allocation - function(vr1, vr2, vr3) { d - ddply(vn, MECH.NAME, summarise, SUM = vr1 + vr2 + vr3) vn - merge(vn, d, by.x=MECH.NAME, by.y=MECH.NAME, all=T) new - (vr1+vr2+vr3) / vn$SUM return(new) } # run function vn$PROV.PM.FBCTS - allocation(PROV.PM.FBCTS, FBCTS.INV.TOT, FBCTS.REC.TOT) Here's the error: vn$PROV.PM.FBCTS - allocation(PROV.PM.FBCTS, FBCTS.INV.TOT, FBCTS.REC.TOT) Error in eval(expr, envir, enclos) : object 'vr1' not found # If I pull the calculations out of the function it works: d - ddply(vn, MECH.NAME, summarise, SUM = sum(PROV.PM.FBCTS, FBCTS.INV.TOT, FBCTS.REC.TOT)) vn - merge(vn, d, by.x=MECH.NAME, by.y=MECH.NAME, all=T) vn$PROV.PM.FBCTS - (PROV.PM.FBCTS + FBCTS.INV.TOT + FBCTS.REC.TOT) / vn$SUM vn MECH.NAME PROV.PM.FBCTS FBCTS.INV.TOT FBCTS.REC.TOT SUM 1 Mechanism A0. 0 0 7713774 2 Mechanism A0. 0 0 7713774 3 Mechanism A0.34103091958612 1638818 7713774 4 Mechanism A0.10515004487990297119 7713774 5 Mechanism A0.09543077413344299436 7713774 6 Mechanism A0.13151418573347414164 7713774 7 Mechanism A0.18326628870307515735 7713774 8 Mechanism A0.14360783552681529001 7713774 9 Mechanism B0. 0 0 5402533 10 Mechanism B0. 0 0 5402533 11 Mechanism B0.11067280163831427341 5402533 12 Mechanism B0.19337580400161625893 5402533 13 Mechanism B0.14974155353000437854 5402533 14 Mechanism B0.14565046358322407091 5402533 15 Mechanism B0.17332290489969425119 5402533 16 Mechanism B0.03309685147379 8663 5402533 17 Mechanism B0.19413964 1022769 0 5402533 Can anyone help me figure out why I can't put this calculation in a function? Is this a systemic thing I should look for in the future? I know there are other ways to do what I want, but I am not very curious about this. Best, Jen [[alternative HTML version deleted]] __ 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, reproducible code.
[R] Execution of a function
Hi i have aproblem withe execution of my function first, i wrote my function in the script of R nom_fonction - function(arg1[=expr1], arg2[=expr2], ...){ bloc d'instructions } when i want to have the result i mean the laste instruction in the bloc of instruction , i try to wrote the name of function source(aj.fun) Error in readLines(file, warn = FALSE) : 'con' is not a connection return(aj.fun) Error: no function to return from, jumping to top level thanks for helping hafida, univ of algeria -- View this message in context: http://r.789695.n4.nabble.com/Execution-of-a-function-tp4639424.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
[R] help to program my function
HI i have a problem please help me to solve it: http://r.789695.n4.nabble.com/file/n4639434/aj.pdf aj.pdf i want to calculate the vecteur a[j] where j: 1...8 this is the code in R: aj.fun - function(j, i, X, z, E, beta0, beta1){ + n - length(X) + iX - order(X) + iz - order(z) + e1 - -(beta)*z[ iz[1:(i - 1)] ] + numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1) ) + e2 - -(beta)*z[ iz[i:n] ] + denom - sum( exp(e2) ) + numer/denom + } iX-order(X) iX [1] 75 37 29 60 73 20 69 55 30 70 72 38 26 35 65 61 74 50 71 57 25 54 64 76 56 [26] 58 48 67 46 63 28 62 36 49 47 66 1 42 41 19 39 43 22 51 68 33 27 9 15 11 [51] 10 59 32 40 45 44 52 16 18 34 4 53 21 23 31 7 6 13 14 12 17 24 5 8 2 [76] 3 iZ-order(Z) iZ [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 [51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 [76] 76 e1 - -(beta)*Z[ iZ[1:(i - 1)] ] Warning message: In 1:(i - 1) : numerical expression has 76 elements: only the first used e1 [1] -442 -1664 numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1)) Warning message: In 1:(i - 1) : numerical expression has 76 elements: only the first used numer [1] 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 e2 - -(beta)*Z[ iZ[i:n] ] Warning message: In i:n : numerical expression has 76 elements: only the first used e2 [1] -442 -1664 -442 -1792 -476 -1792 -476 -1792 -510 -1920 -510 -1920 [13] -510 -1920 -510 -1920 -510 -1920 -510 -2048 -544 -2048 -544 -2048 [25] -544 -2048 -544 -2048 -544 -2048 -544 -2048 -544 -2048 -578 -2176 [37] -578 -2176 -578 -2176 -578 -2176 -578 -2176 -578 -2176 -578 -2176 [49] -578 -2176 -578 -2176 -578 -2304 -612 -2304 -612 -2304 -612 -2304 [61] -612 -2304 -612 -2304 -612 -2304 -612 -2304 -646 -2432 -646 -2432 [73] -646 -2432 -646 -2432 denom - sum( exp(e2) ) numer/denom [1] 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 [6] 4.313746e+192 4.313746e+192 4.313746e+192 my problem that the vecteur a[j] could not have the same number!!! thank you in advance hafida -- View this message in context: http://r.789695.n4.nabble.com/help-to-program-my-function-tp4639434.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code.
Re: [R] summing and combining rows
On Tue, Aug 7, 2012 at 12:47 PM, Christopher R. Dolanc crdol...@ucdavis.edu wrote: Hello, I have a data set that needs to be combined so that rows are summed by a group based on a certain variable. I'm pretty sure rowsum() or rowsums() can do this but it's difficult for me to figure out how it will work for my data based on the examples I've read. My data are structured like this: PlotSizeClassStems 12 Class31 12 Class43 17 Class35 17 Class42 I simply want to sum the size classes by plot Which variable do you want to sum? You'll want to use something like aggregate( XXX ~ YYY, data = dat.name, FUN = sum) to sum variable XXX by classes YYY. See ? aggregate for more details and worked examples. Cheers, Michael and create a new data frame with a size class called Class34 or with the SizeClass variable removed. I actually do have other size classes that I want to leave alone, but combine 3 and 4, so if I could figure out how to do this by creating a new class, that would be preferable. I've also attached a more detailed sample of data. Thanks, Chris Dolanc -- Christopher R. Dolanc Post-doctoral Researcher University of Montana and UC-Davis __ 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, reproducible code. __ 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, reproducible code.
Re: [R] test if elements of a character vector contain letters
On Tue, Aug 7, 2012 at 4:28 AM, Liviu Andronic landronim...@gmail.com wrote: On Mon, Aug 6, 2012 at 7:35 PM, Marc Schwartz marc_schwa...@me.com wrote: is.letter - function(x) grepl([[:alpha:]], x) is.number - function(x) grepl([[:digit:]], x) Quick follow-up question. I'm always reluctant to create functions that would resemble the method of a function (here, is() ), but would in fact not be a genuine method. So would there be any incompatibility between is() and is.letter(), given that the latter is not a method of the former? Is it good (or acceptable) practice to define is.letter() as above? Would is_letter() be better? It certainly won't cause problems if you never define anything of class letter or number. Regards Liviu __ 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, reproducible code.
Re: [R] Execution of a function
On Tue, Aug 7, 2012 at 11:26 AM, hafida hafida...@hotmail.fr wrote: Hi i have aproblem withe execution of my function first, i wrote my function in the script of R nom_fonction - function(arg1[=expr1], arg2[=expr2], ...){ bloc d'instructions } when i want to have the result i mean the laste instruction in the bloc of instruction , i try to wrote the name of function source(aj.fun) Error in readLines(file, warn = FALSE) : 'con' is not a connection source() takes a file name, not a function name. Cheers, Michael return(aj.fun) Error: no function to return from, jumping to top level Don't use return() outside of functions. thanks for helping hafida, univ of algeria -- View this message in context: http://r.789695.n4.nabble.com/Execution-of-a-function-tp4639424.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code.
[R] Re-grouping data in R
I have a data frame with a column of values that I want to bucket (group) into specific levels. str(dat)'data.frame': 3678 obs. of 39 variables: $ id : int 23 76 129 156 166 180 200 214 296 344 ... $ final_purchase_amount : Factor w/ 32 levels \\N,1082,1109,..: 1 1 1 1 1 1 1 1 1 1 ... So I ran the following to produce new levels, one for values from 100 to 400, 401 to 1000, and 1001+. dat$final_purchase_amount- NA dat$final_purchase_amount[dat$final_purchase_amount %in% levels(dat$final_purchase_amount)[c(8,9,11,12,13,15,16,17,18,19,20,21)]] - 100 to 400 dat$final_purchase_amount[dat$final_purchase_amount %in% levels(dat$final_purchase_amount)[c(22,23,24,25,26,27,28,29,30,31,32)]] - 401 to 1000 dat$final_purchase_amount[dat$final_purchase_amount %in% levels(dat$final_purchase_amount)[c(2,3,4,5,6,7,10,14)]] - 1001 + dat$final_purchase_amount - factor(dat$final_purchase_amount) levels(dat$final_purchase_amount) table(dat$final_purchase_amount) However, this doesn't seem to produce any levels and returns the following. levels(dat$final_purchase_amount)character(0) Can anyone point to what I'm doing wrong. Thanks! -- *Abraham Mathew Statistical Analyst www.amathew.com 720-648-0108 @abmathewks* [[alternative HTML version deleted]] __ 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, reproducible code.
[R] What is this called? lapply(datum,[[,ColumnName)
Hello R users I recently learned how to use this command: lapply(datum,[[,ColumnName) Unfortunately, I don't know how exactly it works, what it's called (in particular the [[ part], and what other things you can do with it (retrieve multiple columns?). Given datum is a list of dataframes with the same column, but different number of rows, lapply(datum,[[,ColumnName), Returns you a list of a particular column form each of your dataframes from datum. I think this is a really useful command, and would like to learn more about it. Unfortunately I don't know what subject or topic it is under and cannot look it up in a book. Thank you, Kevin Master of Science Student Department of Food, Resource and Agricultural Economics University of Guelph Office:519-824-4120 ext. 58528 Mobile: 226-979-2813 http://fare.uoguelph.ca/users/kchang01 http://fare.uoguelph.ca/users/kchang01 [[alternative HTML version deleted]] __ 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, reproducible code.
Re: [R] Decimal number
Hi hafida, I fail to understand the question. Could you elaborate please ? Is this what you want ? beta0 = 64.90614 beta1 = 17.7025 beta-c(beta0, beta1) beta [1] 64.90614 17.70250 As a side note, please keep in mind that R doesn't allow white space within variable name (name it her_beta instead). Cheers, Eloi Salut Hafida, je ne comprend pas la question. Peux tu détailler stp ? Si c'est pour afficher les valeurs complètes de beta0 et beta1 alors l'exemple ci-dessus devrait faire l'affaire. Autrement, R n'autorise pas la présence d'espace dans le nom des variables. Cordialement, Eloi On 12-08-07 01:37 PM, hafida wrote: hello arun her beta can be considered simply as an object. when i wrote beta I want to get the number of beta and beta with the full part after the comma hafida -- View this message in context: http://r.789695.n4.nabble.com/Decimal-number-tp4639428p4639452.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. -- Eloi Mercier Bioinformatics PhD Student, UBC Paul Pavlidis Lab 2185 East Mall University of British Columbia Vancouver BC V6T1Z4 __ 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, reproducible code.
Re: [R] NADA Package: Referencing Data Frame Columns
On Aug 7, 2012, at 11:31 AM, R. Michael Weylandt wrote: On Tue, Aug 7, 2012 at 11:26 AM, Rich Shepard rshep...@appl-ecosys.com wrote: The sample data sets that come with the NADA package are limited to one or two variables and a censored measurement indicator column. I try to mimic examples using my data but keep missing the target. snipped Is the appropriate way to use the NADA methods for analyses and plotting to subset each chemical separately from the 'chem' data frame? Or, is there a syntax other than, for example, _ cenboxplot(chemVdis, chem$ceneq1, chem$era) ___^ Incorrect use of '' when '$' was intended. Error in cenros(obs[group == i], cen[group == i]) : error in evaluating the argument 'obs' in selecting a method for function 'ros': Error: object 'Vdis' not found I get the same error when trying to use the 'chem.cast' data frame. Take a look at with() Michael David Winsemius, MD Alameda, CA, USA __ 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, reproducible code.
Re: [R] process evaluation packages (slightly off topic)
Hello, There's also, apparently for simple needs, plotrix::gantt.chart See an example in http://addictedtor.free.fr/graphiques/sources/source_74.R To transfer graphs to timelines, etc, (or anything graph related) package igraph. Hope this helps, Rui Barradas Em 07-08-2012 14:46, Bert Gunter escreveu: Search on R package Gantt, where you will find, among others, http://cran.r-project.org/web/packages/plan/plan.pdf -- Bert On Tue, Aug 7, 2012 at 1:28 AM, Petr PIKAL petr.pi...@precheza.cz wrote: Dear all I need to perform some process evaluation. Sorry for not posting data and code - I do not have any, I ask only for pointing me to correct direction. Suppose I have several connected processes P1, P2, ..., Pn. Each process takes some time and have some capacity (let say like preparing a dinner for several persons - only one stove, limited capacity of utensils, heating and cooling takes some time) and some processes can by cyclic (fry onion in pan, put it aside, in the same pan fry meat, put an onion and some water and simmer for a while...). I can prepare some oriented graph (paper/pencil) or Word or drawing programme, I can also evaluate whole process by shading spreadsheet cells but those two tasks are not connected. Is there any R package/other software suitable for simplifying or helping in such tasks? E.g. When I prepare oriented graph with capacity and time for each node is there any automatic way to transfer this graph to timeline to see how long whole process will take, where are bottlenecks or so? Thank you Petr __ 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, reproducible code. __ 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, reproducible code.
Re: [R] What is this called? lapply(datum,[[,ColumnName)
I... cannot look it up in a book. Baloney! Read the R Language Definition manual section on indexing in the Evaluation of Expressions Chapter. Then ?lapply and ?[[ -- and the relevant sections in The Introduction to R manual. However, I will admit that it's tricky. The point to grasp -- described at various levels of detail in the above manuals and in numerous other resources that you can check out on the CRAN website -- is that y[[a]] is just syntactic sugar for [[(y,a) . R is a functional language (mostly). So your lapply statement is just lapplying the [[ function(extraction operator ) to the list of data frames. Cheers, Bert On Tue, Aug 7, 2012 at 12:06 PM, Kevin Chang kchan...@uoguelph.ca wrote: Hello R users I recently learned how to use this command: lapply(datum,[[,ColumnName) Unfortunately, I don't know how exactly it works, what it's called (in particular the [[ part], and what other things you can do with it (retrieve multiple columns?). Given datum is a list of dataframes with the same column, but different number of rows, lapply(datum,[[,ColumnName), Returns you a list of a particular column form each of your dataframes from datum. I think this is a really useful command, and would like to learn more about it. Unfortunately I don't know what subject or topic it is under and cannot look it up in a book. Thank you, Kevin Master of Science Student Department of Food, Resource and Agricultural Economics University of Guelph Office:519-824-4120 ext. 58528 Mobile: 226-979-2813 http://fare.uoguelph.ca/users/kchang01 http://fare.uoguelph.ca/users/kchang01 [[alternative HTML version deleted]] __ 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, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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, reproducible code.
Re: [R] Decimal number
Hello Hafida, So, I guess the decimal number problem is solved. I'll check on it. A.K. From: hafida goual hafida...@hotmail.fr To: smartpink...@yahoo.com Sent: Tuesday, August 7, 2012 4:58 PM Subject: RE: [R] Decimal number thank you a lot please can you visite my post titled executed function. hafida Date: Tue, 7 Aug 2012 13:55:00 -0700 From: smartpink...@yahoo.com Subject: Re: [R] Decimal number To: hafida...@hotmail.fr CC: r-help@r-project.org Hello, beta0-64.90614 beta1-17.7025 herbeta-c(beta0,beta1) herbeta [1] 64.90614 17.70250 So, here you have herbeta (or is it simply beta) assigned to the vector containing values of beta0 and beta1. Your statement I want to get the number of beta and beta with the full part after the comma is confusing. A.K. - Original Message - From: hafida hafida...@hotmail.fr To: r-help@r-project.org Cc: Sent: Tuesday, August 7, 2012 4:37 PM Subject: Re: [R] Decimal number hello arun her beta can be considered simply as an object. when i wrote beta I want to get the number of beta and beta with the full part after the comma hafida -- View this message in context: http://r.789695.n4.nabble.com/Decimal-number-tp4639428p4639452.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code.
Re: [R] Execution of a function
HI, Suppose, I have a function like this: fun1-function(x){ ifelse(x[1]0, sum(x[min(which(x0)):(which.max(x0)-1)]), sum(x[min(which(x0)):max(which(x0))]) ) } #And I save it as aj.fun (-- filename) #Then, source(aj.fun) fun1 function(x){ ifelse(x[1]0, sum(x[min(which(x0)):(which.max(x0)-1)]), sum(x[min(which(x0)):max(which(x0))]) ) } a1-c(-5,-2,4,2,-4,-6,3) fun1(a1) #[1] -7 Hope this helps. A.K. - Original Message - From: hafida hafida...@hotmail.fr To: r-help@r-project.org Cc: Sent: Tuesday, August 7, 2012 12:26 PM Subject: [R] Execution of a function Hi i have aproblem withe execution of my function first, i wrote my function in the script of R nom_fonction - function(arg1[=expr1], arg2[=expr2], ...){ bloc d'instructions } when i want to have the result i mean the laste instruction in the bloc of instruction , i try to wrote the name of function source(aj.fun) Error in readLines(file, warn = FALSE) : 'con' is not a connection return(aj.fun) Error: no function to return from, jumping to top level thanks for helping hafida, univ of algeria -- View this message in context: http://r.789695.n4.nabble.com/Execution-of-a-function-tp4639424.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code.
[R] reshape2's dcast() Adds NAs to Data Frame
I need to understand how and why dcast() adds NAs to a data frame that contained no missing values. The database table of chemical concentrations has all missing values removed because they cannot contribute to data analyses. The structure of the R data frame of these data have no NA values, and neither does the data frame resulting from applying the reshape2 melt() function to it. However, the data frame produced by the dcast() function does contain NAs for all chemicals. I assume this is because of the syntax I used: chem.cast - dcast(chem.melt, site + sampdate + era + ceneq1 + floor + ceiling ~ param) How should I reshape the data frame from long to wide without adding these spurious NAs? Rich __ 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, reproducible code.
[R] Setting Number of Displayed Digits
Some chemicals have concentrations at or below the method detection limit (MDL; 'less-thans') of 0.005 mg/L. When I look at the data frame that is how the concentration is displayed. But, when I ask for a summary() of that data frame column only 0 is displayed. How can I adjust the number of digits displayed by functions such as summary()? Rich __ 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, reproducible code.
Re: [R] help to program my function
Hello, Your problem is something else, before returning a vector of only the same values there are warning messages. Inline. Em 07-08-2012 18:14, hafida escreveu: HI i have a problem please help me to solve it: http://r.789695.n4.nabble.com/file/n4639434/aj.pdf aj.pdf i want to calculate the vecteur a[j] where j: 1...8 this is the code in R: aj.fun - function(j, i, X, z, E, beta0, beta1){ + n - length(X) + iX - order(X) + iz - order(z) + e1 - -(beta)*z[ iz[1:(i - 1)] ] + numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1) ) + e2 - -(beta)*z[ iz[i:n] ] + denom - sum( exp(e2) ) + numer/denom + } iX-order(X) iX [1] 75 37 29 60 73 20 69 55 30 70 72 38 26 35 65 61 74 50 71 57 25 54 64 76 56 [26] 58 48 67 46 63 28 62 36 49 47 66 1 42 41 19 39 43 22 51 68 33 27 9 15 11 [51] 10 59 32 40 45 44 52 16 18 34 4 53 21 23 31 7 6 13 14 12 17 24 5 8 2 [76] 3 iZ-order(Z) iZ [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 [51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 [76] 76 e1 - -(beta)*Z[ iZ[1:(i - 1)] ] Warning message: In 1:(i - 1) : numerical expression has 76 elements: only the first used This means that 'i' is a vector of length 76, which, in this context, is illegal. The variable 'i' must be a vector of only ONE value. If you want to compute the function for several (76) values do it one at a time, the function aj.fun is not vectorized. Hope this helps, Rui Barradas e1 [1] -442 -1664 numer - E[j] - sum( X[ iX[1:(i - 1)] ] * exp(e1)) Warning message: In 1:(i - 1) : numerical expression has 76 elements: only the first used numer [1] 9.5 9.5 9.5 9.5 9.5 9.5 9.5 9.5 e2 - -(beta)*Z[ iZ[i:n] ] Warning message: In i:n : numerical expression has 76 elements: only the first used e2 [1] -442 -1664 -442 -1792 -476 -1792 -476 -1792 -510 -1920 -510 -1920 [13] -510 -1920 -510 -1920 -510 -1920 -510 -2048 -544 -2048 -544 -2048 [25] -544 -2048 -544 -2048 -544 -2048 -544 -2048 -544 -2048 -578 -2176 [37] -578 -2176 -578 -2176 -578 -2176 -578 -2176 -578 -2176 -578 -2176 [49] -578 -2176 -578 -2176 -578 -2304 -612 -2304 -612 -2304 -612 -2304 [61] -612 -2304 -612 -2304 -612 -2304 -612 -2304 -646 -2432 -646 -2432 [73] -646 -2432 -646 -2432 denom - sum( exp(e2) ) numer/denom [1] 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 4.313746e+192 [6] 4.313746e+192 4.313746e+192 4.313746e+192 my problem that the vecteur a[j] could not have the same number!!! thank you in advance hafida -- View this message in context: http://r.789695.n4.nabble.com/help-to-program-my-function-tp4639434.html Sent from the R help mailing list archive at Nabble.com. __ 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, reproducible code. __ 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, reproducible code.
[R] Which R function for GLMM with binary response, nested random factors with temporal correlation?
Despite lots of investigation, I haven't found any R packages might be suitable for the following problem. I'd be very grateful for suggestions. I have three-way nested data, with a series of measures (obs) taken in quick succession (equal time spacing) from each subject on different days. The measures taken on the same day are temporally correlated, so I'd like to use an AR1 correlation structure for those, but treat subjects and days as nested random factors (random intercept) since there is little temporal correlation between days. The response is binary. So I need a GLMM with a correlation structure. I've tried using GEE, but the R packages can't cope with multilevel nested data. The only R function I've found that can do this is glmmPQL. m - glmmPQL(y ~ f1 * f2 * f3 + (1|subj/day), correlation=corAR1(form =~obsno|subj/day)) f1 - f3 are fixed factors However, PQL estimation is not recommended for binary response data. With no AIC and unreliable p values, model selection seems impossible! So my question is: 1) are there any other functions which are suitable for a GLMM with multilevel nested random effects and a AR1 correlation structure? Or is MCMC the only option? 2) to make things more complicated, I'd also like to include a varFunc variance structure to cope with heterogeneity. Is this possible in ML methods in R? I'd also like to extend to a multinomial response at a later stage. GEE seems the best bet, but I come unstuck with the three-way nested factors. Thanks for your help. __ 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, reproducible code.
[R] Setting Number of Displayed Digits
Some chemicals have concentrations at or below the method detection limit (MDL; 'less-thans') of 0.005 mg/L. When I look at the data frame that is how the concentration is displayed. But, when I ask for a summary() of that data frame column only 0 is displayed. How can I adjust the number of digits displayed by functions such as summary()? Rich __ 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, reproducible code.
Re: [R] Which R function for GLMM with binary response, nested random factors with temporal correlation?
Have you posted on R-sig-mixed-models? That would be more likely to yield useful responses than here. -- Bert On Tue, Aug 7, 2012 at 3:02 PM, Andrew Digby andrewdi...@mac.com wrote: Despite lots of investigation, I haven't found any R packages might be suitable for the following problem. I'd be very grateful for suggestions. I have three-way nested data, with a series of measures (obs) taken in quick succession (equal time spacing) from each subject on different days. The measures taken on the same day are temporally correlated, so I'd like to use an AR1 correlation structure for those, but treat subjects and days as nested random factors (random intercept) since there is little temporal correlation between days. The response is binary. So I need a GLMM with a correlation structure. I've tried using GEE, but the R packages can't cope with multilevel nested data. The only R function I've found that can do this is glmmPQL. m - glmmPQL(y ~ f1 * f2 * f3 + (1|subj/day), correlation=corAR1(form =~obsno|subj/day)) f1 - f3 are fixed factors However, PQL estimation is not recommended for binary response data. With no AIC and unreliable p values, model selection seems impossible! So my question is: 1) are there any other functions which are suitable for a GLMM with multilevel nested random effects and a AR1 correlation structure? Or is MCMC the only option? 2) to make things more complicated, I'd also like to include a varFunc variance structure to cope with heterogeneity. Is this possible in ML methods in R? I'd also like to extend to a multinomial response at a later stage. GEE seems the best bet, but I come unstuck with the three-way nested factors. Thanks for your help. __ 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, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm __ 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, reproducible code.
[R] r-forge down?
Hi Folks, I've looked around, haven't found anything, and I'm not sure where else to check. I haven't visited R-forge (http://r-forge.r-project.org) in a long time. Now that I'm trying, it seems to be down. Anyone know if this is a temporary condition, and if so, when it's expected to rise again? Thanks, Allie __ 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, reproducible code.
Re: [R] Re-grouping data in R
Your first command erases all the data in that column: dat$final_purchase_amount- NA so when you refer to it later, it consists of only NAs. -- David L Carlson Associate Professor of Anthropology Texas AM University College Station, TX 77843-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Abraham Mathew Sent: Tuesday, August 07, 2012 1:57 PM To: r-help@r-project.org Subject: [R] Re-grouping data in R I have a data frame with a column of values that I want to bucket (group) into specific levels. str(dat)'data.frame': 3678 obs. of 39 variables: $ id : int 23 76 129 156 166 180 200 214 296 344 ... $ final_purchase_amount : Factor w/ 32 levels \\N,1082,1109,..: 1 1 1 1 1 1 1 1 1 1 ... So I ran the following to produce new levels, one for values from 100 to 400, 401 to 1000, and 1001+. dat$final_purchase_amount- NA dat$final_purchase_amount[dat$final_purchase_amount %in% levels(dat$final_purchase_amount)[c(8,9,11,12,13,15,16,17,18,19,20,21)] ] - 100 to 400 dat$final_purchase_amount[dat$final_purchase_amount %in% levels(dat$final_purchase_amount)[c(22,23,24,25,26,27,28,29,30,31,32)]] - 401 to 1000 dat$final_purchase_amount[dat$final_purchase_amount %in% levels(dat$final_purchase_amount)[c(2,3,4,5,6,7,10,14)]] - 1001 + dat$final_purchase_amount - factor(dat$final_purchase_amount) levels(dat$final_purchase_amount) table(dat$final_purchase_amount) However, this doesn't seem to produce any levels and returns the following. levels(dat$final_purchase_amount)character(0) Can anyone point to what I'm doing wrong. Thanks! -- *Abraham Mathew Statistical Analyst www.amathew.com 720-648-0108 @abmathewks* [[alternative HTML version deleted]] __ 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, reproducible code. __ 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, reproducible code.
Re: [R] r-forge down?
http://www.rforge.net -Roy On Aug 7, 2012, at 3:25 PM, Alexander Shenkin wrote: Hi Folks, I've looked around, haven't found anything, and I'm not sure where else to check. I haven't visited R-forge (http://r-forge.r-project.org) in a long time. Now that I'm trying, it seems to be down. Anyone know if this is a temporary condition, and if so, when it's expected to rise again? Thanks, Allie __ 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, reproducible code. ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center 1352 Lighthouse Avenue Pacific Grove, CA 93950-2097 e-mail: roy.mendelss...@noaa.gov (Note new e-mail address) voice: (831)-648-9029 fax: (831)-648-8440 www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. From those who have been given much, much will be expected the arc of the moral universe is long, but it bends toward justice -MLK Jr. __ 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, reproducible code.
Re: [R] r-forge down?
Thanks Roy, That's one R-forge site, but my impression is that the r-forge.r-project.org site is a different one (and it's the one that hosts the package I'm interested in). Please correct me if those two sites are somehow related. thanks, allie On 8/7/2012 5:29 PM, Roy Mendelssohn wrote: http://www.rforge.net -Roy On Aug 7, 2012, at 3:25 PM, Alexander Shenkin wrote: Hi Folks, I've looked around, haven't found anything, and I'm not sure where else to check. I haven't visited R-forge (http://r-forge.r-project.org) in a long time. Now that I'm trying, it seems to be down. Anyone know if this is a temporary condition, and if so, when it's expected to rise again? Thanks, Allie __ 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, reproducible code. ** The contents of this message do not reflect any position of the U.S. Government or NOAA. ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center 1352 Lighthouse Avenue Pacific Grove, CA 93950-2097 e-mail: roy.mendelss...@noaa.gov (Note new e-mail address) voice: (831)-648-9029 fax: (831)-648-8440 www: http://www.pfeg.noaa.gov/ Old age and treachery will overcome youth and skill. From those who have been given much, much will be expected the arc of the moral universe is long, but it bends toward justice -MLK Jr. __ 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, reproducible code.
[R] Setting Number of Displayed Digits
Some chemicals have concentrations at or below the method detection limit (MDL; 'less-thans') of 0.005 mg/L. When I look at the data frame that is how the concentration is displayed. But, when I ask for a summary() of that data frame column only 0 is displayed. How can I adjust the number of digits displayed by functions such as summary()? Rich __ 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, reproducible code.