Page 1 of 2

People who can "do coding"

Posted: Thu Jan 14, 2021 12:12 pm
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:

Re: People who can "do coding"

Posted: Thu Jan 14, 2021 12:24 pm
by Rich B
Haaa, yeah what a noob!

Re: People who can "do coding"

Posted: Thu Jan 14, 2021 12:27 pm
by dan
My god what an idiot, everyone knows whatever you just said :roll:

Re: People who can "do coding"

Posted: Thu Jan 14, 2021 12:29 pm
by Sundayjumper
Get bent, all of you :D

Re: People who can "do coding"

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

What mik understands.

Image

Re: People who can "do coding"

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

What mik understands.

Image
:lol:

Re: People who can "do coding"

Posted: Thu Jan 14, 2021 2:49 pm
by mr_jon
Variables and loops is the hard.

Re: People who can "do coding"

Posted: Thu Jan 14, 2021 4:28 pm
by Delphi
Fuck me, that's special. Why not use the built-in floor function and literally sack off all that shit?

Re: People who can "do coding"

Posted: Thu Jan 14, 2021 5:06 pm
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.

Re: People who can "do coding"

Posted: Fri Jan 15, 2021 12:01 pm
by JonMad
were they charging by lines of code?

Re: People who can "do coding"

Posted: Fri Jan 15, 2021 9:51 pm
by NGRhodes
Does this person happen to call themselves a Data Scientist ?

Re: People who can "do coding"

Posted: Fri Jan 15, 2021 9:59 pm
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 ?

Re: People who can "do coding"

Posted: Fri Jan 15, 2021 10:12 pm
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.

Re: People who can "do coding"

Posted: Fri Jan 15, 2021 10:26 pm
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.

Re: People who can "do coding"

Posted: Sat Jan 16, 2021 5:23 pm
by NGRhodes
Dare you to do a security audit...

Re: People who can "do coding"

Posted: Thu Jan 21, 2021 1:50 pm
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.

Re: People who can "do coding"

Posted: Thu Jan 21, 2021 1:51 pm
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

Re: People who can "do coding"

Posted: Thu Jan 21, 2021 1:53 pm
by Sundayjumper
And that one's a true story IIRC ?

Re: People who can "do coding"

Posted: Thu Jan 21, 2021 1:55 pm
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.

Re: People who can "do coding"

Posted: Thu Jan 21, 2021 2:04 pm
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.