Analyze data with R, first project

Hello,
I went by a different approach btu had no success. Am I totally wrong??

find_place <- function (runner) {

for (place in 1:length(race_results)) {

if race_results[place] == runner {

  return place

}

}

return 0

}

Your code is mostly okay structure wise with a couple errors. In r unlike other programming languages return is treated like a function, and as such you need to use brackets around the items e.g. return(place) not return place. You have also not place brackets around your if statement. Therefore it should look like the following:

find_place <- function (runner) {
   for (place in 1:length(race_results)) {
      if (race_results[place] == runner) {
         return(place)
      }
   }
   return(0)
}

Thank you, it worked!