Writing Your Own Functions in R: Introduction

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 61

  • @jannonflores1113
    @jannonflores1113 2 года назад +7

    I purchased a freakin course in R and I had trouble understanding this one topic. Well, I found your topic here on youtube and it was well explained in a 12 minute video. Props to you man..... Thanks a lot

    • @weecology
      @weecology  2 года назад +1

      Thanks! Functions are definitely tricky and it's taken me years of iteration to get to that 12 minutes so I'm very glad that it's useful.

  • @GurpreetSingh-uj6bq
    @GurpreetSingh-uj6bq 2 года назад +1

    One of The best videos I ever watched on functions

  • @jacksfacts20
    @jacksfacts20 2 года назад +3

    First I wanna say thank you for this very informative video, 2nd, As a small youtuber myself, the fact that you did a lot of this in one take is impressive and tough to do. From personal experience, you can make it a lot easier on yourself by breaking up what your saying into small chunks that you can cut together. That why you don't have to worry about awkward pauses as much. People don't mind cuts of you speaking if they're in logical places like the end of sentences and such.

  • @rayraystinz
    @rayraystinz 2 года назад +1

    this was incredibly clear, helpful and I appreciate the format! nice to see a human face (instead of just the typical voiceovers)

    • @weecology
      @weecology  2 года назад

      So glad it was useful!

  • @epijournal8423
    @epijournal8423 4 года назад +7

    A very clear video ! There are few tutorial on function building on RUclips.
    Going to go through the others now :)
    Cheers.

  • @donniemarshall2531
    @donniemarshall2531 Год назад

    Thank You! This helped my learning curve tremendously. You are an awsome teacher! and singer!

    • @weecology
      @weecology  Год назад

      Thanks! So glad it’s helpful!

  • @KameshwarChoppella
    @KameshwarChoppella Год назад

    Very well explained. I'm likely coming back to this channel. Subbed

  • @aayushimittal5270
    @aayushimittal5270 3 года назад +1

    Awesome video...
    Thanks to you I finally know the meaning of curly brackets

    • @weecology
      @weecology  3 года назад

      Soo glad it was helpful!

  • @jaclynjuarez9289
    @jaclynjuarez9289 3 года назад

    Thank you for this video. It really helped with my studies. Your explanation made it easy to understand functions in r

    • @weecology
      @weecology  3 года назад

      Awesome! Very glad it was helpful.

  • @shotpana
    @shotpana 2 года назад +1

    Thank you! You are an amazing professor!

    • @weecology
      @weecology  2 года назад

      So glad it's helpful!

  • @timmytesla9655
    @timmytesla9655 2 года назад +1

    This is super clear. Thank you!

  • @mukisacharlotte
    @mukisacharlotte 11 дней назад

    Honestly you explain it so well but I don't know why mine isn't just working out anything

  • @quantowen1124
    @quantowen1124 2 года назад +1

    This was extremely helpful! Love it!

    • @weecology
      @weecology  2 года назад +1

      So glad it was useful!

  • @Samyak_Patil
    @Samyak_Patil 2 года назад

    Thank you so much. You made it super easy.

    • @weecology
      @weecology  2 года назад

      Glad it was helpful!

  • @multitaskprueba1
    @multitaskprueba1 2 года назад

    You are a genius! Thank you!

  • @willatkinson141
    @willatkinson141 3 года назад +1

    How would you go about returning more than one calculation at a time for the same function? Great video.

    • @weecology
      @weecology  3 года назад +1

      That's a great question. Typically if you want to return more than one value you pass those values back in a single object that can store multiple values. Most commonly this would be a list, but it could also be a vector or something else. In the function you create a list that holds each of the things you want to return and then return the list at the end.

  • @Skyking8383
    @Skyking8383 2 года назад

    How would you create a function in order to create a time series plot? I am not sure what information you would put

  • @karanthakker2672
    @karanthakker2672 2 года назад +1

    This is a fantastic tutorial!
    Keep it up, you've earned a sub :)

  • @tatianam7657
    @tatianam7657 2 года назад

    Excellent!

  • @mitch6151
    @mitch6151 5 месяцев назад

    Clear! Great!

  • @diegocitizen
    @diegocitizen 3 года назад

    great explanation

  • @taiwolawal9687
    @taiwolawal9687 2 года назад

    this was super helpful, what if i want the function to take input from a sequence say example output of test

    • @weecology
      @weecology  2 года назад

      You can pass any object to a function, so you can certainly pass test as an argument in this case. Then inside the function you treat test however you would outside of the function. Any operations that work on sequences can be used inside the function.

  • @aniladeepu8999
    @aniladeepu8999 2 года назад

    sir, how to integrate the following function in r using limits -Infinity to x.
    f1

  • @redrosin99
    @redrosin99 2 года назад

    Your explanation is very good however I would like to know: 1. Which editor are you using?
    2. Where in memory should I save the function (as a separate R file) and how should I let R know about its existence (does it have to be loaded as a package or do I have a workspace?)

    • @weecology
      @weecology  2 года назад +1

      The video uses RStudio, which is the most common development environment for R.
      For small projects I recommend just keeping the function in the same R file as the rest of your code. Just put all of the functions at the top of the code (after loading any packages but before any code that isn't in functions) and then all the functions in the code. If it's a bigger project you can put one or more functions into one or more separate R files. To let R know about them at the top of your code you run `source("/path/to/yourfile.R")`. This will run all of the code in that file and so if that file is just functions it will define all of those functions so that you can use them.

    • @redrosin99
      @redrosin99 2 года назад

      @@weecology thank you for your answer and for your great videos!!

    • @weecology
      @weecology  2 года назад

      @@redrosin99 You're welcome!

  • @andreasioannides3868
    @andreasioannides3868 2 года назад

    Hi sir im a student and i have a question that tells me to construct a function with two arguments A and u that return only the non zero entries of a vector E. Vector E has length 25000 and is defined as E=max(A-u, 0) i have already build a function for vector A in a previous part. i desperately need help thank you

  • @carlyap5943
    @carlyap5943 3 года назад +1

    AYOS YAN PRE PALIKE

  • @bismaarshad280
    @bismaarshad280 Год назад

    OMG! THANKSSSS MANNNN!

  • @rishabhkansal3309
    @rishabhkansal3309 2 года назад

    much useful

  • @asadkhanbb
    @asadkhanbb Год назад

    ❣️❣️❣️

  • @gsalem7351
    @gsalem7351 3 года назад

    Thank you

  • @divyabadlia5830
    @divyabadlia5830 5 месяцев назад

    Whenever I try to change line after using braces to write function body I can't seem to do it
    I can't seem to separate those braces can anyone help me with this

    • @weecology
      @weecology  3 месяца назад

      Is this in RStudio?

  • @gabrielamendezospino6415
    @gabrielamendezospino6415 2 года назад

    Hi, I get the error object 'lenght' not found when trying to call the function, I image it's because there should be a dataset with the variable of that name, right?

    • @weecology
      @weecology  2 года назад

      Looks like maybe you just have a typo. The way I wrote it It's 'length' not 'lenght'. All that actually matters is that it is the same in the parentheses and in the body of the function.

  • @ckeong9012
    @ckeong9012 3 года назад

    clear. tq sir

  • @krushnachChandra
    @krushnachChandra 3 года назад

    helpful video you got new sub

  • @auracristinareynavarro2523
    @auracristinareynavarro2523 3 года назад

    great!

  • @Oluwaseun_Adeyemi
    @Oluwaseun_Adeyemi 3 года назад

    how can I write a function to calculate kurtosis?

    • @weecology
      @weecology  3 года назад

      The input value to your function would be a vector of the values that you want to use for the kurtosis calculation. You would then calculate the kurtosis for that vector, which is something like mean((values - mean(values)) / sqrt(var(values))) (I haven't checked this so you should make sure it matches en.wikipedia.org/wiki/Kurtosis and works. This functionality is also available in a bunch of packages including the moments package cran.r-project.org/web/packages/moments/index.html

  • @theunitydev5418
    @theunitydev5418 3 года назад

    As someone that knows how to code this hurts to watch and learn and its most definetly not your fault but Rs. Who came up with the idea of not having to define the type of variable you are using shit get confusing fast

  • @richardsmith9399
    @richardsmith9399 2 года назад

    Good talk, but you a goofy lookin dude. Thanks man!