Re: [R] function import file csv Openair

2024-04-30 Thread Avi Gross
Unless the functionality to read in a CSV file had special functionality, it probably is simple enough to read it in using other available functions like read.csv() or others available. Many packages have functions they later remove as not really needed or if others are available. On Tue, Apr 30

Re: [R] function import file csv Openair

2024-04-30 Thread Ivan Krylov via R-help
Dear Evelina Ballato, В Tue, 30 Apr 2024 10:36:32 + Evelina Ballato пишет: > In the Openair package it is possible to restore the import csv file > function? This question is best addressed to the maintainer of the package (see the output of maintainer("openair")) if not to their GitHub iss

Re: [R] Function with large nested list

2023-12-18 Thread avi.e.gross
Emily, I too copied/pasted your code in and it worked fine. I then asked for the function definition and got it. Did you put the entire text in? I mean nothing extra above or below except maybe whitespace or comments? What sometimes happens to make the code incomplete is to leave out a matching

Re: [R] Function with large nested list

2023-12-18 Thread Michael Dewey
Dear Emily Comment in-line On 18/12/2023 09:56, Emily Bakker wrote: Hello list, I want to make a large rulebased algorithm, to provide decision support for drug prescriptions. I have defined the algorithm in a function, with a for loop and many if statements. The structure should be as follo

Re: [R] Function with large nested list

2023-12-18 Thread Ivan Krylov
В Mon, 18 Dec 2023 09:56:16 + Emily Bakker пишет: > When i try to run the function definiton, the command never > "completes" in de console. How do you run the function definition? I copied and pasted your example into a character variable and gave it to parse(text = ...). It parsed successf

Re: [R] function doesn't exists but still runs..... (akshay kulkarni)

2023-01-22 Thread akshay kulkarni
iller Sent: Friday, January 20, 2023 11:29 PM To: r-help@r-project.org ; akshay kulkarni ; Jorgen Harmse ; r-help@r-project.org ; williamwdun...@gmail.com Subject: Re: [R] function doesn't exists but still runs. (akshay kulkarni) This is not a "problem" ... it is a "fea

Re: [R] function doesn't exists but still runs..... (akshay kulkarni)

2023-01-20 Thread Jeff Newmiller
rted. >environment(package_function) is the private environment, so you can use it to >see all the private objects and everything in the ancestor environments. You >can repeat the trick to see private environments of packages you didn't >directly pull in. I think yo

Re: [R] function doesn't exists but still runs..... (akshay kulkarni)

2023-01-20 Thread akshay kulkarni
unlap To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] function doesn't exists but still runs. Message-ID: Content-Type: text/plain; charset="utf-8" Look into R's scoping rules. E.g., https://bookdown.org/rdpeng/rprogdatascience/scoping-rules-of-r.h

Re: [R] function doesn't exists but still runs.....

2023-01-20 Thread akshay kulkarni
From: Bill Dunlap Sent: Friday, January 20, 2023 5:32 AM To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] function doesn't exists but still runs. Look into R's scoping rules. E.g., https://bookdown.org/rdpeng/rprogdatascience/scoping-rules-of-r.html. * When a functio

Re: [R] function doesn't exists but still runs.....

2023-01-20 Thread akshay kulkarni
Dear Greg, THanks for a very well pointed answer. THanking you, yours sincerely AKSHAY M KULKARNI From: Greg Snow <538...@gmail.com> Sent: Friday, January 20, 2023 10:28 PM To: akshay kulkarni Cc: R help Mailing list Subject:

Re: [R] function doesn't exists but still runs.....

2023-01-20 Thread Greg Snow
A little simpler answer than the others. Look at package Namespaces. When a package is created, the NAMESPACE file defines which functions in the package are exported (i.e. available for you to use), the other functions are "private" to the package meaning that other functions in the package can

Re: [R] function doesn't exists but still runs..... (akshay kulkarni)

2023-01-20 Thread Jorgen Harmse via R-help
--- Message: 17 Date: Thu, 19 Jan 2023 16:02:31 -0800 From: Bill Dunlap To: akshay kulkarni Cc: R help Mailing list Subject: Re: [R] function doesn't exists but still runs. Message-ID: Content-Type: text/plain; charset="utf-8" Look into R's s

Re: [R] function doesn't exists but still runs.....

2023-01-19 Thread Bill Dunlap
Look into R's scoping rules. E.g., https://bookdown.org/rdpeng/rprogdatascience/scoping-rules-of-r.html. * When a function looks up a name, it looks it up in the environment in which the function was defined. * Functions in a package are generally defined in the package's environment (although so

Re: [R] Function for Distribution Fitting

2022-10-26 Thread Ebert,Timothy Aaron
-help Sent: Wednesday, October 26, 2022 10:01 AM To: r-help@r-project.org Subject: Re: [R] Function for Distribution Fitting [External Email] "all possible probability distributions" I doubt that is a finite set. To select "a bunch of them" would seem to imply a reduction of tha

Re: [R] Function for Distribution Fitting

2022-10-26 Thread Gabor Grothendieck
A Cullen & Frey graph (fitdistrplus::descdist) can be used to compare certain common distributions. On Wed, Oct 26, 2022 at 9:42 AM Paul Bernal wrote: > > Dear friends from the R community, > > Hope you are all doing great. So far, whenever I need to perform > distribution fitting on a particular

Re: [R] Function for Distribution Fitting

2022-10-26 Thread Bert Gunter
Of course it's an infinite set! The OP should look here: https://cran.r-project.org/web/views/Distributions.html -- Bert On Wed, Oct 26, 2022 at 7:01 AM JRG via R-help wrote: > > "all possible probability distributions" > > I doubt that is a finite set. To select "a bunch of them" would seem t

Re: [R] Function for Distribution Fitting

2022-10-26 Thread JRG via R-help
"all possible probability distributions" I doubt that is a finite set. To select "a bunch of them" would seem to imply a reduction of that set based on what's possible/promising/pertinent in your specific problem. IMHO, what's the "most suitable distribution" tends to depend partly on knowledge

Re: [R] function problem: multi selection in one argument

2022-01-25 Thread Martin Maechler
> Rui Barradas > on Tue, 25 Jan 2022 14:22:47 + writes: > Hello, > Here are 3 functions that do what the question asks for. The first 2 are > tidyverse solutions, the last one a base R function. > I don't understand why the group_by and mutate, that's why I've in

Re: [R] function problem: multi selection in one argument

2022-01-25 Thread Rui Barradas
Hello, Here are 3 functions that do what the question asks for. The first 2 are tidyverse solutions, the last one a base R function. I don't understand why the group_by and mutate, that's why I've included a 2nd tidyverse function. And the base R function follows the same lines of outputing

Re: [R] function problem: multi selection in one argument

2022-01-25 Thread PIKAL Petr
Hallo You should explain better what do you want as many people here do not use tidyverse functions. I am not sure what the function should do. table(iris$Species) give the same result and whatever you do in tidyverse part it always finalise in table(...$Species) Cheers Petr > -Original M

Re: [R] Function of "matrix"

2020-10-22 Thread Bill Dunlap
> 10.1/0.1 was successfully calculated Note that 'computed as' is not the same as 'printed as'. Computations are done with 52 binary digits of precision and printing is, by default, done with 7 decimal digits of precision. See FAQ 7.31. > 101 - 10.1/0.1 [1] 1.421085e-14 > options(digits=17)

Re: [R] Function of "matrix"

2020-10-22 Thread Patrick (Malone Quantitative)
(Neglected to cc the list--please reply-all to this version) What was the warning? I hazard a guess you've run into precision issues for binary representation, and the result of your division is not *exactly* 101. Pat On Thu, Oct 22, 2020 at 2:42 PM 奈良県奈良市 wrote: > > Dear R project team > > I

Re: [R] Function of "matrix"

2020-10-22 Thread Bert Gunter
1. Answers on this list are from volunteers who are not part of any R project team. We have no official status and what we say comes with no guarantees. 2. There is no such thing as a "matrix 'environment' ". 3. The answer to your question is "computer arithmetic." See FAQ 7.31. Someone may follo

Re: [R] Function that finds elements from matrix, and saves the indices of the elements to another matrix

2020-09-14 Thread Rui Barradas
Hello, This is simple: which(A == 1, arr.ind = TRUE) Hope this helps, Rui Barradas Às 12:03 de 14/09/20, Tuomas Koponen escreveu: Hi all dear R-list users, This might sound a silly problem, but but for one reason or another it has proved unsolvable to me. I need to solve the following ta

Re: [R] Function that finds elements from matrix, and saves the indices of the elements to another matrix

2020-09-14 Thread Bert Gunter
Is this a homework problem? We try not to do others' homework here. Incidentally, this can easily be done much more efficiently without any for() loops. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed

Re: [R] function to return plots

2020-06-12 Thread Naresh Gurbuxani
Thanks for your quick response.  It works as I wanted.  From: Rui Barradas Sent: Friday, June 12, 2020 7:08 AM To: Naresh Gurbuxani ; r-help@r-project.org Subject: Re: [R] function to return plots   Hello, plot.list is a list, try '[[' to access its members. ('[' return

Re: [R] function to return plots

2020-06-12 Thread Rui Barradas
Hello, plot.list is a list, try '[[' to access its members. ('[' returns sub-lists.) plot(plot.list[[1]], position = c(0, 0, 1, 0.5), more = TRUE) #Works plot(plot.list[[2]], position = c(0, 0.5, 1, 1), more = FALSE) #Works Hope this helps, Rui Barradas Às 10:52 de 12/06/20, Naresh Gurbuxan

Re: [R] function to return plots

2020-06-12 Thread Jim Lemon
Hi Naresh, The somewhat obscure syntax of lattice. print(plot.list[[1]]) print(plot.list[[2]]) Jim On Fri, Jun 12, 2020 at 7:53 PM Naresh Gurbuxani wrote: > > > I want to write a function that will return lattice plots. This simple > function output a list of two plots. These plots can be > i

Re: [R] Function Hints in Mac Dark Mode

2020-05-08 Thread Marc Schwartz via R-help
> On May 8, 2020, at 11:02 AM, Jeff Newmiller wrote: > > You seem to be confusing R and RStudio... so yeah, wrong mailing list. I > don't know exactly where you should post either. Perhaps the GitHub issues > page for RStudio? > > On May 6, 2020 12:54:43 PM PDT, Andrew Swift via R-help >

Re: [R] Function Hints in Mac Dark Mode

2020-05-08 Thread Andrew Swift via R-help
Marc, Yes, that is exactly the issue. I’ll post to r-sig-mac. On May 8, 2020, at 10:11 AM, Marc Schwartz mailto:marc_schwa...@me.com>> wrote: On May 8, 2020, at 11:02 AM, Jeff Newmiller mailto:jdnew...@dcn.davis.ca.us>> wrote: You seem to be confusing R and RStudio... so yeah, wrong mailin

Re: [R] Function Hints in Mac Dark Mode

2020-05-08 Thread Jeff Newmiller
You seem to be confusing R and RStudio... so yeah, wrong mailing list. I don't know exactly where you should post either. Perhaps the GitHub issues page for RStudio? On May 6, 2020 12:54:43 PM PDT, Andrew Swift via R-help wrote: >Sorry, wasn’t sure exactly where to post this but I noticed that

Re: [R] function sample: diferences across R versions

2019-07-31 Thread Jose Claudio Faria
It works! Thanks, ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ Jose Claudio Faria UESC/DCET/Brasil joseclaudio.faria at gmail.com Telefones: 55(73)3680.5545 - UESC 55(73)99966.9100 - VIVO ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ If you have software to deal with statistics, you have ar

Re: [R] function sample: diferences across R versions

2019-07-30 Thread Jeff Newmiller
There seem to be a couple of ways to do this. Rngkind( sample.kind="Rounding" ) or RNGversion("3.5.2") per ?Random https://stat.ethz.ch/pipermail/r-help/2019-June/463109.html On July 30, 2019 5:31:13 PM PDT, Jose Claudio Faria wrote: >Thanks Patrick. > >I took a look at the documentation o

Re: [R] function sample: diferences across R versions

2019-07-30 Thread Jose Claudio Faria
Thanks Patrick. I took a look at the documentation of the RNGkind and RNGversion functions but didn't understand how they work. Can you exemplify how I can, through them, to recapture the old behavior? Best, ///\\\///\\\///\\\///\\\///\\\///\\\///\\\///\\\ Jose Claudio Faria UESC/DCET/Brasil jose

Re: [R] function sample: diferences across R versions

2019-07-30 Thread Patrick (Malone Quantitative)
Poorly phrased--makes it act differently with respect to set.seed() . On Tue, Jul 30, 2019 at 6:55 PM Patrick (Malone Quantitative) wrote: > > My understanding is that sample() in 3.6.0 did, in fact, change in > ways that detach it from set.seed(). > > You can use RNGkind() or RNGversion() to rec

Re: [R] function sample: diferences across R versions

2019-07-30 Thread Patrick (Malone Quantitative)
My understanding is that sample() in 3.6.0 did, in fact, change in ways that detach it from set.seed(). You can use RNGkind() or RNGversion() to recapture the old behavior. See https://cran.rstudio.com/bin/windows/base/NEWS.R-3.6.1.html in the section CHANGES IN R 3.6.0 . Also, please do not pos

Re: [R] function predict

2019-04-03 Thread J C Nash
I was about to reply to the item with a similar msg as Bert, but then realized that the students were pointing out that the function (possibly less than perfectly documented -- I didn't check) only works for complete years. I've encountered that issue myself when teaching forecasting. So I was prep

Re: [R] function predict

2019-04-03 Thread Bert Gunter
This list has *no homework* policy. I would assume that the purpose of your "project" is for you to learn how to deal with exactly the sorts of issues you describe. (But you might get lucky with a response anyway). Bert Gunter "The trouble with having an open mind is that people keep coming alon

Re: [R] Function doesn't work inside loop but works outside

2019-03-05 Thread Ek Esawi
Thank you Peter. That's a dumb question on my part! At least i should have known that i need an assignment statement. Thanks again--EK On Tue, Mar 5, 2019 at 11:36 AM peter dalgaard wrote: > > You need a print() around the gsub(...) when inside a loop. > > -pd > > > On 5 Mar 2019, at 17:18 , Ek

Re: [R] Function doesn't work inside loop but works outside

2019-03-05 Thread peter dalgaard
You need a print() around the gsub(...) when inside a loop. -pd > On 5 Mar 2019, at 17:18 , Ek Esawi wrote: > > Hi All, > > I am using xlsx package to extract and clean data from an Excel > Workbook. I ran into a strange behavior that I don’t understand. The > gsub doesn’t work inside the loop

Re: [R] Function in default parameter value closing over variables defined later in the enclosing function

2019-01-26 Thread Ivan Krylov
On Thu, 24 Jan 2019 06:53:20 -0800 Jeff Newmiller wrote: > It would be better to also make secret an argument to outside instead > of a local variable or to give up on supplying the inside function as > an argument. This was in a small, mostly self-contained one-off script that tested different

Re: [R] Function in default parameter value closing over variables defined later in the enclosing function

2019-01-24 Thread Jeff Newmiller
My objection to this design pattern is that this gives the default implementation of inside an ability that cannot be altered using functions provided by the caller. You might think this is what you want now but it has the potential to render the code unreusable in the future, which renders the

Re: [R] Function in default parameter value closing over variables defined later in the enclosing function

2019-01-24 Thread Ivan Krylov
Dear Jan & Duncan, Thanks for your replies! On Wed, 23 Jan 2019 09:56:25 -0500 Duncan Murdoch wrote: > Defaults of variables are evaluated in the evaluation frame of the > call. So the inside() function is created in the evaluation frame, > and it's environment will be that frame. > When it i

Re: [R] Function in default parameter value closing over variables defined later in the enclosing function

2019-01-23 Thread Jan T Kim via R-help
Hi Duncan, On Wed, Jan 23, 2019 at 10:02:00AM -0500, Duncan Murdoch wrote: > On 23/01/2019 5:27 a.m., Jan T Kim wrote: > >Hi Ivan & All, > > > >R's scoping system basically goes to all environments along the call > >stack when trying to resolve an unbound variable, see the language > >definition [

Re: [R] Function in default parameter value closing over variables defined later in the enclosing function

2019-01-23 Thread Duncan Murdoch
On 23/01/2019 5:27 a.m., Jan T Kim wrote: Hi Ivan & All, R's scoping system basically goes to all environments along the call stack when trying to resolve an unbound variable, see the language definition [1], section 4.3.4, and perhaps also 2.1.5. You are misinterpreting that section. It's no

Re: [R] Function in default parameter value closing over variables defined later in the enclosing function

2019-01-23 Thread Duncan Murdoch
On 23/01/2019 4:53 a.m., Ivan Krylov wrote: Hi! I needed to generalize a loss function being optimized inside another function, so I made it a function argument with a default value. It worked without problems, but later I noticed that the inner function, despite being defined in the function ar

Re: [R] Function in default parameter value closing over variables defined later in the enclosing function

2019-01-23 Thread Jan T Kim
Hi Ivan & All, R's scoping system basically goes to all environments along the call stack when trying to resolve an unbound variable, see the language definition [1], section 4.3.4, and perhaps also 2.1.5. Generally, unbound variables should be used with care. It's a bit difficult to decide wheth

Re: [R] Function for displaying arbitrary text as in 'help'.

2019-01-02 Thread Duncan Murdoch
On 02/01/2019 1:36 p.m., Nicolás San Martín wrote: In this case I am not able to store the text in a file, because it could be modified at any time and I need to display the most recent version (I fetch it from the internet). But I can assume that it is correctly organized for displaying. It is

Re: [R] Function for displaying arbitrary text as in 'help'.

2019-01-02 Thread Nicolás San Martín
In this case I am not able to store the text in a file, because it could be modified at any time and I need to display the most recent version (I fetch it from the internet). But I can assume that it is correctly organized for displaying. El mié., 2 ene. 2019 a las 14:31, Jeff Newmiller () escribi

Re: [R] Function for displaying arbitrary text as in 'help'.

2019-01-02 Thread Nicolás San Martín
Yes, the file.show() is good enough. Thanks El mié., 2 ene. 2019 a las 13:48, Duncan Murdoch () escribió: > On 02/01/2019 8:47 a.m., Nicolás San Martín wrote: > > Hi all, > > > > I am looking for a function that receives some text (any text) and > displays > > it to the user in the same way as th

Re: [R] Function for displaying arbitrary text as in 'help'.

2019-01-02 Thread Jeff Newmiller
You can probably cobble together something, but spitting large chunks of information at users when the program wants to is bad design. It would be better to make a vignette or help file in a package and put the associated code from which you had been planning to spit out that text. On January 2

Re: [R] Function for displaying arbitrary text as in 'help'.

2019-01-02 Thread Duncan Murdoch
On 02/01/2019 8:47 a.m., Nicolás San Martín wrote: Hi all, I am looking for a function that receives some text (any text) and displays it to the user in the same way as the 'help' function does. Unlike 'cat', that outputs the text in the current window, the one I'm looking for should work as 'he

Re: [R] Function for displaying arbitrary text as in 'help'.

2019-01-02 Thread Duncan Murdoch
On 02/01/2019 8:47 a.m., Nicolás San Martín wrote: Hi all, I am looking for a function that receives some text (any text) and displays it to the user in the same way as the 'help' function does. Unlike 'cat', that outputs the text in the current window, the one I'm looking for should work as 'he

Re: [R] Function gutenberg_download in the gutenbergr package

2018-01-24 Thread Jeff Newmiller
I have never used that package, but it seems obvious to me that you need to "reflect" on the meaning of the word "mirror". There is no reason to assume that a site hosting a mirror of the CRAN archive is also going to host a mirror of Project Gutenberg [1]. If, after you know you are giving rea

Re: [R] function pointers?

2017-11-23 Thread jim holtman
I am replying to the first part of the question about the size of the object. It is probably best to use the "object_size" function in the "pryr" package: ‘object_size’ works similarly to ‘object.size’, but counts more accurately and includes the size of environments. ‘compare_size’ ma

Re: [R] function pointers?

2017-11-22 Thread Duncan Murdoch
On 22/11/2017 11:29 AM, Paul Johnson wrote: We have a project that calls for the creation of a list of many distribution objects. Distributions can be of various types, with various parameters, but we ran into some problems. I started testing on a simple list of rnorm-based objects. I was a lit

Re: [R] Function to save results

2017-11-01 Thread Rui Barradas
--- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Priya Arasu via R-help Sent: Wednesday, November 1, 2017 9:57 AM To: Eric Berge

Re: [R] Function to save results

2017-11-01 Thread Priya Arasu via R-help
n, TX 77843-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Priya Arasu via R-help Sent: Wednesday, November 1, 2017 9:57 AM To: Eric Berger Cc: r-help@r-project.org Subject: Re: [R] Function to save results Hi Eric,Thanks for the explanation. Is

Re: [R] Function to save results

2017-11-01 Thread David L Carlson
al Message- From: R-help [mailto:r-help-boun...@r-project.org<mailto:r-help-boun...@r-project.org>] On Behalf Of Priya Arasu via R-help Sent: Wednesday, November 1, 2017 9:57 AM To: Eric Berger mailto:ericjber...@gmail.com>> Cc: r-help@r-project.org<mailto:r-help@r-proje

Re: [R] Function to save results

2017-11-01 Thread Eric Berger
> output with File | Save to File. > > --- > David L Carlson > Department of Anthropology > Texas A&M University > College Station, TX 77843-4352 > > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Be

Re: [R] Function to save results

2017-11-01 Thread David L Carlson
ave to File. --- David L Carlson Department of Anthropology Texas A&M University College Station, TX 77843-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Priya Arasu via R-help Sent: Wednesday, November 1, 2017

Re: [R] Function to save results

2017-11-01 Thread Priya Arasu via R-help
Hi Eric,Thanks for the explanation. Is there a way to save the results automatically after the analysis gets over?. As I recently lost the results, because I didn't save the results. I don't want to run the sink or save command after the analysis is over rather run the command for saving the fil

Re: [R] Function to save results

2017-11-01 Thread Priya Arasu via R-help
Hi Eric,I tried as you suggested but I could not find the output in the text file I created (attr.txt) net <- loadNetwork("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenesis//regulationof_dopamine_signaling_submodule3.txt")sink("C://Users//Priya//Desktop//Attractor analysis

Re: [R] Function to save results

2017-11-01 Thread Eric Berger
Hi Priya, You did not follow the logic of the pseudo-code. The sink("filename"), sink() pair captures whatever output is generated between the first sink statement and the second sink statement. You need (possibly) to do: sink("C://Users//Priya//Desktop//Attractor analysis_all genes//synaptogenes

Re: [R] Function to save results

2017-11-01 Thread Eric Berger
Some comments: 1. sink() does not return a value. There is on point to set attr <- sink(...). Just give the command sink("C://etc") 2. to complete the saving to the file you must give a second sink command with no argument: sink() So your code would be (pseudo-code, not actual code) sink( "fi

Re: [R] Function Relevel DOE NOT FOUND

2017-10-28 Thread José María Mateos
On Sat, Oct 28, 2017 at 03:25:18PM +, CHIRIBOGA Xavier wrote: Dear Forum, Which functions and packages should be installed to make work the function "relevel"? treatment<-revel(treatment,ref="Db") Error: no se pudo encontrar la funci?n "revel" You have a typo there, it should be "rele

Re: [R] Function Relevel DOE NOT FOUND

2017-10-28 Thread Bert Gunter
Check your spelling: "relevel" not "revel" It's in stats (as well as probably others). Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Sat, Oct

Re: [R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread William Dunlap via R-help
When searching for the object referred to by a name, R looks first in the current environment, then in the environment's parent environment, then in that environment's parent environment, etc. It stops looking either when the name is found or when it hits .EmptyEnv, the ultimate ancestor of all en

Re: [R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread Bert Gunter
OK. Try: nlWaldTest:::vectorize.args (3 colons) Your error message said it was *not* exported, so you need 3 colons (which, in general, is a bad idea.It's usually not exported for a reason). I presume vectorize.args is is in the environment of the function copied from the name space, because f

Re: [R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread Marc Girondot via R-help
Thanks Bert for the explanation about identical. For the vectorize.args, note that vectorize.args is not a function but an variable that is unknown in the namespace nlWaldTest. > nlWaldTest::vectorize.args Erreur : 'vectorize.args' n'est pas un objet exporté depuis 'namespace:nlWaldTest' F

Re: [R] Function that works within a package and not when copied in global environment. Why?

2017-02-02 Thread Bert Gunter
1. No they're not. e.g. > f <- function() NULL > g <- function()NULL > identical(f,g) [1] FALSE > str(f) function () - attr(*, "srcref")=Class 'srcref' atomic [1:8] 1 6 1 20 6 20 1 1 .. ..- attr(*, "srcfile")=Classes 'srcfilecopy', 'srcfile' > str(g) function () - attr(*, "srcref")=Class

Re: [R] Function implemented in R returns the wrong value

2016-12-11 Thread peter dalgaard
There are limits to how much people will do your debugging for you, but it looks like you are unpacking beta,gamma from par, but packing gamma,beta into start. Otherwise, print some of the values computed in the function and check. -pd > On 10 Dec 2016, at 20:01 , Fernando de Souza Bastos wrot

Re: [R] Function implemented in R returns the wrong value

2016-12-11 Thread Fernando de Souza Bastos
Thank you Duncan, it really was that! Fernando de Souza Bastos Professor Assistente Universidade Federal de Viçosa (UFV) Campus UFV - Florestal Doutorando em Estatística Universidade Federal de Minas Gerais (UFMG) Cel: (31) 99751-6586 2016-12-11 11:25 GMT-02:00 Duncan Murdoch : > On 10/12/2

Re: [R] Function implemented in R returns the wrong value

2016-12-11 Thread Duncan Murdoch
On 10/12/2016 2:01 PM, Fernando de Souza Bastos wrote: The Log.lik function below returns the value '-INF' when it should return the value -5836.219. I can not figure out the error, does anyone have any suggestions? I haven't read it carefully, but a likely problem is that you are using constr

Re: [R] Function argument and scope

2016-11-14 Thread Bernardo Doré
Thank you all for replying so quickly. @Jim You are right, I ran into that. You can see as.character() being called to remedy the situation you described. I dropped the factors from the data frame in a line outside the function. Creating the dataframe with stringsAsFactors = F is the easiest way t

Re: [R] Function argument and scope

2016-11-14 Thread jeremiah rounds
Hi, Didn't bother to run the code because someone else said it might do what you intended, and also your problem description was complete unto itself. The issue is that R copies on change. You are thinking like you have a reference, which you do not. That is not very R like in style, but it cer

Re: [R] Function argument and scope

2016-11-13 Thread Jim Lemon
Hi Bernardo, I don't think that your function is doing anything like you expect it to do: test <- data.frame(var1=c("a","b","c"),var2=c("d","e","f")) test var1 var2 1ad 2be 3cf You have a data frame with two columns, the first thing you do is extract the first value in th

Re: [R] function ave() with seq_along returning char sequence instead of numeric

2016-11-01 Thread Charles C. Berry
On Mon, 31 Oct 2016, Jeff Newmiller wrote: The help page describes the first argument x as a numeric... it is not designed to accept character, Actually it is so designed, but not advertised as such. See below. so the fact that you get anything even close to right is just a bonus. As the do

Re: [R] function ave() with seq_along returning char sequence instead of numeric

2016-11-01 Thread S Ellison
> The help page describes the first argument x as a numeric... It also describes the _value_ as numeric. One for the help page issue list? In fact there seems no obvious reason for a hard restriction to numeric*; the return value will depend largely on what FUN does, as there's no argument clas

Re: [R] function ave() with seq_along returning char sequence instead of numeric

2016-10-31 Thread Nordlund, Dan (DSHS/RDA)
s > -Original Message- > From: Jeff Newmiller [mailto:jdnew...@dcn.davis.ca.us] > Sent: Monday, October 31, 2016 4:34 PM > To: Nordlund, Dan (DSHS/RDA); r-help@r-project.org > Subject: Re: [R] function ave() with seq_along returning char sequence > instead of numeric &

Re: [R] function ave() with seq_along returning char sequence instead of numeric

2016-10-31 Thread Jeff Newmiller
The help page describes the first argument x as a numeric... it is not designed to accept character, so the fact that you get anything even close to right is just a bonus. As the doctor says, "if it hurts, don't do that". ave( rep( 1, length( v ), v, FUN=seq_along ) -- Sent from my phone. Plea

Re: [R] function which returns number of occurrences of a pattern in string

2016-10-24 Thread Jan Kacaba
Bob and Max, I thank you. It helped me much. 2016-10-21 3:47 GMT+02:00 Bob Rudis : > `stringi::stri_count()` > > I know that the `stringr` pkg saves some typing (it wraps the > `stringi` pkg), but you should really just use the `stringi` package. > It has many more very useful functions with not

Re: [R] function which returns number of occurrences of a pattern in string

2016-10-20 Thread Bob Rudis
`stringi::stri_count()` I know that the `stringr` pkg saves some typing (it wraps the `stringi` pkg), but you should really just use the `stringi` package. It has many more very useful functions with not too much more typing. On Thu, Oct 20, 2016 at 5:47 PM, Jan Kacaba wrote: > Hello dear R-help

Re: [R] function which returns number of occurrences of a pattern in string

2016-10-20 Thread Mark Sharp
Jan, Within the stringr package you can find the function str_count(). Mark R. Mark Sharp, Ph.D. Director of Primate Records Database Southwest National Primate Research Center Texas Biomedical Research Institute P.O. Box 760549 San Antonio, TX 78245-0549 Telephone: (210)258-9476 e-mail: msh...

Re: [R] Function Distributions does not exist in package stats

2016-10-13 Thread Jim Lemon
Hi Hugo, If you look at the help page for "distributions", you will see that it describes a number of functions that return density functions, etc. for specific distributions. If you are looking for something that informs you which distribution might approximate an existing set of values, try the "

Re: [R] Function Distributions does not exist in package stats

2016-10-13 Thread Rui Barradas
Hello, 'Distribution' is not the name of a function in package stats. At an R prompt type ?Distributions. In that help page you will read "Distributions {stats} R Documentation Distributions in the stats package Description Density, cumulative distribution function, quantile function and ra

Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread William Dunlap via R-help
dump("yourObject", file=stdout()) is, IMO, a bit nicer than plain dput(yourObject). It makes copying and pasting even easier by putting "yourObject <-" in front of dput()'s output so readers don't have to type that themselves. E.g., > myData <- data.frame(X=1:2, Y=c(exp(1), pi)) > dump("myData",

Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread John Sorkin
I am trying to run a repeated measures analysis of data in which each subject (identified by SS) has 3 observations at three different times (0, 3, and 6). There are two groups of subjects (identified by group). I want to know if the response differs in the two groups. I have tried to used lme.

Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread Jim Lemon
Hi John, I think it is "dput". Jim On Thu, Aug 25, 2016 at 8:00 AM, John Sorkin wrote: > > There is a function that can be used to convert data structures such as a > data frame into a different format that allows the data to be sent to the > mailing list. The structure that is created can be

Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread David Winsemius
> On Aug 24, 2016, at 3:00 PM, John Sorkin wrote: > > > There is a function that can be used to convert data structures such as a > data frame into a different format that allows the data to be sent to the > mailing list. The structure that is created can be used to easily reconstruct > the

Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread Bert Gunter
?dput Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Aug 24, 2016 at 3:00 PM, John Sorkin wrote: > > There is a function that can be used t

Re: [R] function that converts data into a form that can be included in a question to mailing list

2016-08-24 Thread John Sorkin
Jim, Yes, you are correct! Give yourself a pat on the back and a gold start THANK YOU, John John David Sorkin M.D., Ph.D. Professor of Medicine Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology and Geriatric Medicine Baltimore VA Medical Cente

Re: [R] function for over dispersed poisson regression in the setting of a random effects model

2016-06-26 Thread Mark Podolsky
Hi John, The Gamlss.mx package can accommodate variables that follow negative binomial (and other) distributions in multilevel models. Mark > On Jun 25, 2016, at 11:00 PM, John Sorkin wrote: > > Is there a function that will run a model appropriate for over dispersed data

Re: [R] FUNCTION ctree

2016-03-10 Thread Achim Zeileis
Thanks to Erich and Sarah for the clarifications. For those wondering whether ctree() from "party" or from "partykit" should be used: the latter is the newer and improved implementation. On Thu, 10 Mar 2016, Erich Neuwirth wrote: If you do ??ctree and the package partykit is installed, you wi

Re: [R] FUNCTION ctree

2016-03-10 Thread Erich Neuwirth
If you do ??ctree and the package partykit is installed, you will see that this function is defined in this package. So, you should run library(partykit) before running your function call If partykit is not installed, you need to install it. > On Mar 10, 2016, at 15:58, CHIRIBOGA Xavier wro

Re: [R] FUNCTION ctree

2016-03-10 Thread Sarah Goslee
Probably load the package that ctree() comes from, possibly party. library(party) The code you're looking at should tell you. On Thu, Mar 10, 2016 at 9:58 AM, CHIRIBOGA Xavier wrote: > Dear all, > > > I am using Rstudio. What to do when you get this message? > > Error in plot(ctree(Surv(hours,

Re: [R] Function calling a function, column name not passed properly

2015-12-01 Thread William Dunlap
The short answer is to provide an argument that your function does not pass through substitute(), so standard evaluation takes place. E.g., change SmallFn <- function(v,d) { column <- deparse(substitute(v)) d[,column] } to SmallFn <- function(v, d, column=deparse(substi

Re: [R] Function calling a function, column name not passed properly

2015-12-01 Thread David Winsemius
> On Dec 1, 2015, at 4:32 PM, David Winsemius wrote: > > >> On Dec 1, 2015, at 2:57 PM, John Sorkin wrote: >> >> I am trying to write a function that calls a function. The first call to >> SmallFn works without any problem, printing both the passed data and the >> column Wstscr. The second

Re: [R] Function calling a function, column name not passed properly

2015-12-01 Thread David Winsemius
> On Dec 1, 2015, at 2:57 PM, John Sorkin wrote: > > I am trying to write a function that calls a function. The first call to > SmallFn works without any problem, printing both the passed data and the > column Wstscr. The second call does not work (error, Error in d[, column] : > subscript ou

Re: [R] Function help

2015-10-26 Thread Jim Lemon
Hi Alexander, I suspect that when you write "try" you mean that you try to run the function with some value for "pid". The "unexpected symbol" error message usually includes the offending symbol and that will probably identify the problem. Jim On Mon, Oct 26, 2015 at 1:20 PM, wrote: > Hello, >

  1   2   3   4   5   6   7   8   >