in cbaf/R you could have a file cbaf-constants.R (this name is consistent with the other filenaming in that folder) that includes assignments like the one I sketched. Your functions can then use the values defined in this R program.
Your code would benefit from simplifications of this type ... but all we are doing is avoiding redefinition of L1.characteristics in activities like cbaf-obtainMultipleStudies.R: existing.L1.charac <- AvailableDataTypes[,2] %in% L1.characteristics cbaf-obtainMultipleStudies.R: f.condition <- (AvailableDataTypes[,2])[existing.L1.charac] There are opportunities for simplifying and improving trustworthiness of code like that above that go beyond reducing the repetitive definition of vectors of constants. We can take it off list if you would like to discuss further. On Tue, Dec 31, 2019 at 10:27 AM Arman Shahrisa <shahrisa.ar...@hotmail.com> wrote: > Thank you very much for your response. I really appreciate it. > > > > How can I define those vectors in my package? Another R script that > possesses only > > all the vectors? Which also needs documentation. Am I correct? > > > > Best regards, > > Arman > > > > *From: *Vincent Carey <st...@channing.harvard.edu> > *Sent: *سه شنبه, 10 دی 1398 07:31 > *To: *Arman Shahrisa <shahrisa.ar...@hotmail.com> > *Cc: *bioc-devel <bioc-devel@r-project.org> > *Subject: *Re: [Bioc-devel] Repetitive variables within multiple function > > > > > > > > On Mon, Dec 30, 2019 at 9:35 PM Arman Shahrisa <shahrisa.ar...@hotmail.com> > wrote: > > Hi to all, > > I’m the maintainer of the package cbaf. The package relies on various > terms to find > the cancer studies that possess specific data e.g. RNA-Seq. > > These terms are used by three various functions. I was wondering maybe it > would be > much better to include them in a separate file such as zzz.R so that every > function > could read the same variables. I already use the zzz.R file to print a > message upon > package loading on console. > > What is the best way to achieve what I’m looking for? I really appreciate > any suggestions. > > > > I don't really understand the question. I see some repetitiveness in > grepping for "Tumor" > > in cbaf/R/* > > > > cbaf-availableData.R: "Tumor Samples with mRNA data (RNA Seq V2)", > > cbaf-availableData.R: "Tumors with mRNA data (RNA Seq V2)", > > cbaf-availableData.R: "Tumor Samples with mRNA data (RNA Seq)", > > cbaf-availableData.R: "Tumors with mRNA data (RNA Seq)", > > cbaf-availableData.R: microRNA.Seq_terms_L1 <- c("Tumors with microRNA > data (microRNA-Seq)", > > cbaf-availableData.R: "Tumor Samples with > microRNA data (microRNA-Seq)" > > ... > > cbaf-obtainMultipleStudies.R: c("Tumor Samples with mRNA data > (RNA Seq V2)", > > cbaf-obtainMultipleStudies.R: "Tumors with mRNA data (RNA Seq > V2)", > > cbaf-obtainMultipleStudies.R: "Tumor Samples with mRNA data > (RNA Seq)", > > cbaf-obtainMultipleStudies.R: "Tumors with mRNA data (RNA > Seq)", > > > > Is your question about how to avoid repetitive definition of string > constants in multiple > > functions? There is no need to use zzz.R ... you can define your vectors > of constants > > outside of functions in R code in your package. The following is found > inside one of your > > functions, and can't be seen by other functions that need the same content. > > > > RNA.Seq_terms_L1 <- c("Tumor Samples with mRNA data (RNA Seq V2)", > > "Tumors with mRNA data (RNA Seq V2)", "Samples with mRNA data (RNA > Seq V2)", > > "Tumor Samples with mRNA data (RNA Seq)", "Tumors with mRNA data > (RNA Seq)", > > "Samples with mRNA data (RNA Seq)") > > > > But as long as this is defined outside of a function it will be > accessible > > to any function in your package. It can be documented and exported like > > any other value or function, should this be desired. If not exported it > will > > be private to code in the package. > > > Best regards, > Arman > > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioc-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/bioc-devel > > > The information in this e-mail is intended only for the person to whom it > is > addressed. If you believe this e-mail was sent to you in error and the > e-mail > contains patient information, please contact the > Partners Compliance HelpLine at > http://www.partners.org/complianceline . If the e-mail was sent to you in > error > but does not contain patient information, please contact the sender and > properly > dispose of the e-mail. > > > -- The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline <http://www.partners.org/complianceline> . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. [[alternative HTML version deleted]] _______________________________________________ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel