Superscripts and subscripts in ylab() function - rstudio

This code might be a little messy (just starting to use R), but I'm looking for help to get subscripts and superscripts using ggplot2 and ylab().
I need a superscripted -1 after the mL in lab():
chaptoplot=ggplot(chaptodat, aes(x=treatment, y=mean, shape=treatment))+geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.1, position=pd) +geom_line(position=pd) +geom_point(position=pd, size=4) + ylab("Corrected haptoglobin \nconcentration (mg mL)\n") + theme_bw() +theme(panel.grid.major = element_blank(),panel.grid.minor=element_blank())+theme_classic()+theme(axis.text = element_text(colour = "black", size=12))+theme(axis.title=element_text(size=12)) +theme(legend.position="none") +ylim(0.2,0.7)
For this code, I need a subscripted 405 after the OD in ylab():
natabplot=ggplot(natabdat, aes(x=bin, y=mean, shape=treatment)) +geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.1, position=pd) +geom_line(position=pd) +geom_point(position=pd, size=4) +xlab("\nTime of sampling") +ylab("Total circulating IgY\n(corrected OD)\n")+theme_bw() +theme(panel.grid.major = element_blank(),panel.grid.minor=element_blank())+theme_classic()+theme(axis.text = element_text(colour = "black", size=12))+theme(axis.title=element_text(size=12))+theme(legend.position="none")
I've tried searching using ^"-1" and ["405"], but it either doesn't work or I get an error message. Any help would be appreciated!

Next time you won't need to write all your code, otherwise people would rather not read it. Just write the important part of your code, with the special code block ctrl+k.
However, you should write something like that:
chaptoplot = ggplot(chaptodat, aes(x=treatment, y=mean, shape=treatment)) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.1, position=pd) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.1, position=pd) +
geom_line(position=pd) +geom_point(position=pd, size=4) +
ylab(expression("Corrected haptoglobin \nconcentration "("mg mL"^"-1")\n))) +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor=element_blank()) +
theme_classic() +
theme(axis.text = element_text(colour = "black", size=12)) +
theme(axis.title=element_text(size=12)) +
theme(legend.position="none") +
ylim(0.2,0.7)
The other one should be as follows:
natabplot = ggplot(natabdat, aes(x=bin, y=mean, shape=treatment)) +
geom_errorbar(aes(ymin=mean-se, ymax=mean+se), colour="black", width=.1, position=pd) +
geom_line(position=pd) +
geom_point(position=pd, size=4) +
xlab("\nTime of sampling") +
ylab(expression("Corrected haptoglobin \nconcentration"("mg mL"^"-1")))+
theme_bw() +
theme(panel.grid.major = element_blank(),panel.grid.minor=element_blank()) +
theme_classic()+theme(axis.text = element_text(colour = "black", size=12)) +
theme(axis.title=element_text(size=12)) +
theme(legend.position="none")

Related

How to query ARCGIS REST Service via ajax with street address

Not very familiar with the necessary GIS concepts so this is a beginner question. From my web app I am querying a GIS REST Service using this query:
require([
"dojo/dom", "dojo/on",
"esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!"
], function (dom, on, Query, QueryTask) {
var queryTask = new QueryTask("http://gis.something.org/arcgis/rest/services/XXXX/Operational/MapServer/6");
var query = new Query();
query.returnGeometry = false;
query.outFields = [
"DISTRICTID "
];
query.where = "SUBID = '" + SUBJID + "'";
queryTask.execute(query, showResults);
In this scenario I had a subject ID (SUBID) which I used for the query to return which district the subject falls in (i.e. the respective DistrictID). I now want to query the service by street address, rather than by SUBID. Any pointers how to structure the query in this case?
thank you!
in query.where, just add ' AND ' or ' OR ' to concatenate the where attribute with other conditions...
example:
query.where = "SUBID = '" + SUBJID + "'" + ' AND ' + "otherAttr = " + otherVar;
Any pointers query in this case
var q = new Query();
var query = "SUBID = '" + SUBJID + "'";
query = query + " and " + "attr = " + attrValue
q.where = query;

SELECT * INTO Incomplete Query Clause

I seem to be doing something wrong in my OleDbCommand, but I don't know what it is. I am trying to create another table in my access database that is exactly the same as the first but with a different name, by copying everything from one and using SELECT INTO. I don't know why it doesn't work.
OleDbCommand copyAttendanceCommand = new OleDbCommand("SELECT * INTO '" + "Attendance " + DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + "' FROM Attendance",loginForm.connection);
copyAttendanceCommand.ExecuteNonQuery();
The Error message that I get says "Syntax error in query. Incomplete query clause." Does anyone know what that means?
Table or field names with spaces are not specified with '' around them, but with square brackets.
Your command should be:
"SELECT * INTO [Attendance " + DateTime.Now.Day + "/" + DateTime.Now.Month + "/"
+ DateTime.Now.Year + "] FROM Attendance"
You may even format your date to make the code more readable:
string today = DateTime.Today.ToString("d'/'M'/'yyyy");
string sql ="SELECT * INTO [Attendance " + today + "] FROM Attendance";
OleDbCommand copyAttendanceCommand = new OleDbCommand(sql, loginForm.connection);
copyAttendanceCommand.ExecuteNonQuery();

Mixing Vertical and Horizontal layouts (for horizontally laid out class diagram)

I am trying to display a class diagram in GraphViz. I would like it to be laid out primarily horizontally - but am having a problem because it is separating out the three parts of each class horizontally too (i.e. class name, attributes, and methods) are also being displayed horizontally. I have tried subgraphs with rankdir = LR for each individual node, but it isn't working.
Here is my code:
digraph hierarchy {
node[shape=record,style=filled,fillcolor=gray95]
edge[dir=back, arrowtail=empty]
graph[size="20,10"]
rankdir=LR
1[label = "{Hazards|+ ID\n + Description\n + RiskLevel|+f Topics}" ]
2[label = "{Faults|+ ID\n + Fault\n + Likelihood\n + Impact\n + Mitigation|+f Topics}"]
3[label = "{User Requirements|+ ID\n + Requirement\n + Status\n + Priority\n + Contributors|+f NFR Types\n+fTopics\n +f Find-the-expert\n+f Volatility}"]
4[label = "{Acceptance Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage}"]
5[label = "{Acceptance Test Log|+ TestID\n +DateRun\n + Relevance}"]
6[label = "{Regulatory Codes|+ ID\n + Regulation\n + Likelihood\n + Impact\n + Mitigation|+f Topics}"]
7[label = "{State Transition Diagram|+ ID\n + States\n + Transitions\n + Model}"]
8[label = "{System Requirements|+ ID\n + Description\n +Status\n + Priority|+f Topics}"]
9[label = "{Work Item|+ ID\n +Description\n + AssignedTo\n + DateCompleted\n + Comments|+f ProjectVelocity}"]
10[label = "{Bug Tracker|+ ID\n + Title\n +ReportedOn\n + FixedOn\n + Symptoms\n + State\n + Effort|+f Find-the-expert}"]
11[label = "{Source Code|+ ClassName\n +Code\n + CreatedBy\n + CreatedOn\n + LastModifiedBy\n + LastModifiedOn|+f Fault Likelihood\n + f Topics}"]
12[label = "{Unit Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage}"]
13[label = "{Unit Test Log|+ TestID\n + DateRun\n + ByWhom\n +Status\n + ActionItems}"]
14[label = "{Components|+ ID\n + Name|+f Fault Likelihood}"]
1->2
2->3
3->4
4->5
2->8
3->8
8->6
8->7
8->9
10->9
8->11
14->11
11->12
12->13
11->9
}
Unfortunately I am not allowed to post images as I don't have an StackOverflow reputation. However, you can see the vertical solution by replacing rankdir =LR with rankdir=TB.
Does anyone know how to combine the two layouts so that the classes stay stacked i.e. class name above attributes above functions etc, but that the overall layout is LR?
I prefer not to use the UMLGraph.lib if there is a way to specify this directly in GraphVis.
Many thanks
jane
The answer is therefore:
digraph hierarchy {
node[shape=record,style=filled,fillcolor=gray95]
edge[dir=back, arrowtail=empty]
graph[size="15,20"]
rankdir=LR
1[label = "Hazards|+ ID\n + Description\n + RiskLevel\n+f Topics"]
2[label = "Faults|+ ID\n + Fault\n + Likelihood\n + Impact\n + Mitigation|+f Topics"]
3[label = "User Requirements|+ ID\n + Requirement\n + Status\n + Priority\n + Contributors|+f NFR Types\n+fTopics\n +f Find-the-expert\n+f Volatility"]
4[label = "Acceptance Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage"]
5[label = "Acceptance Test Log|+ TestID\n +DateRun\n + Relevance"]
6[label = "Regulatory Codes|+ ID\n + Regulation\n + Likelihood\n + Impact\n + Mitigation|+f Topics"]
7[label = "State Transition Diagram|+ ID\n + States\n + Transitions\n + Model"]
8[label = "System Requirements|+ ID\n + Description\n +Status\n + Priority|+f Topics"]
9[label = "Work Item|+ ID\n +Description\n + AssignedTo\n + DateCompleted\n + Comments|+f ProjectVelocity"]
10[label = "Bug Tracker|+ ID\n + Title\n +ReportedOn\n + FixedOn\n + Symptoms\n + State\n + Effort|+f Find-the-expert"]
11[label = "Source Code|+ ClassName\n +Code\n + CreatedBy\n + CreatedOn\n + LastModifiedBy\n + LastModifiedOn|+f Fault Likelihood\n + f Topics"]
12[label = "Unit Tests|+ TestID\n + Script\n +CurrentStatus|+f Coverage"]
13[label = "Unit Test Log|+ TestID\n + DateRun\n + ByWhom\n +Status\n + ActionItems"]
14[label = "Components|+ ID\n + Name|+f Fault Likelihood"]
1->2
2->3
3->4
4->5
2->8
3->8
8->6
8->7
8->9
10->9
8->11
14->11
11->12
12->13
11->9
}

Conditionally modifying multiple strings with For

So I have 13 binary values, which I call b_1... b_13, and based off these values I'd like to either set something I call indic_j to a previously defined string called inf_j, or nothing at all. Is it possible to do this without using 13 "If..." statements? What I have tried is below:
inf_1 = "aaaaa"
inf_2 = "bbbbb"
... and so on defining 13 infs, where aaaaa, bbbbb etc are names of columns in a table that I want to select.
FOR j = 1 to 13
IF b_j = 1 THEN "indic_"+j = inf_j + ",";
ELSE "indic_"+j = ""
ENDIF
ENDFOR
Also, before this I haven't introduced anything called indic_1, indic_2, etc. Is this needed?
My end goal is to transfer selected columns over to Excel. I've no problems doing this with predetermined columns, but I'm not sure how to allow for selected columns only.
I've tried using 13 IF statements, but I'm getting operator/operand type mismatch errors. My code currently is
IIF(b_1 = 1, indic_1 = inf_1 + ",",indic_1 = "")
IIF(b_2 = 1, indic_1 = inf_2 + ",",indic_1 = "")
IIF(b_3 = 1, indic_1 = inf_3 + ",",indic_1 = "")
and so on for 13 times, and then
SELECTIONRANG = indic_1 + indic_2 + indic_3 + indic_4 + indic_5 + indic_6 +indic_7 + indic_8 + indic_9 + indic_10 + indic_11 + indic_12 + indic_13
SELECTIONRANGE = LEFT(SELECTIONRANG,LEN(Selectionrang)-1)
You could create te variable name as a string and use it with &
As:
ind = 13
Var = "inf_" + ind
&Var ** inf_13

Understanding the output log's auto layout data

I'm debugging a crash that I believe is auto layout related. When the crash occurs, I get an enormous dump of information on the output area that begins like this:
2015-06-04 13:23:44.158 SpeedySend[22084:861374] Objective: {objective
0x7f99e06b3730: <500:242.5, 250:18443.5> +
<500:1>*0x7f99e061e570.negError{id: 4899} +
<500:1>*0x7f99e061e570.posErrorMarker{id: 4898} + <500:1,
250:-1>*0x7f99e061f940.negError{id: 4913} + <500:1,
250:1>*0x7f99e061f940.posErrorMarker{id: 4912} + <500:1,
250:-1>*0x7f99e061fb40.negError{id: 4915} + <500:1,
250:1>*0x7f99e061fb40.posErrorMarker{id: 4914} + <500:1,
250:-2>*0x7f99e0620890.negError{id: 4807} + <500:1,
250:2>*0x7f99e0620890.posErrorMarker{id: 4806} +
<500:2>*0x7f99e06496f0.posErrorMarker{id: 4916} +
<500:2>*0x7f99e0649f40.posErrorMarker{id: 4920} + <50 ...
and then runs on for a very long time and ends like this:
... 250:-1>*0x7f99e1d77ec0.negError{id: 5023} + <800:1,
250:1>*0x7f99e1d77ec0.posErrorMarker{id: 5022} + <500:1,
250:-1>*0x7f99e1d78150.negError{id: 5025} + <500:1,
250:1>*0x7f99e1d78150.posErrorMarker{id: 5024} +
<500:1>*0x7f99e1d78310.negError{id: 5027} +
<500:1>*0x7f99e1d78310.posErrorMarker{id: 5026} +
<500:1>*0x7f99e1d78620.negError{id: 5045} +
<500:1>*0x7f99e1d78620.posErrorMarker{id: 5044} +
<500:1>*0x7f99e1d788c0.negError{id: 5031} +
<500:1>*0x7f99e1d788c0.posErrorMarker{id: 5030} +
<500:1>*0x7f99e1d78d30.negError{id: 5033} +
<500:1>*0x7f99e1d78d30.posErrorMarker{id: 5032} +
<500:1>*0x7f99e1d790a0.negError{id: 5035} +
<500:1>*0x7f99e1d790a0.posErrorMarker{id: 5034} +
<500:1>*0x7f99e1d79460.negError{id: 5037} +
<500:1>*0x7f99e1d79460.posErrorMarker{id: 5036} +
<500:1>*0x7f99e1d79840.negError{id: 5039} +
<500:1>*0x7f99e1d79840.posErrorMarker{id: 5038} +
<500:1>*0x7f99e1d79c50.negError{id: 5041} +
<500:1>*0x7f99e1d79c50.posErrorMarker{id: 5040} +
<500:1>*0x7f99e1d7a080.negError{id: 5043} +
<500:1>*0x7f99e1d7a080.posErrorMarker{id: 5042} +
<500:1>*0x7f99e1d7aa60.negError{id: 5047} +
<500:1>*0x7f99e1d7aa60.posErrorMarker{id: 5046} +
<500:-7.45058e-08>*0x7f99e1f7ae60.negError{id: 3600}}
I would like to understand this data better as an aid to debugging my problem.
Is there a document or a posting that I can access that explains the format and meaning of this data?
Like, for instance, what does something like <500:1,250:-1> represent?
What is a negError?
And, most importantly, can something like {id: 3600} be tied back to a specific control that auto layout is laying out for me?
I'm particularly interested in the last questions because I've read here that very small numbers, when seen in these dumps, can indicate a crash due to accumulated loss of floating point precision in the auto layout engine.
You'll note that I have such a number on the very last line of my output data. So, if I can relate {id: 3600} back to one of my controls, I hope that will put me close to the origin of the problem.

Resources