Re: [R] Compute z
To which I will add: Start up R. At the prompt, type ?Control This will show you the syntax for 'for' loops. (is this homework?) -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 7/26/15, 8:19 AM, R-help on behalf of Jeff Newmiller r-help-boun...@r-project.org on behalf of jdnew...@dcn.davis.ca.us wrote: 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 NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.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.dslcompu...@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@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. __ R-help@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. __ R-help@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.
Re: [R] Compute z
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 NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.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.dslcompu...@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@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. __ R-help@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.
[R] Compute z
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@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.
Re: [R] Compute z
Dear Hal Are you looking for %*% by any chance? On 26/07/2015 09:38, admin.dslcompu...@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@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. -- Michael http://www.dewey.myzen.co.uk/home.html __ R-help@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.