Afternoon- I am trying to subtract a matrix, basically a vector of 28 values, each by the same number to account for differences in regression fitting. I am taking the 1x28 and minus it by the mean value of the matrix, each number. The result I receive is a 1X29 matrix. Does anyone know why the result has an extra value?> lffeb_march[1] 6.588926 7.663877 6.917706 6.824374 7.029973 6.549651 6.517671 6.070738 5.916202 [10] 6.993933 6.091310 7.313220 5.135798 6.762730 6.381816 7.999679 6.851185 5.799093 [19] 7.774856 6.956545 8.218787 8.218787 7.549609 7.222566 7.170120 6.173786 5.075174 [28] 4.700480 6.672033 5.198497 4.867534 7.170120 6.131226 6.802395> meanf_fm<-mean(lffeb_march) > X3_fm<-(lffeb_march-meanf_fm) > X3_fm[1] -0.03784990 1.03710088 0.29092923 0.19759729 0.40319653 -0.07712564 -0.10910511 [8] -0.55603865 -0.71057432 0.36715660 -0.53546650 0.68644401 -1.49097794 0.13595313 [15] -0.24496036 1.37290220 0.22440855 -0.82768372 1.14807939 0.32976906 1.59201078 [22] 1.59201078 0.92283279 0.59578964 0.54334317 -0.45299027 -1.55160256 -1.92629601 [29] 0.04525657 -1.42827935 -1.75924193 0.54334317 -0.49554989 0.17561839 Thanks for the help Meredith -- View this message in context: http://r.789695.n4.nabble.com/Subtracting-a-matrix-1x28-from-a-scalar-tp4615590.html Sent from the R help mailing list archive at Nabble.com.
On May 7, 2012, at 3:26 PM, meredith wrote:> Afternoon- > I am trying to subtract a matrix, basically a vector of 28 values, > each by > the same number to account for differences in regression fitting. I am > taking the 1x28 and minus it by the mean value of the matrix, each > number. > The result I receive is a 1X29 matrix.No. You simply do not understand what you are looking at that is NOT a matrix, but rather a 34 element vector. The [28] and hte [29] refer to the item location of the succeeding value. -- David.> Does anyone know why the result has > an extra value? > >> lffeb_march > [1] 6.588926 7.663877 6.917706 6.824374 7.029973 6.549651 6.517671 > 6.070738 > 5.916202 > [10] 6.993933 6.091310 7.313220 5.135798 6.762730 6.381816 7.999679 > 6.851185 > 5.799093 > [19] 7.774856 6.956545 8.218787 8.218787 7.549609 7.222566 7.170120 > 6.173786 > 5.075174 > [28] 4.700480 6.672033 5.198497 4.867534 7.170120 6.131226 6.802395 >> meanf_fm<-mean(lffeb_march) >> X3_fm<-(lffeb_march-meanf_fm) >> X3_fm > [1] -0.03784990 1.03710088 0.29092923 0.19759729 0.40319653 > -0.07712564 > -0.10910511 > [8] -0.55603865 -0.71057432 0.36715660 -0.53546650 0.68644401 > -1.49097794 > 0.13595313 > [15] -0.24496036 1.37290220 0.22440855 -0.82768372 1.14807939 > 0.32976906 > 1.59201078 > [22] 1.59201078 0.92283279 0.59578964 0.54334317 -0.45299027 > -1.55160256 > -1.92629601 > [29] 0.04525657 -1.42827935 -1.75924193 0.54334317 -0.49554989 > 0.17561839 > > Thanks for the help > Meredith > > -- > View this message in context: http://r.789695.n4.nabble.com/Subtracting-a-matrix-1x28-from-a-scalar-tp4615590.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.David Winsemius, MD West Hartford, CT
* Disregard message please Afternoon- I am trying to subtract a matrix, basically a vector of 28 values, each by the same number to account for differences in regression fitting. I am taking the 1x28 and minus it by the mean value of the matrix, each number. The result I receive is a 1X29 matrix. Does anyone know why the result has an extra value?> lffeb_march[1] 6.588926 7.663877 6.917706 6.824374 7.029973 6.549651 6.517671 6.070738 5.916202 [10] 6.993933 6.091310 7.313220 5.135798 6.762730 6.381816 7.999679 6.851185 5.799093 [19] 7.774856 6.956545 8.218787 8.218787 7.549609 7.222566 7.170120 6.173786 5.075174 [28] 4.700480 6.672033 5.198497 4.867534 7.170120 6.131226 6.802395> meanf_fm<-mean(lffeb_march) > X3_fm<-(lffeb_march-meanf_fm) > X3_fm[1] -0.03784990 1.03710088 0.29092923 0.19759729 0.40319653 -0.07712564 -0.10910511 [8] -0.55603865 -0.71057432 0.36715660 -0.53546650 0.68644401 -1.49097794 0.13595313 [15] -0.24496036 1.37290220 0.22440855 -0.82768372 1.14807939 0.32976906 1.59201078 [22] 1.59201078 0.92283279 0.59578964 0.54334317 -0.45299027 -1.55160256 -1.92629601 [29] 0.04525657 -1.42827935 -1.75924193 0.54334317 -0.49554989 0.17561839 Thanks for the help Meredith -- View this message in context: http://r.789695.n4.nabble.com/Subtracting-a-matrix-1x28-from-a-scalar-tp4615590p4615599.html Sent from the R help mailing list archive at Nabble.com.
I'm sorry but where is 28 coming from? It looks to me like you have a vector of length 34 and the result is of length 34. Oh, I see, the 28 and 29 are the indices for the first number on the line not the total length. John Kane Kingston ON Canada> -----Original Message----- > From: mmballar at mtu.edu > Sent: Mon, 7 May 2012 12:26:15 -0700 (PDT) > To: r-help at r-project.org > Subject: [R] Subtracting a matrix 1x28 from a scalar > > Afternoon- > I am trying to subtract a matrix, basically a vector of 28 values, each > by > the same number to account for differences in regression fitting. I am > taking the 1x28 and minus it by the mean value of the matrix, each > number. > The result I receive is a 1X29 matrix. Does anyone know why the result > has > an extra value? > >> lffeb_march > [1] 6.588926 7.663877 6.917706 6.824374 7.029973 6.549651 6.517671 > 6.070738 > 5.916202 > [10] 6.993933 6.091310 7.313220 5.135798 6.762730 6.381816 7.999679 > 6.851185 > 5.799093 > [19] 7.774856 6.956545 8.218787 8.218787 7.549609 7.222566 7.170120 > 6.173786 > 5.075174 > [28] 4.700480 6.672033 5.198497 4.867534 7.170120 6.131226 6.802395 >> meanf_fm<-mean(lffeb_march) >> X3_fm<-(lffeb_march-meanf_fm) >> X3_fm > [1] -0.03784990 1.03710088 0.29092923 0.19759729 0.40319653 > -0.07712564 > -0.10910511 > [8] -0.55603865 -0.71057432 0.36715660 -0.53546650 0.68644401 > -1.49097794 > 0.13595313 > [15] -0.24496036 1.37290220 0.22440855 -0.82768372 1.14807939 > 0.32976906 > 1.59201078 > [22] 1.59201078 0.92283279 0.59578964 0.54334317 -0.45299027 > -1.55160256 > -1.92629601 > [29] 0.04525657 -1.42827935 -1.75924193 0.54334317 -0.49554989 > 0.17561839 > > Thanks for the help > Meredith > > -- > View this message in context: > http://r.789695.n4.nabble.com/Subtracting-a-matrix-1x28-from-a-scalar-tp4615590.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 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
I'm sorry but where is 28 coming from? It looks to me like you have a vector of length 34 and the result is of length 34. Oh, I see, the 28 and 29 are the indices for the first number on the line not the total length. John Kane Kingston ON Canada> -----Original Message----- > From: mmballar at mtu.edu > Sent: Mon, 7 May 2012 12:26:15 -0700 (PDT) > To: r-help at r-project.org > Subject: [R] Subtracting a matrix 1x28 from a scalar > > Afternoon- > I am trying to subtract a matrix, basically a vector of 28 values, each > by > the same number to account for differences in regression fitting. I am > taking the 1x28 and minus it by the mean value of the matrix, each > number. > The result I receive is a 1X29 matrix. Does anyone know why the result > has > an extra value? > >> lffeb_march > [1] 6.588926 7.663877 6.917706 6.824374 7.029973 6.549651 6.517671 > 6.070738 > 5.916202 > [10] 6.993933 6.091310 7.313220 5.135798 6.762730 6.381816 7.999679 > 6.851185 > 5.799093 > [19] 7.774856 6.956545 8.218787 8.218787 7.549609 7.222566 7.170120 > 6.173786 > 5.075174 > [28] 4.700480 6.672033 5.198497 4.867534 7.170120 6.131226 6.802395 >> meanf_fm<-mean(lffeb_march) >> X3_fm<-(lffeb_march-meanf_fm) >> X3_fm > [1] -0.03784990 1.03710088 0.29092923 0.19759729 0.40319653 > -0.07712564 > -0.10910511 > [8] -0.55603865 -0.71057432 0.36715660 -0.53546650 0.68644401 > -1.49097794 > 0.13595313 > [15] -0.24496036 1.37290220 0.22440855 -0.82768372 1.14807939 > 0.32976906 > 1.59201078 > [22] 1.59201078 0.92283279 0.59578964 0.54334317 -0.45299027 > -1.55160256 > -1.92629601 > [29] 0.04525657 -1.42827935 -1.75924193 0.54334317 -0.49554989 > 0.17561839 > > Thanks for the help > Meredith > > -- > View this message in context: > http://r.789695.n4.nabble.com/Subtracting-a-matrix-1x28-from-a-scalar-tp4615590.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!
Hello, meredith wrote> > Afternoon- > I am trying to subtract a matrix, basically a vector of 28 values, each > by the same number to account for differences in regression fitting. I am > taking the 1x28 and minus it by the mean value of the matrix, each number. > The result I receive is a 1X29 matrix. Does anyone know why the result has > an extra value? > >> lffeb_march > [1] 6.588926 7.663877 6.917706 6.824374 7.029973 6.549651 6.517671 > 6.070738 5.916202 > [10] 6.993933 6.091310 7.313220 5.135798 6.762730 6.381816 7.999679 > 6.851185 5.799093 > [19] 7.774856 6.956545 8.218787 8.218787 7.549609 7.222566 7.170120 > 6.173786 5.075174 > [28] 4.700480 6.672033 5.198497 4.867534 7.170120 6.131226 6.802395 >> meanf_fm<-mean(lffeb_march) >> X3_fm<-(lffeb_march-meanf_fm) >> X3_fm > [1] -0.03784990 1.03710088 0.29092923 0.19759729 0.40319653 > -0.07712564 -0.10910511 > [8] -0.55603865 -0.71057432 0.36715660 -0.53546650 0.68644401 > -1.49097794 0.13595313 > [15] -0.24496036 1.37290220 0.22440855 -0.82768372 1.14807939 > 0.32976906 1.59201078 > [22] 1.59201078 0.92283279 0.59578964 0.54334317 -0.45299027 > -1.55160256 -1.92629601 > [29] 0.04525657 -1.42827935 -1.75924193 0.54334317 -0.49554989 > 0.17561839 > > Thanks for the help > Meredith >Each of your two vectors has 34 elements, not 28 and 29. And when I suntract mean( lffeb_march) from lffeb_march (the first vector) I get a vector close but not equal to your second vector. It's off by 1e-7 or 1e-8, mostly 1e-7. The function all.equal() gives [1] "Mean relative difference: 3.568577e-07" So, please, revise your results. (You should use dput(lffeb_march) to post your data.) Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/Subtracting-a-matrix-1x28-from-a-scalar-tp4615590p4615624.html Sent from the R help mailing list archive at Nabble.com.