Display percentage which takes into account missing without displaying missing percentage in gtsummary? - percentage

How do I display percentages which take into account missing but without actually displaying percentage of missing?
Following the question asked on this thread
How to add percentage to "unknown" in gtsummary
I'd like the response % to read
67 (68%)
28 (28%)
without the
3 (3.1%)
displayed
Thanks!
I've tried missing = "no" combined with
dplyr::mutate(response = factor(response) %>% forcats::fct_explicit_na())
But it obviously doesn't work

Related

phyloseq: Discrepancies in otu counts before and after using tax_glom

Maybe I missed something in how tax_glom works but as I did not find any info here nor elsewhere on the web, maybe someone here can help.
I do not provide data but I can on request. Here is the code highlighting the issue I have
colSums(CYANO%>%otu_table())
CYANO_gen <- CYANO %>%
tax_glom(taxrank = "Genus")
colSums(CYANO_gen%>%otu_table())
CYANO is a phyloseq object that I wanted to agglomerate at the Genus rank but I noticed that a sample (named 100) was not present in a dataviz. This led me to check where the issue happened. 7 samples out of 54 present discrepancies as shown in the last line of the attached image, weird isn't it?
Results given by the code above and 2 additional lines which highlight the importance of discrepancies and the fact that this is not always the case
Thank, Guillaume
The NArm term in the tax_glom function is, by default, set as TRUE. To avoid losing observations with NA cells you need to set the NArm = FALSE.
Cheers

R apply cannot get multiple mins when rows exceed certain numbers

I am trying to get a random variable when there are 2 minimal values, using a line of code like
sliced_coor$option<-apply(sliced_coor[1:312], 1, function(t) sample(names(t)[which(t==min(t[c('intuitive','reflective')]))],1))
I intend to apply for all rows, [1:312] is just where I found the abnormality. It is very strange that the function fails to get 2 minimal values once the rows exceed 312, and the limit is not constant when I tested with other data..
Although I managed to fix the issue with moving the specification of columns [c('intuitive','reflective')] to data parameter - sliced_coor , but I am still don't understand the problem of the early method.

PHPexcel formula cell getting overrided instead of replace on filter column

I am using PHPExcel_v1_8, I have implemented formula to some cells like following.
$objPHPExcel->getActiveSheet()->SetCellValue('G4','=SUBTOTAL(2,B6:B'.$row.')');
$objPHPExcel->getActiveSheet()->SetCellValue('H4','=ROUND(SUBTOTAL(9,Q6:Q'.$row.'),2)');
I also tried like
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow(6,4,'=SUBTOTAL(2,B6:B'.$row.')');
Here $row means total number of rows.
But when I filter any column then it append/override value of formula applied cell. Please see following filtered total row.
I want only latest value should in filtered total row means want to replace existing value. Right now, I am getting correct value but why it is overrided? Any suggestions what can be the solution?
You've actually discovered a genuine bug here.
I wasn't aware when I implemented the SUBTOTAL logic in PHPExcel that it only worked with visible rows, and ignored hidden rows. Can you please raise an issue on the github repo
However, reading through the MS Excel docs for SUBTOTAL, a function of 2 or 9 will return the result for all rows in the range (hidden or otherwise) while 102 or 109 will return the result only for visible rows

Google Spreadsheet IF and AND

im trying to find an easy formula to do the following:
=IF(AND(H6="OK";H7="OK";H8="OK";H9="OK";H10="OK";H11="OK";);"OK";"X")
This actually works. But I want to apply to a range of cells within a column (H6:H11) instead of having to create a rule for each and every one of them... But trying as a range:
=IF(AND(H6:H11="OK";);"OK";"X")
Does not work.
Any insights?
Thanks.
=ArrayFormula(IF(AND(H6:H11="OK");"OK";"X"))
also works
arrayformulas work the same way they do in excel... they just need an ArrayFormula() around to work (will be automatically set when pressing Ctrl+Alt+Return like in excel)
In google sheets the formula is:
=ArrayFormula(IF(SUM(IF(H6:H11="OK";1;0))=6;"OK";"X"))
in excel:
=IF(SUM(IF(H6:H11="OK";1;0))=6;"OK";"X")
And confirm with Ctrl-Shift-Enter
This basically counts the number of times the said range is = to the criteria and compares it to the number it should be. So if the range is increased then increase the number 6 to accommodate.

How to conditionally plot in gnuplot with missing or invalid data?

In gnuplot (I'm using 5.1 CVS) one can specify missing data (set datafile missing '?' for example) and gnuplot also knows invalid data (like NaN or 1/0).
How can I conditionally react to them? If my data has one of them I sometimes (i.e. on some columns, but not on all) want to do something else instead of just skipping them. So, basically I want to say (pseudocode)
plot 'datafile' using 1:($2 = MISSING ? $3+$4 : $2 )
I can use strcol(2) to check the column content, but this does not work for the string specified by missing set datafile missing '?' because the string specified by set datafile missing seems to have a higher "importance", because I can't check it using colstr() (gnuplot stops handling the datapoint before it even comes to evaluating strcol()).
My data can have missing data in several columns. If it is, for example, missing in column 2 I just want a gap in the data (like it's invalid), but if it is in column 3 I want it to plot something else instead and not leaving a gap.
For invalid data (like the pre-defined NaN) this works perfectly fine. It is skipped when appearing in the data, but I can also react to it by saying strcol(2) == 'NaN' ? $3+$4 : $2. So for invalid data, gnuplot first evaluates strcol() if (and only if) it is there.
I can simulate this behaviour by using two "missing chars", one that I use for set datafile missing and another one that I use for strcol() checks. But this is an ugly workaround, I would have to edit my datafiles and replacing half of the missing chars by hand. Is there a way to handle missing also data conditionally, like one can handle invalid data?

Resources