Given a vector;> ab = seq(0.5,1, by=0.1)> ab[1] 0.5 0.6 0.7 0.8 0.9 1.0 The euclidean distance between the vector elements is given by the lower triangular matrix > dd1 = dist(ab,"euclidean")> dd1 1 2 3 4 52 0.1 3 0.2 0.1 4 0.3 0.2 0.1 5 0.4 0.3 0.2 0.1 6 0.5 0.4 0.3 0.2 0.1 Convert the lower triangular matrix to a full matrix> ddm = as.matrix(dd1)> ddm 1 2 3 4 5 61 0.0 0.1 0.2 0.3 0.4 0.52 0.1 0.0 0.1 0.2 0.3 0.43 0.2 0.1 0.0 0.1 0.2 0.34 0.3 0.2 0.1 0.0 0.1 0.25 0.4 0.3 0.2 0.1 0.0 0.16 0.5 0.4 0.3 0.2 0.1 0.0 I would be grateful if someone could provide me with a code to convert ddm to the lower triangular matrix as before i.e. dd1 above. Your help will be greatly appreciated.JN [[alternative HTML version deleted]]
This is R-help, not the linear algebra hotline. Please stay on topic.
---------------------------------------------------------------------------
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.
Juliet Ndukum <jpntsang at yahoo.com> wrote:
>Given a vector;> ab = seq(0.5,1, by=0.1)> ab[1] 0.5 0.6 0.7 0.8 0.9
1.0
>The euclidean distance between the vector elements is given by the
>lower triangular matrix?> dd1 = dist(ab,"euclidean")> dd1? ?
1 ? 2 ? 3
>? 4 ? 52 0.1 ? ? ? ? ? ? ? ?3 0.2 0.1 ? ? ? ? ? ?4 0.3 0.2 0.1 ? ? ? ?5
>0.4 0.3 0.2 0.1 ? ?6 0.5 0.4 0.3 0.2 0.1
>Convert the lower triangular matrix to a full matrix> ddm
>as.matrix(dd1)> ddm? ? 1 ? 2 ? 3 ? 4 ? 5 ? 61 0.0 0.1 0.2 0.3 0.4 0.52
>0.1 0.0 0.1 0.2 0.3 0.43 0.2 0.1 0.0 0.1 0.2 0.34 0.3 0.2 0.1 0.0 0.1
>0.25 0.4 0.3 0.2 0.1 0.0 0.16 0.5 0.4 0.3 0.2 0.1 0.0
>I would be grateful if someone could provide me with a code to convert
>ddm to the lower triangular matrix as before i.e. dd1
> above.
>Your help will be greatly appreciated.JN
> [[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.
On Nov 15, 2011, at 5:38 PM, Juliet Ndukum wrote:> Given a vector;> ab = seq(0.5,1, by=0.1)> > ab[1] 0.5 0.6 0.7 0.8 0.9 1.0 > The euclidean distance between the vector elements is given by the > lower triangular matrix> > dd1 = dist(ab,"euclidean")> > dd1 1 2 3 4 5> 2 0.1 > 3 0.2 0.1 > 4 0.3 0.2 0.1 > 5 0.4 0.3 0.2 0.1 > 6 0.5 0.4 0.3 0.2 0.1 > Convert the lower triangular matrix to a full matrix> > ddm = as.matrix(dd1)> > ddm 1 2 3 4 5 61 0.0 0.1 0.2 0.3 0.4 0.52 0.1 0.0 0.1 > 0.2 0.3 0.43 0.2 0.1 0.0 0.1 0.2 0.34 0.3 0.2 0.1 0.0 0.1 0.25 0.4 > 0.3 0.2 0.1 0.0 0.16 0.5 0.4 0.3 0.2 0.1 0.0 > I would be grateful if someone could provide me with a code to > convert ddm to the lower triangular matrix as before i.e. dd1Surely this would be the logical inverse dd1.b <- as.dist(ddm) -- David Winsemius, MD West Hartford, CT
On Tue, Nov 15, 2011 at 2:38 PM, Juliet Ndukum <jpntsang at yahoo.com> wrote:> Given a vector;> ab = seq(0.5,1, by=0.1)> ab[1] 0.5 0.6 0.7 0.8 0.9 1.0 > The euclidean distance between the vector elements is given by the lower triangular matrix?> dd1 = dist(ab,"euclidean")> dd1? ? 1 ? 2 ? 3 ? 4 ? 52 0.1 ? ? ? ? ? ? ? ?3 0.2 0.1 ? ? ? ? ? ?4 0.3 0.2 0.1 ? ? ? ?5 0.4 0.3 0.2 0.1 ? ?6 0.5 0.4 0.3 0.2 0.1 > Convert the lower triangular matrix to a full matrix> ddm = as.matrix(dd1)> ddm? ? 1 ? 2 ? 3 ? 4 ? 5 ? 61 0.0 0.1 0.2 0.3 0.4 0.52 0.1 0.0 0.1 0.2 0.3 0.43 0.2 0.1 0.0 0.1 0.2 0.34 0.3 0.2 0.1 0.0 0.1 0.25 0.4 0.3 0.2 0.1 0.0 0.16 0.5 0.4 0.3 0.2 0.1 0.0 > I would be grateful if someone could provide me with a code to convert ddm to the lower triangular matrix as before i.e. dd1 > ?above.as.dist(ddm) Peter
1. Please post in plain text, not HTML (as the posting guide asks!) 2. This might actually be an R question -- is ?lower.tri what you want? -- Bert On Tue, Nov 15, 2011 at 2:50 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:> This is R-help, not the linear algebra hotline. Please stay on topic. > --------------------------------------------------------------------------- > 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. > > Juliet Ndukum <jpntsang at yahoo.com> wrote: > >>Given a vector;> ab = seq(0.5,1, by=0.1)> ab[1] 0.5 0.6 0.7 0.8 0.9 1.0 >>The euclidean distance between the vector elements is given by the >>lower triangular matrix?> dd1 = dist(ab,"euclidean")> dd1? ? 1 ? 2 ? 3 >>? 4 ? 52 0.1 ? ? ? ? ? ? ? ?3 0.2 0.1 ? ? ? ? ? ?4 0.3 0.2 0.1 ? ? ? ?5 >>0.4 0.3 0.2 0.1 ? ?6 0.5 0.4 0.3 0.2 0.1 >>Convert the lower triangular matrix to a full matrix> ddm >>as.matrix(dd1)> ddm? ? 1 ? 2 ? 3 ? 4 ? 5 ? 61 0.0 0.1 0.2 0.3 0.4 0.52 >>0.1 0.0 0.1 0.2 0.3 0.43 0.2 0.1 0.0 0.1 0.2 0.34 0.3 0.2 0.1 0.0 0.1 >>0.25 0.4 0.3 0.2 0.1 0.0 0.16 0.5 0.4 0.3 0.2 0.1 0.0 >>I would be grateful if someone could provide me with a code to convert >>ddm to the lower triangular matrix as before i.e. dd1 >> above. >>Your help will be greatly appreciated.JN >> ? ? ? [[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. > > ______________________________________________ > 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. >-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
A follow-up on the data/variable issue I posted earlier:
Here was what I did, which might was obviously causing the problem:
I inserted the following line in my file "Rprofile.site":
setwd("z:/R")
Then, as soon as I run R (before I read any data) I issue
summary(mydata)
I get summary statistics for a dozen variables from a file that
appeared to reside in z:/R.
Am I not supposed to set the working directory by the line above
(which brings me to my preferred working directory each time I run R)?
At 06:05 PM 11/15/2011, Steven Yen wrote:>Can someone help me with this variable/data reading issue?
>I read a csv file and transform/create an additional variable (called y).
>
>The first set of commands below produced different sample statistics
>for hw11$y and y
>
>In the second set of command I renameuse the variable name yy, and
>sample statistics for $hw11$yy and yy are identical.
>
>Using y <- yy fixed it, but I am not sure why I would need to do that.
>
>That "y" appeared to have come from a variable called
"y" from
>another data frame (unrelated to the current run).
>
>Help!
>
> > setwd("z:/homework")
> > sink ("z:/homework/hw11.our", append=T, split=T)
> > hw11 <- read.csv("ij10b.csv",header=T)
> > hw11$y <- hw11$e3
> > attach(hw11)
>The following object(s) are masked _by_ '.GlobalEnv':
> y
> > (n <- dim(hw11)[1])
>[1] 13765
> > summary(hw11$y)
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> 0.0000 0.4500 1.0000 1.6726 2.0000 140.0000
> > length(hw11$y)
>[1] 13765
> > summary(y)
> Min. 1st Qu. Median Mean 3rd Qu. Max.
>0.00000 0.00000 0.00000 0.24958 0.00000 1.00000
> > length(y)
>[1] 601
> >
>
> > setwd("z:/homework")
> > sink ("z:/homework/hw11.our", append=T, split=T)
> > hw11 <- read.csv("ij10b.csv",header=T)
> > hw11$yy <- hw11$e3
> > attach(hw11)
> > hw11$yy <- hw11$e3
> > summary(hw11$yy)
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> 0.0000 0.4500 1.0000 1.6726 2.0000 140.0000
> > length(hw11$yy)
>[1] 13765
> > summary(yy)
> Min. 1st Qu. Median Mean 3rd Qu. Max.
> 0.0000 0.4500 1.0000 1.6726 2.0000 140.0000
> > length(yy)
>[1] 13765
> >
>
>--
>Steven T. Yen, Professor of Agricultural Economics
>The University of Tennessee
>http://web.utk.edu/~syen/
--
Steven T. Yen, Professor of Agricultural Economics
The University of Tennessee
http://web.utk.edu/~syen/
[[alternative HTML version deleted]]