Re: [R] Call `rlang::last_error()` to see a backtrace

2019-07-10 Thread Patrick (Malone Quantitative)
It was David's answer, not mine. Please ask him (and R-Help). On Wed, Jul 10, 2019 at 7:01 PM Ana Marija wrote: > > do I have to update maybe any of the libraries show in attach? > > On Wed, Jul 10, 2019 at 6:01 PM Ana Marija > wrote: >> >> Hi Patrick, >> >> do you refer to this? >> https://git

Re: [R] Call `rlang::last_error()` to see a backtrace

2019-07-10 Thread Ana Marija
Hi Patrick, do you refer to this? https://github.com/kenhanscombe/ukbtools/issues/20 I did it: > devtools::install_github("kenhanscombe/ukbtools", build_vignettes = TRUE, dependencies = TRUE,force=TRUE) but still the same error: > library(ukbtools) > my_ukb_data <- ukb_df("ukb31212") > ukb_icd_

Re: [R] Call `rlang::last_error()` to see a backtrace

2019-07-10 Thread Patrick (Malone Quantitative)
On Wed, Jul 10, 2019 at 4:52 PM David Winsemius wrote: > > Did you read the bug report from three weeks ago and the suggested fix > documented on the webpage you cited? > > — > David > > > Sent from my iPhone > > > On Jul 10, 2019, at 1:09 PM, Patrick (Malone Quantitative) > > wrote: > > > > Fi

Re: [R] Call `rlang::last_error()` to see a backtrace

2019-07-10 Thread Ana Marija
Hi Patrick, can you please send me link to David's previous answer? I don't see it in this thread. Thanks Ana On Wed, Jul 10, 2019 at 5:17 PM Patrick (Malone Quantitative) < mal...@malonequantitative.com> wrote: > See David's answer about this specific issue . Also, always reply to list. > > On

Re: [R] Call `rlang::last_error()` to see a backtrace

2019-07-10 Thread Patrick (Malone Quantitative)
See David's answer about this specific issue . Also, always reply to list. On Wed, Jul 10, 2019, 6:08 PM Ana Marija wrote: > Hi Patrick, > > thanks for getting back to me, I tried that: > > > ukb_icd_diagnosis(my_ukb_data, eid = "117", icd.version = 10) > Error in ukb_icd_diagnosis(my_ukb_da

Re: [R] Call `rlang::last_error()` to see a backtrace

2019-07-10 Thread David Winsemius
Did you read the bug report from three weeks ago and the suggested fix documented on the webpage you cited? — David Sent from my iPhone > On Jul 10, 2019, at 1:09 PM, Patrick (Malone Quantitative) > wrote: > > First response: The ID column in your data is labeled "eid" but your > function

Re: [R] Call `rlang::last_error()` to see a backtrace

2019-07-10 Thread Patrick (Malone Quantitative)
First response: The ID column in your data is labeled "eid" but your function call refers to "id". On Wed, Jul 10, 2019 at 1:38 PM Ana Marija wrote: > > Hello, > > I am trying to use this program: > https://github.com/kenhanscombe/ukbtools > > > my_ukb_data[1:3,1:3] > eid sex_f31_0_0 year_

[R] Call `rlang::last_error()` to see a backtrace

2019-07-10 Thread Ana Marija
Hello, I am trying to use this program: https://github.com/kenhanscombe/ukbtools > my_ukb_data[1:3,1:3] eid sex_f31_0_0 year_of_birth_f34_0_0 1 117 Female 1938 2 125 Female 1951 3 138Male 1961 > ukb_icd_diagno

Re: [R] need help in if else condition

2019-07-10 Thread Duncan Murdoch
On 10/07/2019 11:54 a.m., Richard O'Keefe wrote: Expectation: ifelse will use the same "repeat vectors to match the longest" rule that other vectorised functions do. So a <- 1:5 b <- c(2,3) ifelse(a < 3, 1, b) => ifelse(T T F F F <<5>>, 1 <<1>>, 2 3 <<2>>) => ifelse(T T F F F <<5>>, 1 1 1 1 1 <<

Re: [R] need help in if else condition

2019-07-10 Thread Dénes Tóth
On 7/10/19 5:54 PM, Richard O'Keefe wrote: Expectation: ifelse will use the same "repeat vectors to match the longest" rule that other vectorised functions do. So a <- 1:5 b <- c(2,3) ifelse(a < 3, 1, b) => ifelse(T T F F F <<5>>, 1 <<1>>, 2 3 <<2>>) => ifelse(T T F F F <<5>>, 1 1 1 1 1 <<5>>

Re: [R] need help in if else condition

2019-07-10 Thread Jeff Newmiller
Sigh. I don't agree with this "avoid ifelse because you might not know the shape of the arguments" advice. All R variables have shapes and sizes, and the better advice is to _pay attention to shapes and sizes_, especially when using vectorized functions like ifelse. An easy way to maintain shape

Re: [R] need help in if else condition

2019-07-10 Thread Eric Berger
Of course the behavior of ifelse is predictable. My point was that for newb's (I was one once) you can get burned if you don't appreciate that ifelse is vectorized. Especially if you have some "muscle memory" from using ifelse() in Excel. On Wed, Jul 10, 2019 at 6:55 PM Richard O'Keefe wrote: >

Re: [R] need help in if else condition

2019-07-10 Thread Richard O'Keefe
Expectation: ifelse will use the same "repeat vectors to match the longest" rule that other vectorised functions do. So a <- 1:5 b <- c(2,3) ifelse(a < 3, 1, b) => ifelse(T T F F F <<5>>, 1 <<1>>, 2 3 <<2>>) => ifelse(T T F F F <<5>>, 1 1 1 1 1 <<5>>, 2 3 2 3 2 <<5>>) => 1 1 2 3 2 and that is inde

Re: [R] need help in if else condition

2019-07-10 Thread Richard O'Keefe
The answer here is that in "ifelse(a < 3, ..)" you ALWAYS expect "a" to be a vector because there would be no point in using ifelse if it weren't. If you believe that "a" is or ought to be a single number, you write x <- if (a < 3) 1 else 2 The whole point of ifelse is to vectorise. On Thu,

Re: [R] need help in if else condition

2019-07-10 Thread Eric Berger
Or even > a <- 1:5 > [lots of other code] > x <- ifelse( a < 3, 1, 2) The point (in this example) is that you might have introduced a bug because you forgot that 'a' is a vector. Looking (in isolation) at the assignment to 'x' you believe it's going to be a single number, either 1 or 2 (unless you

Re: [R] need help in if else condition

2019-07-10 Thread Eric Berger
For example, can you predict what the following code will do? > a <- 1:5 > b <- c(2,3) > ifelse( a < 3, 1, b) On Wed, Jul 10, 2019 at 4:34 PM José María Mateos wrote: > On Wed, Jul 10, 2019, at 04:39, Eric Berger wrote: > > 1. The ifelse() command is a bit tricky in R. Avoiding it is often a go

Re: [R] need help in if else condition

2019-07-10 Thread José María Mateos
On Wed, Jul 10, 2019, at 04:39, Eric Berger wrote: > 1. The ifelse() command is a bit tricky in R. Avoiding it is often a good > policy. You piqued my curiosity, can you elaborate a bit more on this? -- José María (Chema) Mateos || https://rinzewind.org _

Re: [R] Warning: Error in *: non-numeric argument to binary operator

2019-07-10 Thread Eric Berger
Well, for example > "a" + 2 Error in "a" + 2 : non-numeric argument to binary operator On Wed, Jul 10, 2019 at 2:36 PM Tolulope Adeagbo wrote: > Dear All, > > Please what could be the cause of this error, I created a GUI with shiny R > and it throws this error. > But running it alone in R, it

[R] Warning: Error in *: non-numeric argument to binary operator

2019-07-10 Thread Tolulope Adeagbo
Dear All, Please what could be the cause of this error, I created a GUI with shiny R and it throws this error. But running it alone in R, its fine. I just need to know what are the possible causes for this error. Thanks for your assistance. [[alternative HTML version deleted]] _

Re: [R] need help in if else condition

2019-07-10 Thread Richard O'Keefe
Since this has already been answered, I'll just mention one point that was not addressed. > d=c(1,2,3,"-","dnr","post",10) This is rather odd. > str(d) chr [1:7] "1" "2" "3" "-" "dnr" "post" "10" You can create a vector of logical values, or a vector of numbers, or a vector of strings, but if ther

Re: [R] need help in if else condition

2019-07-10 Thread Shubhasmita Sahani
Hello Eric, Thank you, it worked. both approach. On Wed, Jul 10, 2019 at 2:09 PM Eric Berger wrote: > Change the definition of de to > > de <- data.frame(d,e,stringsAsFactors=FALSE) > > Then you should be ok. > > Some additional remarks: > > 1. The ifelse() command is a bit tricky in R. Avoiding

Re: [R] need help in if else condition

2019-07-10 Thread Eric Berger
Change the definition of de to de <- data.frame(d,e,stringsAsFactors=FALSE) Then you should be ok. Some additional remarks: 1. The ifelse() command is a bit tricky in R. Avoiding it is often a good policy. 2. I find %in% very useful. You could replace the multiple conditions check de$d=="-

[R] need help in if else condition

2019-07-10 Thread Shubhasmita Sahani
Hello all, I am trying to run if else condition to alter my data. I have created a column F with reference to column d where I want to replace the value to 0 where ever it finds a string or character value like -,dnr, post and keep the rest of the rows should have the original value of column d.