Please, could you give me an example about how to use cat() to read the value of a variable in a function? Any other way? I've found how to make it globally available, thus printing it, but I don't know how to read out the value of any variable within the function. Thanks for your help, Ricardo -- Ricardo Rodr?guez Your XEN ICT Team
Hi, On Aug 6, 2009, at 7:25 PM, [Ricardo Rodriguez] Your XEN ICT Team wrote:> Please, could you give me an example about how to use cat() to read > the value of a variable in a function? Any other way?Can you please give an example of what you're trying to do? It seems like you're asking to use cat() for something it's not meant to do. cat() is generally used to write output, either to the screen or to a file.> I've found how to make it globally available, thus printing it, but > I don't know how to read out the value of any variable within the > function.You can use cat *in* a function to print the value of a variable, but you can't "reach into" a function to pull out a variable's value. Are you trying to debug something? See: ?debug to step through a function to examine what it's doing one step at a time. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: cbio.mskcc.org/~lianos/contact
Thanks, Bill Bill.Venables at csiro.au wrote:> fn <- function(x) { > j <- x+1 > cat("the value of j is ", j, "\n") > j > } > > fn(1:10)It is clear for me now the use of cat(). As Steve pointed out in his mail, I've failed at providing an example, one of the rules of thumb of this list! Sorry about that. Also as Steve says, I am trying to use cat() for something it's not meant to do. I am trying to pull out the value of a variable, well, some variables, without making them global by using <<- Following your example, I was guessing if something like fn.j could be used. Cheers, Ricardo -- Ricardo Rodr?guez Your XEN ICT Team
Ricardo Rodr?guez wrote:> > Please, could you give me an example about how to use cat() to read the > value of a variable in a function? Any other way? > > I've found how to make it globally available, thus printing it, but I > don't know how to read out the value of any variable within the function. > > Thanks for your help, > > Ricardo > > > > Can you give some more sample question and answers. How great your info > is! It really useful for me. Thanks. > > [url=simulationempruntimmobilier.com/][color=#FFFFFF][u]calcul pret > assurance simulation taux emprunt > immobilier[/u][/color][/url][color=#FFFFFF] - Taux emprunt immobilier. > Comparez les offres d?emprunt immobilier, simulation emprunt immobilier, > taux emprunt > immobilier[/color][url=simulationempruntimmobilier.com/][color=#FFFFFF][u]calcul > pret assurance simulation taux emprunt immobilier[/u][/color][/url] > > > -- > Ricardo Rodr?guez > Your XEN ICT Team > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >-- View this message in context: nabble.com/using-cat()-tp24856419p24951464.html Sent from the R help mailing list archive at Nabble.com.