[R] Apply() on columns
John Kane
jrkrideau at inbox.com
Wed Jun 20 17:32:03 CEST 2012
Okay, I think you need to read up a bit on how to use R.
Have a look at ?apply. It has nothing to do with graphing data. It is a way to summarize data.
What I think you want to do is to select the first 4 columns and then use apply() wih sum to get the total number of worlers and then use apply(() to get the sum of the hours.
You will get two vectors workers and hours , Then hours/workers gives you the mean hours worked by each team. Since this looks like a homework assignment I will leave the actual programing to you.
To graph something you need to select the data you want and then give the command you want
For example if we call the data.frame 'sp' then boxplot(sp$V6) gives you a boxplot of V6.
Have a look at ?boxplot for more information on how to make the plot look better by adding titles etc.
Also try with(sp, boxplot(V6,V7,V8, V9, V10 )) for a grouped boxplot
John Kane
Kingston ON Canada
> -----Original Message-----
> From: f.a.elsendoorn at gmail.com
> Sent: Tue, 19 Jun 2012 22:25:31 -0700 (PDT)
> To: r-help at r-project.org
> Subject: Re: [R] Apply() on columns
>
> Hi,
>
> Yes, the columns are related: V1 is related to V6, V2 is related to V7
> and
> so on. The columns V1,V2,V3,V4,V5 contains the number of employees (in a
> filling team). The columns V6,V7,V8,V9,V10 contains the number of worked
> hours of the filling team.
> What I am interested in is the average working hours per employee.
> Therefore
> I have go give some graphical and numerical summaries to present the
> average
> working hours per employee. The function that I must use is apply().
>
> How can I present with that function a graphical and numerical summarie
> of
> the average working hours per employee? [some example and explanation
> would
> be respected]
>
> Yours,
>
> FA Elsendoorn
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Apply-on-columns-tp4633468p4633917.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!
More information about the R-help
mailing list