Re: [R] Help with function and survey data

2022-10-31 Thread Edjabou Vincent
Dear Bert Thank you for your suggestion. I have tried it but it did not work. For record, I am reposting the post with the plain text. library(tidyverse) library(plyr) library(survey) dat <- structure(list( r3a_1 = structure(c(3L, 2L, 3L, 3L, 3L, 3L, 3L,3L, 3L, 3L, 3L, 2L, 2L, 3L, 3L, 3L, 3L

Re: [R] Help with function and survey data

2022-10-31 Thread Bert Gunter
1. This is a plain text list. Set your email to post in plain text, not html, which often gets mangled (see below). 2. I did not run your example, but try: my_funca(mk =names(dat)[1:9], y = dat$seg_2) ## seg_2 is a component of dat and is not in the environment of the call. I did not see any data

Re: [R] help with function calls

2016-03-27 Thread Bert Gunter
... and here is a maybe slightly neater approach using ?mapply (again with the method column changed to character(): f <- function(meth,i,fr) do.call(meth,list((fr[i,]))) mapply(FUN=f,meth=input.df[,4],seq_len(nrow(input.df)), MoreArgs = list(fr = input.df[,1:3]) ) Cheers, Bert Bert G

Re: [R] help with function calls

2016-03-27 Thread Bert Gunter
OOPS! I forgot to tell you that I first changed the "method" column, which is a factor, to character, with input.df$method <- as.character(input.df$method) Then things will work properly. -- Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking t

Re: [R] help with function calls

2016-03-27 Thread Bert Gunter
1. return() is not needed in R functions (it's harmless, however). You might wish to go through an R function tutorial (many good ones are on the web) to learn about what slick things you can do with functions in R. 2. The following is just a brute force loop, so more elegant approaches are likely

Re: [R] help with function

2010-12-18 Thread Iain Gallagher
B.utf8 LC_NUMERIC=C [3] LC_TIME=en_GB.utf8 LC_COLLATE=en_GB.utf8 [5] LC_MONETARY=C LC_MESSAGES=en_GB.utf8 [7] LC_PAPER=en_GB.utf8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_GB.utf8 LC

Re: [R] help with function

2010-12-17 Thread Charles C. Berry
On Fri, 17 Dec 2010, Iain Gallagher wrote: Hello List I'm moving this over from the bioC list as, although the problem I'm working on is biological, the current bottle neck is my poor understanding of R. I wonder if someone would help me with the following function. Here is how I'd take it

Re: [R] Help with function writing

2010-10-11 Thread Michael Bedward
Hello Tim, This function will do it where the covariates are provided as separate arguments. It would be easy to modify this to handle a list too. function(outcome, ...) { arg.names <- as.character(match.call())[-1] nargs <- length(arg.names) f <- as.formula(paste(arg.names[1], "~", paste(a

Re: [R] Help with function "fitdistr" in "MASS"

2010-01-04 Thread Peter Ehlers
Saji Ren wrote: Thank you,man. the problem solved. Plus. when I got the parameters of the data. And I used the "truehist(mydata)" to get a histogram of the data, How can I draw a line of the distribution of the estimated parameters in the histogram plot? for example: fitdistr(na.exclude(mydat

Re: [R] Help with function "fitdistr" in "MASS"

2010-01-04 Thread Saji Ren
Thank you,man. the problem solved. Plus. when I got the parameters of the data. And I used the "truehist(mydata)" to get a histogram of the data, How can I draw a line of the distribution of the estimated parameters in the histogram plot? for example: >fitdistr(na.exclude(mydata),"normal") m

Re: [R] Help with function "fitdistr" in "MASS"

2010-01-03 Thread Bernardo Rangel Tura
On Sat, 2010-01-02 at 23:20 -0800, Saji Ren wrote: > Hi, R users: > > I want to fit my data into a normal distribution by using the command > "fitdistr" in "MASS". > I changed my data class from "ts" to "numeric" by > > >class(mydata)="numeric" > > but after using "fitdistr", I got the result be

Re: [R] Help with function "fitdistr" in "MASS"

2010-01-03 Thread Prof Brian Ripley
Please read the footer of this message. ?fitdistr says x: A numeric vector. and setting the class does not make it a numeric vector (it is just a label). And fitdistr early on does if (missing(x) || length(x) == 0L || mode(x) != "numeric") stop("'x' must be a non-empty nu

Re: [R] Help with function "fitdistr" in "MASS"

2010-01-02 Thread Saji Ren
And when I used the command below: >fitdistr(mydata, "normal", na.rm=TRUE) the result is still the same. -- View this message in context: http://n4.nabble.com/Help-with-function-fitdistr-in-MASS-tp997609p997615.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Help with function "fitdistr" in "MASS"

2010-01-02 Thread Saji Ren
I check my data again, and find that: 1. when the class of "mydata" is ts, I can't compute the sd of it. R returns 'NA'. 2. when I change the class from ts into numeric, R still can't compute the sd of the data. Any suggestion? -- View this message in context: http://n4.nabble.com/Help-with-fu

Re: [R] Help with Function!

2009-03-13 Thread Paul Johnson
On Fri, Mar 13, 2009 at 6:28 PM, Lars Bishop wrote: > Dear All, > > I need to write 'n' functions on 'm' variables. The functions should be > constructed according to the values of an (nxm) matrix of '1/0' values as > follows. For example, > > if row1 is equal to ,say [1 0  ...0 0] then f1 <-

Re: [R] help with function filter

2008-06-09 Thread jim holtman
I think you can get the median with: filter(MATDINAMIC$VELOCIDADFIN[1:1000],c(0, 1, 0)) On Mon, Jun 9, 2008 at 5:08 PM, wilquin Minaya <[EMAIL PROTECTED]> wrote: > > Hi everybody > > I need to create a program using the function filter with this vector. > MATDINAMIC$VELOCIDADFIN[1:1000] >