i want to add sub cb and closing from the above query in sqllite the query is posted below - sqlite

WITH inputs(op, input,cb,usage,closing) AS (VALUES(op, input,cb,usage,closing))
SELECT *,
(SELECT CASE when MOD((substr(op, 4, instr(op, '-')-1) + substr(input, 4, instr(input, '-')-1)),60) < 60
then (substr(op, 1, instr(op, '-')-1) + substr(input, 1, instr(input, '-')-1) + ((substr(op, 4, instr(op, '-')-1) + substr(input, 4, instr(input, '-')-1))/60)) ||'-'||
cast( MOD((substr(op, 4, instr(op, '-')-1) + substr(input, 4, instr(input, '-')-1)),60) + ((substr(op, 7, instr(op, '-')-1) + substr(input, 7, instr(input, '-')-1))/10)as int ) ||'-'||
cast( MOD((substr(op, 7, instr(op, '-')-1) + substr(input, 7, instr(input, '-')-1)),10)+((substr(op, 9, instr(op, '-')-1) + substr(input, 9, instr(input, '-')-1))/7)as int)||'-'||
cast( MOD((substr(op, 9, instr(op, '-')-1) + substr(input, 9, instr(input, '-')-1)),7) as int )
else (substr(op, 1, instr(op, '-')-1) + substr(input, 1, instr(input, '-')-1)) ||'-'||
(substr(op, 4, instr(op, '-')-1) + substr(input, 4, instr(input, '-')-1)) ||'-'||
(substr(op, 7, instr(op, '-')-1) + substr(input, 7, instr(input, '-')-1)||'-'||
(substr(op, 9, instr(op, '-')-1) + substr(input, 9, instr(input, '-')-1)))
end ) as cb,
(SELECT CASE when MOD((substr(usage, 4, instr(usage, '-')-1) + substr(tout, 4, instr(tout, '-')-1)),60) < 60
then (substr(usage, 1, instr(usage, '-')-1) + substr(tout, 1, instr(tout, '-')-1) + ((substr(usage, 4, instr(usage, '-')-1) + substr(tout, 4, instr(tout, '-')-1))/60)) ||'-'||
cast( MOD((substr(usage, 4, instr(usage, '-')-1) + substr(tout, 4, instr(tout, '-')-1)),60) + ((substr(usage, 7, instr(usage, '-')-1) + substr(tout, 7, instr(tout, '-')-1))/10)as int ) ||'-'||
cast( MOD((substr(usage, 7, instr(usage, '-')-1) + substr(tout, 7, instr(tout, '-')-1)),10)+((substr(usage, 9, instr(usage, '-')-1) + substr(tout, 9, instr(tout, '-')-1))/7)as int)||'-'||
cast( MOD((substr(usage, 9, instr(usage, '-')-1) + substr(tout, 9, instr(tout, '-')-1)),7) as int )
else (substr(usage, 1, instr(usage, '-')-1) + substr(tout, 1, instr(tout, '-')-1)) ||'-'||
(substr(usage, 4, instr(usage, '-')-1) + substr(tout, 4, instr(tout, '-')-1)) ||'-'||
(substr(usage, 7, instr(usage, '-')-1) + substr(tout, 7, instr(tout, '-')-1)||'-'||
(substr(usage, 9, instr(usage, '-')-1) + substr(tout, 9, instr(tout, '-')-1)))
end ) as closing
FROM cottonyarntab
in the above query i want substract cb and closing please guide
the values of cb = 21-1-2-2 and closing 00-00-2-2 are the result of above query
i want 21-1-0-0 after sub cb - closing
enter image description here

Related

Difference between fit$loadings and fit$Vaccounted for variance accounted for in factor analysis?

I am getting different values for variance accounted for by factors in factor analysis whether I check them with fit$loadings or with fit$Vaccounted. I am using the psych package with the fa() function. Why would that be the case if they're supposed to be exactly the same thing (I guess they're not or that they are calculated differently)?
The total difference is not huge, but still not trivial (about 0.7 for cumulative). I have a reprex below.
(I'm sorry for the large dataset, I was not able to replicate the issue with different datasets or a subset, so it might have to do with something funky with the data.)
data <- structure(list(X1 = c(5, 5, 5, 7, 2, 2, 2, 2, 7, 5, 4, 9, 8,
8, 6, 9, 9, 2, 2, 2, 2, 3, 2, 2, 9, 7, 8, 4, 3, 4, 6, 6, 3, 4,
4, 4, 8, 7, 6, 7, 5, 6, 6, 4, 8, 8, 8, 3, 9, 9, 6, 4, 8, 7, 8,
7, 8, 8, 8, 8), X2 = c(6, 4, 4, 6, 2, 2, 2, 2, 6, 5, 4, 8, 7,
9, 6, 9, 4, 2, 2, 2, 6, 4, 6, 7, 9, 6, 8, 4, 3, 3, 5, 5, 2, 3,
4, 7, 7, 5, 5, 6, 7, 7, 7, 3, 8, 5, 3, 2, 9, 9, 4, 4, 4, 6, 4,
4, 8, 8, 8, 8), X3 = c(7, 5, 4, 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 3,
4, 4, 6, 8, 8, 8, 8, 9, 8, 9, 8, 5, 8, 8, 8, 8, 8, 6, 7, 6, 7,
7, 5, 4, 3, 4, 4, 6, 4, 6, 5, 8, 5, 8, 8, 7, 7, 4, 5, 7, 7, 6,
7, 8, 8, 9, 8), X30 = c(3, 3, 4, 5, 2, 2, 2, 2, 5, 4, 2, 5, 8,
7, 7, 6, 2, 2, 2, 2, 2, 2, 2, 2, 6, 5, 6, 3, 3, 2, 2, 2, 2, 2,
4, 3, 7, 8, 7, 6, 2, 2, 2, 2, 2, 9, 3, 2, 4, 3, 6, 5, 3, 2, 4,
3, 2, 2, 2, 4), X32 = c(2, 3, 3, 3, 2, 4, 2, 3, 3, 2, 2, 6, 8,
7, 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 8, 5, 8, 2, 2, 2, 2, 2, 3, 2,
2, 3, 2, 6, 4, 6, 9, 9, 9, 5, 2, 9, 2, 2, 5, 4, 6, 7, 2, 2, 2,
2, 5, 6, 5, 6), X34 = c(2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 4,
3, 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2,
6, 6, 2, 2, 3, 2, 6, 8, 7, 2, 2, 2, 3, 2, 6, 4, 3, 3, 3, 4, 3,
3, 4, 3, 4, 2)), class = "data.frame", row.names = c(NA, 60L))
Now that we defined the dataset, let's jump in with the code.
library(psych)
fit <- fa(data, nfactors = 4)
#> Loading required namespace: GPArotation
print(fit$loadings)
#>
#> [Loadings truncated for brevity]
#>
#> MR1 MR2 MR3 MR4
#> SS loadings 9.464 3.571 2.171 1.682
#> Proportion Var 0.338 0.128 0.078 0.060
#> Cumulative Var 0.338 0.466 0.543 0.603
print(fit$Vaccounted, digits = 3)
#> MR1 MR2 MR3 MR4
#> SS loadings 10.392 4.328 2.324 1.8283
#> Proportion Var 0.371 0.155 0.083 0.0653
#> Cumulative Var 0.371 0.526 0.609 0.6740
Created on 2022-02-10 by the reprex package (v2.0.1)
We can see the values differ. Any ideas why?
https://www.researchgate.net/post/How_can_of_Variance_of_factors_in_exploratory_factor_analysis_be_calculated_when_factors_are_correlated
I am not familiar with factor analysis, but as shown here, it seems that SS loading cannot be calculated as a sum of squares because of inter-factor correlations when oblique rotation is used. Perhaps, fit$Vaccounted takes this problem into account but fit$loadings is simply the sum of squares. I think this difference appears.
Note that the default rotation in the fa package is oblimin which is obliqu rotation, so I think this difference will appear.

How can I change the grid line spacing on a ggplot2 dotplot?

I'm analyzing data from the result of pulling 10 numbered balls from a jar with replacement, repeated 70 times. Here's my code (data included):
numbers <- c(8, 3, 9, 5, 1, 9, 10, 8, 8, 1, 9, 9, 8, 5, 1, 10, 5, 9, 6, 4, 10, 3,
10, 9, 8, 4, 8, 8, 9, 9, 1, 5, 9, 8, 4, 1, 8, 6, 7, 8, 2, 9, 5, 6,
10, 9, 1, 1, 5, 6, 2, 8, 6, 5, 2, 5, 4, 10, 10, 2, 2, 4, 9, 6, 9,
9, 6, 10, 9, 10)
num_frame <- data.frame(numbers)
ggplot(num_frame) +
geom_dotplot(aes(numbers), binwidth = 1, dotsize = 0.4) +
theme_bw() +
xlab("Numbers") +
ylab("Frequency")
The resulting plot is nice, except it labels gridlines at 0, 2.5, 5, 7.5, and 10, which is obviously not what I want. The scale is fine, but I would like the gridlines to be at integer values 1 through 10 (0 is fine too if necessary). How can I do this? I'd also like the y-axis to adjust likewise so that the grid is still square. Thanks!
Just add:
scale_x_continuous(breaks=1:10, minor_breaks=NULL)
minor_breaks=NULL suppress lines that aren't at the breaks

Add legend to graph in R

For a sample dataframe:
df <- structure(list(antibiotic = c(0.828080341411847, 1.52002304506738,
1.31925434545302, 1.66681722567074, 1.17791610945551, 0.950096368502059,
1.10507733691997, 1.0568193215304, 1.03853131016669, 1.02313195567946,
0.868629787234043, 0.902126485349154, 1.12005679002801, 1.88261441540084,
0.137845900627507, 1.07040656448604, 1.41496470588235, 1.30978543173373,
1.16931780610558, 1.05894439450366, 1.24805122785724, 1.21318238007025,
0.497310305098053, 0.872362356327429, 0.902584749481137, 0.999731895498823,
0.907560340983954, 1.05930840957587, 1.40457554864091, 1.09747179272879,
0.944219456216072, 1.10363111431903, 0.974649273935516, 0.989983064420841,
1.14784471036171, 1.17232858907798, 1.44675812720393, 0.727078405331282,
1.36341361598635, 1.06120293299474, 1.06920290856811, 0.711007267992205,
1.39034247642439, 0.710873996527168, 1.30529753573398, 0.781191310196629,
0.921788181250106, 0.932214675722466, 0.752289683770589, 0.942392026874501
), year = c(3, 1, 4, 1, 2, 4, 1, 3, 4, 3, 4, 1, 2, 3, 4, 1, 1,
4, 1, 1, 1, 1, 4, 1, 3, 3, 1, 4, 1, 4, 2, 1, 1, 1, 3, 4, 3, 2,
2, 2, 3, 3, 1, 2, 3, 2, 3, 4, 4, 1), imd.decile = c(8, 2, 5,
5, 4, 3, 2, 8, 6, 4, 3, 6, 9, 2, 5, 3, 5, 6, 4, 2, 9, 11, 2,
8, 3, 5, 7, 8, 7, 4, 9, 7, 6, 4, 8, 10, 5, 6, 6, 11, 6, 4, 2,
4, 10, 8, 2, 8, 4, 3)), .Names = c("antibiotic", "year", "imd.decile"
), row.names = c(17510L, 6566L, 24396L, 2732L, 13684L, 28136L,
1113L, 15308L, 28909L, 21845L, 23440L, 1940L, 8475L, 22406L,
27617L, 4432L, 3411L, 27125L, 6891L, 6564L, 1950L, 5683L, 25240L,
5251L, 20058L, 18068L, 5117L, 29066L, 2807L, 24159L, 12309L,
6044L, 7629L, 2336L, 16583L, 23921L, 17465L, 14911L, 8879L, 13929L,
17409L, 19421L, 7239L, 11570L, 15283L, 8283L, 16246L, 27950L,
23723L, 4411L), class = "data.frame")
I am trying to graph imd.decile by antibiotic for each year
library(ggplot2)
p <- ggplot(df, aes(x = imd.decile, y = antibiotic, group = factor(year))) +
stat_summary(geom = "line", fun.y = mean)
p
How do I add the wave to colour the corresponding graph and add a legend (I can't seem to use the aes command correctly).

En-dash in axis label in ggplot2 when printing to pdf()

I am struggling to get an en-dash in the axis label of a plot in ggplot2 when using pdf(). I am using MacOS High Sierra.
The graphing code is:
fit1 <- lm(y ~ x, data.df)
p1 <- ggplot(data.df, aes(x=x, y=y)) +
geom_point() +
geom_abline(fit1, intercept = coef(fit1)[[1]], slope = coef(fit1) .
[[2]], color="red", size=.2) +
xlab("CMP Left–Right Score")) +
ylab("Disposition Towards BI")
This seems to render correctly if we do
quartz()
p1
However, the following gives a hyphen instead of an en-dash:
pdf(file="pooled.pdf", width=8, height=6)
p1
dev.off()
The data is:
structure(list(x = c(-16.667, -36.735, 43.243, -64.286, 37.963,
-9.091, 6.593, -38.614, -30.496, -10.549, -45.455, -46.515, 25.926,
-23.81, -29.53, -38.614, -4.478, 1.266, 1.176, -30.357, 5, 13.084,
-7.692, -38.614, 14.62, 26.829, -13.725, -14.894, 24.299, 13.084,
4.145, -13.433, 29.464, -1.049, -1.37, -38.168, 19.444, -5.882,
14.516, -6.25, 9.756, -7.636, -24.742, -45.946, 7.813, -5.882,
-19.931, -33.523, -20.556, -15.09, -36.432, -42.051, -15.108,
-6.518, -25.472, -21.471, 13.75, -16.383, -11.384, -44.767, -16.771,
0.472, -23.392, -27.715), y = c(-0.295492376, 0.187137648,
-0.209073538,
1.026732887, -0.524148543, 0.232093035, -1.617201837, -0.038851011,
-0.351777544, 0.637192933, -0.783167803, 1.549387151, -0.742792721,
-0.054633476, -2.204811412, 0.009461977, -0.594714182, 1.172333694,
-0.951553793, 1.59911439, -1.246200649, -0.337551454, -2.631499836,
0.6051641, -0.885991535, 1.492537342, -1.275241929, 1.658246706,
-1.331133971, -0.676627085, -3.220241861, 0.82922329, -0.841711554,
1.611623219, -1.531110402, 1.469424694, -1.979679497, -0.724442893,
-3.523278033, 1.187782421, -0.842631246, 1.35252299, -1.950335,
0.859798616, -2.152810527, -0.623310324, -3.48956421, 1.718330701,
-0.809637545, 0.741273409, -1.96458669, 1.466255347, -2.675088542,
-1.066556748, -3.436585287, 1.935368096, -0.870188157, 0.477034948,
-2.49292584, 1.93375064, -2.924310472, -1.033098158, -3.250669464,
2.086336567), party = c(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5,
6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2,
3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7,
8, 1, 2, 3, 4, 5, 6, 7, 8)), .Names = c("x", "y", "party"), row.names =
c(NA,
-64L), class = "data.frame")
Cairo is usually better at dealing with fonts,
library(ggplot2)
ggsave('en.pdf',ggplot() + xlab("hyphen-hyphen en–en em—em"),
device = cairo_pdf)

Error reading dataset in R

I have problem in reading a dataset
My code :
require(igraph)
g <- graph(c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4,
4, 5, 5, 3, 4, 6, 6, 7, 7, 8,
8, 6, 9, 10, 10, 11, 11, 9))
Error :
Error in graph(c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4, 4, 5, 5, 3, 4, 6, 6, 7, :
At structure_generators.c:84 : Invalid (negative) vertex id, Invalid vertex id
The problem seems to be vertex of name 0
yourgraph <- c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4,
4, 5, 5, 3, 4, 6, 6, 7, 7, 8,
8, 6, 9, 10, 10, 11, 11, 9)
g <- graph(yourgraph + 1)

Resources