Hi Colleagues, Could you please help? I get as the output of my calculations following [1] 0.000000e+00 1.890000e-04 3.933000e-05 1.701501e-04 2.040456e-04 [6] 3.119242e-04 2.545665e-04 1.893930e-03 1.303112e-03 9.880183e-04 [11] 1.504378e-03 1.549246e-03 5.877690e-04 4.771359e-04 8.528219e-04 How is it possible to transform the data to get a vector as following 10 0.017511063 11 0.017819918 12 0.017944472 Thank you in advance! -- Best regards, Andy [[alternative HTML version deleted]]
On Thu, Jul 16, 2009 at 10:09 PM, Andriy Fetsun <fetsun at googlemail.com> wrote:> ? [1] ?0.000000e+00 ?1.890000e-04 ?3.933000e-05 ?1.701501e-04 ?2.040456e-04 > ? [6] ?3.119242e-04 ?2.545665e-04 ?1.893930e-03 ?1.303112e-03 ?9.880183e-04 > ?[11] ?1.504378e-03 ?1.549246e-03 ?5.877690e-04 ?4.771359e-04 ?8.528219e-04That it a vector of length 15.> How is it possible to transform the data to get a vector as following > > 10 ? 0.017511063 > 11 ? 0.017819918 > 12 ? 0.017944472That looks like a 3x2 matrix. How do you get that from the vector above? -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/
On 17/07/2009, at 8:09 AM, Andriy Fetsun wrote:> Hi Colleagues, > > Could you please help? > > I get as the output of my calculations following > > [1] 0.000000e+00 1.890000e-04 3.933000e-05 1.701501e-04 > 2.040456e-04 > [6] 3.119242e-04 2.545665e-04 1.893930e-03 1.303112e-03 > 9.880183e-04 > [11] 1.504378e-03 1.549246e-03 5.877690e-04 4.771359e-04 > 8.528219e-04 > > How is it possible to transform the data to get a vector as following > > 10 0.017511063 > 11 0.017819918 > 12 0.017944472 > > > Thank you in advance!Huh? What about: foo <- function(x){ y <- matrix(c(0.017511063,0.017819918,0.017944472),ncol=1) rownames(y) <- 10:12 y } (Translation: Your question makes absolutely no sense at all.) cheers, Rolf Turner ###################################################################### Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
I'm guessing you want to perform some sort of transformation on all the elements in the matrix you've posted and that you've only presented those 3 elements as an example of how the transformation will affect those 3 elements. Is that right? -- David -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Andriy Fetsun Sent: Thursday, July 16, 2009 4:10 PM To: r-help-request at r-project.org; r-help at r-project.org Subject: [R] Transformation of data! Hi Colleagues, Could you please help? I get as the output of my calculations following [1] 0.000000e+00 1.890000e-04 3.933000e-05 1.701501e-04 2.040456e-04 [6] 3.119242e-04 2.545665e-04 1.893930e-03 1.303112e-03 9.880183e-04 [11] 1.504378e-03 1.549246e-03 5.877690e-04 4.771359e-04 8.528219e-04 How is it possible to transform the data to get a vector as following 10 0.017511063 11 0.017819918 12 0.017944472 Thank you in advance! -- Best regards, Andy [[alternative HTML version deleted]] ______________________________________________ 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.
That is what you have. It just prints to screen that way. If you want you could put it into a one column data.frame, that is, mydata <- data.frame(myvector) which may give you the layout you want. --- On Thu, 7/16/09, Andriy Fetsun <fetsun at googlemail.com> wrote:> From: Andriy Fetsun <fetsun at googlemail.com> > Subject: [R] Transformation of data! > To: r-help-request at r-project.org, r-help at r-project.org > Received: Thursday, July 16, 2009, 4:09 PM > Hi Colleagues, > > Could you please help? > > I get as the output of my calculations following > > ???[1]? 0.000000e+00? > 1.890000e-04? 3.933000e-05? 1.701501e-04? > 2.040456e-04 > ???[6]? 3.119242e-04? > 2.545665e-04? 1.893930e-03? 1.303112e-03? > 9.880183e-04 > ? [11]? 1.504378e-03? 1.549246e-03? > 5.877690e-04? 4.771359e-04? 8.528219e-04 > > How is it possible to transform the data to get a vector as > following > > 10???0.017511063 > 11???0.017819918 > 12???0.017944472 > > > Thank you in advance! > > -- > Best regards, > > Andy > > ??? [[alternative HTML version deleted]] > > ______________________________________________ > 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. >__________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com.
On Fri, Jul 17, 2009 at 10:29 AM, Andriy Fetsun<fetsun at googlemail.com> wrote:> I want to perform some sort of transformation on all the > elements in the matrix I have posted and that I have only presented > those 3 elements as an example of how the transformation will affect > those 3 elements. > > Do you see the problem now?Hmmm ... I don't think to. If you have a function f, you can apply it to all elements in a vector x by simply typing f(x). If you want to arrange it in two columns as you suggest, you could do cbind(1:length(x),f(x)), but I really can't see why you would ever want to do that.> Here the proposed by R-guy solution > > ?mydata <- data.frame(W21)Where is your function, and what is W21? -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/