JS Line Chart - Null values \ Missing Data Points - lightningchart

I saw that in the .NET version of LightningChart that there is a way to add breaks in line charts. Is this possible in the JS version as well? I saw someone ask a similar question a couple years ago, but hoping that this has been implemented since then.
I've looked through the documentation and examples and didn't couldn't find anything. I'm hoping to replicate something that looks like this in ApexCharts:
https://apexcharts.com/javascript-chart-demos/line-charts/null-values/

Line breaks in LineSeries can be specified by using NaN.
At this time there is no official mention of supporting this, but this is just about to be changed with the next version release. Afterwards, please check the data input method documentation of each series type whether this is supported or not because it might be that not all features support it.
Here is a snippet with the same data as in your referenced ApexCharts example.
const {
lightningChart
} = lcjs
const chart = lightningChart().ChartXY()
const data = [
[5, 5, 10, 8, 7, 5, 4, NaN, NaN, NaN, 10, 10, 7, 8, 6, 9],
[10, 15, NaN, 12, NaN, 10, 12, 15, NaN, NaN, 12, NaN, 14, NaN, NaN, NaN],
[NaN, NaN, NaN, NaN, 3, 4, 1, 3, 4, 6, 7, 9, 5, NaN, NaN, NaN]
]
data.forEach(yValues => chart.addPointLineSeries().addArrayY(yValues))
<script src="http://unpkg.com/#arction/lcjs#3.3.0/dist/lcjs.iife.js"></script>

Related

survival::tmerge: how to manage events that are actually not not be intended as multiple?

I'm struggling to set a dataframe for multistate survival analysis. Here is the reproducible example with only 3 individuals (ID). This is only a part of the multistate.
f <- structure(list(ID = c(3, 4, 5), time_to_end = c(30, 36, 36)), row.names = c(NA, -3L), class = c("tbl_df", "tbl", "data.frame"))
f.long<–structure(list(ID = c(3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5), resp_pois = c(1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), time = c(6, 12, 18, 24, 30, 36, 42, 48, 6, 12, 18, 24, 30, 36, 42, 48, 6,
12, 18, 24, 30, 36, 42, 48)), row.names = c(NA, -24L), class = c("tbl_df", "tbl", "data.frame"))
f includes 3 individual taking a new drug and observed for time_to_end.
f.long includes the biochemical response at different time points.
E.g., ID 3 immediately respond to the drug up to 24 months, but at 30 months there is evidence of lack of biochemical response, while ID 4 shows only an isolated response at 24 months but never again or before.
I'm trying to manage this reversible condition between response and no-response with tmerge, as follows:
f.merge <- tmerge(f %>% select(ID), f, id=ID, tstart = 0, tstop = time_to_end)
f.merge <- tmerge(f.merge, f.long, id=ID, response=event(time, resp_pois))
survfit(Surv(tstart, tstop, response)~1, data=f.merge)
The problem is that tmerge interpretes every resp==1 as a new event, so at the end the survfit function give 5, instead of 2.
Can someone suggest any solution? Am i probably misusing tmerge?
I got this answer from Prof Terry Therneau by e-mail
Okay,
0. When debugging a purported issue with the survival package, my first step is run in an R session with the survival package loaded, and NOTHING else.
I can't read your data set: I'm getting a syntax error somewhere. But by cutting and pasting, I was able to create a "de tibbled" version of the data.
But what exactly is the data? The variable name "resp_pois" means nothing to me. You gave some information on where you want to go, but none about where you are starting. I will hazard a guess that you are dealing with panel data, i.e., subjects come in at regular intervals and you mesure their state at each visit?
Now, tmerge has no way to distinguish a data set with multiple heart attacks, and one row per attack; from a panel study data set.

Updating a data.frame based on a lookup value

So I've got a very strict system that allows for adding in R scripting to handle some data. It's a front end system and I've got about 1000 characters to throw in as much as I can. What I'm working on doing is replacing the values on a data.frame (filedata_model) with a value from a translation list.
here's what I have so far:
vGrades <- c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 4, 4, 3.7, 3.3, 3, 2.7, 2.3, 2, 1.7, 1.3, 1, 0, 0);
vGradeMx <- matrix(vGrades, nrow = 14, ncol = 2);
colnames(vGradeMx) <- c("CB_GRADE", "RNL_GPA");
vGradeTb <- as.data.frame(vGradeMx);
I get this is probably wildly inefficient. I'm used to working with VBA and C based programming languages and a LOT of SQL. If I could write an update statement this would take me 2 seconds. But I don't have any kind of back end access, or write capabilities on the actual data itself outside of this small box I can throw R scripting into.
So here's why I've written what I have:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 - These are the values we're getting back from a research vendor in a file
0, 4, 4, 3.7, 3.3, 3, 2.7, 2.3, 2, 1.7, 1.3, 1, 0, 0 - These are the values that we'd like to change them to.
I set up an additional data frame to hold the original and translation values, but now what? Everything I have tried generally fails. All the R I've learned has come from a weekend of trying to cram as many books in my brain as I can.
I appreciate the help!
filedata_model$column_name_here <- vGradeTb$RNL_GPA[match(filedata_model$column_name_here,
vGradeTb$CB_GRADE)]
where column_name_here is the column containing the values you want to change.

How to get the order of the model used in auto.arima?

I am trying to use auto.arima on a timeseries. Now I need to know the order of the arima that has been selected. The return value is of type ARIMA, which doesn't hold the order anywhere. (or am I missing the values). Given in code snippet and the output attributes. (This is same as in R Documentation)
double[] list1 = {0, 0, 2, 1, 2, 10, 21, 0, 0, 3, 6, 5, 11, 51, 0, 11, 8, 6, 24, 25, 104, 0, 0, 6, 4, 5, 25, 71};
rconnection.assign("myData1", list1);
rconnection.eval("timeSeries1 <- ts(myData1,start=1,frequency="+staticBookingStage+")");
REXP fc = rconnection.eval("fitModel1 <- auto.arima(timeSeries1)");
System.out.println( fc.asList().names);
Output
[coef, sigma2, var.coef, mask, loglik, aic, arma, residuals, call, series, code, n.cond, nobs, model, bic, aicc, x, fitted]
Use the arimaorder() function:
library(forecast)
fit <- auto.arima(WWWusage)
arimaorder(fit)

Merging three vectors with NaN's

I have three vectors that look something like this:
x = c(NaN, 15, 16, 14, 14, NaN)
y = c(NaN, NaN, NaN, NaN, NaN, 11)
z = c(17, NaN, NaN, NaN, NaN, 12)
I need to merge them into one vector. I need these three to mesh together smoothly, and where there are overlapping values (as seen in y and z), priority should be given to the value from z. The end result should look like so:
xyz = c(17, 15, 16, 14, 14, 12)
I've looked into using rowSums to handle the na's, but this doesn't work in cases where there are multiple values on the same index. I'm trying to avoid for loops if possible.
Pretty sure I could do this by iterating through the vectors but I'm working with a fairly large data set.
This seems to work. NB It relies on z being the last column of the data frame, then flips it so that it's first (i.e., rev).
df <- data.frame(x = c(NaN, 15, 16, 14, 14, NaN),
y = c(NaN, NaN, NaN, NaN, NaN, 11),
z = c(17, NaN, NaN, NaN, NaN, 12))
do.call(dplyr::coalesce, rev(df))
You can also use zoo package:
df <- rbind(x, y, z)
#it replaces last row with latest non-NA value therefore z always has priority:
xyz <- zoo::na.locf(df)['z',]
#[1] 17 15 16 14 14 12
Data:
x <- c(NaN, 15, 16, 14, 14, NaN)
y <- c(NaN, NaN, NaN, NaN, NaN, 11)
z <- c(17, NaN, NaN, NaN, NaN, 12)
Or you can using base R function na.omit
x = c(NaN, 15, 16, 14, 14, NaN)
y = c(NaN, NaN, NaN, NaN, NaN, 11)
z = c(17, NaN, NaN, NaN, NaN, 12)
dt=data.frame(z=z,x=x,y=y)
unlist(lapply(apply(dt,1,na.omit), `[[`, 1))
[1] 17 15 16 14 14 12

highcharts display all dates for all points on x-axis

I have a spline graph with date time on x-axis. i want the date time to be automatic but also display it for all points on the x-axis. Take the demo for example - i want all the points to be display with their dates on the x-axis. how do i do this? the demo is found here . I have not tried anything because i do not know how to, that is why I am asking on here. why it is complaining to not let me post still i do not know why.
You can use tickPositions like in the example: http://jsfiddle.net/z5P8d/
tickPositions: [Date.UTC(1970,9, 27),Date.UTC(1970, 9, 26),Date.UTC(1970, 11, 1),Date.UTC(1970, 11, 11),Date.UTC(1970, 11, 25), Date.UTC(1971, 0, 8),Date.UTC(1971, 0, 15), Date.UTC(1971, 1, 1),Date.UTC(1971, 1, 8), Date.UTC(1971, 1, 21),Date.UTC(1971, 2, 12), Date.UTC(1971, 2, 25),Date.UTC(1971, 3, 4), Date.UTC(1971, 3, 9),Date.UTC(1971, 3, 13), Date.UTC(1971, 3, 19), Date.UTC(1971, 4, 25),Date.UTC(1971, 4, 31), Date.UTC(1971, 5, 7) ],

Resources