-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibly add a primes key to the new integer keyboard? #7565
Comments
@rdstern I've had a look at this, mainly looking at stackoverflow. So do we want two functions? One for Had a look on stack overflow, and to find
The
|
@lilyclements many thanks. If we include the function, then I assume we could have a primes key on our integer keyboard. @anastasia-mbithe can you include this? |
@rdstern and @lilyclements, This is great! However, my biggest worry is how we will incorporate this into the calculator. If you look at the calculator code it's implemented differently from the other dialogs, and it's effective with **single functions. (When I say single functions I mean functions like Factorize(), nextPrime(), isprime() etc) |
@anastasia-mbithe that's an interesting idea. I was hoping that if @lilyclements writes this as an R-Instat function, then the calculator could simply call it? Or might there even be a (for now) trivial package that we then load in the same way as other packages. We will soon be having our own packages, so might this be a simple start? When discussing with @Wycklife there is another (small?) improvement in the calculator that would be great to add. Finally, while improving the calculator, could the default be to save the variable, i.e. the default is with the saving checkbox ticked. You may want to write out some of these suggestions as separate issues, so they can be spelled out in more detail? |
@rdstern @anastasia-mbithe once the new lists/data frame PR is merged (hopefully soon as it’s ready for review) I can add these new prime functions to the stand-alone-functions.R file. Then we can make the changes to the calculator with the primes. @rdstern ill look into the binary, octal, etc functions and comment on the issue related to them about it |
@rdstern, yeah I saw the comment and I have been testing them and I also think they are interesting to add to the integer keyboard. I can get started on adding them before @lilyclements and I figure out how to add the Primes function to the calculator. |
@lilyclements @anastasia-mbithe any progress on this? |
@rdstern and @lilyclements, there is this package called primes I just came across, I think it will help us fix this issue. What do you think about it and which functions can we consider? |
Good find @anastasia-mbithe it looks great. I'm delighted as there's lots you can add from here. It will be good to add the package first, so this improvement gets into the July release. Can you start with that. Note the important generate_n_primes can include (for us) the n, because that's the length of the data frame. I really like the nth_prime and the prime_count, because they (I think) can have vectors as input. We will have to be imaginative on what we call the keys, so it isn't too long = and also how we use some of the functions, that may (or may not) allow columns as input. That's one reason for starting by just adding the package into the new version - then it is easier to play. Though good to add it to your version now to try it out. |
Thanks for the feedback. |
@anastasia-mbithe nice find! Looks like a great package :) |
@rdstern, Unfortunately generate_n_primes() does not accept vectors. is it okay to have nth_prime() for the start? |
@anastasia-mbithe this is interesting. @anastasia-mbithe @rdstern have we considered having the calculator to have the ability to do things that don't necessarily require the data frame for (and, say, disabiling the data frame selector when those buttons are chosen?). Perhaps this defeats the point but I am intrigued why we wouldn't. |
@anastasia-mbithe I am still happy with the generate_n_primes in the calculator, where it would give the command just like that including the n parameter, either as a number of sa nrows(dataframe). |
This is only (at this stage) if it is really easy (less than 45 minutes?) for @lilyclements to code! Then @anastasia-mbithe or @Wycklife could implement.
It changes the current prime key to
is_prime
and adds a vectorised key calledprime
to the keyboard.a) We already have a
next prime
key, so (I presume) this could be done via purrr so the command prime(from = n) gives a set of prime numbers of length equal to the data frame. Perhaps it needs a second argument such as values = m, where the default is the length of the data frame? @lilyclements is this a really simple bit of code that could become the prime key?The website on the first 50 million primes says "Usually it is faster to run a program on your own computer than to download them, but by popular demand, here they are!"
So that's one reason why this function would be useful. It may also show how purrr avoids "old fashioned" loops?
This site also gives various functions on primes. I don't know if there is any help here?
The text was updated successfully, but these errors were encountered: