[R] summing items within a row
Hello, I am trying to figure out how to do a sum of items within a row. For example, I have a data frame something like this: A1 B1 ... A2 B2 ... 1 1 41 4 2 2 52 5 3 3 63 6 What I want, is for each row, to get A1 + A2, B1 + B2, etc. which would, perhaps, give me a vector something like this c(2, 8, ... 4, 10 ... 6, 12). Does anyone know of a simple way to do this? Thanks a lot, Q -- View this message in context: http://r.789695.n4.nabble.com/summing-items-within-a-row-tp2195458p2195458.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 items within a row
Thank you Dennis. That was a great idea and it worked quite well! -- View this message in context: http://r.789695.n4.nabble.com/summing-items-within-a-row-tp2195458p2196793.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] Dealing with 1000+ sequentially named vectors
Hello! I'm having trouble figuring out how to apply a function to a set of vectors or data frames, when that set is over 1000 large. I've created 1891 vectors named as follows: vector.names <- paste("vector",1:1891,sep="") These can be referred to easily by using get as follows: vector <- get(vector.names[1]) The problem is, I can't figure out a way to refer to all of them as a group, and then apply a function to each one. Basically, I have 5000 data frames, each with 1891 rows. I want a vector for each row, and a cell from each data frame in each vector. That would give me 1891 vectors with 5000 members each. The only way I know how to do this, is to use loops, which end up being really slow. So: for(a in 1:5000){ data <- get(dataframes[a]) for(b in 1:1891){ vector <- get(vector.names[b] vector[a] <- data$value assign(vector.names[b], vector) } } Does anyone have any insight into dealing with large quantities of data like this? Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Dealing-with-1000-sequentially-named-vectors-tp2221942p2221942.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] Dealing with 1000+ sequentially named vectors
Thanks a lot! This has helped send me in the right direction. I'm not used to think outside of the loop. -- View this message in context: http://r.789695.n4.nabble.com/Dealing-with-1000-sequentially-named-vectors-tp2221942p2225360.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] SAP ABAP Consultant available
Please DO NOT put ads for your services on this site. This is a violation of the R forum terms. I will be forwarding this issue to the appropriate moderator to take further action. On Tue, Jun 12, 2012 at 1:37 PM, Kanna wrote: > > [1]Click here to unsubscribe if you no longer wish to receive our emails > > Hello, > > We have an excellent consultant, Pritesh Agrawal - SAP ABAP . Below is > his/her quick profile for your review. > > Pritesh Agrawal - SAP ABAP - > > Rate: Open Total Exp: 9+ Available: immediate Relocation: > OPEN > > > Over 9.5 years of work experience in SAP R/3 technical, functional and > project management for clients in UK, Europe, Asia, and North America. > Specializes in, SAP ABAP, ABAP OOPS, Interfaces using ALE/EDI/IDOC and > SAP > Business Workflow. Worked extensively in functional areas FI/CO, SD, MM, > PP, > QM, SC, DC, CRM, APO IS-Utilities, IS-Retail. Implementation experience > on > all types of ABAP development which included designing and developing > objects related to Interfaces, Conversions, Enhancements, SAP scripts, > Smartforms, Reports, Data Dictionary, RFCs, ALE/EDI, Workflows, BADIs, > Enhancement spots, BAPIs, Dialog Programming & Program Optimization. > Extensively used LSMW for Master Data uploads. Expertise in applying OSS > Notes and performing runtime analysis and optimization of programs. > > Working experience in environments R/3 4.0, 4.6, 4.7, ECC 5.0, ECC 6.0, > ERP > 6.0 EHP5. Upgrade and Support Pack application activities using SPAU and > SPDD > > > Rate: Open Total Exp: 9 + Available: immediate Relocation: > OPEN > > To obtain a complete resume of this consultant and many others we have > available, please feel free to contact me. > > Thanks & Regards, > Kanna > SilverXis > We Deliver: Talent, Solution, Satisfaction > 1162 W Pioneer Pkwy, > Arlington, TX 76013. > T: 817-861-*533 > F: 847-758-2770 > [2]ka...@silverxis.com > [3]www.silverxis.com > _ > > This email is generated using [4]CONREP software. > [5][8011234857.jpg] > > G5540 > > References > > 1. > http://adso.conrep.com/conrep/actions/mail/unsubscribe.php?param=QVBSSUQ9MTEwMTA5NTAyMzU0JkFQTUlEPTQyNCZDTVBDRD01NTQwJkZST009a2FubmFAc2lsdmVyeGlzLmNvbSZUTz1yLWhlbHBAci1wcm9qZWN0Lm9yZyZKT0JJRD0xMTAxMDAyMTkwOTcmU1VCSj1TQVAgQUJBUCBDb25zdWx0YW50IGF2YWlsYWJsZSZ1c3JpZD0xMTAxMDAzMDUyMTYmSkJDSUQ9NjEwMDAzNzk5OTU2 > 2. mailto:ka...@silverxis.com > 3. http://www.silverxis.com/ > 4. > http://www.conrep.com/?emlsrc=110109823481-110100305216&emailed=r-help@r-project.org&T=MM > 5. > http://www.conrep.com/?emlsrc=110109823481-110100305216&emailed=r-help@r-project.org&T=MM > __ > 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] Create a data frame of all possible unique combinations of factors
Hello, I'm trying to create a data frame where each row has a unique combination of factors. I start with a vector of species like so: > 1> test <- c("A","B","C","D") > > 1> test > > [1] "A" "B" "C" "D" > To get all species combinations I have used expand.grid like this: > 1> pairs <- expand.grid(test,test) > 1> pairs >Var1 Var2 > 1 AA > 2 BA > 3 CA > 4 DA > 5 AB > 6 BB > 7 CB > 8 DB > 9 AC > 10BC > 11CC > 12DC > 13AD > 14BD > 15CD > 16DD > Now I want to select only the unique pairs, which I have tried to do with the function "unique": > 1> unique(pairs) > , but that doesn't do anything... I guess because it considers A,B to be different from B,A. The data frame I would like to end up with should look like this. >Var1 Var2 > 1 AA > 2 BA > 3 CA > 4 DA > 6 BB > 7 CB > 8 DB > 11CC > 12DC > 16DD > Thanks for your help! Q -- View this message in context: http://r.789695.n4.nabble.com/Create-a-data-frame-of-all-possible-unique-combinations-of-factors-tp3647338p3647338.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] Create a data frame of all possible unique combinations of factors
Ah! I like the idea. Thanks! jholtman wrote: > > Missed that you wanted to elim duplicated: > >> z <- expand.grid(test,test) >> # add 'unique' key >> z$key <- apply(z, 1, function(x)paste(sort(x), collapse='')) >> str(z) > 'data.frame': 16 obs. of 3 variables: > $ Var1: Factor w/ 4 levels "A","B","C","D": 1 2 3 4 1 2 3 4 1 2 ... > $ Var2: Factor w/ 4 levels "A","B","C","D": 1 1 1 1 2 2 2 2 3 3 ... > $ key : chr "AA" "AB" "AC" "AD" ... > - attr(*, "out.attrs")=List of 2 > ..$ dim : int 4 4 > ..$ dimnames:List of 2 > .. ..$ Var1: chr "Var1=A" "Var1=B" "Var1=C" "Var1=D" > .. ..$ Var2: chr "Var2=A" "Var2=B" "Var2=C" "Var2=D" > -- View this message in context: http://r.789695.n4.nabble.com/Create-a-data-frame-of-all-possible-unique-combinations-of-factors-tp3647338p3647415.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] Find pattern in matrix
Hello all, I'm trying to find all combinations of 4 numbers that satisfy 4 criteria, inside of a matrix (62 x 25). I've found a way to do this using for loops, but it is extremely slow because it involves checking every possible combination of numbers (567300) to see if the criteria are satisfied. Do you think there is a faster method of doing this? Or some functions that might help me out? The matrix is of species abundances, with each row representing a species (A,B,C...) and each column representing a site (1,2,3...). The numbers in the matrix tell the abundance of the species at that site: > 1 2 3... > A 0 5 6... > B 7 8 2... > C 4 1 3... > ... > I'm trying to find combinations of species/sites such that A1>B1,A1>A2,B2>B1,B2>A2 I have used expand.grid to get all combinations of species pairs and site pairs, and then checked to see if the inequalities are satisfied. However, as I said, it takes forever. I tried to write a function that would take vectors and trick R into searching for my pattern: > count <- function(i,j,k,l){ > length(matrix[matrix[i,k] > matrix[i,l] && > matrix[i,k] > matrix[j,k] && > matrix[j,l] > matrix[j,k] && > matrix[j,l] > matrix[i,l]]) > } > That didn't work. So I wonder if anyone has any ideas of another way to proceed or functions I could look up that would head me in the right direction. Something fully fleshed out isn't necessary. Thanks! Q -- View this message in context: http://r.789695.n4.nabble.com/Find-pattern-in-matrix-tp3685278p3685278.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] Data frame to PostgreSQL without primary key
Hi, I just got started with R. I am trying to load some data into PostgreSQL using RPostgreSQL. Everything went quite smoothly except for that the table created by using dbWriteTable does not have a primary key. The ideal solution is to ask PostgreSQL to do a auto-increment with the rows I am going to load into the table so I don't have to manually generate a primary key column in the data frame. Does anybody know how to do this? Many thanks. Bill [[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] Collecting output from terminal nodes in a recursion tree
I have a recursive function. The recursion forms a tree with many (millions) terminal nodes. The function must output a value (say, a number or a vector) from each terminal node. At the end, when all recursion is done, we want to collect all the output values. How can that be done cleanly and efficiently? A prototype example is a recursive function that generates all permutations of a vector (or simply of 1:n). One permutation is generated at each terminal node. Terminal nodes occur at various depths in the tree. We don't need to pass anything up the tree, just output from the terminal nodes. Is there a way to create a global data structure and have a function tack data onto that structure? sort of like the C++ pushback()? One solution is to output values to a file, and at the end read the file back. This worked ok, but is there a better way? _ Live. __ 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] dumping data objects
I am using R version 2.9.1 (2009-06-26) on Windows. I am trying to dump some data objects from R so that I can subsequently import them into S-PLUS (version 6.2). Using dump("foo") appends Ls to integers, as explained in the documentation for deparseOpts. Here is a simple example. I tired using > .deparseOpts(control="S_compatible") [1] 128 > dump("foo") But still get: C:\wqm\Run>cat dumpdata.R foo <- structure(list(Kilocycles = c(94L, 96L, 99L), Status = structure(c(2L, 2L, 1L), .Label = c("Censored", "Failed"), class = "factor"), Weight = c(1L, 1L, 2L)), .Names = c("Kilocycles", "Status", "Weight"), class = "data.frame", row.names = c("1", "2", "3")) I have also tried a number of different combinations of options to .deparseOpts, but the resulting file always has the appended Ls. What am I missing? Bill Meeker William Q. Meeker Department of Statistics 2109 Snedecor Hall Iowa State University Ames, Iowa 50011 Phone: 515-294-5336 Fax: 515-294-4040 Home Fax: 515-232-1323 www.public.iastate.edu/~wqmeeker __ 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] dumping data objects
While > .deparseOpts(control="S_compatible") > dump("foo") did not work as I had expected, dump("foo",control="S_compatible") did work OK. Bill Meeker William Q. Meeker Department of Statistics 2109 Snedecor Hall Iowa State University Ames, Iowa 50011 Phone: 515-294-5336 Fax: 515-294-4040 Home Fax: 515-232-1323 www.public.iastate.edu/~wqmeeker __ 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 Studio v3.0.3 for Windows 32bits is too slow
Hi R'er, I have a dataset which has a matrix of 7502 x 1426 (rows x columns). The data is in a CSV format which has a size around 68Mb. This dataset is less than 10% of our dataset. I have been adopting the Anomaly detection method as described by http://www.mattpeeples.net/kmeans.html . It has been running more than 24hrs and still haven't completed the calculation. I did manage to run it with a smaller dataset (ie, 2100 rows x 1426 columns). It took around 12hrs to run. I have a few questions and need your expertise guidance. 1) Is there any better Open source tools to use to do in one tool (eg, R Studio): prepare data, build models, validate models, test models and present data. I am looking a tool which will allow me to do the same as per the above link (Matt Peeples' blog). 2) Is there an Open source tools to perform the above which will allow me to run on top of Hadoop eco-system? 3) Can we use R Studio for windows as a client to run on top of Hadoop eco-system? If yes, please point me to the site where they have a use cases or samples. Thanks and Regards, Truong Phan [[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] R Studio v3.0.3 for Windows 32bits is too slow
Hi All, Thanks for all comments/suggestions. I would like to clarify a few things for some of your questions/doubts. 1) Matt Peeples' K-Clusters R scripts has covered some of pre-requisite steps for the K-Clusters algorithm. I would recommend for those who has not done K-Clusters to read it. a) Convert count data to percent b) Allow to use Z-score standardize data when variables differ greatly in range or standard deviation or are not directly comparable measures 2) K-Clusters algorithm can handle well for the dataset which has less than 5000 features. 3) Our original dataset has more than 9000 parameters which I have been using Hadoop MapReduce streaming via Python to reduce them down to around 2000 parameter and then I use R to further cleansing data down to 1426 parameters. 4) I have been trying to use Mahout and Cloudera's Oryx tools but the integration of different tools perform tasks: Prepare data, Build models, Cross Validating models, Test models and Present data product are far too complicate for this small POC. Thanks and Regards, Truong Phan P + 61 2 8576 5771 M + 61 4 1463 7424 E troung.p...@team.telstra.com W www.telstra.com -Original Message- From: peter dalgaard [mailto:pda...@gmail.com] Sent: Thursday, 10 July 2014 10:08 AM To: Jeff Newmiller Cc: Bert Gunter; Phan, Truong Q; r-help@r-project.org Subject: Re: [R] R Studio v3.0.3 for Windows 32bits is too slow Grumpy today, Jeff? For the concrete issue, I'd conjecture that the base problem is that there are way too many columns in the data and that the nature of the method is not properly understood. It is not obvious that k-means clustering based on Euclidean distance makes sense in 1426-dimensional space. It is quite possible that the data set not even consists of columns measured in the same units. Even if it does fit the problem, it is a quite computationally intensive. Some sort of feature extraction or data reduction technique is likely to be required. So basically, further study of the methodology, or contact with a machine learning expert (which I am not) seems advisable. -pd On 09 Jul 2014, at 18:24 , Jeff Newmiller wrote: > Grumpy today, Bert? > > While it is a fact that RStudio is a separate tool from R, it is clear from > the question that the OP is interested in capabilities that R is providing > and he simply cannot tell the difference. > > OP: > > 1) "Better" is a word that leads to pointless arguments. You will have to be > the judge of what works for you. I caution you that Open Source tools almost > always achieve success by interoperating with other OS tools, and much of the > success you have already obtained is the result of many contributions, of > which R and its contributed packages deserve the lion's share of credit. > RStudio is a very convenient editor that makes using R and LaTeX and Markdown > and version control easier, but it is unlikely that either the blame for your > dissatisfaction or the credit for your success should be attributed to > RStudio. > > I have successfully used all sorts of plain text editors and command line > interfaces with R, and if you plan to scale up your projects then you will > likely want to be very clear on this distinction between editors and > computing tools so you can distribute your work on multiple parallel servers > (where editors may not necessarily even be helpful) even if you choose to use > RStudio as your controlling environment for launching such tasks. > > 2) and 3) I know that R has contributed packages that can manage Hadoop data > processing, but I have no personal experience with them. Google is your > friend... especially if you keep in mind that these tools are not all found > in one monolithic package. > > For future reference: this is a plain text mailing list, so please adjust > your mail client appropriately when sending to this list. Also, there are > considerable resources mentioned in the Posting Guide that you should be > aware of... see the link below. > --- > Jeff NewmillerThe . . Go Live... > DCN:Basics: ##.#. ##.#. 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. > > On July 9, 2014 7:10:00 AM PDT, Bert Gunter wrote: >> RStudio is a separate product with its own support. Post there, not >> here. >> >> -- Bert >> >
[R] Passing (Optional) Arguments
Dear List: In short, I am writing a number of functions as building blocks for other functions and have some questions about scoping and passing arguments. Suppose I have functions foo1, foo2, and foo3 such that: foo1<-function(a=1,b=TRUE,c=FALSE){#do stuff}; foo2<-function(x=1,y=FALSE,z=c(1,2,3,4)){#do stuff}; foo3<-function(lambda,...){lambda*foo1()*foo2()}; I want to be able to pass a,b,c,x,y,z to the functions foo1 and foo2 though foo3 (whether I define default values or not). How do I do this? I read a bit in the wiki about problems with partial argument matching and argument matching (lesson: make argument names not match truncated versions of other argument names in the "target" function). To get a better feel for things I've been playing with examples such as: b<-c(0.25,0.25); fun<-function(a=1,...){a*b}; fun() returns 0.25 0.25 as expected. fun(a=2) returns 0.5 0.5 as expected. However, fun(b=1) returns 0.25 0.25 when I want to overwrite b with the value 1 and have it return 1. Likewise with fun<-function(a=1,...){a*return(b)}; any argument I supply for b seems to be ignored. I understand as b is not defined within the function when I enter fun() lexical scoping means R looks for b up one level and, finding b, uses it. Thanks for any/all help. Sincerely, Jason Q. McClintic -- Jason Q McClintic UST MB 1945 2115 Summit Avenue St. Paul, MN 55105 [EMAIL PROTECTED] [EMAIL PROTECTED] "It is insufficient to protect ourselves with laws, we must protect ourselves with mathematics."--Bruce Schneier __ 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 (Optional) Arguments
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Sir: Thank you for your assistance. I am most interested in your suggestion | You can use list(...) in foo3, and manually split the args to those | that | belong in foo1 and those that belong in foo2, and then construct calls | from them. (This allows you to recognize args that don't go to either | place, and signal errors.) as I am not especially interested in managing ever growing lists of arguments, especially in functions where there is a choice of methods each with its own distinct requisite arguments. Is this an example of what you mean? foofun<-function(...){tf<-is.list(list(...));return(tf)} which, for instance, can be invoked as: foofun(a=1,b=2,c=3) and returns TRUE. This makes sense to me given arguments are supplied. Is the following in this context the correct way to handle "missing" arguments to a function--assuming someone is supposed to supply a, b, and c? foofun<-function(...){ argList<-list(...); if(is.null(argList$a)==TRUE){argList$a<-1}; if(is.null(argList$b)==TRUE){argList$b<-2}; if(is.null(argList$c)==TRUE){argList$c<-3}; return(argList$a*argList$b*argList$c); } Then would it be appropriate to use an "else if"-type construction to check for invalid argument types. How would I know when there are extra args? If I use the second version of foofun and invoke it as foofun(a=1,b=2,c=3,d=4) then I get 6 even though d is unused without an error message. How can I have it check? I think about trying to find the intersection of the set of desired argument names with the given set of argument names and if the intersection is not as desired, then return some sort of warning. Perhaps using ifelse? Thanks again for your assistance. Sincerely, Jason Q. McClintic - -- Jason Q McClintic UST MB 1945 2115 Summit Avenue St. Paul, MN 55105 [EMAIL PROTECTED] [EMAIL PROTECTED] "It is insufficient to protect ourselves with laws, we must protect ourselves with mathematics."--Bruce Schneier Duncan Murdoch wrote: | Jason Q. McClintic wrote: |> Dear List: |> |> In short, I am writing a number of functions as building blocks for |> other functions and have some questions about scoping and passing arguments. |> |> Suppose I have functions foo1, foo2, and foo3 such that: |> |> foo1<-function(a=1,b=TRUE,c=FALSE){#do stuff}; |> foo2<-function(x=1,y=FALSE,z=c(1,2,3,4)){#do stuff}; |> foo3<-function(lambda,...){lambda*foo1()*foo2()}; |> |> I want to be able to pass a,b,c,x,y,z to the functions foo1 and foo2 |> though foo3 (whether I define default values or not). How do I do this? |> I read a bit in the wiki about problems with partial argument matching |> and argument matching (lesson: make argument names not match truncated |> versions of other argument names in the "target" function). |> | That's tricky, because ... becomes one big list. You have a few choices: | | foo1 and foo2 can gain a ... arg, and ignore it. Then you pass ... to | both of them. Problem: you can pass typos to them and won't get a | complaint. | | foo3 can gain a,b,c,x,y,z args, and pass those along to foo1 and foo2. | Problem: duplication, maintenance problems, etc. | | You can use list(...) in foo3, and manually split the args to those that | belong in foo1 and those that belong in foo2, and then construct calls | from them. (This allows you to recognize args that don't go to either | place, and signal errors.) | | You can pass foo1Args and foo2Args as lists to foo3, and construct calls | from those, e.g. | | foo3 <- function(lambda, foo1Args, foo2Args) | lambda*do.call(foo1, foo1Args)*do.call(foo2,foo2Args) | | There are other options (e.g. using local versions of foo1 and foo2 | within foo3) that are variations on the ones above. | | It's hard to give good advice on this, because whatever you do will be a | tradeoff. You'll see variations on all of the above in the base packages. | | Duncan Murdoch |> To get a better feel for things I've been playing with examples such as: |> |> b<-c(0.25,0.25); |> fun<-function(a=1,...){a*b}; |> |> fun() returns 0.25 0.25 as expected. |> fun(a=2) returns 0.5 0.5 as expected. |> However, fun(b=1) returns 0.25 0.25 when I want to overwrite b with the |> value 1 and have it return 1. |> |> Likewise with |> |> fun<-function(a=1,...){a*return(b)}; |> |> any argument I supply for b seems to be ignored. |> |> I understand as b is not defined within the function when I enter |> |> fun() |> |> lexical scoping means R looks for b up one level and, finding b, uses it. |> |> Thanks for any/all help. |> |> Sincerely, |> |> Jason Q. McClintic
[R] Empty Set In a Set
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Dear List: I'm looking for a form of the empty set such that if ES is said representation, ~ES %in% c(1,2,3) evaluates to TRUE. Thank you in advance for your assistance. Sincerely, Jason Q. McClintic - -- Jason Q McClintic UST MB 1945 2115 Summit Avenue St. Paul, MN 55105 [EMAIL PROTECTED] [EMAIL PROTECTED] "It is insufficient to protect ourselves with laws, we must protect ourselves with mathematics."--Bruce Schneier -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQEVAwUBSBfN5hMtGNvij6jtAQgx3gf7Bxmht6ODCjsvhuFPkW1QWC1ey/ygVW9m uuwNZVCz2hBNDSV2NktaOHe+hl3sEj4gmxv0Q6onf4Opg59o9OQ1EtaeY13S/ouk EIO2fERY7VQcFbqjr1SnhlXGfyjX5bLk0ipFlqd11R+yXzFxzbafDtfcfKP+sp59 CQ8uZ2wAshPgrN5ZHIrg8RpBEWUnjH19iS4vDr40IrYyVbFLSnT1XM+D3kaMHgtc oEi3wldigmSllX8KGVVp7DeXbEvUdrvsJgF1VLG/R8EFlMMHUVE1OD3d8SJ+y9Wh SuVqWcL+aFXqJvjpQsQaE/2ywk8mis+46EjX1zcYKHPyoIoeqv4OdQ== =tBx1 -END PGP SIGNATURE- __ 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] Empty Set In a Set
-BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Exactly what I needed. Thanks to everyone who replied. Sincerely, Jason Q. McClintic - -- MIDN 1/C Jason Q McClintic Battalion Commander Naval ROTC Battalion University of Minnesota UST MB 1945 2115 Summit Avenue Saint Paul, MN 55105 [EMAIL PROTECTED] [EMAIL PROTECTED] (c) 763-442-3404 "It is insufficient to protect ourselves with laws, we must protect ourselves with mathematics."--Bruce Schneier Duncan Murdoch wrote: | On 29/04/2008 9:39 PM, Jason Q. McClintic wrote: | Dear List: | | I'm looking for a form of the empty set such that if ES is said | representation, | | ~ES %in% c(1,2,3) | | evaluates to TRUE. | |> %in% is a vector operator, checking each element of ES and returning a |> vector result. It sounds like you want a subset test, i.e. to check |> that all the results are TRUE, | |> all(ES %in% c(1,2,3)) | |> which returns TRUE when ES is empty. | |> Duncan Murdoch | | Thank you in advance for your assistance. | | Sincerely, | | Jason Q. McClintic |> __ 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. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQEVAwUBSBiD6BMtGNvij6jtAQj+awf+KNXnXImjCi/x0V+pYZI+3A41Pf3yRbXo oV99Px/ymBjGjwO4q3rKnMZmJFNTr906MPziAgTKxVQ1tboJyGpF/KAhk8ASQhO0 JqxlpzlEMwVnfZlORgo9vOjmNyl5nGL4G5X8Q1Ta9HqrvovZk2MJooP7jg37uEJy CaSLmGQrFiqQjdrXpDEfkmThUYQaAcpAKQtJFo3BeC3qjFeF2h+fK9lrFEb2bNX+ jCKWIZbJSdFHsxR6rZrsExcyE6uv+WCgPMb0WW9LXYR03mGMmin6Sr/xcqW6jXKJ dzrXc6RmFlsgfdqg/afTYwk9CVzIyWjq9/4FT9+Muj7VKClnCYlMOA== =fxWV -END PGP SIGNATURE- __ 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 in optim while using fitdistr() function
I get the digest, so I apologize if this is a little late. For your situation (based on the description and what I think your code is doing, more on that below), it looks like you are modeling a Poisson flow where the number of hits per unit time is a random integer with some mean value. If I understand your code correctly, you are trying to put your data into k bins of width f<-(max(V1)-min(V1))/k. In that case I would think something like this would work more efficiently: m<-min(V1); k<-floor(1 + log2(length(V1))); f<-(max(V1)-min(V1))/k; binCount<-NULL; for(i in seq(length=k)){ binIndex<-which((m+(i-1)*f Send R-help mailing list submissions to > r-help@r-project.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://stat.ethz.ch/mailman/listinfo/r-help > or, via email, send a message with subject or body 'help' to > [EMAIL PROTECTED] > > You can reach the person managing the list at > [EMAIL PROTECTED] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of R-help digest..." > __ 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 while using fitdistr() function or goodfit() function
Try changing your method to "ML" and try again. I tried the run the first example from the documentation and it failed with the same error. Changing the estimation method to ML worked. @List: Can anyone else verify the error I got? I literally ran the following two lines interactively from the example for goodfit: dummy <- rnbinom(200, size = 1.5, prob = 0.8) gf <- goodfit(dummy, type = "nbinomial", method = "MinChisq") and got back Warning messages: 1: In pnbinom(q, size, prob, lower.tail, log.p) : NaNs produced 2: In pnbinom(q, size, prob, lower.tail, log.p) : NaNs produced Again, I hope this helps. Sincerely, Jason Q. McClintic Aswad Gurjar wrote: > Hello, > > Thanks for help.But I am facing different problem. > > I have 421 readings of time and no of requests coming at perticular > time.Basically I have data with interval of one minute and corresponding no > of requests.It is discrete in nature.I am collecting data from 9AM to 4PM.But > some of readings are coming as 0.When I plotted histogram of data I could not > get shape of any standard distribution.Now,my aim is to find distribution > which is "best fit" to my data among standard ones. > > So there was huge data.That's why I tried to collect data into no of > bins.That was working properly.Whatever code you have given is working > properly too.But your code is more efficient.Now,problem comes at next > stage.When I apply fitdistr() for continuous data or goodfit() for discrete > data I get following error.I am not able to remove that error.Please help me > if you can. > Errors are as follows: > library(vcd) > gf<-goodfit(binCount,type= "nbinomial",method= "MinChisq") > Warning messages: > 1: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) > 2: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) > 3: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) > 4: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) > 5: NaNs produced in: pnbinom(q, size, prob, lower.tail, log.p) >> summary(gf) > > Goodness-of-fit test for nbinomial distribution > > X^2 dfP(> X^2) > Pearson 9.811273 2 0.007404729 > Warning message: > Chi-squared approximation may be incorrect in: summary.goodfit(gf) > > for another distribution: > gf<-goodfit(binCount,type= "poisson",method= "MinChisq") > Warning messages: > 1: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) > 2: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) > 3: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) > 4: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) > 5: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) > 6: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) > 7: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) > 8: NA/Inf replaced by maximum positive value in: optimize(chi2, range(count)) > Goodness-of-fit test for poisson distribution > > X^2 df P(> X^2) > Pearson 1.660931e+115 30 > Warning message: > Chi-squared approximation may be incorrect in: summary.goodfit(gf) > > > Aswad > On 2/10/08, Jason Q. McClintic < [EMAIL PROTECTED]> wrote: > > I get the digest, so I apologize if this is a little late. > > For your situation (based on the description and what I think your code > is doing, more on that below), it looks like you are modeling a Poisson > flow where the number of hits per unit time is a random integer with > some mean value. > > If I understand your code correctly, you are trying to put your data > into k bins of width f<-(max(V1)-min(V1))/k. In that case I would think > something like this would work more efficiently: > > m<-min(V1); > k<-floor(1 + log2(length(V1))); > f<-(max(V1)-min(V1))/k; > binCount<-NULL; > for(i in seq(length=k)){ > binIndex<-which((m+(i-1)*f binCount[i]<-sum(V2[binIndex]); > }; > > where i becomes the index of time intervals. > > Hope it helps. > > Sincerely, > > Jason Q. McClintic > > [EMAIL PROTECTED] wrote: >> Send R-help mailing list submissions to >> r-help@r-project.org >> >> To subscribe or unsubscribe via the World Wide Web, visit >> https://stat.ethz.ch/mailman/listinfo/r-help >> or, via email, send a message with subject or body 'help' to >> [EMAIL PROTECTED] >> >> You can reach the person managing the list at >> [EMAIL PROTECTED] >> >> When replying, please edit your Subject line so it is more specific >> than "Re: Contents of R-help digest..." >> > > > __ 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.