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
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.
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.
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.
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?)
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.
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
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
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?
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.
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
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
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
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.
One of The best videos I ever watched on functions
Thanks!
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.
this was incredibly clear, helpful and I appreciate the format! nice to see a human face (instead of just the typical voiceovers)
So glad it was useful!
A very clear video ! There are few tutorial on function building on RUclips.
Going to go through the others now :)
Cheers.
Thank You! This helped my learning curve tremendously. You are an awsome teacher! and singer!
Thanks! So glad it’s helpful!
Very well explained. I'm likely coming back to this channel. Subbed
Thanks!
Awesome video...
Thanks to you I finally know the meaning of curly brackets
Soo glad it was helpful!
Thank you for this video. It really helped with my studies. Your explanation made it easy to understand functions in r
Awesome! Very glad it was helpful.
Thank you! You are an amazing professor!
So glad it's helpful!
This is super clear. Thank you!
You're welcome!
Honestly you explain it so well but I don't know why mine isn't just working out anything
This was extremely helpful! Love it!
So glad it was useful!
Thank you so much. You made it super easy.
Glad it was helpful!
You are a genius! Thank you!
Thanks!
How would you go about returning more than one calculation at a time for the same function? Great video.
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.
How would you create a function in order to create a time series plot? I am not sure what information you would put
This is a fantastic tutorial!
Keep it up, you've earned a sub :)
Thanks!
Excellent!
Clear! Great!
Thanks!
great explanation
this was super helpful, what if i want the function to take input from a sequence say example output of test
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.
sir, how to integrate the following function in r using limits -Infinity to x.
f1
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?)
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.
@@weecology thank you for your answer and for your great videos!!
@@redrosin99 You're welcome!
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
AYOS YAN PRE PALIKE
OMG! THANKSSSS MANNNN!
You’re welcome!
much useful
❣️❣️❣️
Thank you
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
Is this in RStudio?
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?
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.
clear. tq sir
helpful video you got new sub
great!
how can I write a function to calculate kurtosis?
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
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
Good talk, but you a goofy lookin dude. Thanks man!