Introduction to Functions in R

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
5,363
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Jan 25, 2010

This video tutorial gives you an introduction to creating functions in R.

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (off2themovies2)

  • Hi Tentenlaw, Here is an easy way to do that.

    Suppose we call your dataset data1 which has 40 columns and 40 rows. To obtain the mean simply do the following:

    mean( data1[ ,1:20] ) # This gives the mean for all data in columns 1 through 20.

    mean( data1[ 1:20, 1:20]) # This gives the mean for all data in columns 1 through 20 and in rows 1 through 20.

    Hope this helps.

  • You will have to specify exactly what you mean by the Jacobi method. My guess is that it is probably already coded in R in one of the contributed packages. But if I knew what algorithm you are trying to use I could probably help.

  • @insomnialu. Sure I can give you tips. But R is so vast you need to provide some idea of the types of tips you would like. One big tip is: Avoid using Loops. R does not do loops well. Sometimes you can't avoid a loop but if you can trick R into doing something without a loop your program will probably run much faster.

  • @insomnialu I will work on a video showing how to do basic model selection in R. It may take me a few weeks to get to it.

see all

All Comments (8)

Sign In or Sign Up now to post a comment!
  • Mr. Boone, I need some assistance please. I want to find the mean of a row between particular columns.

    For example, say I have 40 columns and 40 rows. I want to find the mean of the data in row 1 from column 1-20. I know how to do this! I simply have to use the transpose command to switch the variables. However, I can only do it for one row at a time.

    How can I find the mean for all the rows from column 1-20? My professor suggested "for loops". I don't know how to do that! Please help!

  • hi, i need to program the jacobi method and i dont know how to put it in R language, could you help me?

  • @off2themovies2 oh, ok, sorry for the late reply. I really like ur videos and it helped me a lot. Also I am taking a R programming course now, I hope if you could give me some tips.

    Thank you so much

  • Hi I really love ur video which helped have better proficiency in r. I am wondering if you could show us the method for model selection like forward and backward selection? Thank you very much....

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more