round up with ceil and start from x value - math

I am using a plugin lately to do some calculations for my products in wordpress.
ceil({uni_cpo_height} /10)*10
Is the line i'm using currently to round up the customer input height by 10 centimeters.
But I need it to start from 150cm.
Is there a way i can combine this ceil calculation together with another operator which makes it start at 150?
Would appreciate the help, thankyou

So i've tried a couple things, and a friend reached out who found the solution
This piece of code did the trick:
max(ceil({uni_cpo_height} /10)*10,150)
now it rounds up by 10 cm and it starts at 150 cm, even if the input is below 150.

Related

is there a way to select Shift F3 via r code

My computer screen locks after 10 mins (there is no way to change this as admin controls all of this). So, I want to write a looping code that selects "Shift + F3" keys to prevent this.
Is it possible to use code to select "Shift + F3" keys?
Looked in The interweb with no luck.
Any ideas?
Following the package example from #ekoam the library and function:
library(KeyboardSimulator)
keybd.press('Shift+F3')
Then an idea is to wrap keybd.press in a while loop: https://www.datamentor.io/r-programming/while-loop/ or repeat loop https://www.datamentor.io/r-programming/repeat-loop/ that is stopped by a condition of your choosing.
You can, for example, have the loop break once your clock reaches a certain time: Get current time including seconds from Sys.Date() in R but perhaps there is an easier way to do this.

How to change wave speed in a-frame-extras - Ocean?

I am using frame extras to create an ocean
https://webvr.donmccurdy.com/water/
The ocean is working great but I would like to adjust the speed of the waves and the documentation seems to suggest this is possible using either 'speed' or 'speedVariance'. When I change these it does not seem to effect it however.
I include the following script
https://cdn.rawgit.com/donmccurdy/aframe-extras/v3.13.1/dist/aframe-extras.min.js
And then try the below to no avail - all the other parameters work fine;
<a-ocean
width=“50”
depth=“50"
density=“10”
color=“#d9d0ae ”
position=“0 0 0”
opacity=“1"
speed=“0.1”
speedVariance=“0.2">
</a-ocean>
Is there a minimum speed perhaps? But even if I put it up to 10 it does not change. Also, is it possible to stop the animation all together?
Thanks for any help

Google Spreadsheet IF and AND

im trying to find an easy formula to do the following:
=IF(AND(H6="OK";H7="OK";H8="OK";H9="OK";H10="OK";H11="OK";);"OK";"X")
This actually works. But I want to apply to a range of cells within a column (H6:H11) instead of having to create a rule for each and every one of them... But trying as a range:
=IF(AND(H6:H11="OK";);"OK";"X")
Does not work.
Any insights?
Thanks.
=ArrayFormula(IF(AND(H6:H11="OK");"OK";"X"))
also works
arrayformulas work the same way they do in excel... they just need an ArrayFormula() around to work (will be automatically set when pressing Ctrl+Alt+Return like in excel)
In google sheets the formula is:
=ArrayFormula(IF(SUM(IF(H6:H11="OK";1;0))=6;"OK";"X"))
in excel:
=IF(SUM(IF(H6:H11="OK";1;0))=6;"OK";"X")
And confirm with Ctrl-Shift-Enter
This basically counts the number of times the said range is = to the criteria and compares it to the number it should be. So if the range is increased then increase the number 6 to accommodate.

What is wrong with this lines of my R script?What I am missing?

Ok, So I got this long line of code as a part of a script which someone wrote ( I know it seems horrible). So I tried to simplify it.
dH=((-HMF )*( 1.013*10^10*((T+273.2)/298)*exp((292131/1.987)*(1/298-1/(T+273.2)))/(1+(exp((331573/1.987)*(1/284.9-1/(T+273.2))))))*( 4.371*10^-8*((RH+273.2)/298)*exp((55763.5/1.987)*(1/298-1/(RH+273.2)))/(1+(exp((77245.3/1.987)*(1/365.3-1/(RH+273.2))))))*(H[hour]*I[hour]))-((LGR1)*( 123.8*((T+273.2)/298)*exp((-390540/1.987)*(1/298-1/(T+273.2)))/(1+(exp((-402880/1.987)*(1/300.1-1/(T+273.2)))))) *H[hour]*L1a[hour])-((LGR2)*( 123.8*((T+273.2)/298)*exp((-390540/1.987)*(1/298-1/(T+273.2)))/(1+(exp((-402880/1.987)*(1/300.1-1/(T+273.2)))))) *H[hour]*L2a[hour])- ((LGR3)*( 123.8*((T+273.2)/298)*exp((-390540/1.987)*(1/298-1/(T+273.2)))/(1+(exp((-402880/1.987)*(1/300.1-1/(T+273.2)))))) *H[hour]*L3a[hour])
I simplified it like this:
a<-(1.013*10^10*((T+273.2)/298)*exp((292131/1.987)*(1/298-1/(T+273.2)))/(1+(exp((331573/1.987)*(1/284.9-1/(T+273.2))))))
b<-( 4.371*10^-8*((RH+273.2)/298)*exp((55763.5/1.987)*(1/298-1/(RH+273.2)))/(1+(exp((77245.3/1.987)*(1/365.3-1/(RH+273.2))))))
c<-(123.8*((T+273.2)/298)*exp((-390540/1.987)*(1/298-1/(T+273.2)))/(1+(exp((-402880/1.987)*(1/300.1-1/(T+273.2))))))
d<-(1.7168*((T+273.2)/298)*exp((14275.4/1.987)*(1/298-1/(T+273.2)))/(1+(exp((49087.1/1.987)*(1/298.85-1/(T+273.2))))))
dH=((-HMF )*a*b*(H[hour]*I[hour]))-(LGR1*c*H[hour]*L1a[hour])-(LGR2*c*H[hour]*L2a[hour])-(LGR3*c*H[hour]*L3a[hour])
So what basically the model does is that it takes T and RH for different hours and LGR1,LGR2 and LGR3 are constant values. Also L1a, L2a and L3a are also claculated for different hours and a,b,c and d are used to calculate L1a, L2a and L3a for different hours.
The odd thing is that when I only and simply replace the messy long formula with a,b,c, and d my output model changes which I expect not to. I know it might be vague but I was not sure if I can post the full script here.
Thanks in advance for your advice
I took it into an editor that is syntax-aware and use the parenthesis matching capacity to break into its 4 arithmetic terms (separated by minus signs):
dH=
((-HMF )*( 1.013*10^10*((T+273.2)/298)*exp((292131/1.987)*(1/298-1/(T+273.2)))/(1+(exp((331573/1.987)*(1/284.9-1/(T+273.2))))))*( 4.371*10^-8*((RH+273.2)/298)*exp((55763.5/1.987)*(1/298-1/(RH+273.2)))/(1+(exp((77245.3/1.987)*(1/365.3-1/(RH+273.2))))))*(H[hour]*I[hour]))-
((LGR1)*( 123.8*((T+273.2)/298)*exp((-390540/1.987)*(1/298-1/(T+273.2)))/(1+(exp((-402880/1.987)*(1/300.1-1/(T+273.2)))))) *H[hour]*L1a[hour])-
((LGR2)*( 123.8*((T+273.2)/298)*exp((-390540/1.987)*(1/298-1/(T+273.2)))/(1+(exp((-402880/1.987)*(1/300.1-1/(T+273.2)))))) *H[hour]*L2a[hour])-
((LGR3)*( 123.8*((T+273.2)/298)*exp((-390540/1.987)*(1/298-1/(T+273.2)))/(1+(exp((-402880/1.987)*(1/300.1-1/(T+273.2)))))) *H[hour]*L3a[hour])
The fact that your terms seem to start in different sections of that expression make me think you separated terms inappropriately. It does appear (in my editor that the last three terms all share a common factor and tht the only items that vary in those three terms are the first and last factors:
( 123.8*((T+273.2)/298)*exp((-390540/1.987)*(1/298-1/(T+273.2)))/(1+(exp((-402880/1.987)*(1/300.1-1/(T+273.2)))))) *H[hour]

Selecting first n observations of each group

I and my coworkers enter data in turns. One day I do, the next week someone else does and we always enter 50 observations at a time (into an Excel sheet). So I can be pretty sure that I entered the cases from 101 to 150, and 301 to 350. We then read the data into R to work with it. How can I select only the cases I entered?
Now I know that I can do that by copying from the excel sheet, however, I wonder if it is doable in R?
I checked several documents about subsetting data with R, also tried things like
data<-data[101:150 & 301:350,]
but didn't work. I appreciate if someone would guide me to a more comprehensive guide answering this question.
The answer to the specific example you gave is
data[c(100:150,300:350),]
Can you be more specific about which cases you want? Is it the first 50 of each 100, or the first 50 of each 300, or ... ? To get the indices for the first n of each m cases you could use something like
c(outer(0:4,seq(1,100,by=10),"+"))
(here n=5, m=10); outer is a generalized outer product. An alternate (and possibly more intuitive) solution would use rep, e.g.
rep(0:4,10) + rep(seq(1,100,by=10),each=5)
Because R automatically recycles vectors where necessary you could actually shorten this to:
0:4 + rep(seq(1,100,by=10),each=5)
but I would recommend the slightly longer formulation as more understandable.

Resources