How to use color_palette and fill_palette in ggbarplot? - ggpubr

I'm using this code ggbarplot(cell_tidy,"label","n",fill = "groups",color = "label",position = position_dodge(),add = "mean_se",palette = c("white","royalblue4"))+theme_classic2()
and I obtained this: enter image description here
I want to change only the color palette as a function of label, I have tried color_palette but I received this error Error in !is.null(facet.by) | combine :
operations are possible only for numeric, logical or complex types
Thanks in advance for the help!

Related

metafor package, rma.uni, mods, Model matrix contains character variables

I'm trying to run a meta-regression with MD's as dependent variable. I want to add a numeric moderator (year published) to the rma.uni function.
Formula so far:
metafor::rma.uni(yi=MCID12, sei=SE12, method="FE", data=Pain, slab=paste(Pain$Author, Pain$Year), weighted=TRUE, subset=(Pain$outcomegruppe=="9"), mods =("Pain$Year") )
I always get the error message:
Error in metafor::rma.uni(yi = MCID12, sei = SE12, method = "FE", data = Pain, :
Model matrix contains character variables.
My "Year" veriable is definetly numeric. As soon as I don't use the "mods" argument, everything works normal.
Could anyone help me with this problem?
Thanks in advance!
Don't put Year in quotes. Also, you don't need the Pain$ parts and weighted=TRUE is the default. This should do it:
metafor::rma.uni(yi=MCID12, sei=SE12, method="FE", data=Pain, slab=paste(Author, Year),
subset=(outcomegruppe=="9"), mods=~Year)

using lightgbm with average precision recall score

I am using LightGBM and would like to use average precision recall as a metric.
I tried defining feval:
cv_result = lgb.cv(params=params, train_set=lgb_train, feature_name=Rel_Feat_Names, feval=APS)
where APS defined as:
def APS(preds, train_data):
y_pred_val = []
y_test_val = []
for i, stat in enumerate(train_data.get_label.isnull()):
if ~stat:
y_pred_val.append(preds[i])
y_test_val.append(train_data.get_label[i])
aps = average_precision_score(np.array(y_test_val), np.array(y_pred_val))
return aps
and I get an error:
TypeError: Unknown type of parameter:feval, got:function
I also try to use "MAP" as the metric
cv_result = lgb.cv(params=params, train_set=lgb_train, feature_name=Rel_Feat_Names, "metric="MAP")
but got the following error:
"lightgbm.basic.LightGBMError: For MAP metric, there should be query information"
I can't find what is the query information required.
How can I use feval corrctly and define the query required for "MAP"
Thanks
Right now you can put map (alias mean_average_precision) as your metric as described here, but to answer the question of applying feval correctly:
Output of the customized metric should be a tuple of name, value and greater_is_better, so in your case:
def APS(preds, train_data):
aps = average_precision_score(train_data.get_label(), preds)
return 'aps', aps, False
then also include in your params the following: 'objective': 'binary', 'metric': 'None'

SendKeys() is adding default value (issue) + datetime value sent

basically the issue is taking place at the moment when I send some value which is appended to a default value '01/01/2000' somehow. I've tried different ways to do this without succeed, I've used these exact lines in other script and it worked but I don't know why this isn't working here. Please find below the last code I used followed by the picture with the issue displayed.
var targetStartDate = browser.driver.findElement(by.id('StartDate'));
targetStartDate.clear().then(function () {
targetStartDate.sendKeys('09/01/2016');
})
example of the issue
Thanks in advance for any response.
You can try issuing clear() call before sending keys:
targetStartDate.clear();
targetStartDate.sendKeys('09/01/2016');
The other option would be to select all text in the input prior to sending keys:
// protractor.Key.COMMAND on Mac
targetStartDate.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, "a"));
targetStartDate.sendKeys('09/01/2016');
I have encountered this same issue before. There is an input mask formatting the input in the field. In order to solve this, you must write your test as if it were the actual user, with the formatting in mind:
var targetStartDate = browser.driver.findElement(by.id('StartDate'));
// Remove the forward slashes because the input field takes care of that.
var inputDate = '09012016';
targetStartDate.clear();
// Loop through each character of the string and send it to the input
// field followed by a delay of 250 milliseconds to give the field
// enough time to format the input as you keep sending keys.
for (var i = 0; i < inputDate.length; i++) {
targetStartDate.sendKeys(inputDate[i]);
browser.driver.sleep(250);
}
Depending on the latency of the site and performance, you may either need to decrease the 250 millisecond delay, or be able to decrease it.
Hope this helps!

Can't print ggmap's get_map object on mac

I have a simple problem. I'm not able to print objects obtained via the get_map function on my Mac. I'm running the following code taken from another threat on stackoverflow:
library(ggmap)
library(mapproj)
map <- get_map(location = 'England', zoom = 7)
print(ggmap(map))
While the get_map function produces the intended object, the print function does not do its job. Specifically, I get the following error:
Error in layer(mapping = NULL, data = NULL, stat = "identity", geom = <environment>, :
unused argument (geom_params = list(raster = c("#B0CEFE", "#B0CEFE",
Help would be greatly appreciated. I should note that all packages are up to date, including RStudio, which I am using. Note that this function has worked well half a year ago. Not sure what happened.
Thank you!

How to assign the text box value to a variable

I wanted to get the t#test.com value from the text box which has introduced as the (By.Id("Email")) and compare with the selectEmail value. I have used the following code, but it doesnot take any value which was saved from the text box in the text box. When I debug it I could get only null value for the foundEmail variable.
var checkEmail = driver.FindElement(By.Id("Email"));
string foundEmail = checkEmail.Text;
string selectedEmail = "t#test.com";
Assert.AreEqual(foundEmail, selectedEmail);
Please help me to assign the t#test.com value from the text box to the given variable called foundEmail.
Thankyou
You are using checkEmail.Text please use following code
string foundEmail = driver.findElement(By.id("Email")).getAttribute("value"))
Try it
Thanks.

Resources