[R] automation question

stephen sefick ssefick at gmail.com
Fri Jul 31 22:17:22 CEST 2009


look at the apply family of functions and look at the MARGIN argument.

On Fri, Jul 31, 2009 at 2:30 PM, RRRRRRRRRR!<cwalter at usgs.gov> wrote:
>
> I have columns in two tables that need to be compared in order to get a
> statistic. The function calculating the statistic is somers2. Here are the
> two columns I must calculate, row by row.
>
>                      name1           name2
> 1  Pred_pres_a_indpdt[,3,,] population[,23]
> 2  Pred_pres_b_indpdt[,3,,] population[,24]
> 3  Pred_pres_c_indpdt[,3,,] population[,25]
> 4  Pred_pres_d_indpdt[,3,,] population[,26]
> 5  Pred_pres_e_indpdt[,3,,] population[,27]
> 6  Pred_pres_f_indpdt[,3,,] population[,28]
> 7  Pred_pres_a_indpdt[,4,,] population[,23]
> 8  Pred_pres_b_indpdt[,4,,] population[,24]
> 9  Pred_pres_c_indpdt[,4,,] population[,25]
> 10 Pred_pres_d_indpdt[,4,,] population[,26]
> 11 Pred_pres_e_indpdt[,4,,] population[,27]
> 12 Pred_pres_f_indpdt[,4,,] population[,28]
> 13 Pred_pres_a_indpdt[,5,,] population[,23]
> 14 Pred_pres_b_indpdt[,5,,] population[,24]
> 15 Pred_pres_c_indpdt[,5,,] population[,25]
> 16 Pred_pres_d_indpdt[,5,,] population[,26]
> 17 Pred_pres_e_indpdt[,5,,] population[,27]
> 18 Pred_pres_f_indpdt[,5,,] population[,28]
> 19 Pred_pres_a_indpdt[,8,,] population[,23]
> 20 Pred_pres_b_indpdt[,8,,] population[,24]
> 21 Pred_pres_c_indpdt[,8,,] population[,25]
> 22 Pred_pres_d_indpdt[,8,,] population[,26]
> 23 Pred_pres_e_indpdt[,8,,] population[,27]
> 24 Pred_pres_f_indpdt[,8,,] population[,28]
>
> the somers2 function works like this:
>
> somers2(x, y)
>
> for example:   somers2(Pred_pres_a_indpdt[,3,,], population[,23])
>
> so somers2 is calculated for each row, with column 1 as x, column 2 as y.
> Is there anyway to automate this?
>
> -R
>
>
>
>
> --
> View this message in context: http://www.nabble.com/automation-question-tp24761918p24761918.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.
>



-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

								-K. Mullis




More information about the R-help mailing list