Re: [R] Sensitivity and Specificity

2022-10-24 Thread Prof. Dr. Matthias Kohl
MKclass::perfMeasures(predict_testing, truth = testing$case, namePos = 1) should also work and computes 80 performance measures. Best Matthias Am 25.10.22 um 06:42 schrieb Jin Li: Hi Greg, This can be done by: spm::pred.acc(testing$case, predict_testing) It will return both sensitivity and

Re: [R] Sensitivity and Specificity

2022-10-24 Thread Jin Li
Hi Greg, This can be done by: spm::pred.acc(testing$case, predict_testing) It will return both sensitivity and specificity, along with a few other commonly used measures. Hope this helps, Jin On Tue, Oct 25, 2022 at 6:01 AM Rui Barradas wrote: > Às 16:50 de 24/10/2022, greg holly escreveu:

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
Thanks to all, who have helped greatly. I essentially followed Rui to do:   fmt_string<-paste0("\ntol = %.1e","\nreltol  = %.1e","\nsteptol = %.1e","\ngradtol = %.1e") #msg<-sprintf(fmt_string,mycontrol$tol,mycontrol$reltol,mycontrol$steptol,mycontrol$gradtol) #works

Re: [R] cannot print a list with cat

2022-10-24 Thread Rui Barradas
Às 16:21 de 24/10/2022, Steven T. Yen escreveu: Thanks to everyone. I read ? sprint and the following is best I came up with. If there are ways to collapse the lines I'd be glad to know. Otherwise, I will live with this. Thanks again. cat(sprintf("\ntol = %e",mycontrol$tol),    

Re: [R] Sensitivity and Specificity

2022-10-24 Thread Rui Barradas
Às 16:50 de 24/10/2022, greg holly escreveu: Hi Michael, I appreciate your writing. Here are what I have after; predict_testing <- ifelse(predict > 0.5,1,0) head(predict) 1 2 3 5 7 8 0.29006984 0.28370507 0.10761993 0.02204224

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Kelly Thompson
Andrew, Thanks. I reviewed the code for "require" and saw: "if (!character.only) package <- as.character(substitute(package))" #This helps me better understand what is going on. I am sharing this here because I think it might help others understand. as.character(

Re: [R] Sensitivity and Specificity

2022-10-24 Thread greg holly
THanks Michael for this.This is much appreciated. So, how can I estimate the sensitivity and specificity after having the prediction on testing data. Any thoughts? Kind regards, Greg On Mon, Oct 24, 2022 at 12:10 PM Michael Dewey wrote: > So predict is a one-dimensional vector of

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Andrew Simmons
In the first one, the argument is a character vector of length 1, so the code works perfectly fine. The second is a call, and when coerced to a character vector should look like c("[", "packages_i_want_to_use", "1") You can try this yourself with quote(packages_i_want_to_use[1]) which returns

Re: [R] [EXTERNAL] Re: unexpected 'else' in " else" (Ebert, Timothy Aaron)

2022-10-24 Thread Jorgen Harmse via R-help
I agree that the documentation should be clarified. Moreover, my last example shows that the class can be different even when no mode coercion is required. I don't know enough about S3 & S4 to comment on your last point. Regards, Jorgen Harmse. From: Bert Gunter Date: Monday, 24October, 2022

Re: [R] Sensitivity and Specificity

2022-10-24 Thread Michael Dewey
So predict is a one-dimensional vector of predictions but you are treating it as a two-dimensional matrix (presumably you think those are the totals). Michael On 24/10/2022 16:50, greg holly wrote: Hi Michael, I appreciate your writing. Here are what I have after; > predict_testing <-

Re: [R] unexpected 'else' in " else" (Ebert,Timothy Aaron)

2022-10-24 Thread Bert Gunter
I wanted to follow up. A more careful reading of the following: "A vector of the same length and attributes (including dimensions and "class") as test..." So the above **refers only to a "class" attribute that appears among the attributes of test and result**. Using my previous example, note

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Kelly Thompson
Thanks! # Please, can you help me understand why require( 'base' ) # works, but require( packages_i_want_to_use[1] ) # does not work? # In require( 'base' ), what is the "first argument"? On Mon, Oct 24, 2022 at 12:29 PM Andrew Simmons wrote: > > require(), similarly to library(), does not

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Jeff Newmiller
Don't load base. It is already loaded. On October 24, 2022 9:07:44 AM PDT, Kelly Thompson wrote: ># Below, when using require(), why do I get the error message "Error >in if (!loaded) { : the condition has length > 1" ? > ># This is my reproducible code: > >#create a vector with the names of the

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Bert Gunter
Reread ?require more carefully. Especially for the 'package' argument. Incidentally, you don't need to require base. It's always available. -- Bert On Mon, Oct 24, 2022 at 9:25 AM Kelly Thompson wrote: > > # Below, when using require(), why do I get the error message "Error > in if (!loaded)

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Henrik Bengtsson
You need to pass character.only = TRUE to require() whenever you specify the package using a character variable. I agree, the error message is confusing. /Henrik On Mon, Oct 24, 2022 at 9:26 AM Kelly Thompson wrote: > > # Below, when using require(), why do I get the error message "Error > in

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Andrew Simmons
require(), similarly to library(), does not evaluate its first argument UNLESS you add character.only = TRUE require( packages_i_want_to_use[1], character.only = TRUE) On Mon, Oct 24, 2022, 12:26 Kelly Thompson wrote: > # Below, when using require(), why do I get the error message "Error > in

Re: [R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Ivan Krylov
В Mon, 24 Oct 2022 12:07:44 -0400 Kelly Thompson пишет: > require( packages_i_want_to_use[1] ) > #Error in if (!loaded) { : the condition has length > 1 This seems to be a bug in require(). In addition to understanding character strings as arguments, require() can load packages named by

Re: [R] unexpected 'else' in " else" (Ebert,Timothy Aaron)

2022-10-24 Thread Bert Gunter
"...but 'same length and attributes (including dimensions and ‘"class"’) as ‘test’' looks wrong. The output seems to be `logical` or something related to the classes of `yes` & `no`." The documentation in fact says: "A vector of the same length and attributes (including dimensions and "class") as

[R] When using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ?

2022-10-24 Thread Kelly Thompson
# Below, when using require(), why do I get the error message "Error in if (!loaded) { : the condition has length > 1" ? # This is my reproducible code: #create a vector with the names of the packages I want to use packages_i_want_to_use <- c('base', 'this_pac_does_not_exist') # Here I get

Re: [R] Sensitivity and Specificity

2022-10-24 Thread Michael Dewey
Rather hard to know without seeing what output you expected and what error message you got if any but did you mean to summarise your variable predict before doing anything with it? Michael On 24/10/2022 16:17, greg holly wrote: Hi all R-Help , After partitioning my data to testing and

Re: [R] Sensitivity and Specificity

2022-10-24 Thread greg holly
Hi Michael, I appreciate your writing. Here are what I have after; > predict_testing <- ifelse(predict > 0.5,1,0) > > head(predict) 1 2 3 5 7 8 0.29006984 0.28370507 0.10761993 0.02204224 0.12873872 0.08127920 > > # Sensitivity and

Re: [R] cannot print a list with cat

2022-10-24 Thread Bert Gunter
"collapse the lines" means ?? If you mean that you want to control the precision (# of decimals places to show) then that is exactly what sprintf does. ?sprintf tells you how. If you mean something else, please specify more clearly -- or await a reply from someone with greater insight than I. --

Re: [R] unexpected 'else' in " else" (Ebert,Timothy Aaron)

2022-10-24 Thread Jorgen Harmse via R-help
There were several interesting points about `ifelse`. The usual behaviour seems to be that all three inputs are evaluated, and the entries of `yes` corresponding to `TRUE` in `test` are combined with the entries of `no` corresponding to `FALSE` in `test`. Moreover, `yes` & `no` seem to be

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
Thanks to everyone. I read ? sprint and the following is best I came up with. If there are ways to collapse the lines I'd be glad to know. Otherwise, I will live with this. Thanks again. cat(sprintf("\ntol = %e",mycontrol$tol),     sprintf("\nreltol  = %e",mycontrol$reltol),    

[R] Sensitivity and Specificity

2022-10-24 Thread greg holly
Hi all R-Help , After partitioning my data to testing and training (please see below), I need to estimate the Sensitivity and Specificity. I failed. It would be appropriate to get your help. Best regards, Greg inTrain <- createDataPartition(y=data$case, p=0.7,

Re: [R] cannot print a list with cat

2022-10-24 Thread Rui Barradas
Hello, There's also ?message. msg <- sprintf("(tol,reltol,steptol,gradtol): %E %E %E %E", mycontrol$tol,mycontrol$reltol,mycontrol$steptol,mycontrol$gradtol) message(msg) Hope this helps, Rui Barradas Às 14:25 de 24/10/2022, Steven T. Yen escreveu: Thank, Boris and Ivan. The simple

Re: [R] cannot print a list with cat

2022-10-24 Thread Spencer Graves
On 10/24/22 7:39 AM, Steven T. Yen wrote: I have a "list" containing four elements, as shown below: > t(mycontrol) tol reltol steptol gradtol [1,] 0   0  1e-08   1e-12 Printing this in a main program causes no problem (as shown above). But, using the command t(mycontrol) the

Re: [R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
Thank, Boris and Ivan. The simple command suggested by Ivan ( print(t(mycontrol)) ) worked. I went along with Boris' suggestion and do/get the following: cat(sprintf("(tol,reltol,steptol,gradtol): %E %E %E %E",mycontrol$tol, mycontrol$reltol,mycontrol$steptol,mycontrol$gradtol))

Re: [R] cannot print a list with cat

2022-10-24 Thread Boris Steipe
??? t() is the transpose function. It just happens to return your list unchanged. The return value is then printed to console if it is not assigned, or returned invisibly. Transposing your list is probably not what you wanted to do. Returned values do not get printed from within a loop or

Re: [R] cannot print a list with cat

2022-10-24 Thread Ivan Krylov
В Mon, 24 Oct 2022 20:39:33 +0800 "Steven T. Yen" пишет: > Printing this in a main program causes no problem (as shown above). > But, using the command t(mycontrol) the line gets ignored. t() doesn't print, it returns a value. In R, there's auto-printing in the toplevel context (see

[R] cannot print a list with cat

2022-10-24 Thread Steven T. Yen
I have a "list" containing four elements, as shown below: > t(mycontrol) tol reltol steptol gradtol [1,] 0   0  1e-08   1e-12 Printing this in a main program causes no problem (as shown above). But, using the command t(mycontrol) the line gets ignored. Any idea? Thanks. Steven Yen