People who can "do coding"

User avatar
Sundayjumper
Posts: 6266
Joined: Wed Apr 11, 2018 4:04 pm
Currently Driving: Peugeot 406

People who can "do coding"

Post by Sundayjumper »

We had someone here doing a project that used R quite heavily for churning data. Here's an example of some code they wrote:


Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr==1.5,1,Voucherdata_week32$visit_nr)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==2.5,2,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==3.5,3,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==4.5,4,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==5.5,5,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==6.5,6,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==7.5,7,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==8.5,8,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==9.5,9,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==10.5,10,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==11.5,11,Voucherdata_week32$visit_nr2)
Voucherdata_week32$visit_nr2 <- ifelse(Voucherdata_week32$visit_nr2==12.5,12,Voucherdata_week32$visit_nr2)


And there are instructions to add more lines if we ever encounter 13.5, or 14.5, etc.

Jesus Fcuking Wept.

I'm no programmer but even I can see that:

Rounding down a number does not require a separate line of code for every possible case :roll:

Hard coding the current week number as a variable name, so you have to change it every week is a bad idea :roll:

And the visit number should only ever be an integer in the first place, so bouncing it back to the person providing the data in the first place would actually fix the problem properly :roll:
User avatar
Rich B
Posts: 9618
Joined: Wed Apr 11, 2018 4:22 pm
Currently Driving: M2 Competition

Re: People who can "do coding"

Post by Rich B »

Haaa, yeah what a noob!
User avatar
dan
Posts: 569
Joined: Wed Apr 11, 2018 11:22 pm

Re: People who can "do coding"

Post by dan »

My god what an idiot, everyone knows whatever you just said :roll:
User avatar
Sundayjumper
Posts: 6266
Joined: Wed Apr 11, 2018 4:04 pm
Currently Driving: Peugeot 406

Re: People who can "do coding"

Post by Sundayjumper »

Get bent, all of you :D
User avatar
mik
Posts: 11747
Joined: Wed Apr 11, 2018 6:15 pm

Re: People who can "do coding"

Post by mik »

What SundayJumper said to mik.

What mik understands.

Image
User avatar
Swervin_Mervin
Posts: 4737
Joined: Wed Apr 11, 2018 8:58 pm

Re: People who can "do coding"

Post by Swervin_Mervin »

mik wrote: Thu Jan 14, 2021 12:30 pm What SundayJumper said to mik.

What mik understands.

Image
:lol:
mr_jon
Posts: 729
Joined: Thu May 24, 2018 11:07 am

Re: People who can "do coding"

Post by mr_jon »

Variables and loops is the hard.
User avatar
Delphi
Posts: 822
Joined: Thu Apr 12, 2018 8:11 am
Location: Leeds, West Yorkshire
Currently Driving: Porsche 928 S4, Porsche 987 Boxster 2.7, Volvo XC40
Contact:

Re: People who can "do coding"

Post by Delphi »

Fuck me, that's special. Why not use the built-in floor function and literally sack off all that shit?
If you get all wobbly-lipped about the opinion of Internet strangers, maybe it's time to take a bath with the toaster as you'll never amount to sh1t anyway.
User avatar
Sundayjumper
Posts: 6266
Joined: Wed Apr 11, 2018 4:04 pm
Currently Driving: Peugeot 406

Re: People who can "do coding"

Post by Sundayjumper »

Or even, seeing as the issue is the “.5” bit, do a text replace to delete every “.5” in that field.

A schoolchild could do better. And we were actually *paying* for this.
User avatar
JonMad
Posts: 2695
Joined: Wed Apr 11, 2018 9:25 pm
Currently Driving: 2015 Swift; 2012 Yeti; 2006 Fabia

Re: People who can "do coding"

Post by JonMad »

were they charging by lines of code?
Left over crest; tightens.
NGRhodes
Posts: 517
Joined: Thu Jan 14, 2021 2:00 pm
Contact:

Re: People who can "do coding"

Post by NGRhodes »

Does this person happen to call themselves a Data Scientist ?
User avatar
Sundayjumper
Posts: 6266
Joined: Wed Apr 11, 2018 4:04 pm
Currently Driving: Peugeot 406

Re: People who can "do coding"

Post by Sundayjumper »

NGRhodes wrote: Fri Jan 15, 2021 9:51 pm Does this person happen to call themselves a Data Scientist ?
You have nailed the head quite squarely ! Do you have to deal with Data Scientists too ?
NGRhodes
Posts: 517
Joined: Thu Jan 14, 2021 2:00 pm
Contact:

Re: People who can "do coding"

Post by NGRhodes »

Sundayjumper wrote: Fri Jan 15, 2021 9:59 pm
NGRhodes wrote: Fri Jan 15, 2021 9:51 pm Does this person happen to call themselves a Data Scientist ?
You have nailed the head quite squarely ! Do you have to deal with Data Scientists too ?
I work at Leeds Uni in Research Computing, very familiar to see this coding "style" from researchers and scientists.
User avatar
Sundayjumper
Posts: 6266
Joined: Wed Apr 11, 2018 4:04 pm
Currently Driving: Peugeot 406

Re: People who can "do coding"

Post by Sundayjumper »

It's the lack of foresight. Right through their work I'm seeing a total absence of any "what if <xxx> happens" planning.

Guess what ? <yyy> happened.

And totally on the same track, I happened upon this today:

https://xkcd.com/2054/

Image

:lol: It's funny because it's true.
NGRhodes
Posts: 517
Joined: Thu Jan 14, 2021 2:00 pm
Contact:

Re: People who can "do coding"

Post by NGRhodes »

Dare you to do a security audit...
User avatar
Explosive Newt
Posts: 1553
Joined: Sat Feb 23, 2019 7:33 pm

Re: People who can "do coding"

Post by Explosive Newt »

This gives me the fear as I have been trying off and on to learn R for the last several months as it's one of those things that you are meant to learn during a PhD and now I'm in the final six months, that time is very much nigh. The problem is.... it's not terribly easy.
User avatar
Explosive Newt
Posts: 1553
Joined: Sat Feb 23, 2019 7:33 pm

Re: People who can "do coding"

Post by Explosive Newt »

Sundayjumper wrote: Fri Jan 15, 2021 10:26 pm It's the lack of foresight. Right through their work I'm seeing a total absence of any "what if <xxx> happens" planning.

Guess what ? <yyy> happened.

And totally on the same track, I happened upon this today:

https://xkcd.com/2054/

Image

:lol: It's funny because it's true.
See also

Image
User avatar
Sundayjumper
Posts: 6266
Joined: Wed Apr 11, 2018 4:04 pm
Currently Driving: Peugeot 406

Re: People who can "do coding"

Post by Sundayjumper »

And that one's a true story IIRC ?
User avatar
Sundayjumper
Posts: 6266
Joined: Wed Apr 11, 2018 4:04 pm
Currently Driving: Peugeot 406

Re: People who can "do coding"

Post by Sundayjumper »

Explosive Newt wrote: Thu Jan 21, 2021 1:50 pm This gives me the fear as I have been trying off and on to learn R for the last several months as it's one of those things that you are meant to learn during a PhD and now I'm in the final six months, that time is very much nigh. The problem is.... it's not terribly easy.
I'm finding it frustrating because of the plethora of libraries out there, so for any seemingly simple action there's half a dozen different ways of doing it and they all have slightly different syntax. And when you get it wrong the error message is not always very helpful.
User avatar
Explosive Newt
Posts: 1553
Joined: Sat Feb 23, 2019 7:33 pm

Re: People who can "do coding"

Post by Explosive Newt »

I have tried to debug old, undocumented matlab code and failed, leading to me having to explain to a colleague that the analysis pipeline involves putting a stop in at line 95 in one of the sub-scripts, exporting two variables, re-starting the script with the data you want to analyse, re-importing those two variables and hitting run.

The fun of working in academia whereby multiple projects run on an analysis tool that was written ten years ago by a guy who no longer works here and has never been updated.
Post Reply