GSHEETS REGEXMATCH (NO COINCIDENCE) - formula

I looked everywhere but didn´t find de solution. I guess is very simple...
I need to discard from column C the words that are in D. Result desired is Fig. B)
This is the formula I´m using (incorrect)
=SORT(ARRAYFORMULA(SI(ESBLANCO(C4:C),,SI(REGEXMATCH(C4:C,"(?i)"&TEXTJOIN("|",VERDADERO,D4:D)),C4:C,))))
I will apreciate very much your help

Related

r: A column disappears and other columns' names turn to Xs

I've got a piece of code and I don't quite understand how it works. I'm sorry if I may sound stupid...
I'm making a network, so I created an adjacency matrix that looks like this:
Part of my adjacency matrix
So, when I try to calculate cosine similarity via lsa::cosine function the column "authors$book_id" disappears and all the other columns' names that contain authors' IDs are replaced with Xs.
My code is this:
a_cos <- lsa::cosine(t(as.matrix(adj_matrix[, -1]))) %>%
data.frame() %>%
+0.01 %>%
round()
This is what this code returns:
After lsa::cosine
Since I know this is isn't an error I want to know how this happened.
Can someone please explain to me what this piece of code does and why it removes the first column (book IDs) completely and turns authors' IDs to Xs? How can I apply lsa::cosine so that this doesn't happen?
I'm only a beginner, but I really need help and I will appreciate any comments! This is my first question on stackoverflow, I hope I've described the problem extensively enough...

Maxima: equations: eliminate variable inside diff() expression

I have this code:
(%i3)depends([y,x],t)$
eqsp: [y=2*x,
v=diff(y,t,1)+y];
eliminate(eqsp,[y]);
(eqsp) [y=2*x,v='diff(y,t,1)+y]
(%o3) [-'diff(y,t,1)-2*x+v]
And this is a picture for better visualization:
PNG of code in wxMaxima
I was expecting that Maxima would perform a substitution of "y" in the second equation, and then differentiate to get "[-2*diff(x,t,1)-2*x+v]".
This is of course not the real problem (which has many more equations), it's just that I think I'm missing some concept here for Maxima to do what I want.
Thanks in advance for your comments. I'm a newbie in Stackoverflow and in Maxima, sorry if I made some mistake.

closed/fixed:Interpertation of basic R code

I have a basic question in regards to the R programming language.
I'm at a beginners level and I wish to understand the meaning behind two lines of code I found online in order to gain a better understanding. Here is the code:
as.data.frame(y[1:(n-k)])
as.data.frame(y[(k+1):n])
... where y and n are given. I do understand that the results are transformed into a data frame by the function as.data.frame() but what about the rest? I'm still at a beginners level so pardon me if this question is off-topic or irrelevant in this forum. Thank you in advance, I appreciate every answer :)
Looks like you understand the as.data.frame() function so let's look at what is happening inside of it. We're looking at y[1:(n-k)]. Here, y is a vector which is a collection of data points of the same type. For example:
> y <- c(1,2,3,4,5,6)
Try running that and then calling back y. What you get are those numbers listed out. Now, consider the case you want to just call out the number 1 in that vector. How would you do that? Well, this is where the brackets come into play. If you wanted to just call the number 1 in y:
> y[1]
[1] 1
Therefore, the brackets are a way of calling out or indexing specific items in the vector. Note that the indexing starts at the value 1 and goes up to the number of items in the vector, or length. One last thing before we go back to the example you gave. What if we want to index the numbers 1, 2, and 3 from the vector but not the rest?
> y[1:3]
[1] 1 2 3
This is where the colon comes into play. It allows us to reference a subset of the numbers. However, it will reference all the numbers between the index left of the colon and right of it. Try this out for yourself in R! Play around and see what happens.
Finally going back to your example:
y[1:(n-k)]
How would this work based on what we discussed? Well, the colon means that we are indexing all values in the vector y from two index values. What are those values? Well, they are the numbers to the left and right of the colon. Therefore, we are asking R to give us the values from the first position (index of 1) to the (n-k) position. Therefore, it's important to know what n and k are. If n is 4 and k is 1 then the command becomes:
y[1:3]
The same logic can apply to the second as.data.frame() command in your question. Essentially, R is picking out different numbers from a vector y and multiplying them together.
Hope this helps. The best way to learn R is to play around with a command, throw different numbers at it, guess what will happen, and then see what happens!

Convert from matrix to list matrix

Sorry for the noob question but I can't seem to get this to work!
X=cbind(rep(1,m), h2(x), h3(x)) #obs
So I have a 17*3 matrix X I have to create a matrix(list(),17,3) version of this matrix. I did manually below so you can see the desired result, but there must be an easier way to do this?
Z=matrix(list(X[1,1],X[2,1],X[3,1],X[4,1],X[5,1],X[6,1],X[7,1],X[8,1],X[9,1],X[10,1],X[11,1],X[12,1],X[13,1],X[14,1],X[15,1],X[16,1],X[17,1],X[1,2],X[2,2],X[3,2],X[4,2],X[5,2],X[6,2],X[7,2],X[8,2],X[9,2],X[10,2],X[11,2],X[12,2],X[13,2],X[14,2],X[15,2],X[16,2],X[17,2],X[1,3],X[2,3],X[3,3],X[4,3],X[5,3],X[6,3],X[7,3],X[8,3],X[9,3],X[10,3],X[11,3],X[12,3],X[13,3],X[14,3],X[15,3],X[16,3],X[17,3]),17,3)
I tried this (amongst others)
Z2=list(X[1:17,1],X[1:17,2],X[1:17,3])
Z3=matrix(Z2[1:3],17,3)
But it doesn't give the correct results! It just repeats the three column vectors over and over.
Can someone please explain how to do this correctly.
Apparently you want Z <- matrix(as.list(X), ncol = 3). However, I don't see how this structure could be useful.

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]

Resources