[R] Compute z

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Sun Jul 26 17:19:59 CEST 2015


sum(v*w)

There are no "column vectors" in R... there are vectors (that have no "direction"), and there are data frames that might only have one column, and matrices that might have many rows but only one column, and a piece of matrix or data frame is often converted to a vector when indexing is used to extract a column or row (e.g. mat[ , 1 ]).

It may feel too dense to absorb at first, but the Introduction to R document that comes with R actually explains all this. Try (re)reading that occasionally until it sinks in.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On July 26, 2015 1:38:24 AM PDT, admin.dslcomputer at gmail.com wrote:
>Hi Everyone:
>
>
>How do I correctly compute z? 
>
>
>
>z = 0;
>for i = 1:7
>  z = z + v(i) * w(i)
>end
>
>
>If there are two column vectors v and w, each with 7 elements (i.e.,
>they have dimensions 7x1). 
>
>
>Regards,
>
>Hal
>
>
>
>
>
>
>Sent from Surface
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.



More information about the R-help mailing list