Writing Your Own Functions in R: Introduction

  Рет қаралды 46,540

weecology

weecology

Күн бұрын

Пікірлер: 60
@jannonflores1113
@jannonflores1113 2 жыл бұрын
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 жыл бұрын
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.
@jacksfacts20
@jacksfacts20 2 жыл бұрын
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.
@epijournal8423
@epijournal8423 4 жыл бұрын
A very clear video ! There are few tutorial on function building on KZbin. Going to go through the others now :) Cheers.
@GurpreetSingh-uj6bq
@GurpreetSingh-uj6bq 2 жыл бұрын
One of The best videos I ever watched on functions
@weecology
@weecology 2 жыл бұрын
Thanks!
@rayraystinz
@rayraystinz 2 жыл бұрын
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!
@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!
@aayushimittal5270
@aayushimittal5270 3 жыл бұрын
Awesome video... Thanks to you I finally know the meaning of curly brackets
@weecology
@weecology 3 жыл бұрын
Soo glad it was helpful!
@KameshwarChoppella
@KameshwarChoppella Жыл бұрын
Very well explained. I'm likely coming back to this channel. Subbed
@weecology
@weecology Жыл бұрын
Thanks!
@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 жыл бұрын
Thank you! You are an amazing professor!
@weecology
@weecology 2 жыл бұрын
So glad it's helpful!
@timmytesla9655
@timmytesla9655 2 жыл бұрын
This is super clear. Thank you!
@weecology
@weecology 2 жыл бұрын
You're welcome!
@quantowen1124
@quantowen1124 2 жыл бұрын
This was extremely helpful! Love it!
@weecology
@weecology 2 жыл бұрын
So glad it was useful!
@Skyking8383
@Skyking8383 Жыл бұрын
How would you create a function in order to create a time series plot? I am not sure what information you would put
@tatianam7657
@tatianam7657 2 жыл бұрын
Excellent!
@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.
@mitch6151
@mitch6151 3 ай бұрын
Clear! Great!
@weecology
@weecology 2 ай бұрын
Thanks!
@willatkinson141
@willatkinson141 3 жыл бұрын
How would you go about returning more than one calculation at a time for the same function? Great video.
@weecology
@weecology 3 жыл бұрын
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.
@da8804ss
@da8804ss 2 жыл бұрын
great explanation
@Samyak_Patil
@Samyak_Patil 2 жыл бұрын
Thank you so much. You made it super easy.
@weecology
@weecology 2 жыл бұрын
Glad it was helpful!
@aniladeepu8999
@aniladeepu8999 2 жыл бұрын
sir, how to integrate the following function in r using limits -Infinity to x. f1
@karanthakker2672
@karanthakker2672 2 жыл бұрын
This is a fantastic tutorial! Keep it up, you've earned a sub :)
@weecology
@weecology 2 жыл бұрын
Thanks!
@multitaskprueba1
@multitaskprueba1 2 жыл бұрын
You are a genius! Thank you!
@weecology
@weecology 2 жыл бұрын
Thanks!
@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 жыл бұрын
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!
@rishabhkansal3309
@rishabhkansal3309 2 жыл бұрын
much useful
@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
@gsalem7351
@gsalem7351 3 жыл бұрын
Thank you
@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.
@asadkhanbb
@asadkhanbb Жыл бұрын
❣️❣️❣️
@ckeong9012
@ckeong9012 3 жыл бұрын
clear. tq sir
@bismaarshad280
@bismaarshad280 10 ай бұрын
OMG! THANKSSSS MANNNN!
@weecology
@weecology 10 ай бұрын
You’re welcome!
@auracristinareynavarro2523
@auracristinareynavarro2523 3 жыл бұрын
great!
@carlyap5943
@carlyap5943 3 жыл бұрын
AYOS YAN PRE PALIKE
@divyabadlia5830
@divyabadlia5830 4 ай бұрын
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 2 ай бұрын
Is this in RStudio?
@krushnachChandra
@krushnachChandra 3 жыл бұрын
helpful video you got new sub
@Oluwaseun_Adeyemi
@Oluwaseun_Adeyemi 2 жыл бұрын
how can I write a function to calculate kurtosis?
@weecology
@weecology 2 жыл бұрын
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!
A tutorial for writing functions in R (CC177)
14:37
Riffomonas Project
Рет қаралды 15 М.
She's very CREATIVE💡💦 #camping #survival #bushcraft #outdoors #lifehack
00:26
1 сквиш тебе или 2 другому? 😌 #шортс #виола
00:36
Good teacher wows kids with practical examples #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 11 МЛН
The selfish The Joker was taught a lesson by Officer Rabbit. #funny #supersiblings
00:12
Funny superhero siblings
Рет қаралды 11 МЛН
Write your own R functions
15:32
Equitable Equations
Рет қаралды 3,5 М.
How to purrr
17:46
Equitable Equations
Рет қаралды 10 М.
Introduction to Repeating Things in R: Looping Over Files
10:22
Loops using R programming
13:37
R Programming 101
Рет қаралды 14 М.
Learn R in 39 minutes
38:56
Equitable Equations
Рет қаралды 703 М.
The size of your variables matters.
11:03
Core Dumped
Рет қаралды 122 М.
How to read Haskell code (in 7 minutes)
6:51
peppidesu
Рет қаралды 65 М.
She's very CREATIVE💡💦 #camping #survival #bushcraft #outdoors #lifehack
00:26