I think it's easy problem but I can't find solution. I have a vector: vec <- c (23.4, 3.0, 14.7, 7.7) and I would like to add all values which are inside my vector to each other. as a result a want to get one value like sum all values from my vector- sth=(23.4 + 3.0 + 14.7 + 7.7) PS. I usually don't know how long is my vector in my function -- View this message in context: http://www.nabble.com/add-values-inside-vector-tp23812292p23812292.html Sent from the R help mailing list archive at Nabble.com.
?sum On Mon, Jun 1, 2009 at 6:15 AM, Grze¶ <gregorio99@gmail.com> wrote:> > I think it's easy problem but I can't find solution. > > I have a vector: > > vec <- c (23.4, 3.0, 14.7, 7.7) > > and I would like to add all values which are inside my vector to each > other. > > as a result a want to get one value like sum all values from my vector- > sth=(23.4 + 3.0 + 14.7 + 7.7) > > PS. I usually don't know how long is my vector in my function > -- > View this message in context: > http://www.nabble.com/add-values-inside-vector-tp23812292p23812292.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
Use sum: sum(vec) On Mon, Jun 1, 2009 at 7:15 AM, Grze¶ <gregorio99@gmail.com> wrote:> > I think it's easy problem but I can't find solution. > > I have a vector: > > vec <- c (23.4, 3.0, 14.7, 7.7) > > and I would like to add all values which are inside my vector to each > other. > > as a result a want to get one value like sum all values from my vector- > sth=(23.4 + 3.0 + 14.7 + 7.7) > > PS. I usually don't know how long is my vector in my function > -- > View this message in context: > http://www.nabble.com/add-values-inside-vector-tp23812292p23812292.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]