After decoding using ijkplayer why decoded frames have no Y, U, V frame data although being YUVJ420P - decoding

In ijkplayer, after decoding, the obtained frame has no YUV planes data[0], data[1], data[2] are all null and similarly linesize[i], although pix_fmt is YUVJ420P. Can anyone please tell me why?

Related

Turn fd to fData in R

I need to use MBD (modified band depth) in an fd object but it's getting complicated. I've been trying to extract data from my fd object but I can't find them although I get results when applying some functions. The issue is that I have two fd databases and I need to iteratively paste them, so fd data is not useful. Does anyone know how to turn a fd object into fData object.
Thank you so much.
Right. fd and fData are objects for functional data and I have two functional datasets in fd objects, say X and Y. I need to compute Modified Band Depth (MBD) of these data including each observation of the other. I mean, for each curve in X I have to create a functional dataset combining all the observations in Y with the observation in X. I need to do this several times, and the problem is that MBD function is only available for fData objects. I haven´t been able to make the conversion from fd to fData.
SE_hat_U<-fd(basisobj=BSpl)
for(i in 1:61){
SE_hat_U$coefs<-cbind(SE_hat_U$coefs, sm[[i]]$fd$coefs)
}
SE_hat_U$fdnames$reps<-(1:61)
X<-SE_hat_U[as.numeric(NT$Id)]
Y<-SE_hat_U[!datos$Id%in%(NT$Id)]
This is the code I have but i don't know how to turn SE_hat_U into a fData object instead of a fd one.

Easiest way to apply series of calculations to similar data frames in R

The following is an example of how I want to treat my data sets. It might be a bit different to understand how my data frame is structured, but I hope it makes sense:
First density must be calculated for columns A, B, and C using raw data from columns ADry, AEthanol, BDry ...... (Since these were earlier defined as vectors too, i used the vectors instead data frame columns as it was shorter - ADry_1_0 instead of Sample_1_0$ADry_1_0)
Sample_1_0$ADensi_1_0=(ADry_1_0/(ADry_1_0-AEthanol_1_0))*(peth-pair)+pair
Sample_1_0$BDensi_1_0=(BDry_1_0/(BDry_1_0-BEthanol_1_0))*(peth-pair)+pair
Sample_1_0$CDensi_1_0=(CDry_1_0/(CDry_1_0-CEthanol_1_0))*(peth-pair)+pair
This yields 10 densities for both A, B, and C. What's interesting is the mean density
Mean_1_0=apply(Sample_1_0[7:9],2,mean)
Next standard deviations are found. We are mainly interested in standard deviations for our raw data columns (ADry and AEthanol), as error propagation calculations are afterwards carried out to find out how the deviations sum up when calculating the densities
StdAfv_1_0=apply(Sample_1_0,2,sd)
Error propagation (same for B and C)
ASd_1_0=(sqrt((sd(Sample_1_0$ADry_1_0)/mean(Sample_1_0$ADry_1_0))^2+(sqrt((sd(Sample_1_0$ADry_1_0)^2+sd(Sample_1_0$AEthanol_1_0)^2))/(mean(Sample_1_0$ADry_1_0)-mean(Sample_1_0$AEthanol_1_0)))^2))*mean(Sample_1_0$ADensi_1_0)
In the end we semi manually gathered the end informations (mean density and deviation hereof) in a plot-able dataframe. Some of the codes might be a tad long and maybe we could have achieved equal results using shorter codes, but bear with us, we are rookies.
So now to the real actual problem
This was for A_1_0, B_1_0, and C_1_0. We would like to apply the same series of commands to 15 other data frames. The dimensions are the same, and they will be named A_1_1, A_1_2, A_2_0 and so on.
Is it possible to use some kind of loop function or make a loadable script containing x and y placeholders, where we can easily insert A_1_1 for instance??
Thanks in advance, i tried to keep the amount of confusion at a minimum, although it's tough!
Data list
If instead of individual vectors you combine the raw data into data frames (or even better data.tables) and then subsequently store all the data frames for all runs into a list as #Gregor suggested, you can use this function below and the lapply function.
my_func <- function(dataset, peth, pair){
require(data.table)
names <- names(dataset)
setDT(dataset)[, `:=` (ADens = (get(names[1])/(get(names[1])-get(names[4])))*(peth-pair)+pair,
BDens = (get(names[2])/(get(names[2])-get(names[5])))*(peth-pair)+pair,
CDens = (get(names[3])/(get(names[3])-get(names[6])))*(peth-pair)+pair)
][, .(ADens_mean = mean(ADens),
ADens_sd = sd(ADens),
AErr = (sqrt((sd(get(names[1]))/mean(get(names[1])))^2) +
(sqrt((sd(get(names[1]))^2 + sd(get(names[4]))^2))/
(mean(get(names[1])) - mean(get(names[4]))))^2)* mean(ADens),
BDens_mean = mean(BDens),
BDens_sd = sd(BDens),
BErr = (sqrt((sd(get(names[2]))/mean(get(names[2])))^2) +
(sqrt((sd(get(names[2]))^2 + sd(get(names[5]))^2))/
(mean(get(names[2])) - mean(get(names[5]))))^2)* mean(BDens),
CDens_mean = mean(CDens),
CDens_sd = sd(CDens),
CErr = (sqrt((sd(get(names[3]))/mean(get(names[3])))^2) +
(sqrt((sd(get(names[3]))^2 + sd(get(names[6]))^2))/
(mean(get(names[3])) - mean(get(names[6]))))^2)* mean(CDens))
]
}
rbindlist(lapply(list_datasets, my_func, peth = 2, pair = 1))
Now, this assumes that you put your raw vectors into data frames with the columns in the order in which they appeared in your example (and that they are the only columns in the data set). If this is not the case, you may just have to edit the indices in the names[x] calls. If you wanted to have a little more flexibility, you could also define a list of list with the column names for each data set in your individual raw data sets, add that as an argument to my_func and then replace all the instances of names[x] with get(list_column_names[x])
This function should output a data.table with the results for each set of data sets (1-16) in individual rows with 6 columns (ADens_mean, ADens_sd, ...)
NOTE since there was no actual data to work with, I can't say for sure that this function does exactly what you want, but I think it will be close. This will also require you to download the data.table package.

Can't complete cases of a data.frame

I'm coming because, I don't need help to realize the exercise, but I need help on an error that I can't fix..
This is the subject:
In R the more appropriate indicator for missing data is “NA” (not available). Therefore, replace each occurrence of “?” with “NA”.
a. For this exercise, create an R data frame for the mammographic data using only datapoints that have no missing values. This can be done using the complete.cases function which inputs a data frame and returns a Boolean vector v, where v[i] equals TRUE iff the i the data-frame sample is complete (meaning it does not possess an NA). For example, if the data-frame is stored in mammogram.frame, then mammogram2.frame = mammogram.frame[complete.cases(mammogram.frame),] creates a new data frame called mammogram2.frame that has all the complete mammogram data samples.
So I coded that:
mammogram = read.table("https://archive.ics.uci.edu/ml/machine-learning-databases/mammographic-masses/mammographic_masses.data",
sep=",",
col.names=c("Birads","Age","Shape","Margin","Density","Severity"),
fill=TRUE,
strip.white=TRUE)
#Replace N/A by -1
mammogram2.frame = mammogram.frame[complete.cases(mammogram.frame),]
#Display data frame
mammogram2
However I get this error:
> mammogram2.frame = mammogram.frame[complete.cases(mammogram.frame),]
Error: object 'mammogram.frame' not found
I can't find on internet any solution about it, I tried lot of stuff but the missing values are still '?'
Thank

Bandwidth selection using NP package

New to R and having problem with a very simple task! I have read a few columns of .csv data into R, the contents of which contains of variables that are in the natural numbers plus zero, and have missing values. After trying to use the non-parametric package, I have two problems: first, if I use the simple command bw=npregbw(ydat=y, xdat=x, na.omit), where x and y are column vectors, I get the error that "number of regression data and response data do not match". Why do I get this, as I have the same number of elements in each vector?
Second, I would like to call the data ordered and tell npregbw this, using the command bw=npregbw(ydat=y, xdat=ordered(x)). When I do that, I get the error that x must be atomic for sort.list. But how is x not atomic, it is just a vector with natural numbers and NA's?
Any clarifications would be greatly appreciated!
1) You probably have a different number of NA's in y and x.
2) Can't be sure about this, since there is no example. If it is of following type:
x <- c(3,4,NA,2)
Then ordered(x) should work fine. Please provide an example of your case.
EDIT: You of course tried bw=npregbw(ydat=y, xdat=x)? ordered() makes your vector an ordered factor (see ?ordered), which is not an atomic vector (see 2.1.1 link and ?factor)
EDIT2: So the problem was the way of subsetting data. Note the difference in various ways of subsetting. data$x and data[,i] (where i = column number of column x) give you vectors, while data[c("x")] and data[i] give a data frame. Functions expect vectors, unless they call for data = (your data). In that case they work with column names

Returning function output on array of values in R

I'm a beginner R programmer struggling with a multivariate array problem.
I'm attempting to input an array of 4 parameter values, say a=1:10, b=1:10, p=1:10, q=1:10, into a function y=f(x|a, b, p, q) that calculates values of y based on my dataset, x, and every possible combination of the given 4 parameters [(a=1,b=1,p=1,q=1),(a=2,b=1,p=1,q=1),...,(a=10,b=1,p=1,q=1),...,(a=10,b=10,p=10,q=10)] = 10^4 = 10,000 possible combinations and therefore 10,000 y values.
Ideally I'd like the output to be in an array format which I can then graph in R, allowing each parameter to be plotted as a separate axis.
If anyone could point me in the right direction it would be much appreciated!
Thanks,
Robert
I agree with JD Long that the request is too vague to allow a final answer, but there is an answer to the first part:
all.comb.dfrm <- expand.grid(a=1:10, b=1:10, p=1:10, q=1:10)
all.comb.dfrm$Y <- with(all.comb.dfrm, f(a,b,p,q) )

Resources