[R] Calling any method within default method!

2019-05-29 Thread Ivan Bezerra Allaman
Good night dear! For years I have a problem that I have avoided with the use of the switch function, but now I want to solve by following the good practices of object orientation (OOP). My function was created to generate experiments according to some input parameters. Therefore, the first argument

Re: [R] Tying to underdressed the magic of lm redux

2019-05-29 Thread Bert Gunter
Depends on how you want to specify variables. You are not clear (to me) on this. But, for instance: demo <- function(form,df) { av <- all.vars(form) df[,av] } demo(~a+b, df) demo(a~b,df) ?all.vars, ?all.names for details Bert Gunter On Wed, May 29, 2019 at 7:33 PM Sorkin, John wrote:

Re: [R] Tying to underdressed the magic of lm redux

2019-05-29 Thread Sorkin, John
Bert, Thank you for your reply. You are correct that your code will print the contents of the data frame. While it works, it is not as elegant as the lm function. One does not have to pass the independent and dependent variables to lm In parentheses. Fit1<-lm(y~x,data=mydata) None of the param

Re: [R] Tying to underdressed the magic of lm redux

2019-05-29 Thread Bert Gunter
Basically, huh? > df <- data.frame(a = 1:3, b = letters[1:3]) > nm <- names(df) > print(df[,nm[1]]) [1] 1 2 3 > print(df[,nm[2]]) [1] a b c Levels: a b c This can be done within a function, of course: > demo <- function(df, colnames){ +print(df[,colnames]) + } > demo(df,c("a","b")) a b 1 1

[R] Tying to underdressed the magic of lm redux

2019-05-29 Thread Sorkin, John
Thanks to several kind people, I understand how to use deparse(substitute(paramter)) to get as text strings the arguments passed to an R function. What I still can't do is put the text strings recovered by deparse(substitute(parameter)) back together to get the columns of a dataframe passed to

[R] Help with staked bar plot values

2019-05-29 Thread Bill Poling
Hello #RStudio Version 1.2.1335 sessionInfo() # R version 3.6.0 Patched (2019-05-19 r76539) # Platform: x86_64-w64-mingw32/x64 (64-bit) # Running under: Windows 10 x64 (build 17134) I am all over the google map with this so far but have made progress. #https://www.r-graph-gallery.com/stacked-ba

Re: [R] Fitdistrplus package : Error messages

2019-05-29 Thread Rui Barradas
Hello, This is because you have non-integer values in vector x? This one works. ##Poisson distribution f2p <- fitdist(floor(x), "pois") plot(f2p) summary(f2p) Not so well ##negative binomial distribution f2n <- fitdist(floor(x), "nbinom") f2n <- fitdist(ceiling(x), "nbinom") f2n <- fitdist(

[R] Fitdistrplus package : Error messages

2019-05-29 Thread varin sacha via R-help
Dear R-Experts, Here is a toy example, reproducible example, I get error messages. I have tried to fix it by myself using "google is my friend", but I did not get it. If somebody can help me to fix these errors, would be highly appreciated. ## install.packages("fitdistrp