kos59125 / dym Goto Github PK
View Code? Open in Web Editor NEWAdds 'Did you mean' feature to the R interactive
License: Other
Adds 'Did you mean' feature to the R interactive
License: Other
Suppose I mistype "log", as in:
options(error = DYN::DYM)
logg(10)
## Error: could not find function "logg"
## Did you mean: ['log', 'log2', 'logb']
I think it would be useful for this to return log10
, log1p
as well. At least it should be possible to have these returned if I increase the threshold
in findSimilarNames
.
A better approach would be to order by increasing distance, and return the first 10 (or however many) that lie within the threshold. I suggest something like this:
findSimilarName <- function (x, names, threshold = 2, max_n = 10)
{
if (is.na(x)) {
character(0)
}
else {
names <- na.omit(names)
d <- as.integer(adist(x, names))
distance_data <- data.frame(
names = names,
distance = d,
stringsAsFactors = FALSE
)[order(d), ]
distance_data <- distance_data[distance_data$distance <= threshold, ]
head(distance_data, max_n)$names
}
}
# Example usage
x <- "logg"
names <- DYM:::getNames(x)
for(i in 0:4)
{
message("i = ", i)
print(findSimilarName(x, names, threshold = i))
}
## i = 0
## character(0)
## i = 1
## [1] "log" "log2" "logb"
## i = 2
## [1] "log" "log2" "logb" "lag" "load" "log10" "log1p"
## i = 3
## [1] "log" "log2" "logb" "lag" "load" "log10" "log1p" "aov" "Arg" "args"
## i = 4
## [1] "log" "log2" "logb" "lag" "load" "log10" "log1p" "aov" "Arg" "args"
DYM should be take options for user's tuning. It looks better if we can write like:
options(error = DYM(option.a=1, option.b=2))
> ()
エラー: 予想外の ')' です in "()"
wrapup 中にエラーが起こりました: there is no package called ‘ エラー: 予想外の ')' です in "()"
’
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.