Re: [R] Make sure a data frame has been "fun through" a function

2017-02-24 Thread stephen sefick
Update, I have decided to make use S4 in order to solve my problem. Are there any particular resources that might be helpful. Thanks you for all of the help. kindest regards, STephen On Tue, Feb 21, 2017 at 10:52 AM, William Dunlap wrote: > Stray attributes on data.frames may or may not survive

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-21 Thread William Dunlap via R-help
Stray attributes on data.frames may or may not survive some simple operations on the data.frame. E.g., > d <- data.frame(X=1:5, Y=log(1:5), G=factor(rep(c("a","b"),c(2,3 > attr(d, "checked") <- TRUE > wasChecked <- function(x) isTRUE(attr(x, "checked")) > wasChecked(d) [1] TRUE > wasChecked(d

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-21 Thread Charles C. Berry
On Tue, 21 Feb 2017, stephen sefick wrote: Sorry for not being clear. I have never used S3 methods before. Below is some R code that sketches out my idea. Is this a sensible solution? Sure. See comments (untested) inline. Chuck test_data <- data.frame(a=1:10, b=1:10, c=1:10) functionA <-

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-21 Thread stephen sefick
Sorry for not being clear. I have never used S3 methods before. Below is some R code that sketches out my idea. Is this a sensible solution? test_data <- data.frame(a=1:10, b=1:10, c=1:10) functionA <- function(x, impossible_genotype){ ##some data processing y <- x ##return S3 to be

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-21 Thread David Winsemius
> On Feb 20, 2017, at 4:43 PM, stephen sefick wrote: > > Hello All, > > I am writing a package. I would like to encourage the user to look at the > data to rectify errors with function A before utilizing function B to code > these data as binary. I thought about solving this problem by adding a

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-20 Thread stephen sefick
Hello All, I am writing a package. I would like to encourage the user to look at the data to rectify errors with function A before utilizing function B to code these data as binary. I thought about solving this problem by adding a "flag" in the attributes that could be used downstream in B, and ha

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-20 Thread Charles C. Berry
On Mon, 20 Feb 2017, stephen sefick wrote: Hello, I would like to add something to a data frame that is 1) invisible to the user, 2) has no side effects, and 3) I can test for in a following function. Is this possible? I am exploring classes and attributes and I have thought about using a list

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-20 Thread stephen sefick
Just as clarification, I don't want to hide anything from the user. I just want to add something that I can test for in downstream function. I appreciate all of the help. kindest regards, Stephen On Mon, Feb 20, 2017 at 5:53 PM, Bert Gunter wrote: > Yes. > > To elaborate a bit on Ista's reply:

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-20 Thread stephen sefick
Yes, I mean "won't annoy the user", will allow them to do anything they need to do with a dataframe (write to csv, etc.), but will allow me to test for in a down stream function of the analysis to stop the function and present an error. Adding something to the class attribute seems like the right t

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-20 Thread Bert Gunter
Yes. To elaborate a bit on Ista's reply: A) The only way I can imagine hiding info from a user would be to encrypt it. This could be done programmatically I think, but I would have to research it to figure out how. B) If all you want to do is prevent the info from being printed, just create e.

Re: [R] Make sure a data frame has been "fun through" a function

2017-02-20 Thread Ista Zahn
It depends on what you mean by 1). If you mean "won't annoy the user" then yes, e.g., add something to the class attribute. If 1) means "can't be discovered by the user" then no (at least not easily). Anything you can see they can see. Best, Ista On Feb 20, 2017 4:21 PM, "stephen sefick" wrote:

[R] Make sure a data frame has been "fun through" a function

2017-02-20 Thread stephen sefick
Hello, I would like to add something to a data frame that is 1) invisible to the user, 2) has no side effects, and 3) I can test for in a following function. Is this possible? I am exploring classes and attributes and I have thought about using a list (but 1 and 2 not satisfied). Any help would be