Re: [R] R and LINGO?

2017-11-10 Thread Jan Olsen Røyland
Hei
Im struggling with this problem:
b) Another company wants to compose the optimal project portfolio based on the 
following 5-
year project proposals. In the table, the cash flow for each project in each 
year is shown.
Project 1 Project 2 Project 3 Project 4 Project 5 Project 6
1st year of the project -58 -32 -18 -31 -33 -39
2nd year of the project 17 17 11 4 21 30
3rd year of the project 26 30 13 19 20 9
4th year of the project 18 7 4 7 22 13
5th year of the project 40 6 7 17 6 13
In this case, the company can also choose which year each project should 
commence. These six
candidate projects can begin either in 2018, in 2019 or in 2020, or not at all.
The current proposal is to undertake project 1, 2, 3 and 5, with project 3 and 
5 starting in 2018,
project 2 in 2019 and project 1 in 2020. Available funds by the end of year 
2017 will be 70 mill.
The resulting cash flow is given in the following table:
Project 1 Project 2 Project 3 Project 5
Total cash flow
from projects
Available
funds
2017 70
2018 -18 -33 -51 19
2019 -32 11 21 0 19
2020 -58 17 13 20 -8 11
2021 17 30 4 22 73 84
2022 26 7 7 6 46 130
2023 18 6 24 154
2024 40 40 194
Formulate an optimization model in LINGO to determine which projects to 
undertake, and in which
years. The goal is to maximize available funds by the end of year 2024, while 
making sure that
available funds are always non-negative throughout the planning horizon. How 
much can the
improve compared to the current proposal? (For simplicity, assume zero discount 
rate.)

Med Vennelig Hilsen
Jan Olsen R�yland


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Re: [R] How to load fonts in text3d?

2017-03-28 Thread olsen
Following these pointers given by Duncan Murdoch is the key to success,
at least on my system.

Many thanks!
olsen



On 28/03/17 13:49, Duncan Murdoch wrote:
> On 28/03/2017 6:39 AM, olsen wrote:
>> I think I found the fly in the ointment, running the same text3d() lines
>> with 'useFreeType=TRUE' returns:
>> "FreeType not supported in this build"
> 
> You need to install FreeType and FTGL.  I think this is how to do it on
> Trusty.  Don't know if it will work on your Ubuntu version.
> 
> sudo apt-get install libfreetype6-dev
> sudo apt-get install libftgl-dev
> 
> and then reinstall rgl from within R using
> 
> install.packages("rgl", type="source")
> 
> Duncan Murdoch
> 
>>
>>
>> On 28/03/17 11:05, olsen wrote:
>>> thanks, the fonts seem to be on:
>>>> rglFonts()
>>> $serif
>>> [1] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
>>> [2] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
>>> [3] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
>>> [4] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
>>>
>>> $sans
>>> [1] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
>>> [2] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
>>> [3] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
>>> [4] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
>>>
>>> $mono
>>> [1] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
>>> [2] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
>>> [3] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
>>> [4] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
>>>
>>> $symbol
>>> [1] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
>>> [2] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
>>> [3] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
>>> [4] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
>>>
>>> On 27/03/17 20:21, Duncan Murdoch wrote:
>>>> On 27/03/2017 1:09 PM, olsen wrote:
>>>>> I'm trying to run the example given in ?text3d as follows:
>>>>>
>>>>> library(rgl)
>>>>> open3d()
>>>>> famnum <- rep(1:4, 8)
>>>>> family <- c("serif", "sans", "mono", "symbol")[famnum]
>>>>> font <- rep(rep(1:4, each = 4), 2)
>>>>> cex <- rep(1:2, each = 16)
>>>>> text3d(font, cex, famnum, text = paste(family, font), adj = 0.5,
>>>>>color = "blue", family = family, font = font, cex = cex)
>>>>>
>>>>> This results in a couple of warning messages of the following kind:
>>>>>
>>>>> In rgl.texts(x = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L,  ... :
>>>>>   font family "serif" not found, using "bitmap"
>>>>>
>>>>> I would like to use another font instead of bitmap but it seems to
>>>>> switchback to bitmap whatever argument I give as family e.g. 'family =
>>>>> "FreeSans"'.
>>>>> Wonder if this is a bug or I'm doing something wrong.
>>>>>
>>>>> This is on
>>>>> R version 3.3.2 (2016-10-31)
>>>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>>>> Running under: Debian GNU/Linux 9 (stretch)
>>>>> with the following rgl version loaded:
>>>>> [1] rgl_0.96.0
>>>>
>>>> What do you see if you run rglFonts()?  It should list the fonts you
>>>> have installed.  On MacOS, I see
>>>>
>>>>> rglFonts()
>>>> $serif
>>>> [1]
>>>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>>>
>>>>
>>>> [2]
>>>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>>>
>>>>
>>>> [3]
>>>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>>>
>>>>
>>>> [4]
>>>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>>>
>>>>
>>>>
>>>> $sans
>>>> [1]
>>>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/r

Re: [R] How to load fonts in text3d?

2017-03-28 Thread olsen
I think I found the fly in the ointment, running the same text3d() lines
with 'useFreeType=TRUE' returns:
"FreeType not supported in this build"


On 28/03/17 11:05, olsen wrote:
> thanks, the fonts seem to be on:
>> rglFonts()
> $serif
> [1] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
> [2] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
> [3] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
> [4] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
> 
> $sans
> [1] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
> [2] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
> [3] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
> [4] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
> 
> $mono
> [1] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
> [2] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
> [3] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
> [4] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
> 
> $symbol
> [1] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
> [2] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
> [3] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
> [4] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
> 
> On 27/03/17 20:21, Duncan Murdoch wrote:
>> On 27/03/2017 1:09 PM, olsen wrote:
>>> I'm trying to run the example given in ?text3d as follows:
>>>
>>> library(rgl)
>>> open3d()
>>> famnum <- rep(1:4, 8)
>>> family <- c("serif", "sans", "mono", "symbol")[famnum]
>>> font <- rep(rep(1:4, each = 4), 2)
>>> cex <- rep(1:2, each = 16)
>>> text3d(font, cex, famnum, text = paste(family, font), adj = 0.5,
>>>color = "blue", family = family, font = font, cex = cex)
>>>
>>> This results in a couple of warning messages of the following kind:
>>>
>>> In rgl.texts(x = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L,  ... :
>>>   font family "serif" not found, using "bitmap"
>>>
>>> I would like to use another font instead of bitmap but it seems to
>>> switchback to bitmap whatever argument I give as family e.g. 'family =
>>> "FreeSans"'.
>>> Wonder if this is a bug or I'm doing something wrong.
>>>
>>> This is on
>>> R version 3.3.2 (2016-10-31)
>>> Platform: x86_64-pc-linux-gnu (64-bit)
>>> Running under: Debian GNU/Linux 9 (stretch)
>>> with the following rgl version loaded:
>>> [1] rgl_0.96.0
>>
>> What do you see if you run rglFonts()?  It should list the fonts you
>> have installed.  On MacOS, I see
>>
>>> rglFonts()
>> $serif
>> [1]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>
>> [2]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>
>> [3]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>
>> [4]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>
>>
>> $sans
>> [1]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSans.ttf"
>>
>> [2]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSans.ttf"
>>
>> [3]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSans.ttf"
>>
>> [4]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSans.ttf"
>>
>>
>> $mono
>> [1]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeMono.ttf"
>>
>> [2]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeMono.ttf"
>>
>> [3]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeMono.ttf"
>>
>> [4]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeMono.ttf"
>>
>>
>> $symbol
>> [1]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>
>> [2]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>
>> [3]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>
>> [4]
>> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
>>
>>
>> If you don't have Freetype installed on your system, you won't be able
>> to use any of those.
>>
>> Duncan Murdoch
>>
>

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] How to load fonts in text3d?

2017-03-28 Thread olsen
thanks, the fonts seem to be on:
> rglFonts()
$serif
[1] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
[2] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
[3] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
[4] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"

$sans
[1] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
[2] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
[3] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"
[4] "/usr/lib/R/site-library/rgl/fonts/FreeSans.ttf"

$mono
[1] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
[2] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
[3] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"
[4] "/usr/lib/R/site-library/rgl/fonts/FreeMono.ttf"

$symbol
[1] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
[2] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
[3] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"
[4] "/usr/lib/R/site-library/rgl/fonts/FreeSerif.ttf"

On 27/03/17 20:21, Duncan Murdoch wrote:
> On 27/03/2017 1:09 PM, olsen wrote:
>> I'm trying to run the example given in ?text3d as follows:
>>
>> library(rgl)
>> open3d()
>> famnum <- rep(1:4, 8)
>> family <- c("serif", "sans", "mono", "symbol")[famnum]
>> font <- rep(rep(1:4, each = 4), 2)
>> cex <- rep(1:2, each = 16)
>> text3d(font, cex, famnum, text = paste(family, font), adj = 0.5,
>>color = "blue", family = family, font = font, cex = cex)
>>
>> This results in a couple of warning messages of the following kind:
>>
>> In rgl.texts(x = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L,  ... :
>>   font family "serif" not found, using "bitmap"
>>
>> I would like to use another font instead of bitmap but it seems to
>> switchback to bitmap whatever argument I give as family e.g. 'family =
>> "FreeSans"'.
>> Wonder if this is a bug or I'm doing something wrong.
>>
>> This is on
>> R version 3.3.2 (2016-10-31)
>> Platform: x86_64-pc-linux-gnu (64-bit)
>> Running under: Debian GNU/Linux 9 (stretch)
>> with the following rgl version loaded:
>> [1] rgl_0.96.0
> 
> What do you see if you run rglFonts()?  It should list the fonts you
> have installed.  On MacOS, I see
> 
>> rglFonts()
> $serif
> [1]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
> 
> [2]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
> 
> [3]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
> 
> [4]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
> 
> 
> $sans
> [1]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSans.ttf"
> 
> [2]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSans.ttf"
> 
> [3]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSans.ttf"
> 
> [4]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSans.ttf"
> 
> 
> $mono
> [1]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeMono.ttf"
> 
> [2]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeMono.ttf"
> 
> [3]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeMono.ttf"
> 
> [4]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeMono.ttf"
> 
> 
> $symbol
> [1]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
> 
> [2]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
> 
> [3]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
> 
> [4]
> "/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rgl/fonts/FreeSerif.ttf"
> 
> 
> If you don't have Freetype installed on your system, you won't be able
> to use any of those.
> 
> Duncan Murdoch
> 

-- 
Our solar system is the cream of the crop
http://hasa-labs.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] How to load fonts in text3d?

2017-03-27 Thread olsen
I'm trying to run the example given in ?text3d as follows:

library(rgl)
open3d()
famnum <- rep(1:4, 8)
family <- c("serif", "sans", "mono", "symbol")[famnum]
font <- rep(rep(1:4, each = 4), 2)
cex <- rep(1:2, each = 16)
text3d(font, cex, famnum, text = paste(family, font), adj = 0.5,
   color = "blue", family = family, font = font, cex = cex)

This results in a couple of warning messages of the following kind:

In rgl.texts(x = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L,  ... :
  font family "serif" not found, using "bitmap"

I would like to use another font instead of bitmap but it seems to
switchback to bitmap whatever argument I give as family e.g. 'family =
"FreeSans"'.
Wonder if this is a bug or I'm doing something wrong.

This is on
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)
with the following rgl version loaded:
[1] rgl_0.96.0


Thanks in advance for any indications

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.


Re: [R] project test data into principal components of training dataset

2016-04-20 Thread olsen
For the records, a slightly hacky answer, by modifying the ggbiplot
function, is provided now here:
http://stackoverflow.com/questions/36603268/how-to-plot-training-and-test-validation-data-in-r-using-ggbiplot

On 18/04/16 17:20, olsen wrote:
> Hi there,
> 
> I've a training dataset and a test dataset. My aim is to visually
> allocate the test data within the calibrated space reassembled by the
> PC's of the training data set, furthermore to keep the training data set
> coordinates fixed, so they can serve as ruler for measurement for
> additional test datasets coming up.
> 
> Please find a minimum working example using the wine dataset below.
> Ideally I would like to use ggbiplot as it comes with the elegant
> features but it only accepts objects of class prcomp, princomp, PCA, or
> lda, which is not fullfilled by the predicted test data.
> 
> I'm still slightly wet behind my R ears and the only solution I can
> think of is to plot the calibrated space in ggbiplot and the training
> data in ggplot and then join them, in the worst case by exporting them
> as svg and importing them in inkscape. Which is slightly complicated
> plus the scaling is different.
> 
> Any indication how this mission can be accomplished very welcome!
> 
> Thanks and greets
> Olsen
> 
> I started a threat on stackoverflow on that issue but know relevant
> indications so far.
> http://stackoverflow.com/questions/36603268/how-to-plot-training-and-test-validation-data-in-r-using-ggbiplot
> 
> ##MWE
> library(ggbiplot)
> data(wine)
> 
> ##pca on the wine dataset used as training data
> wine.pca <- prcomp(wine, center = TRUE, scale. = TRUE)
> 
> wine$class <- wine.class
> 
> ##simulate test data by generating three new wine classes
> wine.new.1 <- wine[c(sample(1:nrow(wine), 25)),]
> wine.new.2 <- wine[c(sample(1:nrow(wine), 43)),]
> wine.new.3 <- wine[c(sample(1:nrow(wine), 36)),]
> 
> ##Predict PCs for the new classes by transforming
> #them using the predict.prcomp function
> pred.new.1 <- predict(wine.pca, newdata = wine.new.1)
> pred.new.2 <- predict(wine.pca, newdata = wine.new.2)
> pred.new.3 <- predict(wine.pca, newdata = wine.new.3)
> 
> #simulate the classes for the new sorts
> wine.new.1$class <- rep("new.wine.1", nrow(wine.new.1))
> wine.new.2$class <- rep("new.wine.2", nrow(wine.new.2))
> wine.new.3$class <- rep("new.wine.3", nrow(wine.new.3))
> wine.new.bind <- rbind(wine.new.1, wine.new.2, wine.new.3)
> 
> ##compose the plot by joining the PCA ggbiplot training data with the
> testing data from ggplot
> #plot the calibrated space resulting from the test data
> g.train <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups =
> wine$class, ellipse = TRUE, circle = TRUE)
> g.train
> #plot the test data resulting from the prediction
> df.pred = data.frame(PC1 = wine.new.bind[,1], PC2 = wine.new.bind[,2],
> PC3 = wine.new.bind[,3], PC4 = wine.new.bind[,4],
> classes = wine.new.bind$class)
> g.test <- ggplot(df.pred, aes(PC1, PC2, color = classes, shape =
> classes)) +  geom_point() +  stat_ellipse()
> g.test
> 
> 
> 
> 
> 

-- 
Our solar system is the cream of the crop
http://hasa-labs.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] project test data into principal components of training dataset

2016-04-18 Thread olsen
Hi there,

I've a training dataset and a test dataset. My aim is to visually
allocate the test data within the calibrated space reassembled by the
PC's of the training data set, furthermore to keep the training data set
coordinates fixed, so they can serve as ruler for measurement for
additional test datasets coming up.

Please find a minimum working example using the wine dataset below.
Ideally I would like to use ggbiplot as it comes with the elegant
features but it only accepts objects of class prcomp, princomp, PCA, or
lda, which is not fullfilled by the predicted test data.

I'm still slightly wet behind my R ears and the only solution I can
think of is to plot the calibrated space in ggbiplot and the training
data in ggplot and then join them, in the worst case by exporting them
as svg and importing them in inkscape. Which is slightly complicated
plus the scaling is different.

Any indication how this mission can be accomplished very welcome!

Thanks and greets
Olsen

I started a threat on stackoverflow on that issue but know relevant
indications so far.
http://stackoverflow.com/questions/36603268/how-to-plot-training-and-test-validation-data-in-r-using-ggbiplot

##MWE
library(ggbiplot)
data(wine)

##pca on the wine dataset used as training data
wine.pca <- prcomp(wine, center = TRUE, scale. = TRUE)

wine$class <- wine.class

##simulate test data by generating three new wine classes
wine.new.1 <- wine[c(sample(1:nrow(wine), 25)),]
wine.new.2 <- wine[c(sample(1:nrow(wine), 43)),]
wine.new.3 <- wine[c(sample(1:nrow(wine), 36)),]

##Predict PCs for the new classes by transforming
#them using the predict.prcomp function
pred.new.1 <- predict(wine.pca, newdata = wine.new.1)
pred.new.2 <- predict(wine.pca, newdata = wine.new.2)
pred.new.3 <- predict(wine.pca, newdata = wine.new.3)

#simulate the classes for the new sorts
wine.new.1$class <- rep("new.wine.1", nrow(wine.new.1))
wine.new.2$class <- rep("new.wine.2", nrow(wine.new.2))
wine.new.3$class <- rep("new.wine.3", nrow(wine.new.3))
wine.new.bind <- rbind(wine.new.1, wine.new.2, wine.new.3)

##compose the plot by joining the PCA ggbiplot training data with the
testing data from ggplot
#plot the calibrated space resulting from the test data
g.train <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups =
wine$class, ellipse = TRUE, circle = TRUE)
g.train
#plot the test data resulting from the prediction
df.pred = data.frame(PC1 = wine.new.bind[,1], PC2 = wine.new.bind[,2],
PC3 = wine.new.bind[,3], PC4 = wine.new.bind[,4],
classes = wine.new.bind$class)
g.test <- ggplot(df.pred, aes(PC1, PC2, color = classes, shape =
classes)) +  geom_point() +  stat_ellipse()
g.test





-- 
Our solar system is the cream of the crop
http://hasa-labs.org

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.