People who can "do coding"
- Sundayjumper
- Posts: 6269
- Joined: Wed Apr 11, 2018 4:04 pm
- Currently Driving: Peugeot 406
People who can "do coding"
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
Hard coding the current week number as a variable name, so you have to change it every week is a bad idea
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
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
Hard coding the current week number as a variable name, so you have to change it every week is a bad idea
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
Re: People who can "do coding"
Haaa, yeah what a noob!
Re: People who can "do coding"
My god what an idiot, everyone knows whatever you just said
- Sundayjumper
- Posts: 6269
- Joined: Wed Apr 11, 2018 4:04 pm
- Currently Driving: Peugeot 406
Re: People who can "do coding"
Get bent, all of you
Re: People who can "do coding"
What SundayJumper said to mik.
What mik understands.
What mik understands.
- Swervin_Mervin
- Posts: 4742
- Joined: Wed Apr 11, 2018 8:58 pm
Re: People who can "do coding"
Variables and loops is the hard.
- 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"
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.
- Sundayjumper
- Posts: 6269
- Joined: Wed Apr 11, 2018 4:04 pm
- Currently Driving: Peugeot 406
Re: People who can "do coding"
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.
A schoolchild could do better. And we were actually *paying* for this.
Re: People who can "do coding"
Does this person happen to call themselves a Data Scientist ?
- Sundayjumper
- Posts: 6269
- Joined: Wed Apr 11, 2018 4:04 pm
- Currently Driving: Peugeot 406
Re: People who can "do coding"
I work at Leeds Uni in Research Computing, very familiar to see this coding "style" from researchers and scientists.Sundayjumper wrote: ↑Fri Jan 15, 2021 9:59 pmYou have nailed the head quite squarely ! Do you have to deal with Data Scientists too ?
- Sundayjumper
- Posts: 6269
- Joined: Wed Apr 11, 2018 4:04 pm
- Currently Driving: Peugeot 406
Re: People who can "do coding"
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/
It's funny because it's true.
Guess what ? <yyy> happened.
And totally on the same track, I happened upon this today:
https://xkcd.com/2054/
It's funny because it's true.
Re: People who can "do coding"
Dare you to do a security audit...
- Explosive Newt
- Posts: 1553
- Joined: Sat Feb 23, 2019 7:33 pm
Re: People who can "do coding"
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.
- Explosive Newt
- Posts: 1553
- Joined: Sat Feb 23, 2019 7:33 pm
Re: People who can "do coding"
See alsoSundayjumper 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/
It's funny because it's true.
- Sundayjumper
- Posts: 6269
- Joined: Wed Apr 11, 2018 4:04 pm
- Currently Driving: Peugeot 406
Re: People who can "do coding"
And that one's a true story IIRC ?
- Sundayjumper
- Posts: 6269
- Joined: Wed Apr 11, 2018 4:04 pm
- Currently Driving: Peugeot 406
Re: People who can "do coding"
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.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.
- Explosive Newt
- Posts: 1553
- Joined: Sat Feb 23, 2019 7:33 pm
Re: People who can "do coding"
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.
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.