Re: [R] Stacking two graphs with different x and y scale on the same graph

2019-11-26 Thread Ogbos Okike
Dear Rui, Many thanks. It is indeed close to what I am looking for apart from the issues on the axes. I am attaching the result plot. The minimum and maximum values of y1 are respectively -5.470919 and 1.298329 while they are 0.0002937659 and 4.808186 for y2. New problems are: (1) I can't labelle

Re: [R] Stacking two graphs with different x and y scale on the same graph

2019-11-26 Thread Rui Barradas
Hello, The following is not a complete solution, the axis ranges are wrong, but it gets you closer, I think. op <- par(mar = c(5, 5, 5, 5)) plot(c(x1, x2), c(y1, y2), type = "n",xaxt="n", yaxt="n", ylim = range(c(y1, y2))) par(new=TRUE) plot(x1,y1,pch=0,type="b",col="red",yaxt="n",

Re: [R] Conditions

2019-11-26 Thread William Michels via R-help
Hi Val, Here's an answer using a series of ifelse() statements. Because the d4 column is created initially using NA as a placeholder, you can check your conditional logic at the end using table(!is.na(dat2$d4)): > dat2 <-read.table(text="ID d1 d2 d3 + A 0 25 35 + B 12 22 0 + C 0 0 31 + E 10 2

Re: [R] Conditions

2019-11-26 Thread Jim Lemon
Hi val, You had a "conditional leak" in your ifelse statements: dat2 <-read.table(text="ID d1 d2 d3 A 0 25 35 B 12 22 0 C 0 0 31 E 10 20 30 F 0 0 0", header=TRUE,stringsAsFactors=FALSE) dat2$d4<- ifelse(dat2$d1,dat2$d1,ifelse(dat2$d2,dat2$d2,ifelse(dat2$d3,dat2$d3,0))) Even though it works, it i

Re: [R] Conditions

2019-11-26 Thread Bert Gunter
I generally find nested ifelse's to be confusing and prone to error, so I usually prefer to proceed sequentially using subsetting with logicals or replicated, but not nested ifelse's. In your example, the translation to logical indexing seems pretty straightforward. Using your example: > dat2 <-w

[R] Stacking two graphs with different x and y scale on the same graph

2019-11-26 Thread Ogbos Okike
Dear Contributors, I have two data. A is of the form: 05 01 01 -0.00376058013285748 05 01 02 -0.0765481943910918 05 01 03 -1.28158758599964 05 01 04 -1.51612545416506 05 01 05 -1.39481276373467 05 01 06 -1.17644992095997 05 01 07 -0.788249311582716 05 01 08 -0.925737027403825 05 01 09 -1.0

[R] Conditions

2019-11-26 Thread Val
HI All, I am having a little issue in my ifelse statement, The data frame looks like as follow. dat2 <-read.table(text="ID d1 d2 d3 A 0 25 35 B 12 22 0 C 0 0 31 E 10 20 30 F 0 0 0",header=TRUE,stringsAsFactors=F) I want to create d4 and set the value based on the following conditions. If d1

Re: [R] giving priority to stats package

2019-11-26 Thread Greg Snow
I was thinking of using length(search())+1 to be safe and simple. Using grep gives higher priority than length while still solving your issue. On Mon, Nov 25, 2019 at 3:06 PM Gabor Grothendieck wrote: > > Goold idea. This seems to work. > > library(dplyr, pos = grep("package:stats", search())

[R] Hyperparameter tuning

2019-11-26 Thread Neha gupta
I am using xgboost hyperparameter tuning for the value of rmse. I used the following method which returns two values ; mean which is like - 1200.12 and Best value like - 960. I guess the first value is average value and the second is the best rmse value returned by the algorithm. Now if we have to

Re: [R] Error while installing xml2 package in R

2019-11-26 Thread Jeff Newmiller
This may or may not fix your problem but I avoid installing R packages in system libraries... using user libraries without running R as root or with sudo makes life much simpler unless you are a professional sysadmin. On November 26, 2019 7:06:48 AM PST, Manish Gupta wrote: >I am getting follo

[R] Error while installing xml2 package in R

2019-11-26 Thread Manish Gupta
I am getting following error while installing xml2 package in R. install.packages("xml2") Error : unable to load shared object '/usr/local/lib/R/site-library/00LOCK-xml2/00new/xml2/libs/xml2.so': libiconv.so.2: cannot open shared object file: No such file or directory it seems it require lib