Re: [R] Variation of bubble sort (based on divisors)
Hi Piotr, On 03/31/2017 11:16 AM, Piotr Koller wrote: Hi, I'd like to create a function that will sort values of a vector on a given basis: -zeros -ones -numbers divisible by 2 -numbers divisible by 3 (but not by 2) -numbers divisible by 5 (but not by 2 and 3) In other words, you want to sort your values by smallest divisor (not regarding 1 as a divisor). The sorting part is easy if you can map each value to its smaller divisor (mapping 0 to 0 and 1 to 1): 1) Map the values in 'x' to their smallest divisor: x <- as.integer(x) smallest_divisor <- sapply(x, smallestDivisor) smallest_divisor[x == 0L] <- 0L smallest_divisor[x == 1L] <- 1L 2) Then sort 'x' based on the values in 'smallest_divisor': x[order(smallest_divisor)] So the real difficulty here is not the sorting, it's to find the smallest divisor. Here is a function that does this: smallestDivisor <- function(x) { if (!is.integer(x) || length(x) != 1L || is.na(x)) stop("'x' must be a single integer") ## All prime numbers <= 2*3*5*7 = ND pm210 <- as.integer(c(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199)) ans <- which(x %% pm210 == 0L)[1L] if (!is.na(ans)) return(pm210[ans]) ## Use Sieve of Eratosthenes to prepare the divisors that ## are > ND and <= 2*ND. pm0 <- c(3L, 5L, 7L) # must start with 3, not 2 prod0 <- as.integer(cumprod(pm0)[length(pm0)]) ND <- 2L * prod0 div <- 1L + 2L*(0L:(prod0-1L)) for (p in pm0) div <- setdiff(div, p*(1L:(ND%/%p-1L))) div <- div + ND sqrtx <- sqrt(x) while (div[1L] <= sqrtx) { ans <- which(x %% div == 0L)[1L] if (!is.na(ans)) return(div[ans]) div <- div + ND } x } I'm sure there are faster ways to do this. Cheers, H. etc. I also want to omit zeros in those turns. So when I have a given vector of c(0:10), I want to receive 0 1 2 4 6 8 10 3 9 5 7 I think it'd be the best to use some variation of bubble sort, so it'd look like that sort <- function(x) { for (j in (length(x)-1):1) { for (i in j:(length(x)-1)) { if (x[i+1]%%divisor==0 && x[i]%%divisor!=0) { temp <- x[i] x[i] <- x[i+1] x[i+1] <- temp } } } return(x)} This function works out well on a given divisor and incresing sequences. sort <- function(x) { for (j in (length(x)-1):1) { for (i in j:(length(x)-1)) { if (x[i+1]%%5==0 && x[i]%%5!=0) { temp <- x[i] x[i] <- x[i+1] x[i+1] <- temp } } } return(x) } x <- c(1:10) print(x) print(bubblesort(x)) This function does its job. It moves values divisible by 5 on the beginning. The question is how to increase divisor every "round" ? Thanks for any kind of help [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp=DwICAg=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=AeHAcF7RnhWvQIqG5c2ucgFS0WIOmMFeRheLIeSwu0U=xJMmDOJLaQZ0QMmI7rkkNd2T5-zrh843rlJ-R1LQ9G8= PLEASE do read the posting guide https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html=DwICAg=eRAMFD45gAfqt84VtBcfhQ=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA=AeHAcF7RnhWvQIqG5c2ucgFS0WIOmMFeRheLIeSwu0U=c9IcZitWvur2grg8C54Jnt5LmajX0ODDANY-BGRzMbk= and provide commented, minimal, self-contained, reproducible code. -- Hervé Pagès Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M1-B514 P.O. Box 19024 Seattle, WA 98109-1024 E-mail: hpa...@fredhutch.org Phone: (206) 667-5791 Fax:(206) 667-1319 __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variation of bubble sort (based on divisors)
Piotr - keep discussions on-list please. I generally do not open attachments to eMails. You are misinterpreting the results: 0: 0 1: 1 2: 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 3: 3 9 15 21 27 (all even multiples of 3 have been sorted with 2) 5: 5 25 (10, 20, 30 are sorted as multiples of 2; 15 is a multiple of 3) 7: 7 (14, 28 are multiples of 2; 21 is a multiple of 3) others: 11 13 17 19 23 29 B. > On Apr 3, 2017, at 3:27 PM, Piotr Kollerwrote: > > Hi, I've noticed some weird thing about this function. It's not treating one > digit numbers as divisible by themselves. For example, In 0:30 sequence > > > It prints me a result of: > [1] 0 1 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 3 9 15 21 27 5 25 > 7 11 13 17 > [29] 19 23 29 > > > > So, it treats 15 as divisible by 5, 21 as divisible by 7, but not 5 as > divisible by 5 and 7 as divisble by 7. I've also noticed when I use 1:10 > instead of 0:10 sequence, it prints a "double" result > 0 1 2 4 6 8 10 3 9 5 7 2 4 6 8 10 3 9 5 7 > > What's the reason behind those problems? Code is in the attachment. > > > Wolny od wirusów. www.avast.com > > On Sat, Apr 1, 2017 at 2:38 PM, Boris Steipe wrote: > The modulo operator returns remainder after division. The goal is to select a > number if the remainder is zero. Casting a number to logical returns FALSE if > it is zero, TRUE otherwise. The "!" operator inverts that. > > > (2:9) > (2:9) %% 3 > as.logical((2:9) %% 3) > !as.logical((2:9) %% 3) > > > B. > > > > > > On Apr 1, 2017, at 8:16 AM, Piotr Koller wrote: > > > > Thank you very much. You are very helpful. Can you explain what's the > > general purpose of this" !as.logical " operator in for loop? > > > > Wolny od wirusów. www.avast.com > > > > On Sat, Apr 1, 2017 at 2:15 AM, Boris Steipe > > wrote: > > This looks opaque and hard to maintain. > > It seems to me that a better strategy is to subset your vector with modulo > > expressions, use a normal sort on each of the subsets, and add the result > > to each other. 0 and 1 need to be special-cased. > > > > > > myPrimes <- c(2, 3, 5) > > mySource <- sample(0:10) > > > > # special case 0,1 > > sel <- mySource < 2 > > myTarget <- sort(mySource[sel]) > > mySource <- mySource[!sel] > > > > # Iterate over requested primes > > for (num in myPrimes) { > > sel <- !as.logical(mySource %% num) > > myTarget <- c(myTarget, sort(mySource[sel])) > > mySource <- mySource[!sel] > > } > > > > # Add remaining elements > > myTarget <- c(myTarget, sort(mySource)) > > > > > > B. > > > > > > > > > > > > > > > On Mar 31, 2017, at 2:16 PM, Piotr Koller wrote: > > > > > > Hi, I'd like to create a function that will sort values of a vector on a > > > given basis: > > > > > > -zeros > > > > > > -ones > > > > > > -numbers divisible by 2 > > > > > > -numbers divisible by 3 (but not by 2) > > > > > > -numbers divisible by 5 (but not by 2 and 3) > > > > > > etc. > > > > > > I also want to omit zeros in those turns. So when I have a given vector of > > > c(0:10), I want to receive 0 1 2 4 6 8 10 3 9 5 7 I think it'd be the best > > > to use some variation of bubble sort, so it'd look like that > > > > > > sort <- function(x) { > > > for (j in (length(x)-1):1) { > > > for (i in j:(length(x)-1)) { > > > if (x[i+1]%%divisor==0 && x[i]%%divisor!=0) { > > > temp <- x[i] > > > x[i] <- x[i+1] > > > x[i+1] <- temp > > > } > > >} > > > } > > > return(x)} > > > > > > This function works out well on a given divisor and incresing sequences. > > > > > > sort <- function(x) { > > > for (j in (length(x)-1):1) { > > > for (i in j:(length(x)-1)) { > > > if (x[i+1]%%5==0 && x[i]%%5!=0) { > > >temp <- x[i] > > >x[i] <- x[i+1] > > >x[i+1] <- temp > > > } > > > } > > > } > > > return(x) > > > } > > > > > > x <- c(1:10) > > > print(x) > > > print(bubblesort(x)) > > > > > > This function does its job. It moves values divisible by 5 on the > > > beginning. The question is how to increase divisor every "round" ? > > > > > > Thanks for any kind of help > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > > > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variation of bubble sort (based on divisors)
This looks opaque and hard to maintain. It seems to me that a better strategy is to subset your vector with modulo expressions, use a normal sort on each of the subsets, and add the result to each other. 0 and 1 need to be special-cased. myPrimes <- c(2, 3, 5) mySource <- sample(0:10) # special case 0,1 sel <- mySource < 2 myTarget <- sort(mySource[sel]) mySource <- mySource[!sel] # Iterate over requested primes for (num in myPrimes) { sel <- !as.logical(mySource %% num) myTarget <- c(myTarget, sort(mySource[sel])) mySource <- mySource[!sel] } # Add remaining elements myTarget <- c(myTarget, sort(mySource)) B. > On Mar 31, 2017, at 2:16 PM, Piotr Kollerwrote: > > Hi, I'd like to create a function that will sort values of a vector on a > given basis: > > -zeros > > -ones > > -numbers divisible by 2 > > -numbers divisible by 3 (but not by 2) > > -numbers divisible by 5 (but not by 2 and 3) > > etc. > > I also want to omit zeros in those turns. So when I have a given vector of > c(0:10), I want to receive 0 1 2 4 6 8 10 3 9 5 7 I think it'd be the best > to use some variation of bubble sort, so it'd look like that > > sort <- function(x) { > for (j in (length(x)-1):1) { > for (i in j:(length(x)-1)) { > if (x[i+1]%%divisor==0 && x[i]%%divisor!=0) { > temp <- x[i] > x[i] <- x[i+1] > x[i+1] <- temp > } >} > } > return(x)} > > This function works out well on a given divisor and incresing sequences. > > sort <- function(x) { > for (j in (length(x)-1):1) { > for (i in j:(length(x)-1)) { > if (x[i+1]%%5==0 && x[i]%%5!=0) { >temp <- x[i] >x[i] <- x[i+1] >x[i+1] <- temp > } > } > } > return(x) > } > > x <- c(1:10) > print(x) > print(bubblesort(x)) > > This function does its job. It moves values divisible by 5 on the > beginning. The question is how to increase divisor every "round" ? > > Thanks for any kind of help > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Variation of bubble sort (based on divisors)
Hi, I'd like to create a function that will sort values of a vector on a given basis: -zeros -ones -numbers divisible by 2 -numbers divisible by 3 (but not by 2) -numbers divisible by 5 (but not by 2 and 3) etc. I also want to omit zeros in those turns. So when I have a given vector of c(0:10), I want to receive 0 1 2 4 6 8 10 3 9 5 7 I think it'd be the best to use some variation of bubble sort, so it'd look like that sort <- function(x) { for (j in (length(x)-1):1) { for (i in j:(length(x)-1)) { if (x[i+1]%%divisor==0 && x[i]%%divisor!=0) { temp <- x[i] x[i] <- x[i+1] x[i+1] <- temp } } } return(x)} This function works out well on a given divisor and incresing sequences. sort <- function(x) { for (j in (length(x)-1):1) { for (i in j:(length(x)-1)) { if (x[i+1]%%5==0 && x[i]%%5!=0) { temp <- x[i] x[i] <- x[i+1] x[i+1] <- temp } } } return(x) } x <- c(1:10) print(x) print(bubblesort(x)) This function does its job. It moves values divisible by 5 on the beginning. The question is how to increase divisor every "round" ? Thanks for any kind of help [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variation Inflation factor for GLS
Dear Laura, I've modified vif() in the development version of the car package on R-Forge so that it works with a wider variety of models, including gls models. Once the package is built on R-Forge, which usually takes about a day, you can install it via install.packages(car, repos=http://R-Forge.R-project.org;). Eventually, the development version of the car package will be moved to CRAN. Best, John -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Laura Riggi Sent: Tuesday, May 20, 2014 9:27 AM To: r-help@R-project.org Subject: [R] Variation Inflation factor for GLS Dear all, I am running a gls and I would like to check the vif of my model. It seems that the vif function in the car package and the vif.mer function available online do not work for gls. Would you know of a method to measure variance inflation factors for GLS? Thank you Laura [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Variation Inflation factor for GLS
Dear all, I am running a gls and I would like to check the vif of my model. It seems that the vif function in the car package and the vif.mer function available online do not work for gls. Would you know of a method to measure variance inflation factors for GLS? Thank you Laura [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variation Inflation factor for GLS
Dear Laura, There is no car::vif() method for gls objects, but the approach that car:::vif.lm() uses -- to compute VIFs (and generalized VIFs) from the correlation matrix of the coefficients -- should be applicable to models fit by gls(). I'll take a look a providing a vif.gls() method when I have some time, but, especially if you want VIFs, as opposed to GVIFs, you should be able to do the computations yourself. I hope this helps, John John Fox, Professor McMaster University Hamilton, Ontario, Canada http://socserv.mcmaster.ca/jfox/ On Tue, 20 May 2014 13:26:58 + Laura Riggi laura.ri...@slu.se wrote: Dear all, I am running a gls and I would like to check the vif of my model. It seems that the vif function in the car package and the vif.mer function available online do not work for gls. Would you know of a method to measure variance inflation factors for GLS? Thank you Laura [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Variation of predictor of linear model
Hi folks, I use lm to run regression and I don't know how to predict dependent variable based on the model. I used predict.lm(model, newdata=80), but it gave me warnings. Also, how can I get the variance of dependent variable based on model. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variation of predictor of linear model
Hi, Try this: # using the iris dataset mydat - iris mymodel - lm(Sepal.Length ~ Petal.Length + Species, data = mydat) summary(mymodel) newdat - data.frame(Petal.Length = seq(1, 10, by = .1), Species = factor(rep(virginica, 91))) results - predict(object = mymodel, newdata = newdat, se.fit = TRUE) results The main lesson is that generally newdata should be a data frame with columns that have the same name as the predictors (IVs) in your model. I'm not exactly sure what you mean by variance of dependent variable based on model. Do you want its total variance, residual variance, ___ ? Cheers, Josh On Mon, Sep 27, 2010 at 12:58 PM, Yi Du abraham...@gmail.com wrote: Hi folks, I use lm to run regression and I don't know how to predict dependent variable based on the model. I used predict.lm(model, newdata=80), but it gave me warnings. Also, how can I get the variance of dependent variable based on model. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Variation of predictor of linear model
Thanks Josh. The variance of predictor should be var(beta_0+beta_1*newdata+epsilon). It is actually the variance of dependent variable if we plug the concrete value of independent variable into the model. On Mon, Sep 27, 2010 at 2:09 PM, Joshua Wiley jwiley.ps...@gmail.comwrote: Hi, Try this: # using the iris dataset mydat - iris mymodel - lm(Sepal.Length ~ Petal.Length + Species, data = mydat) summary(mymodel) newdat - data.frame(Petal.Length = seq(1, 10, by = .1), Species = factor(rep(virginica, 91))) results - predict(object = mymodel, newdata = newdat, se.fit = TRUE) results The main lesson is that generally newdata should be a data frame with columns that have the same name as the predictors (IVs) in your model. I'm not exactly sure what you mean by variance of dependent variable based on model. Do you want its total variance, residual variance, ___ ? Cheers, Josh On Mon, Sep 27, 2010 at 12:58 PM, Yi Du abraham...@gmail.com wrote: Hi folks, I use lm to run regression and I don't know how to predict dependent variable based on the model. I used predict.lm(model, newdata=80), but it gave me warnings. Also, how can I get the variance of dependent variable based on model. Thanks. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.com/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] variation of the aggregate function
Is there a more efficient/elegant way to obtain the result z below. a - c('pink','pink','blue','blue','gold','gold') b - c(5,8,9,12,7,4) agg - aggregate(x=b,by=list(a), FUN='mean') m - match(a, agg[,1]) z - agg[m,2] z [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variation of the aggregate function
On Fri, Aug 13, 2010 at 12:26 PM, Eva Nordstrom eva.nordst...@yahoo.com wrote: Is there a more efficient/elegant way to obtain the result z below. a - c('pink','pink','blue','blue','gold','gold') b - c(5,8,9,12,7,4) agg - aggregate(x=b,by=list(a), FUN='mean') m - match(a, agg[,1]) z - agg[m,2] z Try: ave(b, a) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] variation
Hi list I am a new user of R. I ask for some beginner question I am searching if there is any function that computes the variation of some discrete values of a vector (mean() and sd() exists, but i have not find variation). Thanks in advance Adel -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variation
What exactly do you mean by variation? As I understand it, this term is a broad term for all kinds of different spread measures (like quantile range or standard deviation). Do you mean the Coefficient of Variation? If you found out how to compute the mean and the std.dev., it is straightforward to calculate it. Adel ESSAFI schrieb: Hi list I am a new user of R. I ask for some beginner question I am searching if there is any function that computes the variation of some discrete values of a vector (mean() and sd() exists, but i have not find variation). Thanks in advance Adel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variation
2010/6/5 Jannis bt_jan...@yahoo.de What exactly do you mean by variation? As I understand it, this term is a broad term for all kinds of different spread measures (like quantile range or standard deviation). Do you mean the Coefficient of Variation? If you found out how to Yes, that what I mean. But I looked for ready function :) compute the mean and the std.dev., it is straightforward to calculate it. Adel ESSAFI schrieb: Hi list I am a new user of R. I ask for some beginner question I am searching if there is any function that computes the variation of some discrete values of a vector (mean() and sd() exists, but i have not find variation). Thanks in advance Adel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variation
2010/6/5 Adel ESSAFI adel.s...@imag.fr 2010/6/5 Jannis bt_jan...@yahoo.de What exactly do you mean by variation? As I understand it, this term is a broad term for all kinds of different spread measures (like quantile range or standard deviation). Do you mean the Coefficient of Variation? If you found out how to Yes, that what I mean. But I looked for ready function :) Yes, that what I mean. But I looked for ready function :) compute the mean and the std.dev., it is straightforward to calculate it. Adel ESSAFI schrieb: Hi list I am a new user of R. I ask for some beginner question I am searching if there is any function that computes the variation of some discrete values of a vector (mean() and sd() exists, but i have not find variation). Thanks in advance Adel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variation
As far as I know there is no such function (i could be wrong here!). The reason for that might be that it is so straightforward to calculate it as the ratio of sd() and mean()for similar reasons there is most probably no function for the variance (and only one for std.dev)I would think that the easiest solution for you is to create the function (~3 lines of code) yourself! Cheers Jannis Adel ESSAFI schrieb: 2010/6/5 Adel ESSAFI adel.s...@imag.fr 2010/6/5 Jannis bt_jan...@yahoo.de What exactly do you mean by variation? As I understand it, this term is a broad term for all kinds of different spread measures (like quantile range or standard deviation). Do you mean the Coefficient of Variation? If you found out how to Yes, that what I mean. But I looked for ready function :) Yes, that what I mean. But I looked for ready function :) compute the mean and the std.dev., it is straightforward to calculate it. Adel ESSAFI schrieb: Hi list I am a new user of R. I ask for some beginner question I am searching if there is any function that computes the variation of some discrete values of a vector (mean() and sd() exists, but i have not find variation). Thanks in advance Adel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variation
Sorry, my remark about the variance and standard deviation was nonsense! There are functions for both measures in R! Jannis Jannis schrieb: As far as I know there is no such function (i could be wrong here!). The reason for that might be that it is so straightforward to calculate it as the ratio of sd() and mean()for similar reasons there is most probably no function for the variance (and only one for std.dev)I would think that the easiest solution for you is to create the function (~3 lines of code) yourself! Cheers Jannis Adel ESSAFI schrieb: 2010/6/5 Adel ESSAFI adel.s...@imag.fr 2010/6/5 Jannis bt_jan...@yahoo.de What exactly do you mean by variation? As I understand it, this term is a broad term for all kinds of different spread measures (like quantile range or standard deviation). Do you mean the Coefficient of Variation? If you found out how to Yes, that what I mean. But I looked for ready function :) Yes, that what I mean. But I looked for ready function :) compute the mean and the std.dev., it is straightforward to calculate it. Adel ESSAFI schrieb: Hi list I am a new user of R. I ask for some beginner question I am searching if there is any function that computes the variation of some discrete values of a vector (mean() and sd() exists, but i have not find variation). Thanks in advance Adel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] variation
?var perhaps --- On Sat, 6/5/10, Adel ESSAFI adel.s...@imag.fr wrote: From: Adel ESSAFI adel.s...@imag.fr Subject: Re: [R] variation To: r-help@r-project.org Received: Saturday, June 5, 2010, 7:57 AM 2010/6/5 Jannis bt_jan...@yahoo.de What exactly do you mean by variation? As I understand it, this term is a broad term for all kinds of different spread measures (like quantile range or standard deviation). Do you mean the Coefficient of Variation? If you found out how to Yes, that what I mean. But I looked for ready function :) compute the mean and the std.dev., it is straightforward to calculate it. Adel ESSAFI schrieb: Hi list I am a new user of R. I ask for some beginner question I am searching if there is any function that computes the variation of some discrete values of a vector (mean() and sd() exists, but i have not find variation). Thanks in advance Adel __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- PhD candidate in Computer Science Address 3 avenue lamine, cité ezzahra, Sousse 4000 Tunisia tel: +216 97 246 706 (+33640302046 jusqu'au 15/6) fax: +216 71 391 166 [[alternative HTML version deleted]] -Inline Attachment Follows- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] variation in one variable
Hello, Could you please tell me wether there is any function in R that tell me how many subgroup in one variable I have? So for example if my data are x - c(rnorm(50,50,3),rgamma(50,2,1),runif(50,0,1)) I want to know how many group I have? Many thank in advance, Samuel --- On Thu, 9/17/09, Samuel Okoye samu...@yahoo.com wrote: From: Samuel Okoye samu...@yahoo.com Subject: SVM To: r-h...@stat.math.ethz.ch Date: Thursday, September 17, 2009, 4:39 AM Hello, I have 12 sample each sample has got 1000 observation, i.e I have a matrix X with 1000 rows and 12 columns! m - svm(t(X)) p - predict (m) Can anyone tell me how to use svmtrain() in R! Many Yhanks, Samuel [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.