Scilab Error 10000 - scilab

Hi I am new to scilab and don't have much mathematical background.
I have been following code for another example and am being shown error 10000 for the following code:
function [z]=f(x,y)
z=0.026*(1.0-(y/ym))*y;
endfunction;
ym=12000;
x0=1950;y0=2555;xn=5;h=10;
x=[x0:h:xn];
y=ode("rk",y0,x0,x,f);
disp("x y")
disp("--------")
disp([x'y']);
function z=fe(x)
z=ym/(1-(1-ym/y0)*e^(-k*(t-t0)));
endfunction;
xe=(x0:h/10:xn);
n=length(xe)
for i=1:n
ye(i)=fe(xe(i));
end;
plot (x,y,'ro',xe, ye,'-b');legend ('rk4','Exact',3);
xtitle('solving dy/dx=k(1-y/ym)y','x','y');
I have worked through several other error messages. I am lost and don't know if the problem is in the code or the way I set up the problem. The following is the current error message:
!--error 10000
plot: Wrong size for input argument #2: A non empty matrix expected.
at line 57 of function checkXYPair called by :
at line 235 of function plot called by :
plot (x,y,'ro',xe, ye,'-b');legend ('rk4','Exact',3);
at line 25 of exec file called by :
I would appreciate any help.
Thanks

Start by adding clear as first statement, this will erase all variables before running your function. In the above script you don't declare ye.
Also the statement x=[x0:h:xn]; is strange with those values for x0,h and xn. You are now trying to get a list of x-values starting at 1950 and with positive steps of 10 up until 5 is reached.
I would recommend to try each line and see if the outcome is as expected. You do not need to know everything about the code, but probaly x and y should contain at least some values. The error is telling you that it expected a non-empty matrix for argument 2. This is y, so essentially it is telling you y is empty.

Related

shiny-server: variable names are limited to 10000 bytes

I am getting error while running the code in shiny-server only. When I am running the same code from R console using runApp() function it is running well. See the error message below....
Warning: Error in assign: variable names are limited to 10000 bytes
Stack trace (innermost first):
46: assign
45: wrapFunctionLabel
44: public_bind_env$initialize
43: Observable$new
42: reactive
41: templateServer
40: server [/home/shiny-apps/ACCPlantAnalysis/server.R#20]
1: runApp
Error in assign(name, func, environment()) :
variable names are limited to 10000 bytes
Line no 41 and 40 are written by me. but other lines are not written by me; call from any reference library. I don't know from which library.
At last I got solution. I wrote functions for every 'if' block and put all code of 'if' block inside the function. Then call the function. And the was problem solved.
SectoralLeverageRatio(){
...
...
}
if (selectedIndex=="Sectoral Leverage Ratio"){
SectoralLeverageRatio()
}
The conclusion is... if your 'if' block is large enough and you got 'variable names are limited to 10000 bytes' error. Replace the code inside the 'if' block with user defined function.
This is the problem of shiny-server; not the problem of 'R'. If you run your code from 'R' console using runApp(), you would not get any error. But if you run through(production environment) you might get an error.
after a day long research I am able to pinpoint the issue. I have a long if..else block in my code. There are 10 if block and every if block has at least 6-8 line of code. When I comment one 'if' block of code (randomly chosen) the code running fantastically.... below is my 'if' block of code...
else if (selectedIndex=="Sectoral Leverage Ratio"){
## Calculated number of row of the matrix ##
rowNum <- selectedMonth[2] - selectedMonth[1] + 1
## Filter data based on criteria ##
filteredData <- subset(rawData,Year %in% selectedYear & Month %in% selectedMonth[1]:selectedMonth[2] & Plant %in% selectedPlant)
LeverageTable <- filteredData[,c('sch1ExpLeverage','sch2ExpLeverage','sch3ExpLeverage','sch4ExpLeverage','sch5ExpLeverage','sch7ExpLeverage','sch10ExpLeverage','sch11ExpLeverage')]
LeverageSum <- apply(LeverageTable,2,sum)
ExpTable <- filteredData[,c('sch1Exp','sch2Exp','sch3Exp','sch4Exp','sch5Exp','sch7Exp','sch10Exp','sch11Exp')]
ExpSum <- apply(ExpTable,2,sum)
LeverageRatio <- as.matrix(LeverageSum / ExpSum)
AvgLeverageRatio <- as.matrix((LeverageSum / ExpSum)/rowNum)
LeverageRatioTable <- cbind(LeverageRatio,AvgLeverageRatio)
colnames(LeverageRatioTable) <- c('Leverage Ratio','Avg.Leverage Ratio')
LeverageRatioTable <- data.frame(Sector=c('Health & Sant.','Edn. & Voc.','Social Welfare','Envt. Sust.','Hrtg & Arts','Sports','Rural Dvpt.','Admin Cost'),LeverageRatioTable)
as.data.frame(LeverageRatioTable)
}
All other 'if' blocks are almost similar (with some difference in calculation).
This is the problem of shiny-server; not the problem of 'R' itself.
If anybody wants to examin my code; I can share the full code.
According to ?name, you have to respect the fact that:
Names are limited to 10,000 bytes (and were to 256 bytes in versions of R before 2.13.0).
and the rule says in ?make.names:
A syntactically valid name consists of letters, numbers and the dot or
underline characters and starts with a letter or the dot not followed
by a number. Names such as ".2way" are not valid, and neither are the
reserved words.

Undefined columns selected error in R

I apologize in advance because I'm extremely new to coding and was thrust into it just a few days ago by my boss for a project.
My data set is called s1. S1 has 123 variables and 4 of them have some form of "QISSUE" in their name. I want to take these four variables and duplicate them all, adding "Rec" to the end of each one (That way I can freely play with the new variables, while still maintaining the actual ones).
Running this line of code keeps giving me an error:
b<- llply(s1[,
str_c(names(s1)
[str_detect(names(s1), fixed("QISSUE"))],
"Rec")],table)
The error is as such:
Error in `[.data.frame`(s1, , str_c(names(s1)[str_detect(names(s1), fixed("QISSUE")) & :
undefined columns selected
Thank you!
Use this to get the subset. Of course there is other ways to do that with simpler code
b<- llply(s1[,
names(s1)[str_detect(names(s1), fixed("QISSUE"))]
],c)
nwnam=str_c(names(s1)[str_detect(names(s1), fixed("QISSUE"))],"Rec")
ndf=data.frame(do.call(cbind,b));colnames(ndf)=nwnam
ndf
# of course you can do
cbind(s1,ndf)

Missing values and NaN's not allowed if 'na.rm' is FALSE

I am just starting out using R, and I am trying to create a False Discovery Rate plot. However, there's an error message that I keep running into that seems very basic. I've search everywhere for a solution but haven't been able to find one.
Here are the inputs and outputs:
> melanoma.data <- pamr.from.excel("MelanomaData.txt", 10, sample.labels=FALSE)
pamr.menu(melanoma.data)
1: pamr.train
2: pamr.cv
3: pamr.plotcv
...(other selections)
Selection: 1
Warning: a class contains only 1 sampleError in quantile.default(sd, offset.percent/100) :
missing values and NaN's not allowed if 'na.rm' is FALSE
Error during wrapup: cannot open the connection
I converted "MelanomaData" from an excel file into a text file. I've searched through the data to make sure that there are no NA's or blank values.
I'm at a lost as to what the problem could be, and any help would be greatly appreciated!
I am seeing two helpful messages here.
The first is Warning: a class contains only 1 sample.
The second says Error in quantile.default(sd, offset.percent/100).
The first argument of quantile.default sounds like 'standard deviation'.
What about this possibility: Your code computes the sd of a one-element vector, which is NA, which quantile.default cannot use because nobody told it to ignore it?
I suggest you go and find out what produces the warning.

window function R code

fine people of stackoverflow. I have become trapped on a rather simple part of my program and was wondering if you guys could help me.
library(nonlinearTseries)
tt<-c(0,500,1000)
mm<-rep(0,2)
for (j in 1:2){mm[j]=estimateEmbeddingDim(window(rnorm(1000), start=tt[j],end=tt[j+1]), number.points=(tt[j+1]-tt[j]),do.plot=FALSE)}
Warning message:
In window.default(rnorm(1000), start = tt[j], end = tt[j + 1]) :
'start' value not changed
If I plug in the values directly (tt[1], tt[2], tt[3]), it works but I also get a warning
estimateEmbeddingDim(window(rnorm(1000), start=tt[1],end=tt[2]), number.points=(tt[2]-tt[1]),do.plot=FALSE)
[1] 9
Warning message:
In window.default(rnorm(1000), start = tt[1], end = tt[2]) :
'start' value not changed
Thanks, Matt.
The problem seems to be with the
window(rnorm(1000), start=tt[j],end=tt[j+1])
lines. First of all, window is only meant to be used with a time series object (class=="ts"). In this case, rnorm(1000) simply returns a numeric vector, there are no dates associated with this object. So i'm not sure what you think this function does. Did you only want to extract the values that were between 0-500 and 500-1000? If so that seems a bit because with a standard normal variable, the max of 1000 samples isn't likely to be much over 4 let alone 500.
So be sure to use a proper "ts" object with dates and everything to get this to work.

Error using \ Out of memory. Type HELP MEMORY for your options

I need to load two data files each of which have 6 columns and I want to plot the ratio of a column from first data file and another column from the second data file. But I keep getting a memory error. None of the numbers are zeros. I plotted the same in Excel. Worked ok. But I need it in Matlab, What do I do?
My current code is something like this:
load file1.dat;
y=file1(:,2);
time=file1(:,1);
hold on;
load file2.dat;
x=file2(:,5);
figure;
plot (t,y/(3*x),'LineWidth',1);
xlabel('Time (s)');
ylabel('Mitochondrial Calcium (um)');
This is the error I get:
Error using \
Out of memory. Type HELP MEMORY for your
options.
Error in plotCmyo (line 9) --> File name, line 9 is the one with the plot command
plot(t,y/x, 'LineWidth',1);
Use y./(3*x) to do element-wise division.
Note the operator: ./

Resources