The R Project for Statistical Golfing

A room for learning and golfing in the R programming language
Jan 4, 2021 19:41
I haven't had time to work on it yet... I'll definitely post it if I get it working.
Dec 31, 2020 16:45
@Giuseppe Thanks for the ginormous bounty!
Dec 25, 2020 10:33
@Giuseppe Hope the exam went well. :-) Merry Xmas to all!
Dec 24, 2020 16:53
@Giuseppe Thanks, nice! I'll need to adapt it to get the column and row names (for restricted source challenges); they aren't included in that version, but I should be able to figure it out!
Dec 21, 2020 08:25
Say, for example, that I want to get the column sums of all numerical columns in all built-in datasets; is there an automated way of doing that, without having to type all the dataset names?
Dec 21, 2020 08:24
Do you know of a why to cycle through all the R built-in datasets?
Dec 5, 2020 23:05
This also means that scan will often be unnecessary once this feature comes out, which will be a relief.
Dec 5, 2020 23:02
Everybody, get ready to golf -7 bytes by replacing all your functions with \s! twitter.com/rabaath/status/1335226691304775681
Dec 4, 2020 15:15
Code golf has officially started to influence my teaching: I was asked during a lecture today how to convert a vector of integers to booleans, and immediately answered !!x. It took me a couple of minutes to realize that the vanilla answer is as.logical(x).
Nov 28, 2020 22:42
This challenge seems impossible in R; I will happily bounty any answer which proves it isn't! codegolf.stackexchange.com/q/215705/86301
Nov 12, 2020 18:02
(Thanks to @DominicvanEssen who found cracks to two earlier versions. Hopefully this one will keep you busy for a little while!)
Nov 11, 2020 20:37
Can you crack this almost illegal string? codegolf.stackexchange.com/a/215086/86301
Oct 27, 2020 17:02
Well, after 3 challenges, I'm out of cop ideas for "Guess my password" (codegolf.stackexchange.com/q/213962/86301), but I'll gladly try to be a robber if one of you comes up with more!
Oct 6, 2020 10:58
@Razetime Lol, I thought you were pinging me!
My favourite aspect of R in day-to-day use is the thousands of packages. I also enjoy the terseness of `apply` and its siblings.
Oct 6, 2020 09:15
@Razetime Yep, I saw your answer and will get to it next! I'm only allowed to put up 3 bounties at a time, so I'll set yours once the first batch lapses.
Oct 6, 2020 07:08
I'll go over some of the R answers over the coming days and weeks, and plan on handing out bounties to all first-time R golfers in September. Don't hesitate to ping me if I don't get to you.
Oct 6, 2020 07:07
I'm sorry I wasn't able to be very active during the R month...
Sep 3, 2020 13:10
And me!
 

 golfR

R golfing Chatroom
Mar 29, 2020 16:55
Right now I am interested in cases where x is very close to an integer, so something like (x+.4)%/%1 would work, but is longer.
Mar 29, 2020 16:54
Can you think of a golfy replacement for round(x)?
Mar 10, 2020 16:36
> cat(letters[c(21,14,6,18,5,5,26,5)],sep="")
unfreeze
Feb 4, 2020 08:31
That's a nice theory, but I don't plan on testing it! ;-)
Feb 4, 2020 08:30
Congrats @Giuseppe! So many new R golfers coming into the world this year!
Feb 1, 2020 14:32
@digEmAll Thanks for asking, I forgot to announce it here!
She was born just after Christmas. Her name is Iseult and we are all delighted! (and exhausted! ;-) )
Jan 31, 2020 10:35
Are there any answers in S on this site?
I've never used S, but I guess that it should be quite easy for R users, and it is old enough to be allowable for this challenge: https://codegolf.stackexchange.com/q/44381/86301
Dec 20, 2019 22:12
Well d can also be \144, but you have several 6s elsewhere.
Dec 20, 2019 13:21
That leaves two pairs of characters with distance 2: 1 and 3, and d and f.
Dec 20, 2019 13:20
Working from your solution to try and get a score of 3, a first step would be to replace all ; with newlines, which allows to replace = with <-.
Dec 20, 2019 13:19
I had
`+`=`s\x63\x61n`;s=+"";`+`=`diff`;f=+s;`+`=`\x6din`;+f
Dec 20, 2019 13:16
@digEmAll Well done! My answer was slightly different, but uses the same tools.
Dec 19, 2019 13:41
Yes. I believe several answers already use the fact that it is unique.
Dec 19, 2019 13:27
Well, you can assume any form for the input since it is a set… I'll clarify the challenge.
Dec 12, 2019 17:49
That's all you need for the solution I have, along with the observation that since default IO rules apply, you can assume the input is sorted.
Dec 10, 2019 16:26
@Giuseppe It is base R.
Dec 10, 2019 09:38
Since I posted the challenge, I won't post an answer any time soon, but this shows that a score >1 is possible. Might be able to push to 3...
Dec 10, 2019 09:37
I have an R solution with a score of 2 for this challenge: codegolf.stackexchange.com/questions/196786/…
Dec 2, 2019 10:43
I think we've all been assuming that chat rooms get frozen after 7days. According to the FAQ, it's actually 14 days. So we can gain many bytes by reducing the number of "please don't freeze" messages! ;-)
Nov 7, 2019 16:10
We are actually expecting baby #3 in a few weeks as well. :-)
Nov 7, 2019 16:09
You need to work on this challenge now: codegolf.stackexchange.com/questions/185872/dad-jokes-are-fun ;-)
Nov 7, 2019 16:09
Congratulations @digEmAll, and welcome to your baby! What is his or her name?
Oct 28, 2019 11:11
It looks like R cannot be broken!
Oct 28, 2019 11:11
Most of my attempts revolved around things like redefining basic functions such as print, + and rm, but I always found a workaround based on internal functions.
Oct 28, 2019 11:09
@Giuseppe That's a neat idea. I tried it on my computer but it didn't do anything (the base functions can still be used). Not sure why…
Oct 22, 2019 06:19
Any ideas how to make R unusable? (codegolf.stackexchange.com/questions/61115/…) That question has loads of answers, but none in R. My attempts have been unfruitful.
Sep 13, 2019 13:50
@digEmAll I've been thinking about that too. I tried having something along the lines of 0*2+n*2 where the *2+n* would bet duplicated, but couldn't find a solution. I would love to see you one if you have ideas! We might end up with 3 distinct R answers to that challenge...
Sep 12, 2019 14:05
Never matter, found a solution! Just added an error to force execution to halt.
 

 The Nineteenth Byte

The Nineteenth Byte: General discussion for codegolf.stackexc...
Feb 4, 2020 08:29
@JoKing Thanks. Yes, if I know that the input will be made only of positive integers, I can add a 0 or -1 at the end and test for that. But SPL will still read in that final value again and again, which is weird (and will add many bytes to the answer I am working on!)
Feb 3, 2020 16:32
@Adám Thanks. By the time I realized this it was too late to edit.
Feb 3, 2020 16:17
Does anyone know how to input a list of integers in Shakespeare Programming Language?
For instance [here](https://tio.run/##Ky7I@f9fR88xK7FCRy@gNDkbyE4uUfC00gtOTs1LBTGiXStSS/NKYqNd80pSixRAShUS81IUQKpjQTwrn8ziktQ8hZL8koxKPf8CIDMjNbGoRM8ntUShtBhsnt7//8ZcpgA), I would like to input 3 and 5 then exit, not input 5 ad infinitum.
(The [equivalent](https://tio.run/##Ky7I@f9fR88xK7FCRy@gNDkbyE4uUfC00gtOTs1LBTGiXStSS/NKYqNd80pSixRAShUS81IUQKpjQTwr/4LUPIXczLwUveCC1MRsCNMntUShtBhsmN7//4lJAA) with characters instead of integers works as expected.)
 
Sep 23, 2019 13:40
I like the challenge idea. Maybe you could rephrase it along the lines of: input a word list and a grid size; output a grid with a unique solution; winning criterion: number of white squares in the output when the input is CSW and 15x15.