text:
Question: problem with using GSVA package
0
7.8 years ago by
Wendy Qiao360
Wendy Qiao360 wrote:
Hi all, I am trying to use the GSVA package, but I encounter the following problems. library(GSVA) Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/Library/Frameworks/R.framework/Versions/2.14/Resources/library/GSVA/ libs/x86_64/GSVA.so': dlopen(/Library/Frameworks/R.framework/Versions/2.14/Resources/library /GSVA/libs/x86_64/GSVA.so, 6): Symbol not found: _gsl_cdf_ugaussian_P Referenced from: /Library/Frameworks/R.framework/Versions/2.14/Resources/library/GSVA/l ibs/x86_64/GSVA.so Expected in: dynamic lookup Error: package/namespace load failed for GSVA I tried to re-install the package and recompile all the packages, but it still gave the same error. Could anybody please help? Thank you so much! Wendy [[alternative HTML version deleted]]
gsva • 951 views
modified 7.8 years ago by Robert Castelo2.3k • written 7.8 years ago by Wendy Qiao360
Answer: problem with using GSVA package
0
7.8 years ago by
Robert Castelo2.3k
Spain/Barcelona/Universitat Pompeu Fabra
Robert Castelo2.3k wrote:
Hi Robert, Thank you very much for your reply. I tried your comments. Everything worked fine until "make install". This comment gives the following errors. Any suggestion is appreciated. Thank you very much. Making install in gsl make[2]: Nothing to be done for install-exec-am'. make[2]: Nothing to be done for install-data-am'. Making install in utils make[2]: Nothing to be done for install-exec-am'. make[2]: Nothing to be done for install-data-am'. Making install in sys make[2]: Nothing to be done for install-exec-am'. test -z "/usr/local/include/gsl" || .././install-sh -c -d "/usr/local/include/gsl" mkdir: /usr/local/include: Permission denied mkdir: /usr/local/include: No such file or directory make[2]: *** [install-pkgincludeHEADERS] Error 1 make[1]: *** [install-am] Error 2 make: *** [install-recursive] Error 1 Wendy On 7 November 2011 07:32, Juan Roberto CASTELO VALDUEZA < robert.castelo@upf.edu> wrote: > hi Wendy, > > sorry about that, i forgot to say that you need to install in your > computer the so-called GNU Scientific Library from: > > http://www.gnu.org/s/gsl > > this is not part of R and should be installed separately. seeing your > output, i guess that you're working on an apple computer. in such a case > you can just try the following: > > 1. download the tarball in your Desktop > > http://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > > 2. open the terminal window from Applications -> Utilities -> Terminal > > 3. write in the terminal window the following commands > > cd Desktop > cd gsl* > ./configure > make > make install > > if these commands are executed without errors, then you can go back to R > and should be able to install GSVA without problems. let me know if you > encounter any difficulty with this. > > cheers, > robert. > > ------------------------------ > From Wendy Qiao <wendy2.qiao@gmail.com> > Sent Mon 11/7/2011 12:51 PM > To bioconductor@r-project.org > Subject [BioC] problem with using GSVA package > > Hi all, > > I am trying to use the GSVA package, but I encounter the following problems. > > library(GSVA) > Error in dyn.load(file, DLLpath = DLLpath, ...) : > unable to load shared object > '/Library/Frameworks/R.framework/Versions/2.14/Resources/library/GSV A/libs/x86_64/GSVA.so': > > dlopen(/Library/Frameworks/R.framework/Versions/2.14/Resources/libra ry/GSVA/libs/x86_64/GSVA.so, > 6): Symbol not found: _gsl_cdf_ugaussian_P > Referenced from: > /Library/Frameworks/R.framework/Versions/2.14/Resources/library/GSVA /libs/ > x86_64/GSVA.so > Expected in: dynamic lookup > > Error: package/namespace load failed for GSVA > > I tried to re-install the package and recompile all the packages, but it > still gave the same error. Could anybody please help? Thank you so much! > > Wendy > > [[alternative HTML version deleted]] > > > > ------------------------------ > > _______________________________________________ > Bioconductor mailing listBioconductor@r-project.orghttps://stat.ethz .ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > [[alternative HTML version deleted]]
hi, i think i forgot again something. those steps try to make a "system-wide" installation by default trying to write to parts of the filesystem where one need's extra privileges to do it. please try, instead of make install write sudo make install then the system will ask for your password, enter your password and hopefully everything should go fine. let me know. cheers, robert. On Mon, 2011-11-07 at 07:56 -0500, Wendy Qiao wrote: > Hi Robert, > > > Thank you very much for your reply. I tried your comments. Everything > worked fine until "make install". This comment gives the following > errors. Any suggestion is appreciated. Thank you very much. > > > Making install in gsl > make[2]: Nothing to be done for install-exec-am'. > make[2]: Nothing to be done for install-data-am'. > Making install in utils > make[2]: Nothing to be done for install-exec-am'. > make[2]: Nothing to be done for install-data-am'. > Making install in sys > make[2]: Nothing to be done for install-exec-am'. > test -z "/usr/local/include/gsl" || .././install-sh -c -d > "/usr/local/include/gsl" > mkdir: /usr/local/include: Permission denied > mkdir: /usr/local/include: No such file or directory > make[2]: *** [install-pkgincludeHEADERS] Error 1 > make[1]: *** [install-am] Error 2 > make: *** [install-recursive] Error 1 > > > Wendy > > > > On 7 November 2011 07:32, Juan Roberto CASTELO VALDUEZA > <robert.castelo at="" upf.edu=""> wrote: > hi Wendy, > > sorry about that, i forgot to say that you need to install in > your computer the so-called GNU Scientific Library from: > > http://www.gnu.org/s/gsl > > this is not part of R and should be installed separately. > seeing your output, i guess that you're working on an apple > computer. in such a case you can just try the following: > > 1. download the tarball in your Desktop > > http://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > > > 2. open the terminal window from Applications -> Utilities -> > Terminal > > 3. write in the terminal window the following commands > > cd Desktop > cd gsl* > ./configure > make > make install > > if these commands are executed without errors, then you can go > back to R and should be able to install GSVA without problems. > let me know if you encounter any difficulty with this. > > cheers, > robert. > > > ______________________________________________________________ > From Wendy Qiao <wendy2.qiao at="" gmail.com=""> > Sent Mon 11/7/2011 12:51 PM > To bioconductor at r-project.org > Subject [BioC] problem with using GSVA package > > > Hi all, I am trying to use the GSVA package, but I encounter > the following problems. library(GSVA) Error in dyn.load(file, > DLLpath = DLLpath, ...) : unable to load shared object > '/Library/Frameworks/R.framework/Versions/2.14/Resources/lib rary/GSVA/libs/x86_64/GSVA.so': dlopen(/Library/Frameworks/R.framework /Versions/2.14/Resources/library/GSVA/libs/x86_64/GSVA.so, 6): Symbol not found: _gsl_cdf_ugaussian_P Referenced from: /Library/Frameworks/R .framework/Versions/2.14/Resources/library/GSVA/libs/ > x86_64/GSVA.so > Expected in: dynamic lookup > > Error: package/namespace load failed for ?GSVA? > > I tried to re-install the package and recompile all the packages, but it > still gave the same error. Could anybody please help? Thank you so much! > > Wendy > > [[alternative HTML version deleted]] > > > > ______________________________________________________________ > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >
This package looks interesting, but when I tried installing GSVA ( V1.20) it failed with "Cannot find the GNU Scientific Library >= 1.6" I have gsl-1.14 installed and the bioc web pages states gsl>=1.12 David -----Original Message----- From: bioconductor-bounces@r-project.org [mailto:bioconductor- bounces@r-project.org] On Behalf Of Robert Castelo Sent: Monday, November 07, 2011 9:03 AM To: Wendy Qiao Cc: bioconductor at r-project.org Subject: Re: [BioC] problem with using GSVA package hi, i think i forgot again something. those steps try to make a "system-wide" installation by default trying to write to parts of the filesystem where one need's extra privileges to do it. please try, instead of make install write sudo make install then the system will ask for your password, enter your password and hopefully everything should go fine. let me know. cheers, robert. On Mon, 2011-11-07 at 07:56 -0500, Wendy Qiao wrote: > Hi Robert, > > > Thank you very much for your reply. I tried your comments. Everything > worked fine until "make install". This comment gives the following > errors. Any suggestion is appreciated. Thank you very much. > > > Making install in gsl > make[2]: Nothing to be done for install-exec-am'. > make[2]: Nothing to be done for install-data-am'. > Making install in utils > make[2]: Nothing to be done for install-exec-am'. > make[2]: Nothing to be done for install-data-am'. > Making install in sys > make[2]: Nothing to be done for install-exec-am'. > test -z "/usr/local/include/gsl" || .././install-sh -c -d > "/usr/local/include/gsl" > mkdir: /usr/local/include: Permission denied > mkdir: /usr/local/include: No such file or directory > make[2]: *** [install-pkgincludeHEADERS] Error 1 > make[1]: *** [install-am] Error 2 > make: *** [install-recursive] Error 1 > > > Wendy > > > > On 7 November 2011 07:32, Juan Roberto CASTELO VALDUEZA > <robert.castelo at="" upf.edu=""> wrote: > hi Wendy, > > sorry about that, i forgot to say that you need to install in > your computer the so-called GNU Scientific Library from: > > http://www.gnu.org/s/gsl > > this is not part of R and should be installed separately. > seeing your output, i guess that you're working on an apple > computer. in such a case you can just try the following: > > 1. download the tarball in your Desktop > > http://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > > > 2. open the terminal window from Applications -> Utilities -> > Terminal > > 3. write in the terminal window the following commands > > cd Desktop > cd gsl* > ./configure > make > make install > > if these commands are executed without errors, then you can go > back to R and should be able to install GSVA without problems. > let me know if you encounter any difficulty with this. > > cheers, > robert. > > > ______________________________________________________________ > From Wendy Qiao <wendy2.qiao at="" gmail.com=""> > Sent Mon 11/7/2011 12:51 PM > To bioconductor at r-project.org > Subject [BioC] problem with using GSVA package > > > Hi all, I am trying to use the GSVA package, but I encounter > the following problems. library(GSVA) Error in dyn.load(file, > DLLpath = DLLpath, ...) : unable to load shared object > '/Library/Frameworks/R.framework/Versions/2.14/Resources/lib rary/GSVA/libs/x86_64/GSVA.so': dlopen(/Library/Frameworks/R.framework /Versions/2.14/Resources/library/GSVA/libs/x86_64/GSVA.so, 6): Symbol not found: _gsl_cdf_ugaussian_P Referenced from: /Library/Frameworks/R .framework/Versions/2.14/Resources/library/GSVA/libs/ > x86_64/GSVA.so > Expected in: dynamic lookup > > Error: package/namespace load failed for ?GSVA? > > I tried to re-install the package and recompile all the packages, but it > still gave the same error. Could anybody please help? Thank you so much! > > Wendy > > [[alternative HTML version deleted]] > > > > ______________________________________________________________ > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > _______________________________________________ Bioconductor mailing list Bioconductor at r-project.org https://stat.ethz.ch/mailman/listinfo/bioconductor Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
hi David, you're right, i'm able to reproduce this error in my linux box, in the transition to the latest released something that escaped to my eye changed that created this problem. i'll try to find out and write back to you with the solution. in the meantime, please let me know whether you're on linux, windows or mac and whether you're on the latest R version 2.14. sorry for the inconvinience, robert. On Mon, 2011-11-07 at 11:52 -0500, Lapointe, David wrote: > This package looks interesting, but when I tried installing GSVA ( V1.20) it failed with > "Cannot find the GNU Scientific Library >= 1.6" > > I have gsl-1.14 installed and the bioc web pages states gsl>=1.12 > > David > > -----Original Message----- > From: bioconductor-bounces at r-project.org [mailto:bioconductor- bounces at r-project.org] On Behalf Of Robert Castelo > Sent: Monday, November 07, 2011 9:03 AM > To: Wendy Qiao > Cc: bioconductor at r-project.org > Subject: Re: [BioC] problem with using GSVA package > > hi, i think i forgot again something. those steps try to make a > "system-wide" installation by default trying to write to parts of the > filesystem where one need's extra privileges to do it. > > please try, instead of > > make install > > write > > sudo make install > > then the system will ask for your password, enter your password and > hopefully everything should go fine. let me know. > > cheers, > robert. > > On Mon, 2011-11-07 at 07:56 -0500, Wendy Qiao wrote: > > Hi Robert, > > > > > > Thank you very much for your reply. I tried your comments. Everything > > worked fine until "make install". This comment gives the following > > errors. Any suggestion is appreciated. Thank you very much. > > > > > > Making install in gsl > > make[2]: Nothing to be done for install-exec-am'. > > make[2]: Nothing to be done for install-data-am'. > > Making install in utils > > make[2]: Nothing to be done for install-exec-am'. > > make[2]: Nothing to be done for install-data-am'. > > Making install in sys > > make[2]: Nothing to be done for install-exec-am'. > > test -z "/usr/local/include/gsl" || .././install-sh -c -d > > "/usr/local/include/gsl" > > mkdir: /usr/local/include: Permission denied > > mkdir: /usr/local/include: No such file or directory > > make[2]: *** [install-pkgincludeHEADERS] Error 1 > > make[1]: *** [install-am] Error 2 > > make: *** [install-recursive] Error 1 > > > > > > Wendy > > > > > > > > On 7 November 2011 07:32, Juan Roberto CASTELO VALDUEZA > > <robert.castelo at="" upf.edu=""> wrote: > > hi Wendy, > > > > sorry about that, i forgot to say that you need to install in > > your computer the so-called GNU Scientific Library from: > > > > http://www.gnu.org/s/gsl > > > > this is not part of R and should be installed separately. > > seeing your output, i guess that you're working on an apple > > computer. in such a case you can just try the following: > > > > 1. download the tarball in your Desktop > > > > http://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > > > > > > 2. open the terminal window from Applications -> Utilities -> > > Terminal > > > > 3. write in the terminal window the following commands > > > > cd Desktop > > cd gsl* > > ./configure > > make > > make install > > > > if these commands are executed without errors, then you can go > > back to R and should be able to install GSVA without problems. > > let me know if you encounter any difficulty with this. > > > > cheers, > > robert. > > > > > > ______________________________________________________________ > > From Wendy Qiao <wendy2.qiao at="" gmail.com=""> > > Sent Mon 11/7/2011 12:51 PM > > To bioconductor at r-project.org > > Subject [BioC] problem with using GSVA package > > > > > > Hi all, I am trying to use the GSVA package, but I encounter > > the following problems. library(GSVA) Error in dyn.load(file, > > DLLpath = DLLpath, ...) : unable to load shared object > > '/Library/Frameworks/R.framework/Versions/2.14/Resources/l ibrary/GSVA/libs/x86_64/GSVA.so': dlopen(/Library/Frameworks/R.framewo rk/Versions/2.14/Resources/library/GSVA/libs/x86_64/GSVA.so, 6): Symbol not found: _gsl_cdf_ugaussian_P Referenced from: /Library/Frame works/R.framework/Versions/2.14/Resources/library/GSVA/libs/ > > x86_64/GSVA.so > > Expected in: dynamic lookup > > > > Error: package/namespace load failed for ?GSVA? > > > > I tried to re-install the package and recompile all the packages, but it > > still gave the same error. Could anybody please help? Thank you so much! > > > > Wendy > > > > [[alternative HTML version deleted]] > > > > > > > > ______________________________________________________________ > > _______________________________________________ > > Bioconductor mailing list > > Bioconductor at r-project.org > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
Hi Robert, I am on Linux (Fedora 14) and gsl is installed as a RPM. I have updated to R 2.14. Other packages installed fine. David -----Original Message----- From: Robert Castelo [mailto:robert.castelo@upf.edu] Sent: Monday, November 07, 2011 12:24 PM To: Lapointe, David Cc: bioconductor at r-project.org Subject: RE: [BioC] problem with using GSVA package hi David, you're right, i'm able to reproduce this error in my linux box, in the transition to the latest released something that escaped to my eye changed that created this problem. i'll try to find out and write back to you with the solution. in the meantime, please let me know whether you're on linux, windows or mac and whether you're on the latest R version 2.14. sorry for the inconvinience, robert. On Mon, 2011-11-07 at 11:52 -0500, Lapointe, David wrote: > This package looks interesting, but when I tried installing GSVA ( V1.20) it failed with > "Cannot find the GNU Scientific Library >= 1.6" > > I have gsl-1.14 installed and the bioc web pages states gsl>=1.12 > > David > > -----Original Message----- > From: bioconductor-bounces at r-project.org [mailto:bioconductor- bounces at r-project.org] On Behalf Of Robert Castelo > Sent: Monday, November 07, 2011 9:03 AM > To: Wendy Qiao > Cc: bioconductor at r-project.org > Subject: Re: [BioC] problem with using GSVA package > > hi, i think i forgot again something. those steps try to make a > "system-wide" installation by default trying to write to parts of the > filesystem where one need's extra privileges to do it. > > please try, instead of > > make install > > write > > sudo make install > > then the system will ask for your password, enter your password and > hopefully everything should go fine. let me know. > > cheers, > robert. > > On Mon, 2011-11-07 at 07:56 -0500, Wendy Qiao wrote: > > Hi Robert, > > > > > > Thank you very much for your reply. I tried your comments. Everything > > worked fine until "make install". This comment gives the following > > errors. Any suggestion is appreciated. Thank you very much. > > > > > > Making install in gsl > > make[2]: Nothing to be done for install-exec-am'. > > make[2]: Nothing to be done for install-data-am'. > > Making install in utils > > make[2]: Nothing to be done for install-exec-am'. > > make[2]: Nothing to be done for install-data-am'. > > Making install in sys > > make[2]: Nothing to be done for install-exec-am'. > > test -z "/usr/local/include/gsl" || .././install-sh -c -d > > "/usr/local/include/gsl" > > mkdir: /usr/local/include: Permission denied > > mkdir: /usr/local/include: No such file or directory > > make[2]: *** [install-pkgincludeHEADERS] Error 1 > > make[1]: *** [install-am] Error 2 > > make: *** [install-recursive] Error 1 > > > > > > Wendy > > > > > > > > On 7 November 2011 07:32, Juan Roberto CASTELO VALDUEZA > > <robert.castelo at="" upf.edu=""> wrote: > > hi Wendy, > > > > sorry about that, i forgot to say that you need to install in > > your computer the so-called GNU Scientific Library from: > > > > http://www.gnu.org/s/gsl > > > > this is not part of R and should be installed separately. > > seeing your output, i guess that you're working on an apple > > computer. in such a case you can just try the following: > > > > 1. download the tarball in your Desktop > > > > http://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > > > > > > 2. open the terminal window from Applications -> Utilities -> > > Terminal > > > > 3. write in the terminal window the following commands > > > > cd Desktop > > cd gsl* > > ./configure > > make > > make install > > > > if these commands are executed without errors, then you can go > > back to R and should be able to install GSVA without problems. > > let me know if you encounter any difficulty with this. > > > > cheers, > > robert. > > > > > > ______________________________________________________________ > > From Wendy Qiao <wendy2.qiao at="" gmail.com=""> > > Sent Mon 11/7/2011 12:51 PM > > To bioconductor at r-project.org > > Subject [BioC] problem with using GSVA package > > > > > > Hi all, I am trying to use the GSVA package, but I encounter > > the following problems. library(GSVA) Error in dyn.load(file, > > DLLpath = DLLpath, ...) : unable to load shared object > > '/Library/Frameworks/R.framework/Versions/2.14/Resources/l ibrary/GSVA/libs/x86_64/GSVA.so': dlopen(/Library/Frameworks/R.framewo rk/Versions/2.14/Resources/library/GSVA/libs/x86_64/GSVA.so, 6): Symbol not found: _gsl_cdf_ugaussian_P Referenced from: /Library/Frame works/R.framework/Versions/2.14/Resources/library/GSVA/libs/ > > x86_64/GSVA.so > > Expected in: dynamic lookup > > > > Error: package/namespace load failed for ?GSVA? > > > > I tried to re-install the package and recompile all the packages, but it > > still gave the same error. Could anybody please help? Thank you so much! > > > > Wendy > > > > [[alternative HTML version deleted]] > > > > > > > > ______________________________________________________________ > > _______________________________________________ > > Bioconductor mailing list > > Bioconductor at r-project.org > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor
hi again, could you give me the result of typing gsl-config --version in your terminal window?? thanks, robert. On Mon, 2011-11-07 at 12:35 -0500, Lapointe, David wrote: > Hi Robert, > > I am on Linux (Fedora 14) and gsl is installed as a RPM. I have updated to R 2.14. Other packages installed fine. > > David > > -----Original Message----- > From: Robert Castelo [mailto:robert.castelo at upf.edu] > Sent: Monday, November 07, 2011 12:24 PM > To: Lapointe, David > Cc: bioconductor at r-project.org > Subject: RE: [BioC] problem with using GSVA package > > hi David, > > you're right, i'm able to reproduce this error in my linux box, in the > transition to the latest released something that escaped to my eye > changed that created this problem. i'll try to find out and write back > to you with the solution. in the meantime, please let me know whether > you're on linux, windows or mac and whether you're on the latest R > version 2.14. > > sorry for the inconvinience, > robert. > > On Mon, 2011-11-07 at 11:52 -0500, Lapointe, David wrote: > > This package looks interesting, but when I tried installing GSVA ( V1.20) it failed with > > "Cannot find the GNU Scientific Library >= 1.6" > > > > I have gsl-1.14 installed and the bioc web pages states gsl>=1.12 > > > > David > > > > -----Original Message----- > > From: bioconductor-bounces at r-project.org [mailto:bioconductor- bounces at r-project.org] On Behalf Of Robert Castelo > > Sent: Monday, November 07, 2011 9:03 AM > > To: Wendy Qiao > > Cc: bioconductor at r-project.org > > Subject: Re: [BioC] problem with using GSVA package > > > > hi, i think i forgot again something. those steps try to make a > > "system-wide" installation by default trying to write to parts of the > > filesystem where one need's extra privileges to do it. > > > > please try, instead of > > > > make install > > > > write > > > > sudo make install > > > > then the system will ask for your password, enter your password and > > hopefully everything should go fine. let me know. > > > > cheers, > > robert. > > > > On Mon, 2011-11-07 at 07:56 -0500, Wendy Qiao wrote: > > > Hi Robert, > > > > > > > > > Thank you very much for your reply. I tried your comments. Everything > > > worked fine until "make install". This comment gives the following > > > errors. Any suggestion is appreciated. Thank you very much. > > > > > > > > > Making install in gsl > > > make[2]: Nothing to be done for install-exec-am'. > > > make[2]: Nothing to be done for install-data-am'. > > > Making install in utils > > > make[2]: Nothing to be done for install-exec-am'. > > > make[2]: Nothing to be done for install-data-am'. > > > Making install in sys > > > make[2]: Nothing to be done for install-exec-am'. > > > test -z "/usr/local/include/gsl" || .././install-sh -c -d > > > "/usr/local/include/gsl" > > > mkdir: /usr/local/include: Permission denied > > > mkdir: /usr/local/include: No such file or directory > > > make[2]: *** [install-pkgincludeHEADERS] Error 1 > > > make[1]: *** [install-am] Error 2 > > > make: *** [install-recursive] Error 1 > > > > > > > > > Wendy > > > > > > > > > > > > On 7 November 2011 07:32, Juan Roberto CASTELO VALDUEZA > > > <robert.castelo at="" upf.edu=""> wrote: > > > hi Wendy, > > > > > > sorry about that, i forgot to say that you need to install in > > > your computer the so-called GNU Scientific Library from: > > > > > > http://www.gnu.org/s/gsl > > > > > > this is not part of R and should be installed separately. > > > seeing your output, i guess that you're working on an apple > > > computer. in such a case you can just try the following: > > > > > > 1. download the tarball in your Desktop > > > > > > http://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > > > > > > > > > 2. open the terminal window from Applications -> Utilities -> > > > Terminal > > > > > > 3. write in the terminal window the following commands > > > > > > cd Desktop > > > cd gsl* > > > ./configure > > > make > > > make install > > > > > > if these commands are executed without errors, then you can go > > > back to R and should be able to install GSVA without problems. > > > let me know if you encounter any difficulty with this. > > > > > > cheers, > > > robert. > > > > > > > > > ______________________________________________________________ > > > From Wendy Qiao <wendy2.qiao at="" gmail.com=""> > > > Sent Mon 11/7/2011 12:51 PM > > > To bioconductor at r-project.org > > > Subject [BioC] problem with using GSVA package > > > > > > > > > Hi all, I am trying to use the GSVA package, but I encounter > > > the following problems. library(GSVA) Error in dyn.load(file, > > > DLLpath = DLLpath, ...) : unable to load shared object > > > '/Library/Frameworks/R.framework/Versions/2.14/Resources /library/GSVA/libs/x86_64/GSVA.so': dlopen(/Library/Frameworks/R.frame work/Versions/2.14/Resources/library/GSVA/libs/x86_64/GSVA.so, 6): Symbol not found: _gsl_cdf_ugaussian_P Referenced from: /Library/Frame works/R.framework/Versions/2.14/Resources/library/GSVA/libs/ > > > x86_64/GSVA.so > > > Expected in: dynamic lookup > > > > > > Error: package/namespace load failed for ?GSVA? > > > > > > I tried to re-install the package and recompile all the packages, but it > > > still gave the same error. Could anybody please help? Thank you so much! > > > > > > Wendy > > > > > > [[alternative HTML version deleted]] > > > > > > > > > > > > ______________________________________________________________ > > > _______________________________________________ > > > Bioconductor mailing list > > > Bioconductor at r-project.org > > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > > > > _______________________________________________ > > Bioconductor mailing list > > Bioconductor at r-project.org > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > >
Answer: problem with using GSVA package
0
7.8 years ago by
Robert Castelo2.3k
Spain/Barcelona/Universitat Pompeu Fabra
Robert Castelo2.3k wrote:
hi, ok, it makes sense because i noticed that as long as gsl-config was not available in my PATH variable i could reproduce your error, but as long as i put it in the PATH variable, just as if i had a system-wide installation of GSL, then GSVA was installing even if the supposedly required version was 1.6 (strange too). please make sure that you installation of GSL is such that either gsl-config falls into one of the paths in your PATH environment variable, and it should work, alternatively add the path where gsl-config is to your PATH environment variable. i'll fix in the meantime the 1.6 requirement which in fact does not seem to be causing the real problem, at least on my side. please let me know if you succeed, robert. On Mon, 2011-11-07 at 12:56 -0500, Lapointe, David wrote: > No gsl-config. Strange. > > -----Original Message----- > From: Robert Castelo [mailto:robert.castelo at upf.edu] > Sent: Monday, November 07, 2011 12:50 PM > To: Lapointe, David > Cc: bioconductor at r-project.org > Subject: RE: [BioC] problem with using GSVA package > > hi again, > > could you give me the result of typing > > gsl-config --version > > in your terminal window?? > > thanks, > robert. > > On Mon, 2011-11-07 at 12:35 -0500, Lapointe, David wrote: > > Hi Robert, > > > > I am on Linux (Fedora 14) and gsl is installed as a RPM. I have updated to R 2.14. Other packages installed fine. > > > > David > > > > -----Original Message----- > > From: Robert Castelo [mailto:robert.castelo at upf.edu] > > Sent: Monday, November 07, 2011 12:24 PM > > To: Lapointe, David > > Cc: bioconductor at r-project.org > > Subject: RE: [BioC] problem with using GSVA package > > > > hi David, > > > > you're right, i'm able to reproduce this error in my linux box, in the > > transition to the latest released something that escaped to my eye > > changed that created this problem. i'll try to find out and write back > > to you with the solution. in the meantime, please let me know whether > > you're on linux, windows or mac and whether you're on the latest R > > version 2.14. > > > > sorry for the inconvinience, > > robert. > > > > On Mon, 2011-11-07 at 11:52 -0500, Lapointe, David wrote: > > > This package looks interesting, but when I tried installing GSVA ( V1.20) it failed with > > > "Cannot find the GNU Scientific Library >= 1.6" > > > > > > I have gsl-1.14 installed and the bioc web pages states gsl>=1.12 > > > > > > David > > > > > > -----Original Message----- > > > From: bioconductor-bounces at r-project.org [mailto :bioconductor-bounces at r-project.org] On Behalf Of Robert Castelo > > > Sent: Monday, November 07, 2011 9:03 AM > > > To: Wendy Qiao > > > Cc: bioconductor at r-project.org > > > Subject: Re: [BioC] problem with using GSVA package > > > > > > hi, i think i forgot again something. those steps try to make a > > > "system-wide" installation by default trying to write to parts of the > > > filesystem where one need's extra privileges to do it. > > > > > > please try, instead of > > > > > > make install > > > > > > write > > > > > > sudo make install > > > > > > then the system will ask for your password, enter your password and > > > hopefully everything should go fine. let me know. > > > > > > cheers, > > > robert. > > > > > > On Mon, 2011-11-07 at 07:56 -0500, Wendy Qiao wrote: > > > > Hi Robert, > > > > > > > > > > > > Thank you very much for your reply. I tried your comments. Everything > > > > worked fine until "make install". This comment gives the following > > > > errors. Any suggestion is appreciated. Thank you very much. > > > > > > > > > > > > Making install in gsl > > > > make[2]: Nothing to be done for install-exec-am'. > > > > make[2]: Nothing to be done for install-data-am'. > > > > Making install in utils > > > > make[2]: Nothing to be done for install-exec-am'. > > > > make[2]: Nothing to be done for install-data-am'. > > > > Making install in sys > > > > make[2]: Nothing to be done for install-exec-am'. > > > > test -z "/usr/local/include/gsl" || .././install-sh -c -d > > > > "/usr/local/include/gsl" > > > > mkdir: /usr/local/include: Permission denied > > > > mkdir: /usr/local/include: No such file or directory > > > > make[2]: *** [install-pkgincludeHEADERS] Error 1 > > > > make[1]: *** [install-am] Error 2 > > > > make: *** [install-recursive] Error 1 > > > > > > > > > > > > Wendy > > > > > > > > > > > > > > > > On 7 November 2011 07:32, Juan Roberto CASTELO VALDUEZA > > > > <robert.castelo at="" upf.edu=""> wrote: > > > > hi Wendy, > > > > > > > > sorry about that, i forgot to say that you need to install in > > > > your computer the so-called GNU Scientific Library from: > > > > > > > > http://www.gnu.org/s/gsl > > > > > > > > this is not part of R and should be installed separately. > > > > seeing your output, i guess that you're working on an apple > > > > computer. in such a case you can just try the following: > > > > > > > > 1. download the tarball in your Desktop > > > > > > > > http://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > > > > > > > > > > > > 2. open the terminal window from Applications -> Utilities -> > > > > Terminal > > > > > > > > 3. write in the terminal window the following commands > > > > > > > > cd Desktop > > > > cd gsl* > > > > ./configure > > > > make > > > > make install > > > > > > > > if these commands are executed without errors, then you can go > > > > back to R and should be able to install GSVA without problems. > > > > let me know if you encounter any difficulty with this. > > > > > > > > cheers, > > > > robert. > > > > > > > > > > > > ______________________________________________________________ > > > > From Wendy Qiao <wendy2.qiao at="" gmail.com=""> > > > > Sent Mon 11/7/2011 12:51 PM > > > > To bioconductor at r-project.org > > > > Subject [BioC] problem with using GSVA package > > > > > > > > > > > > Hi all, I am trying to use the GSVA package, but I encounter > > > > the following problems. library(GSVA) Error in dyn.load(file, > > > > DLLpath = DLLpath, ...) : unable to load shared object > > > > '/Library/Frameworks/R.framework/Versions/2.14/Resourc es/library/GSVA/libs/x86_64/GSVA.so': dlopen(/Library/Frameworks/R.fra mework/Versions/2.14/Resources/library/GSVA/libs/x86_64/GSVA.so, 6): Symbol not found: _gsl_cdf_ugaussian_P Referenced from: /Library/Frame works/R.framework/Versions/2.14/Resources/library/GSVA/libs/ > > > > x86_64/GSVA.so > > > > Expected in: dynamic lookup > > > > > > > > Error: package/namespace load failed for ?GSVA? > > > > > > > > I tried to re-install the package and recompile all the packages, but it > > > > still gave the same error. Could anybody please help? Thank you so much! > > > > > > > > Wendy > > > > > > > > [[alternative HTML version deleted]] > > > > > > > > > > > > > > > > ______________________________________________________________ > > > > _______________________________________________ > > > > Bioconductor mailing list > > > > Bioconductor at r-project.org > > > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > > > > > > > _______________________________________________ > > > Bioconductor mailing list > > > Bioconductor at r-project.org > > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > > >
I needed to install gsl-devel. Now it loads. Thanks -----Original Message----- From: Robert Castelo [mailto:robert.castelo@upf.edu] Sent: Monday, November 07, 2011 1:12 PM To: Lapointe, David Cc: bioconductor at r-project.org Subject: RE: [BioC] problem with using GSVA package hi, ok, it makes sense because i noticed that as long as gsl-config was not available in my PATH variable i could reproduce your error, but as long as i put it in the PATH variable, just as if i had a system-wide installation of GSL, then GSVA was installing even if the supposedly required version was 1.6 (strange too). please make sure that you installation of GSL is such that either gsl-config falls into one of the paths in your PATH environment variable, and it should work, alternatively add the path where gsl-config is to your PATH environment variable. i'll fix in the meantime the 1.6 requirement which in fact does not seem to be causing the real problem, at least on my side. please let me know if you succeed, robert. On Mon, 2011-11-07 at 12:56 -0500, Lapointe, David wrote: > No gsl-config. Strange. > > -----Original Message----- > From: Robert Castelo [mailto:robert.castelo at upf.edu] > Sent: Monday, November 07, 2011 12:50 PM > To: Lapointe, David > Cc: bioconductor at r-project.org > Subject: RE: [BioC] problem with using GSVA package > > hi again, > > could you give me the result of typing > > gsl-config --version > > in your terminal window?? > > thanks, > robert. > > On Mon, 2011-11-07 at 12:35 -0500, Lapointe, David wrote: > > Hi Robert, > > > > I am on Linux (Fedora 14) and gsl is installed as a RPM. I have updated to R 2.14. Other packages installed fine. > > > > David > > > > -----Original Message----- > > From: Robert Castelo [mailto:robert.castelo at upf.edu] > > Sent: Monday, November 07, 2011 12:24 PM > > To: Lapointe, David > > Cc: bioconductor at r-project.org > > Subject: RE: [BioC] problem with using GSVA package > > > > hi David, > > > > you're right, i'm able to reproduce this error in my linux box, in the > > transition to the latest released something that escaped to my eye > > changed that created this problem. i'll try to find out and write back > > to you with the solution. in the meantime, please let me know whether > > you're on linux, windows or mac and whether you're on the latest R > > version 2.14. > > > > sorry for the inconvinience, > > robert. > > > > On Mon, 2011-11-07 at 11:52 -0500, Lapointe, David wrote: > > > This package looks interesting, but when I tried installing GSVA ( V1.20) it failed with > > > "Cannot find the GNU Scientific Library >= 1.6" > > > > > > I have gsl-1.14 installed and the bioc web pages states gsl>=1.12 > > > > > > David > > > > > > -----Original Message----- > > > From: bioconductor-bounces at r-project.org [mailto :bioconductor-bounces at r-project.org] On Behalf Of Robert Castelo > > > Sent: Monday, November 07, 2011 9:03 AM > > > To: Wendy Qiao > > > Cc: bioconductor at r-project.org > > > Subject: Re: [BioC] problem with using GSVA package > > > > > > hi, i think i forgot again something. those steps try to make a > > > "system-wide" installation by default trying to write to parts of the > > > filesystem where one need's extra privileges to do it. > > > > > > please try, instead of > > > > > > make install > > > > > > write > > > > > > sudo make install > > > > > > then the system will ask for your password, enter your password and > > > hopefully everything should go fine. let me know. > > > > > > cheers, > > > robert. > > > > > > On Mon, 2011-11-07 at 07:56 -0500, Wendy Qiao wrote: > > > > Hi Robert, > > > > > > > > > > > > Thank you very much for your reply. I tried your comments. Everything > > > > worked fine until "make install". This comment gives the following > > > > errors. Any suggestion is appreciated. Thank you very much. > > > > > > > > > > > > Making install in gsl > > > > make[2]: Nothing to be done for install-exec-am'. > > > > make[2]: Nothing to be done for install-data-am'. > > > > Making install in utils > > > > make[2]: Nothing to be done for install-exec-am'. > > > > make[2]: Nothing to be done for install-data-am'. > > > > Making install in sys > > > > make[2]: Nothing to be done for install-exec-am'. > > > > test -z "/usr/local/include/gsl" || .././install-sh -c -d > > > > "/usr/local/include/gsl" > > > > mkdir: /usr/local/include: Permission denied > > > > mkdir: /usr/local/include: No such file or directory > > > > make[2]: *** [install-pkgincludeHEADERS] Error 1 > > > > make[1]: *** [install-am] Error 2 > > > > make: *** [install-recursive] Error 1 > > > > > > > > > > > > Wendy > > > > > > > > > > > > > > > > On 7 November 2011 07:32, Juan Roberto CASTELO VALDUEZA > > > > <robert.castelo at="" upf.edu=""> wrote: > > > > hi Wendy, > > > > > > > > sorry about that, i forgot to say that you need to install in > > > > your computer the so-called GNU Scientific Library from: > > > > > > > > http://www.gnu.org/s/gsl > > > > > > > > this is not part of R and should be installed separately. > > > > seeing your output, i guess that you're working on an apple > > > > computer. in such a case you can just try the following: > > > > > > > > 1. download the tarball in your Desktop > > > > > > > > http://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz > > > > > > > > > > > > 2. open the terminal window from Applications -> Utilities -> > > > > Terminal > > > > > > > > 3. write in the terminal window the following commands > > > > > > > > cd Desktop > > > > cd gsl* > > > > ./configure > > > > make > > > > make install > > > > > > > > if these commands are executed without errors, then you can go > > > > back to R and should be able to install GSVA without problems. > > > > let me know if you encounter any difficulty with this. > > > > > > > > cheers, > > > > robert. > > > > > > > > > > > > ______________________________________________________________ > > > > From Wendy Qiao <wendy2.qiao at="" gmail.com=""> > > > > Sent Mon 11/7/2011 12:51 PM > > > > To bioconductor at r-project.org > > > > Subject [BioC] problem with using GSVA package > > > > > > > > > > > > Hi all, I am trying to use the GSVA package, but I encounter > > > > the following problems. library(GSVA) Error in dyn.load(file, > > > > DLLpath = DLLpath, ...) : unable to load shared object > > > > '/Library/Frameworks/R.framework/Versions/2.14/Resourc es/library/GSVA/libs/x86_64/GSVA.so': dlopen(/Library/Frameworks/R.fra mework/Versions/2.14/Resources/library/GSVA/libs/x86_64/GSVA.so, 6): Symbol not found: _gsl_cdf_ugaussian_P Referenced from: /Library/Frame works/R.framework/Versions/2.14/Resources/library/GSVA/libs/ > > > > x86_64/GSVA.so > > > > Expected in: dynamic lookup > > > > > > > > Error: package/namespace load failed for ?GSVA? > > > > > > > > I tried to re-install the package and recompile all the packages, but it > > > > still gave the same error. Could anybody please help? Thank you so much! > > > > > > > > Wendy > > > > > > > > [[alternative HTML version deleted]] > > > > > > > > > > > > > > > > ______________________________________________________________ > > > > _______________________________________________ > > > > Bioconductor mailing list > > > > Bioconductor at r-project.org > > > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > > > > > > > _______________________________________________ > > > Bioconductor mailing list > > > Bioconductor at r-project.org > > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > > >


text:
# Enumeration Types in Data Contracts

Enumerations can be expressed in the data contract model. This topic walks through several examples that explain the programming model.

## Enumeration Basics

One way to use enumeration types in the data contract model is to apply the DataContractAttribute attribute to the type. You must then apply the EnumMemberAttribute attribute to each member that must be included in the data contract.

The following example shows two classes. The first uses the enumeration and the second defines the enumeration.

[DataContract]
public class Car
{
[DataMember]
public string model;
[DataMember]
public CarConditionEnum condition;
}

[DataContract(Name = "CarCondition")]
public enum CarConditionEnum
{
[EnumMember]
New,
[EnumMember]
Used,
[EnumMember]
Rental,
Broken,
Stolen
}

<DataContract()>  _
Public Class Car
<DataMember()>  _
Public model As String
<DataMember()>  _
Public condition As CarConditionEnum
End Class

<DataContract(Name := "CarCondition")>  _
Public Enum CarConditionEnum
<EnumMember> NewCar
<EnumMember> Used
<EnumMember> Rental
Broken
Stolen
End Enum

An instance of the Car class can be sent or received only if the condition field is set to one of the values New, Used, or Rental. If the condition is Broken or Stolen, a SerializationException is thrown.

You can use the DataContractAttribute properties (Name and Namespace) as usual for enumeration data contracts.

### Enumeration Member Values

Generally the data contract includes enumeration member names, not numerical values. However, when using the data contract model, if the receiving side is a WCF client, the exported schema preserves the numerical values. Note that this is not the case when using the Using the XmlSerializer Class.

In the preceding example, if condition is set to Used and the data is serialized to XML, the resulting XML is <condition>Used</condition> and not <condition>1</condition>. Therefore, the following data contract is equivalent to the data contract of CarConditionEnum.

[DataContract(Name = "CarCondition")]
public enum CarConditionWithNumbers
{
[EnumMember]
New = 10,
[EnumMember]
Used = 20,
[EnumMember]
Rental = 30,
}

<DataContract(Name := "CarCondition")>  _
Public Enum CarConditionWithNumbers
<EnumMember> NewCar = 10
<EnumMember> Used = 20
<EnumMember> Rental = 30
End Enum

For example, you can use CarConditionEnum on the sending side and CarConditionWithNumbers on the receiving side. Although the sending side uses the value "1" for Used and the receiving side uses the value "20," the XML representation is <condition>Used</condition> for both sides.

To be included in the data contract, you must apply the EnumMemberAttribute attribute. In the .NET Framework, you can always apply the special value 0 (zero) to an enumeration, which is also the default value for any enumeration. However, even this special zero value cannot be serialized unless it is marked with the EnumMemberAttribute attribute.

There are two exceptions to this:

• Flag enumerations (discussed later in this topic).

• Enumeration data members with the EmitDefaultValue property set to false (in which case, the enumeration with the value zero is omitted from the serialized data).

### Customizing Enumeration Member Values

You can customize the enumeration member value that forms a part of the data contract by using the Value property of the EnumMemberAttribute attribute.

For example, the following data contract is also equivalent to the data contract of the CarConditionEnum.

[DataContract(Name = "CarCondition")]
public enum CarConditionWithDifferentNames
{
[EnumMember(Value = "New")]
BrandNew,
[EnumMember(Value = "Used")]
PreviouslyOwned,
[EnumMember]
Rental
}

<DataContract(Name := "CarCondition")>  _
Public Enum CarConditionWithDifferentNames
<EnumMember(Value := "New")> BrandNew
<EnumMember(Value := "Used")>PreviouslyOwned
<EnumMember> Rental
End Enum

When serialized, the value of PreviouslyOwned has the XML representation <condition>Used</condition>.

## Simple Enumerations

You can also serialize enumeration types to which the DataContractAttribute attribute has not been applied. Such enumeration types are treated exactly as previously described, except that every member (that does not have the NonSerializedAttribute attribute applied) is treated as if the EnumMemberAttribute attribute has been applied. For example, the following enumeration implicitly has a data contract equivalent to the preceding CarConditionEnum example.

public enum CarCondition
{
New,
Used,
Rental,
[NonSerialized]
Lost
}

Public Enum CarCondition
[New]
Used
Rental
End Enum

You can use simple enumerations when you do not need to customize the enumeration's data contract name and namespace and the enumeration member values.

#### Notes on Simple Enumerations

Applying the EnumMemberAttribute attribute to simple enumerations has no effect.

It makes no difference whether or not the SerializableAttribute attribute is applied to the enumeration.

The fact that the DataContractSerializer class honors the NonSerializedAttribute attribute applied to enumeration members is different from the behavior of the BinaryFormatter and the SoapFormatter. Both of those serializers ignore the NonSerializedAttribute attribute.

## Flag Enumerations

You can apply the FlagsAttribute attribute to enumerations. In that case, a list of zero or more enumeration values can be sent or received simultaneously.

To do so, apply the DataContractAttribute attribute to the flag enumeration and then mark all the members that are powers of two with the EnumMemberAttribute attribute. Note that to use a flag enumeration, the progression must be an uninterrupted sequence of powers of 2 (for example, 1, 2, 4, 8, 16, 32, 64).

The following steps apply to sending a flag's enumeration value:

1. Attempt to find an enumeration member (with the EnumMemberAttribute attribute applied) that maps to the numeric value. If found, send a list that contains just that member.

2. Attempt to break the numeric value into a sum such that there are enumeration members (each with the EnumMemberAttribute attribute applied) that map to each part of the sum. Send the list of all these members. Note that the greedy algorithm is used to find such a sum, and thus there is no guarantee that such a sum is found even if it is present. To avoid this problem, make sure that the numeric values of the enumeration members are powers of two.

3. If the preceding two steps fail, and the numeric value is nonzero, throw a SerializationException. If the numeric value is zero, send the empty list.

### Example

The following enumeration example can be used in a flag operation.

[DataContract][Flags]
public enum CarFeatures
{
None = 0,
[EnumMember]
AirConditioner = 1,
[EnumMember]
AutomaticTransmission = 2,
[EnumMember]
PowerDoors = 4,
AlloyWheels = 8,
DeluxePackage = AirConditioner | AutomaticTransmission | PowerDoors | AlloyWheels,
[EnumMember]
CDPlayer = 16,
[EnumMember]
TapePlayer = 32,
MusicPackage = CDPlayer | TapePlayer,
[EnumMember]
Everything = DeluxePackage | MusicPackage
}

<DataContract(), Flags()>  _
Public Enum CarFeatures
None = 0
<EnumMember> AirConditioner = 1
<EnumMember> AutomaticTransmission = 2
<EnumMember> PowerDoors = 4
AlloyWheels = 8
DeluxePackage = AirConditioner Or AutomaticTransmission Or PowerDoors Or AlloyWheels
<EnumMember> CDPlayer = 16
<EnumMember> TapePlayer = 32
MusicPackage = CDPlayer Or TapePlayer
<EnumMember>Everything = DeluxePackage Or MusicPackage
End Enum

The following example values are serialized as indicated.

CarFeatures cf1 = CarFeatures.AutomaticTransmission;
//Serialized as <cf1>AutomaticTransmission</cf1>

CarFeatures cf2 = (CarFeatures)5;
//Serialized as <cf2>AirConditioner PowerDoors</cf2> since 5=1+4

CarFeatures cf3 = CarFeatures.MusicPackage;
//Serialized as <cf3>CDPlayer TapePlayer</cf3> since MusicPackage itself is not an EnumMember

CarFeatures cf4 = CarFeatures.Everything;
//Serialized as <cf4>Everything</cf4> since Everything itself is an EnumMember

CarFeatures cf5 = CarFeatures.DeluxePackage;
//Throws a SerializationException since neither DeluxePackage nor AlloyWheels are EnumMembers

CarFeatures cf6 = CarFeatures.None;
//Serialized as the empty list <cf6></cf6> since there is no EnumMember mapped to zero

Private cf1 As CarFeatures = CarFeatures.AutomaticTransmission
'Serialized as <cf1>AutomaticTransmission</cf1>

Private cf2 As CarFeatures = ctype(5,CarFeatures)
'Serialized as <cf2>AirConditioner PowerDoors</cf2> since 5=1+4

Private cf3 As CarFeatures = CarFeatures.MusicPackage
'Serialized as <cf3>CDPlayer TapePlayer</cf3> since MusicPackage
' itself is not an EnumMember.

Private cf4 As CarFeatures = CarFeatures.Everything
'Serialized as <cf4>Everything</cf4> since Everything itself is an EnumMember.

Private cf5 As CarFeatures = CarFeatures.DeluxePackage
'Throws a SerializationException since neither DeluxePackage nor
' AlloyWheels are EnumMembers.

Private cf6 As CarFeatures = CarFeatures.None
'Serialized as the empty list <cf6></cf6> since there is no EnumMember mapped to zero.

format: plain


text:
# A Bayesian look at the Mullah Omar affair

A recent new book by the Dutch journalist Bette Dam, and its English summary published as “The Secret Life of Mullah Omar” by the Zomia Center, maintain that Mullah Omar, the erstwhile leader of the Afghan Taliban, lived in a small village in Afghanistan after the American invasion of late 2001, and stayed there until his death in 2011. Ms Dam’s main informants are former associates of the late Mullah Omar, including his personal driver who spent several years with him hiding in a nondescript house a few miles from the American “Wolverine” FOB, near the capital of Zabul province. This revelation runs contrary to the accepted wisdom, and countless previous reports, including American intelligence assessments, according to which Mr Omar was in Pakistan, presiding over the Quetta Shura, the highest level of command of the Taliban. The new report sparked a lively debate including some knee-jerk reactions by the supporters of the “Taliban as Pakistan’s ISI proxy” theory, who saw Ms Dam’s revelations as an attempt to undermine the role of Pakistani intelligence services in the Afghan insurgency and at the same time whitewash the Taliban’s image at a critical juncture of the US-Taliban talks in Doha.

Regardless of the merits of Bette Dam’s recent report and the solidity of its evidence, a simple Bayesian observation shows that the conditional probability of the Taliban being an ISI proxy given that Mullah Omar lived marginalised in an Afghan village after 2001, is actually greater than its a priori probability.

$P ( T \subset \mathit{ISI} \mid MuOm \in \mathit{Afg} ) \gg P ( T \subset \mathit{ISI} )$

This can be seen with a simple application of Bayes theorem: $P ( A \mid X ) = \frac{ P ( X \mid A ) P ( A ) }{ P ( X ) }$.

The first term to consider is the reversed conditional probability. Considering the independence of judgement — for good and bad — shown by Omar when he was the leader, and assuming that the Taliban are indeed controlled by the Pakistanis, the ISI minders would just be happy to have Mr Omar removed from the decision-making room in Quetta, marginalising him in a symbolic role and deal with more pliable apparatchiks. (In fact, they could run the operation for two years after his death and nobody noticed). Hence we can assume that

$P ( \mathit{MuOm} \in \mathit{Afg} \mid T \subset \mathit{ISI} )$

is “quite high”. The second term to consider, that appears in the denominator of Bayes equation, is the a priori probability of Mullah Omar having lived almost all the time in Afghanistan. Given that nobody gave credit to it, and the widespread disbelief — to put it mildly — surrounding Bette Dam’s new report is but a further confirmation, we can assume that

$P ( \mathit{MoOm} \in \mathit{Afg} ) \ll 1$

Putting the pieces together, the factor that relates the a priori and conditional probabilities of the event “the Taliban are controlled by the ISI” is greater than one, which proves the initial statement.

$\frac{ P ( \mathit{MuOm} \in \mathit{Afg} \mid T \subset \mathit{ISI} ) }{ P ( \mathit{MoOm} \in \mathit{Afg} ) } \gg 1$

So the scholars of the ISI-Taliban nexus, both in Afghanistan and elsewhere, have no reasons to worry about the alleged revelations about the secret life of Mullah Omar, and may even enjoy reading the report itself instead of just berating it on Twitter.

Acknowledgements

Photo by Pierpaolo Lanfrancotti on Unsplash


text:
Corpus ID: 1726173

# Inferring User Preferences by Probabilistic Logical Reasoning over Social Networks

@article{Li2014InferringUP,
title={Inferring User Preferences by Probabilistic Logical Reasoning over Social Networks},
author={J. Li and Alan Ritter and Dan Jurafsky},
journal={ArXiv},
year={2014},
volume={abs/1411.2679}
}
• Published 2014
• Computer Science
• ArXiv
We propose a framework for inferring the latent attitudes or preferences of users by performing probabilistic first-order logical reasoning over the social network graph. Our method answers questions about Twitter users like {\em Does this user like sushi?} or {\em Is this user a New York Knicks fan?} by building a probabilistic model that reasons over user attributes (the user's location or gender) and the social network (the user's friends and spouse), via inferences like homophily (I am more… Expand
15 Citations


text:
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。

## Overview

SLO burn rate alerts notify you when the rate of consumption of your SLO error budget has exceeded your specified threshold and is sustained for a specific period of time. For example, you can set an alert if a burn rate of 14.4 or more is measured for the past hour over the past 5 minutes for your SLO’s 30-day target. And you can set it to optionally warn you for a slightly lower threshold than you would want an alert, for example if a burn rate of 7.2 or more is observed.

Note: Burn rate alerts are only available for metric-based SLOs or for monitor-based SLOs that are only composed of Metric Monitor types (Metric, Integration, APM Metric, Anomaly, Forecast, or Outlier Monitors).

## How Burn Rate Alerts work

A burn rate is a unitless value coined by Google that indicates how fast your error budget is consumed relative to your SLO’s target length. For example, a 30-day target, a burn rate of 1 means your error budget would be fully consumed in exactly 30 days if the rate of 1 was kept constant. A burn rate of 2 means the error budget would be exhausted in 15 days if kept constant, and a burn rate of 3 means 10 days, etc.

This relationship is represented by the following formula:

$${\text"length of SLO target" \text" (7, 30 or 90 days)"} / \text"burn rate" = \text"time until error budget is fully consumed"$$

A burn rate alert will use the recent “error rate” in its calculation to measure the observed burn rate. Note that “error rate” means the ratio of bad behavior over total behavior during a given period:

The units of “behavior” will differ depending on the type of SLO. Metric-based SLOs track the number of occurrences of something (like number of successful or failed requests), while monitor-based SLOs track amounts of time (like downtime and uptime of monitors).

When you set a target for your SLO (like 99.9%), your error budget is the amount of unreliability you’re allowed to have:

In other words, your error budget (in fractional form) is the ideal error rate you should be maintaining. So, a burn rate can alternatively be interpreted as a multiplier of your ideal error rate. For example, for a 99.9% SLO over 30 days, if the SLO is experiencing a burn rate of 10 that means the error budget is on pace to be completely depleted in 3 days and that the observed error rate is 10 times the ideal error rate:

Ideally, you should always try to maintain a burn rate of 1 over the course of your SLO’s target (as you invest in evolving your application with new features). However, in practice, your burn rate will fluctuate as issues or incidents cause your burn rate to increase rapidly until the issue is resolved. Therefore, alerting on burn rates allows you to be proactively notified when an issue is consuming your error budget at an elevated rate that could potentially cause you to miss your SLO target.

When you configure a burn rate alert, you specify the burn rate threshold alongside a “long alerting window” and “short alerting window” over which the observed burn rate will be measured. The long alerting window is specified in hours and ensures the monitor measures the burn rate over a period long enough to correspond to a significant issue. This prevents the monitor from triggering flaky alerts due to minor issues. The short alerting window is specified in minutes. It ensures the monitor recovers quickly after the actual issue is over by checking if the recent burn rate is still above the threshold. Google recommends the short window to be 1/12 of the long window. However, you will be able to customize the short window programmatically in Datadog through the API or with Terraform. Here is the full formula for how the burn rate alert evaluates:

## Maximum burn rate values

As noted above, you can use this formula to evaluate the observed burn rate for both the long window and short window:

The maximum error rate that you can ever observe is 1 (for example, when 100% of the total behavior is bad behavior during the given time period). This means that there is a maximum possible burn rate value that you can use in your burn rate alerts:

The lower your SLO target, the lower your maximum possible burn rate value. If you were to attempt to set a burn rate threshold higher than this value, it would be impossible for the alert to trigger. If you set a burn rate alert’s condition to a value higher than the maximum determined by the above formula, you’re telling the burn rate alert to notify you when your SLO is seeing an error rate greater than 100% (which is impossible). So, to avoid unhelpful alerts from being accidentally created, Datadog blocks the creation of burn rate alerts that set a burn rate value beyond their maximum.

## Picking burn rate values

Picking burn rate values to alert off of depends on the target and time window your SLO uses. When you configure a burn rate alert, your main focus should be on setting the burn rate threshold itself and setting the long window. Datadog recommends initially keeping the short window as 1/12 of the long window, as Google suggests, and then adjust the value if needed after using the alert. Your maximum possible burn rate will be bounded by the relationship described in the previous section.

### Approach #1: Time to error budget depletion

For the burn rate threshold, recall the previous relationship:

Solve for burn rate and pick a time until the error budget is fully consumed that would qualify as a significant issue.

For the long window, choose a period of time that an elevated burn rate would have to be sustained to indicate a real issue rather than a minor transient issue. The higher the burn rate you select, the smaller a long window you should pair it with (so that high severity issues are caught sooner).

### Approach #2: Theoretical error budget consumption

Alternatively, you may think of a burn rate and long window pairing in terms of theoretical error budget consumption:

For example, for a 7-day SLO, to be alerted if the theoretical error budget consumption is 10% with 1 hour as your long window, the selected burn rate should be:

Note: For metric-based SLOs, the relationship in Approach #2 extrapolates the total number of occurrences contained in the long window out to the full length of the SLO target. In practice, the error budget consumption observed won’t correspond exactly to this relationship, as the total occurrences tracked by the metric-based SLO in a rolling window will likely differ throughout the day. A burn rate alert is meant to predict significant amounts of error budget consumption before they occur. For monitor-based SLOs, theoretical error budget consumption and actual error budget consumption are equal because time always moves at a constant rate . For example, 60 minutes of monitor data is aways contained in the 1 hour window.

## Monitor creation

1. Navigate to the SLO status page.
2. Create a new SLO or edit an existing one, then click the Save and Set Alert button. For existing SLOs, you can also click the Set up Alerts button in the SLO detail side panel to take you directly to the alert configuration.
3. Select the Burn Rate tab in Step 1: Setting alerting conditions
4. Set an alert to trigger when a certain burn rate is measured during a specific long window:
• The burn rate value must be in the range
• The long window value is limited to: 1 hour <= long window <= 48 hours.
• In the UI the short window is automatically calculated as: short window = 1/12 * long window.
• You can specify a different short window value using the API or Terraform, but it must always be less than the long window.
6. Click the Save and Exit button on the SLO configuration page.

### Examples

Below are tables of Datadog’s recommended values for 7, 30, and 90-day targets.

• These examples assume a 99.9% target, but they are reasonable for targets as low as 96% (the max burn rate for 96% is 25). However, if you are using lower targets you may require lower thresholds as described in the Maximum Burn Rate Values section, Datadog recommends that you use Approach #2 with either a smaller value for theoretical error budget consumed or a higher value for the long window.
• For metric-based SLOs, the theoretical error budget consumed is calculated by extrapolating the number of total occurrences observed in the long alerting window out to the total length of the SLO target.

For 7-day targets:

Burn rateLong windowShort windowTheoretical error budget consumed
16.81 hour5 minutes10%
5.66 hours30 minutes20%
2.824 hours120 minutes40%

For 30-day targets:

Burn rateLong windowShort windowTheoretical error budget consumed
14.41 hour5 minutes2%
66 hours30 minutes5%
324 hours120 minutes10%

For 90-day targets:

Burn rateLong windowShort windowTheoretical error budget consumed
21.61 hour5 minutes1%
10.86 hours30 minutes3%
4.524 hours120 minutes5%

Recommendation: If you find that your burn rate alert is consistently too flaky, this is an indication that you should make your short window slightly larger. However, note that the larger you make your short window, the slower the monitor will be in recovering after an issue has ended.

### API and Terraform

You can create SLO burn rate alerts using the create-monitor API endpoint. Below is an example query for a burn rate alert, which alerts when a burn rate of 14.4 is measured for the past hour and past 5 minutes. Replace slo_id with the alphanumeric ID of the SLO you wish to configure a burn rate alert on and replace time_window with one of 7d, 30d or 90d - depending on which target is used to configure your SLO:

burn_rate("slo_id").over("time_window").long_window("1h").short_window("5m") > 14.4

In addition, SLO burn rate alerts can also be created using the [datadog_monitor resource in Terraform][6]. Below is an example .tf for configuring a burn rate alert for a metric-based SLO using the same example query as above.

Note: SLO burn rate alerts are only supported in Terraform provider v2.7.0 or earlier and in provider v2.13.0 or later. Versions between v2.7.0 and v2.13.0 are not supported.

resource "datadog_monitor" "metric-based-slo" {
name = "SLO Burn Rate Alert Example"


text:
## 8.2 General Principles

Dilbert: I didn’t have any accurate numbers, so I just made up this one. Studies have shown that accurate numbers aren’t any more useful that the ones you make up.
Pointy-Haired Boss: How many studies showed that?
Dilbert: [beat] Eighty-seven.
(S. Adams, Dilbert, 8 May 2008)

### 8.2.1 Approaches to Data Cleaning

We recognize two main philosophical approaches to data cleaning and validation:

• methodical, and

• narrative.

The methodical approach consists in running through a checklist of potential issues and flagging those that apply to the data.

The narrative approach, on the other hand, consists in exploring the dataset while searching for unlikely or irregular patterns. Which approach the consultant/analyst opts to follow depends on a number of factors, not the least of which is the client’s needs and views on the matter – it is important to discuss this point with the clients.

### 8.2.2 Pros and Cons

The methodical approach focuses on syntax; the checklist is typically context-independent, which means that it (or a subset) can be reused from one project to another, which makes data analysis pipelines easy to implement and automate. In the same vein, common errors are easily identified.

On the flip side, the checklist may be quite extensive and the entire process may prove time-consuming.

The biggest disadvantage of this approach is that it makes it difficult to identify new types of errors. The narrative approach focuses on semantics; even false starts may simultaneously produce data understanding prior to switching to a more mechanical approach.

It is easy, however, to miss important sources of errors and invalid observations when the datasets have a large number of features.

There is an additional downside: domain expertise, coupled with the narrative approach, may bias the process by neglecting “uninteresting” areas of the dataset.

### 8.2.3 Tools and Methods

A non-exhaustive list of common data issues can be found in the Data Cleaning Bingo Card (see Figure 8.1).

Other methods include:

• visualizations – which may help easily identify observations that need to be further examined;

• data summaries – # of missing observations; 5-pt summary, mean, standard deviation, skew, kurtosis, for numerical variables; distribution tables for categorical variables;

• $$n$$-way tables – counts for joint distributions of categorical variables;

• small multiples – tables/visualizations indexed along categorical variables, and

• preliminary data analyses – which may provide “huh, that’s odd…” realizations.

It is important to note that there is nothing wrong with running a number of analyses to flush out data issues, but remember to label your initial forays as preliminary analyses. From the client or stakeholder’s perspective, repeated analyses may create a sense of unease and distrust, even if they form a crucial part of the analytical process.

In our (admittedly biased and incomplete) experience,

• computer scientists and programmers tend to naturally favour the methodical approach, while

• mathematicians (and sometimes statisticians) tend to naturally favour the narrative approach,

although we have met plenty of individuals with unexpected backgrounds in both camps.

This is not the place for identity politics: data scientists, data analysts, and quantitative consultants alike need to be comfortable with both approaches.

As an analogy, the narrative approach is akin to working out a crossword puzzle with a pen and accepting to put down potentially erroneous answers once in a while to try to open up the grid (what artificial intelligence researchers call the “exploration” approach).

The mechanical approach, on the other hand, is similar to working out the puzzle with a pencil and a dictionary, only putting down answers when their correctness is guaranteed (the “exploitation” approach of artificial intelligence).

More puzzles get solved when using the first approach, but missteps tend to be spectacular. Not as many puzzles get solved the second way, but the trade-off is that it leads to fewer mistakes.


text:
1. anonymous

|dw:1435498331270:dw|

2. math&ing001

We got : 1 kg = 2.20462 lb 1 m^3 = 35.3147 ft^3 So: $921* \frac{ 1 kg }{ 1 m ^{3} } = 921*\frac{ 2.20462 }{ 35.3147 } lb _{m}/ft ^{3}$


text:
Corollary to Markov's Inequality [closed]

Here is a particular case of Markov's Inequality that I failed to prove:

Let $X$ be a non-negative integer-valued random variable with $\mathbb{E}(X)\leq m$ then $$\mathbb{P}(X=0)\geq 1-m$$

Does anyone has an idea how to prove this? Thank you.

closed as off-topic by user21820, The Phenotype, zz20s, Ethan Bolker, NamasteFeb 22 '18 at 18:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – user21820, The Phenotype, zz20s, Ethan Bolker, Namaste
If this question can be reworded to fit the rules in the help center, please edit the question.

$$m\geq\mathsf EX=\sum_{n=0}^{\infty}n\mathsf P(X=n)\geq\sum_{n=1}^{\infty}\mathsf P(X=n)=\mathsf P(X\geq1)=1-\mathsf P(X=0)$$
• To find it as corollary of Markovs inequality subtitute $a=1$ in $aP(X\geq a)\leq EX$ and work out. – drhab Feb 22 '18 at 12:05


text:
# PW 7

In this practical work we will learn how to create a report in Rstudio using Rmarkdown files. Then we will apply the $$k$$-means clustering algorithm using the standard function kmeans() in , we will use the dataset Ligue1 2017/2018.

## Reporting

### Markdown

Markdown is a lightweight markup language with plain text formatting syntax designed so that it can be converted to HTML and many other formats (pdf, docx, etc..).

Click here to see an example of a markdown (.md) syntaxes and the result in HTML. The markdown syntaxes are on right and their HTML result is on left. You can modify the source text to see the result.

Extra: There is some markdown online editors you can use, like dillinger.io/. See the Markdown source file and the HTML preview. Play with the source text to see the result in the preview.

### R Markdown

R Markdown is a variant of Markdown that has embedded code chunks, to be used with the knitr package to make it easy to create reproducible web-based reports.

First, in Rstudio create a new R Markdown file. A default template will be opened. There is some code in R chunks. Click on knit, save your file and see the produced output. The output is a html report containing the results of the codes. If your file is named report.Rmd, your report is named report.html.

• Make sure to have the latest version of Rstudio.
• If you have problems creating a R Markdown file (problem in installing packages, etc..) close your Rstudio and reopen it with administrative tools and retry.
• Be ready to submit your report (your .html file) at the end of each class.

• You report must be named:

YouLastName_YourFirstName_WeekNumber.html

You can find all the informations about R Markdown on this site: rmarkdown.rstudio.com.

You may also find the following resources helpful:

### The report to be submitted

In Rstudio, start by creating a R Markdown file. When you create it a default template will be opened with the following first lines:

---
title: "Untitled"
output: html_document
---

These lines are the YAML header in which you choose the settings of your report (title, author, date, appearance, etc..)

For your submitted report, use the following YAML header:

---
title: "Week 7"
subtitle: "Clustering"
author: LastName FirstName
date: "#r format(Sys.time())" # remove the # to show the date
output:
html_document:
toc: true
toc_depth: 2
theme: flatly
---

Very Important Remark: Click on the settings button of Rstudio’s text editor and choose to Chunk Output in Console.

In the core of your report:

• Put every exercise in a section, name the section Exercise i (i is the exercise’s number).
• Paste the exercise content.
• Write the code of the exercise in R chunks.
• Run the chunk to make sure it works.
• If there is a need, explain the results.
• Click on knit

## $$k$$-means clustering

1. Download the dataset: Ligue1 2017-2018 and import it into . Put the argument row.names to 1.

# You can import directly from my website (instead of downloading it..)
ligue1 <- read.csv("http://mghassany.com/MLcourse/datasets/ligue1_17_18.csv", row.names=1, sep=";")

2. Print the first two rows of the dataset and the total number of features in this dataset.

You can create an awesome HTML table by using the function kable from the knitr library. For example, if you want to show the first 5 lines and 5 columns of your dataset, you can use knitr::kable(ligue1[1:5,1:5]). Give it a try and see the result on your html report!

### pointsCards

3. We will first consider a smaller dataset to easily understand the results of $$k$$-means. Create a new dataset in which you consider only Points and Yellow.cards from the original dataset. Name it pointsCards

4. Apply $$k$$-means on pointsCards. Chose $$k=2$$ clusters and put the number of iterations to 20. Store your results into km. (Remark: kmeans() uses a random initialization of the clusters, so the results may vary from one call to another. Use set.seed() to have reproducible outputs).

5. Print and describe what is inside km.

6. What are the coordinates of the centers of the clusters (called also prototypes or centroids) ?

7. Plot the data (Yellow.cards vs Points). Color the points corresponding to their cluster.

8. Add to the previous plot the clusters centroids and add the names of the observations.

9. Re-run $$k$$-means on pointsCards using 3 and 4 clusters and store the results into km3 and km4 respectively. Visualize the results like in question 7 and 8.

How many clusters $$k$$ do we need in practice? There is not a single answer: the advice is to try several and compare. Inspecting the ‘between_SS / total_SS’ for a good trade-off between the number of clusters and the percentage of total variation explained usually gives a good starting point for deciding on $$k$$ (criterion to select $$k$$ similar to PCA).

There is several methods of computing an optimal value of $$k$$ with code on following stackoverflow answer: here .

10. Visualize the “within groups sum of squares” of the $$k$$-means clustering results (use the code in the link above).

11. Modify the code of the previous question in order to visualize the ‘between_SS / total_SS’. Interpret the results.

### Ligue 1

So far, you have only taken the information of two variables for performing clustering. Now you will apply kmeans() on the original dataset ligue1. Using PCA, we can visualize the clustering performed with all the available variables in the dataset.

By default, kmeans() does not standardize the variables, which will affect the clustering result. As a consequence, the clustering of a dataset will be different if one variable is expressed in millions or in tenths. If you want to avoid this distortion, use scale to automatically center and standardize the dataset (the result will be a matrix, so you need to transform it to a data frame again).

12. Scale the dataset and transform it to a data frame again. Store the scaled dataset into ligue1_scaled.

13. Apply kmeans() on ligue1 and on ligue1_scaled using 3 clusters and 20 iterations. Store the results into km.ligue1 and km.ligue1.scaled respectively (do not forget to set a seed)

14. How many observations there are in each cluster of km.ligue1 and km.ligue1.scaled ? (you can use table()). Do you obtain the same results when you perform kmeans() on the scaled and unscaled data?

### PCA

15. Apply PCA on ligue1 dataset and store you results in pcaligue1. Do we need to apply PCA on the scaled dataset? Justify your answer.

16. Plot the observations and the variables on the first two principal components (biplot). Interpret the results.

17. Visualize the teams on the first two principal components and color them with respect to their cluster.

# You can use the following code, based on factoextra library.
fviz_cluster(km.ligue1, data = ligue1, # km.ligue1 is where you stored your kmeans results
palette = c("red", "blue", "green"), # 3 colors since 3 clusters
ggtheme = theme_minimal(),
main = "Clustering Plot"
)

18. Recall that the figure of question 17 is a visualization with PC1 and PC2 of the clustering done with all the variables, not on PC1 and PC2. Now apply the kmeans() clustering taking only the first two PCs instead the variables of original dataset. Visualize the results and compare with the question 17.

By applying $$k$$-means only on the PCs we obtain different and less accurate result, but it is still an insightful way.

### Implementing k-means

In this part, you will perform $$k$$-means clustering manually, with $$k=2$$, on a small example with $$n=6$$ observations and $$p=2$$ features. The observations are as follows.

Observation $$X_1$$ $$X_2$$
1 1 4
2 1 3
3 0 4
4 5 1
5 6 2
6 4 0

19. Plot the observations.

20. Randomly assign a cluster label to each observation. You can use the sample() command in to do this. Report the cluster labels for each observation.

21. Compute the centroid for each cluster.

22. Create a function that calculates the Euclidean distance for two observations.

23. Assign each observation to the centroid to which it is closest, in terms of Euclidean distance. Report the cluster labels for each observation.

24. Repeat 21 and 23 until the answers obtained stop changing.

25. In your plot from 19, color the observations according to the cluster labels obtained.

## Hierarchical clustering

### Distances dist()

To calculate the distance in we use the dist() function. Here is a tutorial of how use it.

# Generate a matrix M of values from 1 to 15 with 5 rows and 3 columns
M <- matrix(1:15,5,3)
M
#ans>      [,1] [,2] [,3]
#ans> [1,]    1    6   11
#ans> [2,]    2    7   12
#ans> [3,]    3    8   13
#ans> [4,]    4    9   14
#ans> [5,]    5   10   15
# - Compute the distance between rows of M.
# - The default distance is the euclidian distance.
# - Since there are 3 columns, it is the euclidian
#        distance between tri-dimensional points.
dist(M)
#ans>      1    2    3    4
#ans> 2 1.73
#ans> 3 3.46 1.73
#ans> 4 5.20 3.46 1.73
#ans> 5 6.93 5.20 3.46 1.73
# To compute the Manhattan distance
dist(M, method= "manhattan")
#ans>    1  2  3  4
#ans> 2  3
#ans> 3  6  3
#ans> 4  9  6  3
#ans> 5 12  9  6  3

### Dendrogram hclust()

# First we construct the dendrogram
dendro <- hclust(dist(M))

# Then we plot it
plot(dendro)

### Hierarchical clustering on Iris dataset

1. Download the iris dataset from here and import it into R.

2. Choose randomly 40 observations of the iris dataset and store the sample dataset into sampleiris.

3. Calculate the euclidean distances between the flowers. Store the results in a matrix called D. (Remark: the last column of the dataset is the class labels of the flowers)

4. Construct a dendrogram on the iris dataset using the method average. Store the result in dendro.avg.

5. Plot the dendrogram.

6. Plot again the dendrogram using the following command:

plot(dendro.avg, hang=-1, label=sampleiris\$class)

7. To cut the dendrogram and obtain a clustering use the cutree. You can choose the number of clusters you wish to obtain, or you can cut by choosing the height from the dendrogram figure. Cut the dendrogram in order to obtain 3 clusters. Store the results into vector groups.avg.

8. Visualize the cut tree using the function rect.hclust(). You can choose the colors of the rectangles too!

9. Compare the obtained results obtained with Hierarchical clustering and the real class labels of the flowers (function table()). Interpret the results.

Bonus: You can cut the tree manually (on demand!). To do so, plot a dendrogram first then use the function identify(). On the figure, click on the clusters you wish to obtain. Then hit Escape to finish.

10. Now apply the Hierarchical clustering on the iris dataset (the 150 observations). Choose 3 clusters and compare the results with the real class labels. Compare different methods of Hierarchical clustering (average, complete and single linkages).