Introduction to Functions in R
Uploader Comments (off2themovies2)
All Comments (8)
-
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....
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.
off2themovies2 1 month ago
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.
off2themovies2 4 months ago
@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.
off2themovies2 8 months ago
@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.
off2themovies2 10 months ago