Re: [R] Time complexity of functions in R

2018-05-23 Thread Suzen, Mehmet
Hello Neha, You can try to measure those instructions time-complexiy by yourself. First, generate a benchmark dataset with increasing object size, i.e., set A. Have a look at how to use 'system.time' https://stat.ethz.ch/R-manual/R-devel/library/base/html/system.time.html Best, Mehmet On 24

[R] Time complexity of functions in R

2018-05-23 Thread Neha Aggarwal
Hi, I have implemented an algorithm in R, where i have used while loop and some set operations inside it, for example, while(condition){ union(set A,set B) set C - set D intersection(set D, set E) } I want to calculate the complexity of my algo. Can you tell me the complexity of union,

Re: [R] How to average values from grid cells with coordinates

2018-05-23 Thread Jim Lemon
Hi lili, You can extend it like this. I checked this with two values each for pop and mood, and it looked okay. Obviously I didn't check the result with 365 values for each, but it ran okay. # these values are the centers of the black cells lat<-rep(28:38,11) lon<-rep(98:108,each=11)

Re: [R] Plot qualitative y axis

2018-05-23 Thread Jim Lemon
Hi Pedro, Not too hard. Just have to watch the order of the variables: ppdf<-read.table(text="N M W I 10 106 II 124 484 III 321 874 IV 777 1140 V 896 996 VI 1706 1250 VII 635 433 VIII 1437 654 IX 693 333 X 1343 624 XI 1221 611 XII 25 15 XIII 3 NA XIV 7 8", header=TRUE)

Re: [R] Trouble building R 3.5.0 under Ubuntu 18.04

2018-05-23 Thread Ista Zahn
On Wed, May 23, 2018 at 2:27 PM, Kevin E. Thorpe wrote: > I suspect the main difficulty the OP is having is building R with shlib > support. apt-get update apt-get build-dep r-base wget https://cran.r-project.org/src/base/R-3/R-3.5.0.tar.gz tar -xvf R-3.5.0.tar.gz cd

Re: [R] Bootstrap and average median squared error

2018-05-23 Thread varin sacha via R-help
Hi Rui and Daniel, Many thanks for your responses. It perfectly works. Best, Le mardi 22 mai 2018 à 12:47:14 UTC+2, Rui Barradas a écrit : Hello, Right! I copied from the OP's question without thinking about it. Corrected would be bootMedianSE <-

Re: [R] Recoding variables in R

2018-05-23 Thread Lisa van der Burgh
Thank you all for your help, it worked! Op 23 mei 2018 om 19:27 heeft marta azores > het volgende geschreven: Try that code NewDF<-DF[!DF$Anxiolytics==1,] 2018-05-23 10:14 GMT+00:00 Lisa van der Burgh

Re: [R] Trouble building R 3.5.0 under Ubuntu 18.04

2018-05-23 Thread Kevin E. Thorpe
I suspect the main difficulty the OP is having is building R with shlib support. Steve, can you build from source without the --enable-R-shlib flag on configure? Kevin On 05/23/2018 01:58 PM, Ista Zahn wrote: On Tue, May 22, 2018 at 6:47 PM, Steve Gutreuter wrote: I

Re: [R] Trouble building R 3.5.0 under Ubuntu 18.04

2018-05-23 Thread Ista Zahn
On Tue, May 22, 2018 at 6:47 PM, Steve Gutreuter wrote: > I would love to hear from anyone who has successfully built 3.5.0 under > Ubuntu 18.04 (Bionic Beaver). This is the wrong list, see R-sig-debian. That said, apt-get update apt-get build-dep r-base wget

Re: [R] CKD-Epi formula

2018-05-23 Thread Rui Barradas
Hello, The literal translation of the formula I have found online [1] to R code is eGFR <- function(SCr, Age, Sex, Race){ k <- ifelse(Sex == "M", 0.9, 0.7) alpha <- ifelse(Sex == "M", -0.411, -0.329) S <- ifelse(Sex == "M", 1, 1.018) R <- ifelse(Race = "black", 1.159, 1)

Re: [R] Recoding variables in R

2018-05-23 Thread Rui Barradas
Hello, See if this inspires you. set.seed(1962) DF <- data.frame(Anxiolytics = factor(sample(c(0, 2, NA), 1000, TRUE), levels = 0:2)) summary(DF$Anxiolytics) DF$Anxiolytics <- droplevels(DF$Anxiolytics) summary(DF$Anxiolytics) DF$Anxiolytics <- factor(DF$Anxiolytics, labels = 0:1)

Re: [R] Recoding variables in R

2018-05-23 Thread William Dunlap via R-help
It looks like your data has class "factor". If you call factor() on a factor variable, without supplying an explicit 'levels' argument it produces a new factor variable without any levels not present in the input factor. E.g., > fOrig <- factor(c(NA,"A","B","D",NA,"D"),

[R] MICE passive imputation formula

2018-05-23 Thread A.C. van der Burgh
Hi all, I have a question about multiple imputation within the MICE package. I want to use passive imputation for my variable called X, because it is calculated out of multiple variables, namely Y, Z. Let's give an example with BMI. I know, that if I want to use passive imputation for BMI, I

[R] Recoding variables in R

2018-05-23 Thread Lisa van der Burgh
Hi all, I have a very general question and I think for you maybe very easy, but I am not able to solve it. I have a dataset and that dataset contains the variable Anxiolytics. This variable is coded as 0, 1, 2. The variable looks as follows: > summary(DF$Anxiolytics) 01 2

[R] CKD-Epi formula

2018-05-23 Thread A.C. van der Burgh
Hi all, I have a question and I do not know If I am at the right place to ask this question. But is there someone that has the formula of CKD-Epi in code in R? I have tried a lot of loops, but none of the approaches give me the right answer. Is there someone who has this formula coded? Thank

Re: [R] coef does not work for my ASReml model

2018-05-23 Thread Bert Gunter
?str str(cov.asr2) Does not: coefs(fcov.asr2) give you what you want ? --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 Tue, May 22, 2018 at 10:25

Re: [R-es] Pasar palabras de una lista a una variable del dataframe

2018-05-23 Thread Carlos Ortega
Mira estos ejemplos: > library(stringr) > dataset <- c("corn", "cornmeal", "corn on the cob", "meal") > my_data <- c('corn', 'corn on') > > # for mere occurences of the pattern: > str_count(dataset, "corn on") [1] 0 0 1 0 > # [1] 1 1 1 0 > > # for occurences of the word alone: >

Re: [R] Change the legend order by order function

2018-05-23 Thread S Ellison
> -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Newmiller > Subject: Re: [R] Change the legend order by order function > > [snip] > > I cannot fathom why you think name_b, name_c, name_a is a > natural result of using the order function that

Re: [R] Plot qualitative y axis

2018-05-23 Thread PIKAL Petr
Hi To rotate plot to get levels on Y axis use coord_flip ggplot(dat2, aes(N, value, colour = variable, group = variable)) + geom_point() + geom_line()+coord_flip() Cheers Petr Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohlášení o

Re: [R] Change the legend order by order function

2018-05-23 Thread PIKAL Petr
Hi Which is actually answer the OP already got. > library(ggplot2) > df<-data.frame(x1=c(1,2), y1=c(3,4),z1=c(5,6),w1=c(7,8)) > library(reshape2) > dfm<-melt(df) No id variables; using all as measure variables > dfm$variable<-factor(dfm$variable, levels=levels(dfm$variable)[c(2,1,3,4)]) >

Re: [R] Change the legend order by order function

2018-05-23 Thread Jeff Newmiller
There are two key concepts you seem to be unaware of regarding ggplot: 1) you really need to put your data in long format to work with multiple curves, and 2) the column containing the names of the curves should be a factor with levels in the order you wish them to be presented in the legend

Re: [R] Wired result when I convert from Character to Numeric

2018-05-23 Thread Gerrit Eichner
Hi, Christofer, try print(as.numeric(x), digits = 10) # or another number of digits to increase the printed(!) precision. Hth -- Gerrit Am 23.05.2018 um 12:42 schrieb Christofer Bogaso: Hi, Below is my simple result in R x = "1282553.821000" as.numeric(x) [1] 1282554 Any idea

[R] Wired result when I convert from Character to Numeric

2018-05-23 Thread Christofer Bogaso
Hi, Below is my simple result in R > x = "1282553.821000" > as.numeric(x) [1] 1282554 Any idea where all numbers in the decimal places (ie 8, 2, 1) are gone? Thanks, __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see

Re: [R] Plot qualitative y axis

2018-05-23 Thread John Kane via R-help
Hi Pedro, melt() is probably working. The problem is I did not finish the copy and paste.  It would have been better if I had included the ggplot() command. Try == library(reshape2) library(ggplot2) dat1  <- structure(list(N =

[R] Change the legend order by order function

2018-05-23 Thread John
Hi, I'd like to graph three lines on ggplot2 and I intend the lines to be "solid", "dashed", and "dotted". The legend names are "name_b", "name_c", "name_a". I'd like to legend to present in the order: the "name_b" at the top, and "name_a" at the bottom. Could it be done by order function

Re: [R] find the permutation function of a sorting

2018-05-23 Thread John
Thanks, David, Rui and Jeff!!! The function order works much better. I should have used an example where the permutation and its inverse are not identical: > i <- order(c("B", "C", "A")) > i [1] 3 1 2 > c("D","E", "F")[i] [1] "F" "D" "E" > c("D","E", "F")[order(i)] [1] "E" "F" "D" 2018-05-23

Re: [R-es] Pasar palabras de una lista a una variable del dataframe

2018-05-23 Thread JCMld
Hola, Se me ocurre lo siguiente, no sé si es lo que buscas. Supongamos que tienes la lista de palabras a cotejar en p y en t el las variables de texto donde quieres saber en cada una cuántas palabras de p aparecen. Si hacemos: p<-c("perro","gato","pez") t<-c("un perro","un perro y un gato y

Re: [R] legend order in ggplot2

2018-05-23 Thread PIKAL Petr
Hi. I dunno what you are doing wrong. After that > library(ggplot2) > df<-data.frame(x1=c(1,2), y1=c(3,4),z1=c(5,6),w1=c(7,8)) > library(reshape2) > dfm<-melt(df) No id variables; using all as measure variables > dfm$variable<-factor(dfm$variable, levels=levels(dfm$variable)[c(2,1,3,4)]) >

Re: [R] find the permutation function of a sorting

2018-05-23 Thread Rui Barradas
Hello, Like David said, what you are trying to do with sort() can be done with order() in a much easier way. First, your code x <- sort(c("bc","ac","dd"), index.return=TRUE) Now, with function order() i <- order(c("bc", "ac", "dd")) y <- c("D","E", "F")[i] y #[1] "E" "D" "F" # This