Comments (5)
What I am saying is that whether the first occurrence or the last occurrence takes effect does not come from regular expression's feature. It comes from how the code is executed.
I agree. I didn't want users to be misled by assumptions that there would be some error raised if there were errors within their regular expressions, in terms of duplicated values in the query string. Since these query strings will likely be constructed manually, I believe they are prone to these types user error.
If you believe that the current representation of how this functions is sufficiently represented in your documentation, I will close the issue.
from datasailr.
Thank you for your comment!
Even when ^Hornet appears in regular expressions for both usa and japan, they both work. (i.e. they do not mask each other.)
The following code shows that ^Hornet in usa and ^Hornet in japan work.
library(datasailr)
data(mtcars)
sail(mtcars, '
germany = re/(^Merc|^Porsche|^Volvo)/
usa = re/(^Hornet|^Cadillac|^Lincoln|^Chrysler|^Dodge|^AMC|^Camaro|^Chevrolet|^Pontiac|^Ford)/
japan = re/(^Mazda|^Datsun|^Honda|^Toyota|^Hornet)/
_rowname_ =~ germany
type_germany = rexp_matched(1)
_rowname_ =~ usa
type_usa = rexp_matched(1)
_rowname_ =~ japan
type_japan = rexp_matched(1)
')
from datasailr.
Even when ^Hornet appears in regular expressions for both usa and japan, they both work. (i.e. they do not mask each other.)
The following code shows that ^Hornet in usa and ^Hornet in japan work.
I agree that this situation works; however, when the assignment occurs for a common field (e.g., type
) only the first occurrence of the value (Hornet
) will be recognized.
from datasailr.
when the assignment occurs for a common field (e.g., type) only the first occurrence of the value (Hornet) will be recognized.
This is true when regular expression matching is conducted in if-else's conditions. (you already seem to have mentioned)
In the following code, the last regular expression matching result overwrites the previous results, because those matching results are assigned to the same field (type
).
library(datasailr)
data(mtcars)
sail(mtcars, '
germany = re/(^Merc|^Porsche|^Volvo)/
usa = re/(^Hornet|^Cadillac|^Lincoln|^Chrysler|^Dodge|^AMC|^Camaro|^Chevrolet|^Pontiac|^Ford)/
japan = re/(^Mazda|^Datsun|^Honda|^Toyota|^Hornet)/
_rowname_ =~ germany
type = rexp_matched(1)
_rowname_ =~ usa
type = rexp_matched(1)
_rowname_ =~ japan
type = rexp_matched(1)
')
I am sorry if I misunderstand what you are saying.
What I am saying is that whether the first occurrence or the last occurrence takes effect does not come from regular expression's feature. It comes from how the code is executed.
from datasailr.
I understand. When I make tutorials, I will keep it in mind. Thank you very much for your comments!
from datasailr.
Related Issues (11)
- Quotes HOT 1
- JOSS Review [crvernon]: Code formatting in paper HOT 1
- JOSS Review [crvernon]: Readme code example incorrect HOT 1
- aclocal-1.15 is missing HOT 4
- Add Community guidelines HOT 1
- State target audience HOT 1
- Consider making the function test_sail() an internal function HOT 1
- What is the purpose of the author() function? HOT 1
- Expand on summary and statement of need in the manuscript HOT 1
- JOSS Review [crvernon]: GitHub actions for CI HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasailr.