Re: [R] data.table installation on intel macOS Ventura 13.6

2023-09-26 Thread Carlos Ortega
epos = "https://cran.r-project.org";)
> Installing package into ‘/usr/local/lib/R/4.3/site-library’
> (as ‘lib’ is unspecified)
> trying URL '
> https://cran.r-project.org/src/contrib/data.table_1.14.8.tar.gz'
> Content type 'application/x-gzip' length 5338582 bytes (5.1 MB)
> ==
> downloaded 5.1 MB
>
> * installing *source* package ‘data.table’ ...
> ** package ‘data.table’ successfully unpacked and MD5 sums checked
> ** using staged installation
> zlib 1.2.11 is available ok
> R CMD SHLIB supports OpenMP without any extra hint
> ** libs
> using C compiler: ‘Homebrew clang version 17.0.1’
> using SDK: ‘’
> clang -I"/usr/local/Cellar/r/4.3.1/lib/R/include" -DNDEBUG
>  -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include
> -I/usr/local/opt/xz/include -I/usr/local/include -fPIC  -g -O2  -c
> assign.c -o assign.o
> [several lines deleted]
> clang -dynamiclib -Wl,-headerpad_max_install_names -undefined
> dynamic_lookup -single_module -multiply_defined suppress
> -L/usr/local/Cellar/r/4.3.1/lib/R/lib -L/usr/local/opt/gettext/lib
> -L/usr/local/opt/readline/lib -L/usr/local/opt/xz/lib -L/usr/local/lib -o
> data.table.so assign.o between.o bmerge.o chmatch.o cj.o coalesce.o
> dogroups.o fastmean.o fcast.o fifelse.o fmelt.o forder.o frank.o fread.o
> freadR.o froll.o frollR.o frolladaptive.o fsort.o fwrite.o fwriteR.o
> gsumm.o ijoin.o init.o inrange.o nafill.o nqrecreateindices.o
> openmp-utils.o quickselect.o rbindlist.o reorder.o shift.o snprintf.o
> subset.o transpose.o types.o uniqlist.o utils.o vecseq.o wrappers.o -lz
> -L/usr/local/Cellar/r/4.3.1/lib/R/lib -lR -lintl -Wl,-framework
> -Wl,CoreFoundation
> ld: warning: -single_module is obsolete
> ld: warning: -multiply_defined is obsolete
> ld: warning: -single_module is obsolete
> ld: warning: -multiply_defined is obsolete
> PKG_CFLAGS =
> PKG_LIBS = -lz
> if [ "data.table.so" != "data_table.so" ]; then mv data.table.so
> data_table.so; fi
> if [ "" != "Windows_NT" ] && [ `uname -s` = 'Darwin' ]; then
> install_name_tool -id data_table.so data_table.so; fi
> installing to
> /usr/local/lib/R/4.3/site-library/00LOCK-data.table/00new/data.table/libs
> ** R
> ** inst
> ** byte-compile and prepare package for lazy loading
> ** help
> *** installing help indices
> ** building package indices
> ** installing vignettes
> ** testing if installed package can be loaded from temporary location
> ** checking absolute paths in shared objects and dynamic libraries
> ** testing if installed package can be loaded from final location
> ** testing if installed package keeps a record of temporary installation
> path
> * DONE (data.table)
> > library(data.table)
> data.table 1.14.8 using 1 threads (see ?getDTthreads).  Latest news:
> r-datatable.com
> **
> This installation of data.table has not detected OpenMP support. It should
> still work but in single-threaded mode.
> This is a Mac. Please read https://mac.r-project.org/openmp/. Please
> engage with Apple and ask them for support. Check r-datatable.com for
> updates, and our Mac instructions here:
> https://github.com/Rdatatable/data.table/wiki/Installation. After several
> years of many reports of installation problems on Mac, it's time to
> gingerly point out that there have been no similar problems on Windows or
> Linux.
> **
>
>
>
> > On Sep 25, 2023, at 4:06 AM, Carlos Ortega  wrote:
> >
> > Hi,
> >
> > Yes, on Mac, it takes a while to even get the build to allow data.table
> to be used on multithread.
> >
> > See this installation guide which has sections specially dedicated for
> Mac.
> > • https://github.com/Rdatatable/data.table/wiki/Installation
> >
> > You will see that you will most likely have to modify the "Makevars"
> file to include the paths of different compilers.
> >
> > Thank you,
> > Carlos.
> >
> > On Mon, Sep 25, 2023 at 9:41 AM Ivan Krylov 
> wrote:
> > On Sun, 24 Sep 2023 23:42:14 +
> > Naresh Gurbuxani  wrote:
> >
> > > Instruction on this site do not apply to Ventura 13.6
> >
> > What happens whey you try to follow them?
> >
> > The data.table maintainers have prepared the following guide:
> > <https://github.com/Rdatatable/data.table/wiki/Support>. In particular,
> > in order to help us help you, you need to include your actions, their
> > expected and actual results. Without that, you're effectively asking
> > someone to write a personal tutorial for you, which is not a good use
> > of anyone's time.
> >
> > If you don't get an answer here and don't find anything useful on
> > StackOverflow when searching for [data.table], try
> > r-sig-...@r-project.org.
> >
> > --
> > Best regards,
> > Ivan
> >
> > __
> > 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.
>
>

[[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] data.table installation on intel macOS Ventura 13.6

2023-09-25 Thread Carlos Ortega
Hi,

Yes, on Mac, it takes a while to even get the build to allow data.table to
be used on multithread.

See this installation guide which has sections specially dedicated for Mac.

   - https://github.com/Rdatatable/data.table/wiki/Installation

You will see that you will most likely have to modify the "Makevars" file
to include the paths of different compilers.

Thank you,
Carlos.

On Mon, Sep 25, 2023 at 9:41 AM Ivan Krylov  wrote:

> On Sun, 24 Sep 2023 23:42:14 +
> Naresh Gurbuxani  wrote:
>
> > Instruction on this site do not apply to Ventura 13.6
>
> What happens whey you try to follow them?
>
> The data.table maintainers have prepared the following guide:
> . In particular,
> in order to help us help you, you need to include your actions, their
> expected and actual results. Without that, you're effectively asking
> someone to write a personal tutorial for you, which is not a good use
> of anyone's time.
>
> If you don't get an answer here and don't find anything useful on
> StackOverflow when searching for [data.table], try
> r-sig-...@r-project.org.
>
> --
> Best regards,
> Ivan
>
> __
> 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.
>

[[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] NAs error in caret function

2022-04-21 Thread Carlos Ortega
Hi,

I do not see any issue with the code you provided.
In this situation, you should use a more "debugging" approach for your
problem until catching the problem. In this case, I would start using a
much more simplified version of your "trainControl". No folds, just "cv"
and "number = 2" and try.

Perhaps the problem is that you do not have enough or any representation of
one of your labels and that creates an evaluation problem. If your data is
not balanced and you create a lot of folds that could happen.

And if it works with this very simplified version, start including more
complexity in the trainControl function.

Thanks,
Carlos.


On Thu, Apr 21, 2022 at 12:59 AM javed khan  wrote:

> Carlos Ortega, thank you for your answer.
>
> Class label has three values (Bug, Codel smell and Vulnerability). X is a
> text-based feature that include English statements and we performed some
> preprocessing such as removing symbols, lower-case etc.
>
> Yes, train_label is a factor class.
>
> *I can provide the whole code and data if needed. We followed the same
> method provided in this tutorial*
>
> *https://algotech.netlify.app/blog/text-lime/
> <https://algotech.netlify.app/blog/text-lime/> *
>
>
> cv.folds <- createMultiFolds(train$TYPE, k = 10, times = 3)
>
> ctrl <- trainControl(method = "cv",number=3, index = cv.folds, classProbs
> = TRUE, summaryFunction = multiClassSummary)
> m= train(y = train_label, x = train_x,
>   method = "knn" ,
>   metric = "Accuracy",
>   ## #  preProc = c("center", "scale", "nzv"),
>   trControl = ctrl)
>
> p=predict(m, test_x)
> confusionMatrix(p, as.factor(test_label))
>
> With some models, it show error like: Error in { :
>   task 1 failed - "Not all variable names used in object found in newdata"
>
> However, when I run the base models like naiveBayes, it works.
>
> model_bayes <- naiveBayes(train_x, train_label, laplace = 1)
>
>
> On Wed, Apr 20, 2022 at 11:09 PM Carlos Ortega  wrote:
>
>> Hi,
>>
>> There are many things than could be wrong:
>>
>> 1. What is inside "ctrl" in the trainControl argument ?
>> 2. Your model is a classication one, but if you do not configure
>> correctly "ctrl" you do not get out the metrics correctly. It depends if
>> your model is binary or multi-class.
>> 3. Another thing is that if it is a classification one, you should also
>> check that in the "train()" you "train_label" is a factor.
>>
>> On top of that, remember that your problem is not reproducible.
>> If you attach a portion of your data, we could create a working "caret"
>> code.
>>
>> Thanks,
>> Carlos Ortega.
>>
>> On Wed, Apr 20, 2022 at 10:26 PM Bert Gunter 
>> wrote:
>>
>>> A quick web search on 'R caret package' found a host of useful
>>> results, the first of which was this:
>>> https://topepo.github.io/caret/
>>> Note that the author, Max Kuhn, explicitly says there that you can
>>> email him with questions. I think you should do so, as you do not seem
>>> to be making progress here.
>>>
>>> Bert Gunter
>>>
>>> "The trouble with having an open mind is that people keep coming along
>>> and sticking things into it."
>>> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>>
>>> On Wed, Apr 20, 2022 at 12:51 PM javed khan 
>>> wrote:
>>> >
>>> > Caret produce the error: Something is wrong; all the Accuracy metric
>>> values
>>> > are missing:
>>> > logLoss AUC  prAUCAccuracy   Kappa
>>> >  Min.   : NA   Min.   : NA   Min.   : NA   Min.   : NA   Min.   : NA
>>> >  1st Qu.: NA   1st Qu.: NA   1st Qu.: NA   1st Qu.: NA   1st Qu.: NA
>>> >  Median : NA   Median : NA   Median : NA   Median : NA   Median : NA
>>> >
>>> > We (group of three) working on an assignment and could not fix this
>>> error
>>> > from a few days. The error comes with the majority of the models while
>>> with
>>> > a few model (e.g. nb), the code works. The data is text-based
>>> > classification.
>>> >
>>> > Some Warnings are:
>>> >
>>> > Warning messages:
>>> > 1: In train.default(y = train_label, x = train_x, method = "pls",  ...
>>> :
>>> >   The metric "ROC" was not in the result set. logLoss will be used
>>

Re: [R] multilabel classification XGBoost and hyperparameter tuning

2021-05-27 Thread Carlos Ortega
Hello Agnes,

Yes, it is true, "xgboost" is not oriented for a "multi-label"
classification. "xgboost" can handle "multi-class" but not "multi-label".

Bue in "mlr", you can handle "multi-class" problems although not with
"xgboost" a base learner algorithm. You can see here how you can handle
that with "mlr":


   - https://mlr.mlr-org.com/articles/tutorial/multilabel.html


Besides that, you can see if these other alternatives could work for your
problem:

   - "utiml" was one of them but now it's not avaialble on CRAN (
   https://github.com/rivolli/utiml).
   - And this other one "mldr" could help you out:
   https://cran.r-project.org/web/packages/mldr/vignettes/mldr.pdf.

Thanks,
Carlos.

On Thu, May 27, 2021 at 7:30 PM Agnes g2g  wrote:

> Thank you for your reply.
> As far as I can see xgboost package does not provide multilabel
> classification.
> The mlr package uses a wrapper for xgboost, so I have used the package
> xgboost. But I still have the problem with the hyperparameter tuning.
>
> Did I understand you correctly?
> Do you have any other suggestion?
>
> Bye,
> Agnes
>
> 
> Van: Bert Gunter 
> Verzonden: donderdag 27 mei 2021 16:44
> Aan: Agnes g2g 
> CC: r-help@r-project.org 
> Onderwerp: Re: [R] multilabel classification XGBoost and hyperparameter
> tuning
>
> 1. A web search on "xgboost R" brought up R package "xgboost" which you
> did not mention. Did you not first try a web search or did you find that it
> did not meet your needs?
>
> 2. Have you looked here:
> https://cran.r-project.org/web/views/Cluster.html
> or here: https://cran.r-project.org/web/views/MachineLearning.html
>
> Cran's "task views" are a useful resource for such "does R have...?"
> questions.
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Thu, May 27, 2021 at 7:29 AM Agnes g2g  agnes...@hotmail.com>> wrote:
> Hi all,
>
> I want to do multilabel classification with XGBoost and tune
> hyperparameters.
> With the mlr package this does not seem possible, see
> https://stackoverflow.com/questions/67640953/feature-names-stored-in-object-and-newdata-are-different-using-mlr-package?noredirect=1#comment119651508_67640953
>
> Any ideas how to solve this?
>
> What other packages support multilabel classification for XGBoost and has
> the possibility to tune hyperparameters?
>
> Thanks in advance!
>
> Bye,
> Agnes
>
> [[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.
>
> [[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.
>

[[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] merged data frame with

2020-09-29 Thread Carlos Ortega
Hi All,

I recreated a new "sintetic" df1 based on df2 and I could merge:

> day_1 <- as.POSIXct("2005-11-14-00-00", format="%Y-%m-%d-%H-%M",
tz="Etc/GMT-1")
> day_2 <- as.POSIXct("2005-11-14-12-00", format="%Y-%m-%d-%H-%M",
tz="Etc/GMT-1")
> df2 <- data.frame(data_POSIX=seq(day_1, day_2, by="30 min"))
>
>
>
> df1 <- data.frame(
+   data_POSIX = df2[sample(1:nrow(df2), 15, replace =
FALSE),],
+   event = sample(c('start', 'end'), 15, replace = TRUE)
+ )
>
> df3 <- merge(df2, df1, by=c("data_POSIX"), all.x=TRUE)
> df3
data_POSIX event
1  2005-11-14 00:00:00   end
2  2005-11-14 00:30:00 start
3  2005-11-14 01:00:00  
4  2005-11-14 01:30:00   end
5  2005-11-14 02:00:00   end
6  2005-11-14 02:30:00 start
7  2005-11-14 03:00:00   end
8  2005-11-14 03:30:00   end
9  2005-11-14 04:00:00 start
10 2005-11-14 04:30:00 start
11 2005-11-14 05:00:00  
12 2005-11-14 05:30:00  
13 2005-11-14 06:00:00  
14 2005-11-14 06:30:00 start
15 2005-11-14 07:00:00  
16 2005-11-14 07:30:00  
17 2005-11-14 08:00:00  
18 2005-11-14 08:30:00  
19 2005-11-14 09:00:00 start
20 2005-11-14 09:30:00 start
21 2005-11-14 10:00:00  
22 2005-11-14 10:30:00   end
23 2005-11-14 11:00:00  
24 2005-11-14 11:30:00   end
25 2005-11-14 12:00:00 start

Regards,
Carlos Ortega

On Tue, Sep 29, 2020 at 10:13 AM Ivan Calandra  wrote:

> Hi Stefano,
>
> For the merge() part, I'll leave it to more expert users (I rarely use
> merge(), and every time I need it, it's painful...).
>
> To know why  instead of NA, check the results with str(df3); I guess
> it is not the mode you expected.
>
> For more details, you should provide the file, or better a reproducible
> example using dput().
>
> For the second part, your syntax was not correct (subsetting a column
> for elements based on a column that is not part of the subset!). And
> there is no column "pch" in your example. Try:
> df3[df3$event == "start", "event"] <- 24
>
> HTH,
> Ivan
>
> --
> Dr. Ivan Calandra
> TraCEr, laboratory for Traceology and Controlled Experiments
> MONREPOS Archaeological Research Centre and
> Museum for Human Behavioural Evolution
> Schloss Monrepos
> 56567 Neuwied, Germany
> +49 (0) 2631 9772-243
> https://www.researchgate.net/profile/Ivan_Calandra
>
> On 29/09/2020 9:59, Stefano Sofia wrote:
> > Dear R users,
> > I'm struggling with a simple "merge".
> >
> > I have an external file called df.txt like
> >
> > data_POSIX, event
> > 2005-11-14 02:30:00, "start"
> > 2005-11-14 11:30:00, "end"
> >
> > I load it with
> >
> > df1 <- read.table(file="df.txt", header=TRUE, sep=",", dec = ".",
> stringsAsFactors=FALSE)
> > df1$data_POSIX <- as.POSIXct(df1$data_POSIX, format="%Y-%m-%d %H:%M:%S",
> tz="Etc/GMT-1")
> >
> > Then I create a new data frame df2:
> >
> > day_1 <- as.POSIXct("2005-11-14-00-00", format="%Y-%m-%d-%H-%M",
> tz="Etc/GMT-1")
> > day_2 <- as.POSIXct("2005-11-14-12-00", format="%Y-%m-%d-%H-%M",
> tz="Etc/GMT-1")
> > df2 <- data.frame(data_POSIX=seq(day_1, day_2, by="30 min"))
> >
> > Finally
> >
> > df3 <- merge(df2, df1, by=c("data_POSIX"), all.x=TRUE)
> >
> > gives
> >
> > data_POSIX event
> > 1  2005-11-14 00:00:00
> > 2  2005-11-14 00:30:00
> > 3  2005-11-14 01:00:00
> > 4  2005-11-14 01:30:00
> > 5  2005-11-14 02:00:00
> > 6  2005-11-14 02:30:00  start
> > 7  2005-11-14 03:00:00
> > 8  2005-11-14 03:30:00
> > 9  2005-11-14 04:00:00
> > 10 2005-11-14 04:30:00
> > 11 2005-11-14 05:00:00
> > 12 2005-11-14 05:30:00
> > 13 2005-11-14 06:00:00
> > 14 2005-11-14 06:30:00
> > 15 2005-11-14 07:00:00
> > 16 2005-11-14 07:30:00
> > 17 2005-11-14 08:00:00
> > 18 2005-11-14 08:30:00
> > 19 2005-11-14 09:00:00
> > 20 2005-11-14 09:30:00
> > 21 2005-11-14 10:00:00
> > 22 2005-11-14 10:30:00
> > 23 2005-11-14 11:00:00
> > 24 2005-11-14 11:30:00end
> > 25 2005-11-14 12:00:00
> >
> > Why there is  instead of NA?
> > And why
> >
> > df3$pch[df3$event == "start"] <- 24
> >
> > gives a whole column of NA and not 24 at row 6?
> >
> >
> >   (oo)
> > --oOO--( )--OOo-

Re: [R] Mapping 2D to 3D

2020-09-18 Thread Carlos Ortega
Hi,

There are some further references in the own "RStudio Community" and in
StackOverflow:

   - https://community.rstudio.com/t/options-to-stat-density-2d/792/4
   -
   
https://stackoverflow.com/questions/32206623/what-does-level-mean-in-ggplotstat-density2d

Kind Regards,
Carlos.


On Fri, Sep 18, 2020 at 4:17 AM H  wrote:

> I am trying to understand how to map 2D to 3D using ggplot() and
> eventually plot_gg(). I am, however, stuck on understanding how to express
> the third variable to be mapped. This example:
>
> ggdiamonds = ggplot(diamonds, aes(x, depth)) +
> stat_density_2d(aes(fill = stat(nlevel)),
> geom = "polygon", n = 100, bins = 10,contour = TRUE) +
> facet_wrap(clarity~.) +
> scale_fill_viridis_c(option = "A")
>
> uses a variable nlevel that I now understand is calculated during the
> building of the ggplot but I have not figured out from where it is
> calculated or how to specify a variable of my choosing.
>
> Does anyone have a good reference for understanding how to specify this
> variable? Most examples on the 'net seem to use the same dataset but do not
> specify this particular aspect...
>
> __
> 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.
>

[[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 create a readable plot in R with 10000+ values in a dataframe

2020-07-29 Thread Carlos Ortega
Hello Ritwik,

There is another possibility.

You can count (crosstab) the number of elements for each Region and Machine
(with table() function) and represent this table with geom_tile() function.
Wit this you will get an equivalent of a heatmap which will give you a good
sense of which combination of Region/Machine prevails.

Here you can get an example of how to use it:

   - https://www.r-graph-gallery.com/79-levelplot-with-ggplot2.html

And, just in in case you have to represent numeric values (numeric scatter
plot) there is an excellent way to graph that with this package, without
leaving ggplot ecosystem:

https://github.com/LKremer/ggpointdensity

Thanks,
Carlos Ortega.

On Wed, Jul 29, 2020 at 11:31 AM Jim Lemon  wrote:

> Hi Ritwik,
> I haven't seen any further answers to your request, so I'll make a
> suggestion. I don't think there is any sensible way to illustrate that
> many data points on a single plot. I would try to segment the data by
> machine type or similar and plot a number of plots.
>
> Jim
>
> On Fri, Jul 24, 2020 at 11:34 PM Ritwik Mohapatra 
> wrote:
> >
> > Hi All,
> >
> > These are the two codes i have used so far:-
> > ggplot(df3_machine_region,aes(Region,Machine.Name)) +
> >   geom_count()
> > !![2nd Plot|690x375](upload://gTyYUXe6lPJXCdyvqRBtUZ8zsyL.png) [1st
> > Plot|690x375](upload://bb0ux9WheqM4ViyYf3Gki6TKtlG.png)
> > ggplot(df3_machine_region,aes(Region,Machine.Name)) +
> >   geom_jitter(aes(colour=Region))
> >
> > I have to present the plot to my stakeholders,so thats why its required
> in
> > a readable and legible way.
> >
> > There would be approximately 10k+ values(max) for machine and region
> > combination.
> >
> > I have attached the output plots for your reference.Please find below a
> > snapshot of data for your reference.
> >
> > |Machine.Name|Region|
> > |0460-EPBS1.sga-res.com|Europe|
> > |04821-EABS1.sga-res.com|Europe|
> > |10429-EDABS1.sga-res.com|Europe|
> > |1042619-ESWEBS1.sga-res.com|Europe|
> > |ABE-L-98769.europe.shell.com|Americas|
> > |AB-L-98769.europe.shell.com|APAC|
> > |AB-L-98769.europe.shell.com|Europe|
> > |ABE-L-98769.europe.shell.com (2)|Americas|
> > |ABE-L-98769.europe.shell.com (2)|Europe|
> > |ABE-L-98840.europe.shell.com|Americas|
> > |AB-L-98840.europe.shell.com|APAC|
> > |ABE-L-98840.europe.shell.com|Europe|
> > |AB-L-98854.europe.shell.com|Americas|
> > |ABE-L-98854.europe.shell.com|Europe|
> > |ABE-L-98862.europe.shell.com|Americas|
> >
> > Regards,
> > Ritwik
> >
> > On Fri, Jul 24, 2020 at 6:05 PM Martin Maechler <
> maech...@stat.math.ethz.ch>
> > wrote:
> >
> > > >>>>> Ritwik Mohapatra
> > > >>>>> on Thu, 23 Jul 2020 23:41:57 +0530 writes:
> > >
> > > > How to create a readable and legible plot in R with 10k+ values.I
> > > have a
> > > > dataframe with 17298 records.There are two columns:Machine
> > > Name(Character)
> > > > and Region(Character).So i want to create a readable plot with
> > > region in x
> > > > axis and machine name in y axis.How do i do that using ggplot or
> any
> > > other
> > > > way.Please help.
> > >
> > > Good answers to this question will depend very much on how many
> > > 'Machine' and 'Region' levels there are.
> > >
> > > (and this is a case where in my opinion it'd be *MUCH* more
> > >  useful to have 'factor' instead of 'character'.. if only just
> > >  so
> > >  str()
> > > or   summary()
> > >
> > > would give useful/relevant information.
> > >
> > > --
> > > One possibility for a somewhat cute plot is a  "good ole"
> > > sunflower plot (base graphics, but the idea must be easily
> > > transferable to grid-based graphics such as ggplot2):
> > >
> > >   help(sunflowerplot)
> > >
> > >
> > > Martin Maechler
> > > ETH Zurich
> > >
> > __
> > 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-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.
>

[[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] Converting a list to a data frame

2016-11-04 Thread Carlos Ortega
Hi,

You have also "rbindlist()" function in package "data.table" that does
exactly what you need.

Kind Regards,
Carlos Ortega
www.qualityexcellence.es



2016-11-04 13:37 GMT+01:00 Kevin E. Thorpe :

> There is probably a very simple elegant way to do this, but I have been
> unable to find it. Here is a toy example. Suppose I have a list of data
> frames like this.
>
>  print(x <- list('1'=data.frame(id=1:4,expand.grid(x1=0:1,x2=0:1)),'2'=
> data.frame(id=5:8,expand.grid(x1=2:3,x2=2:3
> $`1`
>   id x1 x2
> 1  1  0  0
> 2  2  1  0
> 3  3  0  1
> 4  4  1  1
>
> $`2`
>   id x1 x2
> 1  5  2  2
> 2  6  3  2
> 3  7  2  3
> 4  8  3  3
>
> The real application will have more than 2 elements so I'm looking for a
> general approach. I basically want to rbind the data frames in each list
> element and add a variable that adds the element name. In this example the
> result would look something like this.
>
> rbind(data.frame(set='1',x[[1]]),data.frame(set='2',x[[2]]))
>   set id x1 x2
> 1   1  1  0  0
> 2   1  2  1  0
> 3   1  3  0  1
> 4   1  4  1  1
> 5   2  5  2  2
> 6   2  6  3  2
> 7   2  7  2  3
> 8   2  8  3  3
>
> Obviously, for 2 elements the simple rbind works but I would like a
> general solution for arbitrary length lists. Hopefully that is clear.
>
> Kevin
>
> --
> Kevin E. Thorpe
> Head of Biostatistics,  Applied Health Research Centre (AHRC)
> Li Ka Shing Knowledge Institute of St. Michael's Hospital
> Assistant Professor, Dalla Lana School of Public Health
> University of Toronto
> email: kevin.tho...@utoronto.ca  Tel: 416.864.5776  Fax: 416.864.3016
>
> __
> 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/posti
> ng-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[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] Lattice equivalent to ggplot function

2016-10-24 Thread Carlos Ortega
Hi,

Yes, it is available in "latticeExtra" package in function
"panel.smoother()".

Thanks,
Carlos Ortega
www.qualityexcellence.es

2016-10-24 15:13 GMT+02:00 Sébastien Bihorel :

> Hi,
>
> The ggplot2 includes the very convenient stat_summary function to summarize
> y variable data and plot this summary statistic in a y vs x graph. I need
> to implement similar functionality in a lattice-based framework.
> Googling this topic using keywords like lattice, equivalent, stat_summary,
> did not provide anything helpful. So, before starting coding something
> myself, I thought I would reach out to the R help list and ask if anybody
> would be aware of a contributed package that would include a equivalent
> function of set of functions to stat_summary.
>
> Thank you in advance for you help
>
> Sebastien
>
> [[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.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[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] Add annotation text outside of an xyplot (lattice package)

2016-09-22 Thread Carlos Ortega
Hi,

Yes, you can use "latticeExtra" package and use a text layer on top of your
current chart.

Thanks,
Carlos Ortega

2016-09-22 16:04 GMT+02:00 Jun Shen :

> Dear list,
>
> Just wonder if there is a way to add annotation text outside an xyplot,
> (e.g. the bottom of the plot). the panel.text seems only add text within
> the plot. Thanks.
>
> Jun
>
> [[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.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[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] implementation for genetic algorithm

2014-05-13 Thread Carlos Ortega
Hello,

The first two references of this query:

http://www.rseek.org/?cx=010923144343702598753%3Aboaz1reyxd4&q=genetic+algorithm&sa=Search+functions%2C+lists%2C+and+more&cof=FORID%3A11&siteurl=rseek.org%2F&ref=&ss=3792j1503136j17

provides a package (genalg) and an example of what you are looking for.

Regards,
Carlos Ortega
www.qualityexcellence.es


2014-05-12 11:31 GMT+02:00 nourhan iyte :

> Dear All,
> I am a beginner for R programming
> Do you an example for implementation for genetic algorithm
> or how to use it in distance between cities algorithm
>
> Thanks in advanced
> Regards
> MAYA
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] SQL vs R

2014-05-06 Thread Carlos Ortega
Hi,

Yes dplyr syntax is quite equivalent to SQL, although it is faster.
Another alternative you could consider is to use *data.table* which has a
syntax very similar to the way you select subset within a data.frame and in
terms of performance is faster (a bit) than sqldf.

You can get some idea of how to work with it here:

http://stackoverflow.com/questions/1727772/quickly-reading-very-large-tables-as-dataframes-in-r

Regards,
Carlos Ortega
www.qualityexcellence.es





2014-05-06 11:12 GMT+02:00 Dr Eberhard Lisse :

> Jeff
>
> It's in MySQL, at the moment roughly 1.8 GB, if I pull it into a
> dataframe it saves to 180MB. I work from the dataframe.
>
> But, it's not only a size issue it's also a speed issue and hence I
> don't care what I am going to use, as long as it is fast.
>
> sqldf is easy to understand for me but it takes ages.  If
> alternatives were roughly similar in speed I would remain with
> sqldf.
>
> dplyr sounds faster, and promising, but the intrinsic stuff is
> way beyond me (elderly Gynaecologist) on the learning curve...
>
> el
>
> on 2014-05-06, 09:41 Jeff Newmiller said the following:
> > In what format is this "growing" data stored?  CSV? SQL? Log
> > textfile?  You say you don't want to use sqldf, but you haven't
> > said what you do want to use.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] SQL vs R

2014-05-02 Thread Carlos Ortega
Hi,

With the new package "dplyr" you can create equivalent SQL sintaxt queries
like the one you need.
You can find examples of how to apply it here:

http://martinsbioblogg.wordpress.com/2014/03/26/using-r-quickly-calculating-summary-statistics-with-dplyr/

http://martinsbioblogg.wordpress.com/2014/03/27/more-fun-with-and/

Regards,
Carlos.




2014-05-02 23:23 GMT+02:00 Dr Eberhard Lisse :

> Hi,
>
> How do I do something like this without using sqldf?
>
> a <- sqldf("SELECT COUNT(*) FROM b WHERE c = 'd'")
>
> or
>
> e <- sqldf("SELECT f, COUNT(*) FROM b GROUP BY f ORDER BY f")
>
> greetings, el
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Download CSV Files from EUROSTAT Website

2013-11-04 Thread Carlos Ortega
Hi Lorenzo,

Perhaps package "pxR" can help you out.

http://cran.at.r-project.org/web/packages/pxR/index.html
pxR: PC-Axis with R

The pxR package provides a set of functions for reading and writing PC-Axis
files, used by different statistical organizations around the globe for
data dissemination.

Regards,
Carlos Ortega.


2013/11/4 Adams, Jean 

> Lorenzo,
>
> You might want to post this is a new question to get some new eyes on it.
>
> Or, you could try posting your question to http://stackoverflow.com/.
>  Scraping the web is a common topic for that group.
>
> Jean
>
>
> On Mon, Nov 4, 2013 at 3:53 AM, Lorenzo Isella  >wrote:
>
> >  Hello,
> > And thanks a lot.
> > This is indeed very close to what I need.
> > I am trying to figure out how not to "lose" the headers and how to avoid
> > downloading labels like "(p)" together with the numerical data I am
> > interested in.
> > If anyone on the list knows how to make this minor modifications, s/he
> > will make my life much easier.
> > Cheers
> >
> > Lorenzo
> >
> >
> > On Fri, 01 Nov 2013 14:25:49 +0100, Adams, Jean 
> wrote:
> >
> > Lorenzo,
> >
> > I may be able to help you get started.  You can use the XML package to
> > grab the information off the internet.
> >
> > library(XML)
> >
> > mylines <- readLines(url("http://bit.ly/1coCohq";))
> > closeAllConnections()
> > mylist <- readHTMLTable(mylines, asText=TRUE)
> > mytable <- mylist1$xTable
> >
> > However, when I look at the resulting object, mytable, it doesn't have
> > informative row or column headings.  Perhaps someone else can figure out
> > how to get that information.
> >
> > Jean
> >
> >
> >
> >
> >
> > On Thu, Oct 31, 2013 at 10:38 AM, Lorenzo Isella <
> lorenzo.ise...@gmail.com
> > > wrote:
> >
> >> Dear All,
> >> I often need to do some work on some data which is publicly available on
> >> the EUROSTAT website.
> >> I saw several ways to download automatically mainly the bulk data from
> >> EUROSTAT to later on postprocess it with R, for instance
> >>
> >> http://bit.ly/HrDICj
> >> http://bit.ly/HrDL10
> >> http://bit.ly/HrDTgT
> >>
> >> However, what I would like to do is to be able to download directly the
> >> csv file corresponding to a properly formatted dataset (typically a
> dynamic
> >> dataset) from EUROSTAT.
> >> To fix the ideas, please consider the dataset at the following link
> >>
> >> http://bit.ly/1coCohq
> >>
> >> what I would like to do is to automatically read its content into R, or
> >> at least to automatically download it as a csv file (full extraction,
> >> single file, no flags and footnotes) which I can then manipulate easily.
> >> Any suggestion is appreciated.
> >> Cheers
> >>
> >> Lorenzo
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >>
> >
> >
> >
> >
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Rose plot (like a windrose)

2012-06-08 Thread Carlos Ortega
Hi,

Please check function radial.plot() in package plotrix.

Regards,
Carlos Ortega
www.qualityexcellence.es

2012/6/8 MartinD 

> Dear R Gurus,
> I spent some time in looking for help but didn't find a way to do what I
> want.
> I do have a vector (in Degrees) containing of 360 elements, one element per
> degree on a circle.
> The data is dimensionless  and in the range of -0.2 to 0.5.
>
> An Example:
>
> Wind Dir [degrees],  Value
> 1,  0.1
> 2 , 0.3
> 3 ,  0.01
> .,.
> .,.
> 180,-0.01
> 181,-0.2
> .,.
> .,.
> .,.
> 359,.0.3
> 360,.0.5
>
> Now I want to have some kind of "rose" plot, a bit like a wind rose.
> Where the actual values per degree are plottet on a circle.
> I had a look to some wind rose packages, but the problem I had was that I
> wasn't able to plot the values but the plots gave me frequencies (which is
> due to the data (one element per degree) always "one" ).
> Do you have any idea how to make these plots?
>
> Thanks a lot in advance
>
> Martin
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Rose-plot-like-a-windrose-tp4632773.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] day of the year for chron objects

2012-06-08 Thread Carlos Ortega
Hi Agustin,

You can check and adapt this solution to your needs:

http://stackoverflow.com/questions/9465817/count-days-per-year

Regards,
Carlos Ortega
www.qualityexcellence.es

2012/6/8 Agustin Lobo 

> Hi!
> Is not there an standard R function to retrieve the day of the year
> (since 1st Jan of the same year)?
> I know I can make my own using julian, but find it weird that having
> days(), months() etc doy() does not exist as an standard function.
>
> Also, is the following not a bit inconsistent?
>
> > a <- chron("20100506",format="ymd")
> > a
> [1] 100506
> > years(a)
> [1] 2010
> Levels: 2010
>
> but instead have to cast to Date to apply julian:
> > julian(a)
> Error in names(d) : 'd' is missing
> > julian(as.Date(a))
> [1] 14735
> attr(,"origin")
> [1] "1970-01-01"
>
> Thanks
>
> Agus
>
> --
> --
> Dr. Agustin Lobo
> Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
> Lluis Sole Sabaris s/n
> 08028 Barcelona
> Spain
> Tel. 34 934095410
> Fax. 34 934110012
> e-mail agustin.l...@ictja.csic.es
> https://sites.google.com/site/aloboaleu/
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] [r] par and complex graph

2012-06-07 Thread Carlos Ortega
Hi Francesco,

No, I haven't tried...
But if you have some code I can try.

Regards,
Carlos Ortega
www.qualityexcellence.es

2012/6/7 Francesco Nutini 

>  Oh thank you Carlos!
> I wasted a lot of time formatting my xyplot by powerpoint.
> Did you used a similar tips for ternaryplot (vcd)?
>
> Many thanks.
> Regards,
> Francesco
>
>
>
>
> --
> Date: Wed, 6 Jun 2012 17:08:39 +0200
>
> Subject: Re: [R] [r] par and complex graph
> From: c...@qualityexcellence.es
> To: nutini.france...@gmail.com
>
>
> Hi,
>
> Sorry, layout is a parameter you should use when plotting several charts
> of the same nature.
> If you want to combien different lattice charts you should use "print()"
> which is a function that has methods to consider trellis objects. Check
> help details for "print.tellis" o consider this example:
>
> p11 <- histogram( ~ height | voice.part, data = singer, xlab="Height")
> p12 <- densityplot( ~ height | voice.part, data = singer, xlab = "Height")
> p2 <- histogram( ~ height, data = singer, xlab = "Height")
>
>
> ## simple positioning by split
> print(p11, split=c(1,1,1,2), more=TRUE)
> print(p2, split=c(1,2,1,2))
>
> ## Combining split and position:
> print(p11, position = c(0,0,.75,.75), split=c(1,1,1,2), more=TRUE)
> print(p12, position = c(0,0,.75,.75), split=c(1,2,1,2), more=TRUE)
> print(p2, position = c(.5,.75,1,1), more=FALSE)
>
> Regards,
> Carlos Ortega
> www.qualityexcellence.es
>
>
>
> 2012/6/6 Carlos Ortega 
>
> Hi Francesco,
>
> The parameter in the lattice package that you can use to arrange several
> plots in the same page is "layout":
>
> xyplot(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width | Species,
>data = iris, scales = "free", *layout = c(2, 2)*,
>auto.key = list(x = .6, y = .7, corner = c(0, 0)))
>
> Regards,
> Carlos Ortega
> www.qualityexcellence.es
>
>
> 2012/6/6 Francesco Nutini 
>
>
> Thank you Brian! So, that's why sometimes I can't use the par()
> Now I'm using the ternaryplot in [vcd]. Then, I have to read the vcd help
> to looking for a function similar to par().
> Many thanks.
> Francesco
>
>
>
> > Date: Tue, 5 Jun 2012 19:01:25 +0100
> > From: rip...@stats.ox.ac.uk
> > To: nutini.france...@gmail.com
> > CC: r-help@r-project.org
> > Subject: Re: [R] [r] par and complex graph
> >
> > On 05/06/2012 11:17, Francesco Nutini wrote:
> > >
> > > Dear R-Users, I'd like to have some tips about printing graph.
> > > I use the command par to print more graphs in one
> window:par(mfrow=c(6,1)); par(oma=c(2.5, 2.5, 2.5, 2.5));  par(mar=c(0.5,4,
> 0.5, 0.5))
> > >
> > > But this command doesn't run with complex graphic command (i.e.
> xyplot, ternaryplot).How can I print more than one graph per page, when I
> work with this "elaborated" graph?Many thanks!Francesco
> >
> > xyplot does lattice (hence grid) plots: you need to read ?print.trellis
> > to find out how to lay those out. par() applies only to base graphics.
> >
> > As for ternaryplot: it depends which package you got it from (and there
> > is more than one on CRAN).
> >
> > >
> > > [[alternative HTML version deleted]]
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> >
> > That does mean you, too.
> >
> > --
> > Brian D. Ripley,  rip...@stats.ox.ac.uk
> > Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> > University of Oxford,     Tel:  +44 1865 272861 (self)
> > 1 South Parks Road, +44 1865 272866 (PA)
> > Oxford OX1 3TG, UKFax:  +44 1865 272595
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>
>
>
>
> --
> Saludos,
> Carlos Ortega
> www.qualityexcellence.es
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R problem nls

2012-04-09 Thread Carlos Ortega
Hi,

And regarding how to extend the nls algorithm to a larger dataset it is a
question of indicating in the nls() functions which data.frame to use.
In you example you were using a small set of x's ad y's, so if you want to
use a large set put it in a new data.frame and pass it to nls().

And if you want to repeat that calculation for many different sets of x,y
(each one of them corresponding to a different wavelength) you could do
that in a loop.

Regards,
Carlos Ortega
www.qualityexcellence.es

2012/4/9 Karen Vandepoel 

> Hi,
>
> I will try to explain what it is I need to do, how far I am in doing it yet
> and where my problem is:
>
> I have a lot of x,y values I need to fit a non linear function through.
> Subsequently, I need to find the intersection point of this fitted curve
> with y=1.01
>
> The problem is I have a lot of values so I want to be able to do it all at
> once.
>
> I already imported my excel file of the points I have to use.
>
> The things I already have are following (not all of the data is visible
> because otherwise the file would be too long for this email, but i just
> showed part of my data so you could better understand my problem):
>
>
> __
>  X1242   X1242.5 X1243   X1243.5 X1244   X1244.5
> X1245   X1245.5 X1246   X1246.5 X1247   X1247.5 X1248
> X1248.5 X1249 =>  names of each data set ( corresponds to wavelengths,
> ranges from 400 to 2500 with 0.5 steps => a lot of points!)
> 18.14 0.9860316 0.9860272 0.9860203 0.9860121 0.9860044 0.9859994 0.9859971
> 0.9859976 0.985 0.9860035 0.9860069 0.9860103 0.9860128 0.9860151
> 0.9860178
> 15.8  0.9857134 0.9857106 0.9857063 0.9857011 0.9856958 0.9856917 0.9856887
> 0.9856874 0.9856880 0.9856893 0.9856906 0.9856919 0.9856922 0.9856916
> 0.9856912
> 13.77 0.9930109 0.9930015 0.9929921 0.9929833 0.9929765 0.9929714 0.9929674
> 0.9929637 0.9929603 0.9929569 0.9929533 0.9929501 0.9929469 0.9929440
> 0.9929416
> 9.03  0.9875374 0.9875321 0.9875242 0.9875140 0.9875024 0.9874921 0.9874840
> 0.9874793 0.9874780 0.9874802 0.9874835 0.9874869 0.9874877 0.9874857
> 0.9874801
> 6.14  0.9900554 0.9900465 0.9900376 0.9900286 0.9900204 0.9900122 0.9900032
> 0.9899924 0.9899802 0.9899669 0.9899544 0.9899445 0.9899372 0.9899333
> 0.9899317
> 4.27  1.0050327 1.0050242 1.0050175 1.0050129 1.0050107 1.0050101 1.0050094
> 1.0050070 1.0050025 1.0049959 1.0049885 1.0049812 1.0049746 1.0049691
> 1.0049647
> 2.77  0.9892697 0.9892585 0.9892454 0.9892311 0.9892164 0.9892030 0.9891906
> 0.9891796 0.9891704 0.9891624 0.9891550 0.9891480 0.9891401 0.9891320
> 0.9891235
> 1.52  0.9979284 0.9979430 0.9979548 0.9979644 0.9979739 0.9979850 0.9979984
> 0.9980137 0.9980312 0.9980498 0.9980691 0.9980897 0.9981105 0.9981323
> 0.9981542
> These are my x-values and y-values
>X1249.5 X1250   X1250.5 X1251   X1251.5 X1252
> X1252.5 X1253   X1253.5 X1254   X1254.5 X1255   X1255.5
> X1256   X1256.5
> 18.14 0.9860214 0.9860261 0.9860320 0.9860377 0.9860425 0.9860456 0.9860462
> 0.9860449 0.9860433 0.9860422 0.9860417 0.9860428 0.9860444 0.9860456
> 0.9860456
> 15.8  0.9856911 0.9856918 0.9856934 0.9856958 0.9856984 0.9857014 0.9857040
> 0.9857069 0.9857099 0.9857132 0.9857153 0.9857156 0.9857132 0.9857080
> 0.9857016
> 13.77 0.9929406 0.9929405 0.9929425 0.9929445 0.9929464 0.9929476 0.9929476
> 0.9929455 0.9929431 0.9929409 0.9929377 0.9929356 0.9929331 0.9929304
> 0.9929279
> 9.03  0.9874721 0.9874641 0.9874578 0.9874542 0.9874529 0.9874541 0.9874556
> 0.9874563 0.9874565 0.9874551 0.9874527 0.9874498 0.9874461 0.9874415
> 0.9874371
> 6.14  0.9899318 0.9899319 0.9899304 0.9899263 0.9899192 0.9899095 0.9898986
> 0.9898873 0.9898777 0.9898703 0.9898641 0.9898591 0.9898546 0.9898495
> 0.9898439
> 4.27  1.0049605 1.0049564 1.0049528 1.0049495 1.0049466 1.0049435 1.0049404
> 1.0049357 1.0049298 1.0049230 1.0049155 1.0049093 1.0049049 1.0049019
> 1.0049002
> 2.77  0.9891158 0.9891100 0.9891058 0.9891036 0.9891013 0.9890986 0.9890943
> 0.9890873 0.9890789 0.9890691 0.9890583 0.9890485 0.9890395 0.9890323
> 0.9890266
> 1.52  0.9981760 0.9981970 0.9982176 0.9982372 0.9982565 0.9982753 0.9982935
> 0.9983102 0.9983259 0.9983408 0.9983533 0.9983647 0.9983749 0.9983841
> 0.9983929
>  X1257   X1257.5 X1258   X1258.5 X1259   X1259.5
> X1260   X1260.5 X1261   X1261.5 X1262   X1262.5 X1263
> X1263.5 X1264
> 18.14 0.9860445 0.9860437 0.9860438 0.9860467 0.9860527 0.9860613 0.9860705
> 0.9860782 0.9860830 0.9860844 0.9860832 0.9860806 0.9860774 0.9860746
> 0.9860716
> 15.8  0.9856955 0.9856925 0.9856930 0.9856967 0.9857032 0.9857098 0.9857162
> 0.9857213 0.9857248 0.9857268 0.9

Re: [R] Creating Better Table in R

2012-04-09 Thread Carlos Ortega
Hi,

Yes, please check package "tables".

Regards,
Carlos Ortega
www.qualityexcellence.es

2012/4/9 bobo 

> Could anyone please direct me on how to make a nicer table in R? THANKS FOR
> ALL THE HELP!
>
> I would like to make a table with the following in it: estimate, t value,
> significance, beta, standard errors, adjusted r squared, and residual
> standard error (3 decimal points if possible, but I can do it by hand).
> Also
> I'd love to include the source of my information on the bottom of the table
> if possible.
>
> file :  http://r.789695.n4.nabble.com/file/n4542349/datpat.csv datpat.csv
>
> this is the code I am using
>
> mod.1<-lm(Patents~FHouse, data=datpat)
> summary(mod.1)
> xtable(summary(mod.1))
>
> *table I'm creating*
> http://r.789695.n4.nabble.com/file/n4542349/chart.jpg
>
>
>
>
> *Detailed code*
>
> *Summary Stats:*
>
> Residuals:
>Min  1Q  Median  3Q Max
> -1.7540 -0.8833 -0.5123  0.1183 11.9858
>
> Coefficients:
>Estimate Std. Error t value Pr(>|t|)
> (Intercept)  2.617760.52866   4.952 1.34e-06 ***
> FHouse  -0.187920.08489  -2.214   0.0277 *
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> Residual standard error: 1.77 on 254 degrees of freedom
> Multiple R-squared: 0.01893,Adjusted R-squared: 0.01507
> F-statistic: 4.901 on 1 and 254 DF,  p-value: 0.02773
>
> *X Table Code:*
> \begin{table}[ht]
> \begin{center}
> \begin{tabular}{r}
>  \hline
>  & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\
>  \hline
> (Intercept) & 2.6178 & 0.5287 & 4.95 & 0. \\
>  FHouse & -0.1879 & 0.0849 & -2.21 & 0.0277 \\
>   \hline
> \end{tabular}
> \end{center}
> \end{table}
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Creating-Better-Table-in-R-tp4542349p4542349.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Saludos,
Carlos Ortega
www.qualityexcellence.es

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Help required in using apply instead of for loop

2012-01-31 Thread Carlos Ortega
Hi,

You can do that even without apply():

v.v<-seq(10,20, by=0.1)

y<-v.v^2


But if you want it with apply...

apply(as.matrix(v.v), 1, function(x) x^2)


Regards,
Carlos Ortega
www.qualityexcellence.es



2012/1/31 arunkumar 

> Hi
>
> I have  a function
>
> y= x^2
>
> min =10
> max=20
> increment=0.1
>
> I want to find the value of y for the value of x between min and max by
> step
> increment.
>
> how to get the values using apply function instead of for loop
>
> -
> Thanks in Advance
>Arun
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Help-required-in-using-apply-instead-of-for-loop-tp4344350p4344350.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Horizontal stacked 100% bars with ggplot2

2012-01-28 Thread Carlos Ortega
Hello,

If it helps...:


Lines <- "pet gender
dog male
dog female
dog male
cat female
cat female
cat male
"

d.f <- read.table(textConnection(Lines), header=T, as.is = TRUE)

d.tab<-table(d.f$pet, d.f$gender)
d.f.tab<-as.data.frame(table(d.f$pet, d.f$gender))
names(d.f.tab)<-c('pet','gender', 'Freq')


library(lattice)
histogram(
  ~ Freq | pet *gender, data=d.f.tab,
  groups=gender, stack=T, horizontal=T
  )


Regards,
Carlos Ortega
www.qualityexcellence.es



2012/1/27 Mario Giesel 

> Hello, R friends,
>
> I'm trying to crack this nut:
>
>
> Example Data.
>
> petgender
> dogmale
> dogfemale
> dogmale
> catfemale
> catfemale
> catmale
>
> Plot Task.
>
> Horizontal 100% bars where
> y axis shows gender factor (male vs. female)
> and x axis shows percentage of kind of pets (dog vs. cat)
> so that % dogs + % cats are stacked in 1 bar and sum up to 100% (for each
> gender group 1 bar).
>
> How can this be done with ggplot2?
>
> Thanks for any comments!
>
> Mario
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Grabbing Column and Row titles

2012-01-27 Thread Carlos Ortega
Hello,

Please check function which().

> > m <- matrix(1:12,3,4) > which(m==5, arr.ind=T) row col
[1,]   2   2> which(m==9, arr.ind=T) row col
[1,]   3   3

>

Regards,
Carlos Ortega
www.qualityexcellence.es


2012/1/27 chuck.01 

> Please use dput() to post your example matrix.
>
>
>
>
> Rambler1 wrote
> >
> > I have run into a problem in my code. What I want to accomplish is this:
> > I have a user input stock symbols into a list and from there I run the
> > quantmod package to get historical data. I compute the correlation matrix
> > and then turn that matrix into a simple matrix with 1's or 0's depending
> > on how strong the correlation is. From here I would like to go into the
> > matrix and take all the 1's and match them with their row/column titles.
> > So for each 1 I have two stock symblos. For example:
> >   MMM ACE ABT ANF HD PEP K GOOG BIDU JNJ
> > MMM  01   0   0 0 1  0   0 0
> > 0
> > ACE  10   0   0 0 0  0   0
> > 0  1
> > ABT  00   0   0 0 1  0   0
> > 0  1
> > ANF 00   0   0 0 0  00
> > 0  0
> > HD   00   0   0 0 0  00
> > 0  0
> > PEP  10  1   0  0 0  00
> > 0  1
> > K   00  0   0  0 0  0   0
> > 0  0
> > GOOG 00  0   0  0 0  0   0  0
> > 0
> > BIDU00  0   0  0 0  0   0
> > 0  0
> > JNJ 0   1  1  0   0 1   0   0
> > 0  0
> >
> > Say I have this matrix computed. I would like to locate every 1 and the
> > corresponding two names that go with it. (eg MMM/ACE, MMM/PEP and so on.)
> > Thank you for your help!
> >
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Grabbing-Column-and-Row-titles-tp4332136p4333698.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] annotate histogram

2011-11-01 Thread Carlos Ortega
Hi,

You can use function segments() to draw them.


Regards,
Carlos Ortega
www.qualityexcellence.es

2011/11/1 Wendy 

> Hi all,
>
> I want to make a histogram like the one show
> http://nar.oxfordjournals.org/content/39/suppl_1/D1011/F1.expansion.html
> here , but I did not figure out how to add the red marks at the bottom of
> the bars. Could anybody help? Thank you very much
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/annotate-histogram-tp3963960p3963960.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] compressing/reducing data for plot

2011-10-17 Thread Carlos Ortega
Hello,

One alternative is to create some kind of contourplot/levelplot which will
enhance and show clearly the spikes and will smooth the rest of the
information. That perhaps will be slow in generating the plot but not with
the postscript file.

Regards,
Carlos Ortega
www.qualityexcellence.es

2011/10/17 Timo Schneider 

> Hello,
>
> I have simulation results in the form of
>
>  Time  V   I
>  0.e+000  7.218354344368e-001  5.224478627497e-006
>  1.e-009  7.218354344368e-001  5.224477718002e-006
>  2.e-009  7.218354344368e-001  5.224477718002e-006
>  4.000108361244e-009  7.218354344368e-001  5.224478627497e-006
>  8.000325083733e-009  7.218354344368e-001  5.224478627497e-006
>
> as the timesteps are small, each simulation results in a lot of data,
> about 1e5 data points per simulation.
>
> Now I want to plot this data. If I do this with a simple
>
> plot(x=data$Time, y=data$V, type="l")
>
> the resulting file (I plot into postscript files) is huge and takes a
> long time to render, since R creates a new line segment for each
> timestep. Of course it makes no sense to plot more than a few hundred
> datapoints in a single plot. However, I don't have a good idea how to
> remove the "uninteresting" part of the data, i.e., the datapoints that
> lie very close to the lines that would be drawn by R anyway if there
> were no datapoint for that time value.
>
> Since the values in my simulation are constant most of the time but
> sometimes have interesting "spikes" a simple
>
> data <- data[seq(1:length(data),1000),]
>
> to only plot every 1000th point does not work for me as it could remove
> some "spikes" completely or lead to aliasing problems.
>
> Is there any standard way to do this in R?
>
>
> The best thing I came up with so far is a function that judges if a row
> in the dataframe should be kept for plotting based on each points
> difference to its predecessor. However, this function has two problems:
>
> * It is very slow! (Takes about 4 seconds for each 1e5 element
> dataframe)
>
> * It does not work well if the values increase/decrease monotonically
> with small values - it will remove them all since the difference between
> each point and its predecessor is minimal
>
> I included my own function below:
>
> === cut ===
>
> get_significant_rows_1 <- function (data, threshold) {
>
> # get the difference between each datapoint and the following datapoint
> # of course this list is one shorter than the input dataset, which does
> # not matter since the first and last datapoint will always be included
> diffs = abs(data[1:nrow(data)-1,] - data[2:nrow(data),]);
>
> # normalize the differences according to the value range in their column
> col.range = apply(data,2, function(d) {abs(max(d) - min(d))});
> normalized_diffs <- t(apply(diffs, 1, function(d) {d/col.range}));
> rm("col.range");
> # get the "biggest difference" in each row
> biggest_difference <- as.vector(apply(normalized_diffs,1, max));
>
> # check if the "biggest difference" is above the threshold -
> # that means the row is "significant" in a plot
> signif <- biggest_difference >= threshold;
> rm("biggest_difference");
> # the last datapoint/row is always significant, otherwise the plot could
> become "shorter"
> signif[length(signif)] = TRUE;
>
> # also the first one - we are adding a TRUE in front of the signif vector
> # now, since it does not include a value for this because the first value
> # naturally doesn't have a predecessor, so there was no entry for it in
> # the diffs array
> signif <- append(signif, TRUE, 0);
>
> # if a point is significant in a plot, the point before that is also
> "important",
> # at least for line plots, otherwise we get angled lines where flat ones
> should be
> signif <- (signif | append(signif[2:length(signif)], FALSE));
>
> return(data[signif,]);
>
> }
>
> #example application (makes no sense for this kind of data though)
>
> data <- data.frame(a=rnorm(1), b=rnorm(1));
> #dataset, threshold
> get_significant_rows_1(data, 0.01)
>
>  here 
>
> Thank you for any helpful advice or comments. :-)
>
> Regards,
> Timo
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] contouring x y scatter data

2011-10-17 Thread Carlos Ortega
Hi,

Please check if this representation helps you.

library(lattice)
library(latticeExtra)
p1.gr <- cloud( ts181 ~ x * z, data=FD, panel.3d.cloud = panel.3dbars,
scales = list(arrows = FALSE, just = "right"))
p2.gr <- cloud( ts1825 ~ x * z, data=FD, panel.3d.cloud = panel.3dbars,
scales = list(arrows = FALSE, just = "right"))
print(p1.gr, position = c(0, 0, 0.5, 1), more = TRUE)
print(p2.gr, position = c(0.5, 0, 1, 1))

Regards,
Carlos Ortega
www.qualityexcellence.es

2011/10/17 emorway 

> Hello,
>
> I'm almost positive R can do the following, I just haven't hit upon the
> right package or search terms, however.  Here's what I'm after:  I've got
> concentration output from two different models that I want to qualitatively
> compare in a contour plot (or some variant of a contour plot).  The problem
> as I see it is that the data is not gridded is the usual regular fashion,
> and even if it were, the models are working with two different irregular
> computational/numerical grids at which concentrations are calculated.
> Running the code below will produce a plot that will hopefully illuminate
> what I'm attempting to describe.  At each location where 'O' appears, there
> is a calculated concentration that I would like to contour.  I'd like to do
> the same thing at each 'X' location and then compare, visually, how close
> the contours are (hopefully close).  Both data.frames contain
> columns/fields
> titled "ts181" and "ts1825" which contain the concentrations at time step
> 181 days and time step 1825 days.  Is it possible to contour x-y-value data
> if it is not laid out on a regular grid?
>
>
>
> X<-c(0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400!
 ,5!
>
>  
> 00,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,0,100,200,300,400,500,600,700,800,900,10!
 00!
>  ,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,2100,2200,2300,2400
>
> ,2500,2600,2700,2800,2900,3000,3100,3200,3300,3400,3500,3600,3700,3800,3900,4000)
>
>
> Z<-c(50,49.95,49.85,49.75,49.65,49.55,49.45,49.35,49.25,49.15,49.05,48.95,48.85,48.75,48.65,48.55,48.45,48.35,48.25,48.15,48.05,47.95,47.85,47.75,47.65,47.55,47.45,47.35,47.25,47.15,47.05,46.95,46.85,46.75,46.65,46.55,46.45,46.35,46.25,46.15,46.1,49.25,49.2,49.1,49,48.9,48.8,48.7,48.6,48.5,48.4,48.3,48.2,48.1,48,47.9,47.8,47.7,47.6,47.5,47.4,47.3,47.2,47.1,47,46.9,46.8,46.7,46.6,46.5,46.4,46.3,46.2,46.1,46,45.9,45.8,45.7,45.6,45.5,45.4,45.35,48.2,48.15,48.05,47.95,47.85,47.75,47.65,47.55,47.45,47.35,47.25,47.15,47.05,46.95,46.85,46.75,46.65,46.55,46.45,46.35,46.25,46.15,46.05,45.95,45.85,45.75,45.65,45.55,45.45,45.35,45.25,45.15,45.05,44.95,44.85,44.75,44.65,44.55,44.45,44.35,44.3,47,46.95,46.85,46.75,46.65,46.55,46.45,46.35,46.25,46.15,46.05,45.95,45.85,45.75,45.65,45.55,45.45,45.

Re: [R] high and lowest with names

2011-10-11 Thread Carlos Ortega
Hi,

With this code you can find row and col names for the largest value applied
to your example:

r.m.tmp<-apply(dat,1,max)
r.max<-names(r.m.tmp)[r.m.tmp==max(r.m.tmp)]

c.m.tmp<-apply(dat,2,max)
c.max<-names(c.m.tmp)[c.m.tmp==max(c.m.tmp)]

It's inmediate how to get the same for the smallest and build a function to
calculate everything and return a list.


Regards,
Carlos Ortega
www.qualityexcellence.es

2011/10/11 Ben qant 

> Hello,
>
> I'm looking to get the values, row names and column names of the largest
> and
> smallest values in a matrix.
>
> Example (except is does not include the names):
>
> > x <- swiss$Education[1:25]
> > dat = matrix(x,5,5)
> > colnames(dat) = c('a','b','c','d','c')
> > rownames(dat) = c('z','y','x','w','v')
> > dat
>   a  b  c  d  c
> z 12  7  6  2 10
> y  9  7 12  8  3
> x  5  8  7 28 12
> w  7  7 12 20  6
> v 15 13  5  9  1
>
> > #top 10
> > sort(dat,partial=n-9:n)[(n-9):n]
>  [1]  9 10 12 12 12 12 13 15 20 28
> > # bottom 10
> > sort(dat,partial=1:10)[1:10]
>  [1] 1 2 3 5 5 6 6 7 7 7
>
> ...except I need the rownames and colnames to go along for the ride with
> the
> values...because of this, I am guessing the return value will need to be a
> list since all of the values have different row and col names (which is
> fine).
>
> Regards,
>
> Ben
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plots of correlation matrices

2011-10-11 Thread Carlos Ortega
Hi,

One way to do that is this  (avoiding the use of a for loop):


l.txt<- "id category attribute1 attribute2 attribute3 attribute4
661 SCHS 43.2 0 56.5 1
12202 SCHS 161.7 5.7 155 16
1182 SCHS 21.4 0 29 0
1356 SSS  8.8182 0.1818 10.6667 0.6667
1864 SCHS 443.7273 9.9091 537 46
12360 SOA 6.6364 0 10 0
3382 SOA 7.1667 0 26 0.5
1033 SOA 63.9231 1.5385 91.5 11.5
14742 SSS 4.3846 0 8 0
12760 SSS 425.0714 1.7857 297.5 3.5
"

dat.df <- read.table(textConnection(l.txt),  header=T, as.is = TRUE)
closeAllConnections()

dat.lt<-by(dat.df[,3:6], dat.df$category, cor)
lapply(dat.lt,corrplot)


Regards,
Carlos Ortega
www.qualityexcellence.es

2011/10/11 gj 

> Hi,
>
> I want to do a visualisation of a matrix plot made up of several plots of
> correlation matrices (using corrplot()). My data is in csv format. Here's
> an
> example:
>
> id,category,attribute1,attribute2,attribute3,attribute4
> 661,SCHS,43.2,0,56.5,1
> 12202,SCHS,161.7,5.7,155,16
> 1182,SCHS,21.4,0,29,0
> 1356,SSS, 8.8182,0.1818,10.6667,0.6667
> 1864,SCHS,443.7273,9.9091,537,46
> 12360,SOA,6.6364,0,10,0
> 3382,SOA,7.1667,0,26,0.5
> 1033,SOA,63.9231,1.5385,91.5,11.5
> 14742,SSS,4.3846,0,8,0
> 12760,SSS,425.0714,1.7857,297.5,3.5
>
> I can get rid of the id. But I need the 'category' as a way of
> distinguishing the various correlation matrices.
> I can do a plot of the correlation matrix using corrplot() function in the
> corrplot package (ignoring the id and category). But what I need is a
> matrix
> of the plots of each correlation matrix based on the category, ie I have
> three categories in the data, hence I will need three plots of the
> correlation matrix  in one diagram (because the correlation matrix only
> makes sense if they are distinguished by category).
>
> Any help?
>
> Regards
> Gawesh
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Background Colors

2011-10-11 Thread Carlos Ortega
Hi,

Yes, one way to do that is by using function polygon().

Regards,
Carlos Ortega
www.qualityexcellence.es

2011/10/11 Gabriel Yospin 

> Hi R-Help -
>
> If I make a plot:
>
> numYears = 500
> plot(x = c(1,numYears), y = c(200,300), xlab = "Time", ylab = "Vegetation
> Class", xlim = c(100,600), ylim = c(200,300), type="n")
>
> Is there a way to make different parts of the background for the plot
> different colors?
>
> For example, I'd like to have the background color col = (250,250,0,50) for
> y = c(200,204), and col = (250,125,0,50) for y = c(210,212).
>
> Any suggestions?
>
> Thanks in advance for the help,
>
> Gabe
> --
> Gabriel I. Yospin
>
> Institute of Ecology and Evolution
> Bridgham Lab
> University of Oregon
> Eugene, OR 97403-5289
>
> Ph: 541 346 1549
> Fax: 541 346 2364
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] "pos" in panel.text

2011-10-10 Thread Carlos Ortega
Hi Allan,

Please could you send the modified code where now it should appear x and y
coordinates?.
I do not fully understand the error message you get.

Regards,
Carlos Ortega
www.qualityexcellence.es

2011/10/10 Allan Sikk 

> Thanks, Carlos,
>
> Tried that, but no success, still getting this error message:
>
> Warning messages:
> 1: In if (pos == 1) { :
>   the condition has length > 1 and only the first element will be used
> 2: In if (pos == 2) { :
>   the condition has length > 1 and only the first element will be used
>
> Thanks,
> Allan
>
> On 10/10/2011 12:10, Carlos Ortega wrote:
> > Hello,
> >
> > To check the possible values of "pos" parameter you need to review
> > "text()" as it is indicated in the lattice help of panel.text().
> > In  text() it says:
> >
> > |pos|
> >
> > a position specifier for the text. If specified this overrides any
> > |adj| value given. Values of |1|, |2|, |3| and |4|, respectively
> > indicate positions below, to the left of, above and to the right of
> > the specified coordinates.
> >
> >
> > So, the coordinates should be "x=4, y=2" for your case.
> > Additionally you can use ltext() function which is explained in the
> > same panel.text() help.
> >
> >
> > Regards,
> > Carlos Ortega
> > www.qualityexcellence.es <http://www.qualityexcellence.es>
> >
> > 2011/10/10 Allan Sikk mailto:a.s...@ucl.ac.uk>>
> >
> > Hi,
> >
> > I need to vary the placements of data labels but I cannot assign a
> > vector to "pos" option. Any vectors work fine with "cex", for
> > example. What could be the problem here?
> >
> > xyplot(Npop~Narea, data=size,
> > scales=list(x=list(log=TRUE), y=list(log=TRUE),
> > xlab=expression(N[A]), ylab=expression(N[P]),
> > panel=function( ...) {
> >panel.lines(..., type="l", col.line="black", lwd=.25)
> >panel.xyplot(..., type="p", col="black", cex=.5, pch=20)
> >panel.text(..., lab=t, cex=.5, pos=c(4,2))
> > })
> >
> > Many thanks,
> > Allan
> >
> > __
> > R-help@r-project.org <mailto:R-help@r-project.org> mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
>
> --
>
> DrAllan Sikk
>
> Lecturer in Baltic Politics
>
> University College London, School of Slavonic and East European Studies
>
> 16 Taviton St, London WC1H 0BW, United Kingdom
>
> tel: +44 (0)20 7679 4872
>
> http://www.homepages.ucl.ac.uk/~tjmsasi/
>
> Latest research:
>
> - 'Newness as a Winning Formula for New Political Parties', /Party
> Politics/, forthcoming.
>
> - 'Parties and Populism', Centre for European Politics, Security and
> Integration (CEPSI) Working Paper (2010), http://bit.ly/partiespopulism.
>
> - (with Rein Taagepera) 'Parsimonius Model for Predicting Mean Cabinet
> Duration on the Basis of Electoral System', /Party Politics/, 16(2),
> 2010, 261-81.
>
> - 'Force Mineure?The Effects of the EU on Party Politics in a Small
> Country: The Case of Estonia,' /Journal of Communist Studies and
> Transition Politics/, 25(4), 2009, 468-90.
>
> - (with Rune Andersen) 'Without a Tinge of Red: The Fall and Rise of
> Estonian Greens, 1987-2007', /Journal of Baltic Studies/, 40(3), 2009,
> 349-73.
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] "pos" in panel.text

2011-10-10 Thread Carlos Ortega
Hi,

OK.
Have you tried to run your code without the "pos" parameter?

Based on the help, "pos" should be just *one* parameter. "pos" offers a
finer adjustment of the text. But in your case, the first thing to get is
that the text label is represented at the specified coordinates. Besides
"pos" you can try "adj" which is a parameter that allows you to use two
parameters (between 0 and 1).


Regards,
Carlos Ortega
www.qualityexcellence.es

2011/10/10 Allan Sikk 

> Here's the code. The problem seems to be specific for lattice as I can
> easily use a vector with pos in "plot".
>
> trellis.device(,width=600, height = 400)
> xyplot(Npop~Narea,
> scales=list(x=list(log=TRUE, at=my.at,labels = formatC(my.at, big.mark =
> ",", format="d")),
> y=list(log=TRUE, at=c(1,10,100,1000,1,10,100))),
> panel=function(...) {
>  panel.xyplot(..., type="p", col="black", cex=.5, pch=20)
>  panel.text(x=log10(Narea), y=log10(Npop), lab=t,  cex=.5, pos=c(4,2))
> }
>
> )
>
> On 10/10/2011 13:58, Carlos Ortega wrote:
> > Hi Allan,
> >
> > Please could you send the modified code where now it should appear x
> > and y coordinates?.
> > I do not fully understand the error message you get.
> >
> > Regards,
> > Carlos Ortega
> > www.qualityexcellence.es <http://www.qualityexcellence.es>
> >
> > 2011/10/10 Allan Sikk mailto:a.s...@ucl.ac.uk>>
> >
> > Thanks, Carlos,
> >
> > Tried that, but no success, still getting this error message:
> >
> > Warning messages:
> > 1: In if (pos == 1) { :
> >   the condition has length > 1 and only the first element will be
> used
> > 2: In if (pos == 2) { :
> >   the condition has length > 1 and only the first element will be
> used
> >
> > Thanks,
> > Allan
> >
> > On 10/10/2011 12:10, Carlos Ortega wrote:
> > > Hello,
> > >
> > > To check the possible values of "pos" parameter you need to review
> > > "text()" as it is indicated in the lattice help of panel.text().
> > > In  text() it says:
> > >
> > > |pos|
> > >
> > > a position specifier for the text. If specified this overrides any
> > > |adj| value given. Values of |1|, |2|, |3| and |4|, respectively
> > > indicate positions below, to the left of, above and to the right of
> > > the specified coordinates.
> > >
> > >
> > > So, the coordinates should be "x=4, y=2" for your case.
> > > Additionally you can use ltext() function which is explained in the
> > > same panel.text() help.
> > >
> > >
> > > Regards,
> > > Carlos Ortega
> > > www.qualityexcellence.es <http://www.qualityexcellence.es>
> > <http://www.qualityexcellence.es>
> > >
> > > 2011/10/10 Allan Sikk  > <mailto:a.s...@ucl.ac.uk> <mailto:a.s...@ucl.ac.uk
> > <mailto:a.s...@ucl.ac.uk>>>
> > >
> > > Hi,
> > >
> > > I need to vary the placements of data labels but I cannot
> > assign a
> > > vector to "pos" option. Any vectors work fine with "cex", for
> > > example. What could be the problem here?
> > >
> > > xyplot(Npop~Narea, data=size,
> > > scales=list(x=list(log=TRUE), y=list(log=TRUE),
> > > xlab=expression(N[A]), ylab=expression(N[P]),
> > > panel=function( ...) {
> > >panel.lines(..., type="l", col.line="black", lwd=.25)
> > >panel.xyplot(..., type="p", col="black", cex=.5, pch=20)
> > >panel.text(..., lab=t, cex=.5, pos=c(4,2))
> > > })
> > >
> > > Many thanks,
> > > Allan
> > >
> > > __
> > > R-help@r-project.org <mailto:R-help@r-project.org>
> > <mailto:R-help@r-project.org <mailto:R-help@r-project.org>>
> > mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible
> > 

Re: [R] "pos" in panel.text

2011-10-10 Thread Carlos Ortega
Hello,

To check the possible values of "pos" parameter you need to review "text()"
as it is indicated in the lattice help of panel.text().
In  text() it says:

pos

a position specifier for the text. If specified this overrides any adj value
given. Values of 1, 2, 3 and 4, respectively indicate positions below, to
the left of, above and to the right of the specified coordinates.

So, the coordinates should be "x=4, y=2" for your case.
Additionally you can use ltext() function which is explained in the same
panel.text() help.


Regards,
Carlos Ortega
www.qualityexcellence.es

2011/10/10 Allan Sikk 

> Hi,
>
> I need to vary the placements of data labels but I cannot assign a vector
> to "pos" option. Any vectors work fine with "cex", for example. What could
> be the problem here?
>
> xyplot(Npop~Narea, data=size,
> scales=list(x=list(log=TRUE), y=list(log=TRUE),
> xlab=expression(N[A]), ylab=expression(N[P]),
> panel=function( ...) {
>panel.lines(..., type="l", col.line="black", lwd=.25)
>panel.xyplot(..., type="p", col="black", cex=.5, pch=20)
>panel.text(..., lab=t, cex=.5, pos=c(4,2))
> })
>
> Many thanks,
> Allan
>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] help with statistics in R - how to measure the effect of users in groups

2011-10-10 Thread Carlos Ortega
Hello,

In package "qualityTools" you can find one way to perform this analysis
through the gageRR() function.
The effect of an operator on the mesasurement system (Reproductibility) is
to me equivalent to the effect you try to study of your users when they are
in different groups.

Regards,
Carlos Ortega
www.qualityexcellence.es


On Mon, Oct 10, 2011 at 12:48 PM, gj  wrote:

> Thanks Petr. I will try it on the real data.
>
> But that will only show that the groups are different or not.
> Is there any way I can test if the users are different when they are in
> different groups?
>
> Regards
> Gawesh
>
> On Mon, Oct 10, 2011 at 11:17 AM, Petr PIKAL 
> wrote:
>
> > >
> > > Hi Petr,
> > >
> > > It's not an equation. It's my mistake; the * are meant to be field
> > > separators for the example data. I should have just use blank spaces as
> > > follows:
> > >
> > > users   Group1   Group2   Group3
> > > u110   5N/A
> > > u2 6  N/A  4
> > > u3 5   23
> > >
> > >
> > > Regards
> > > Gawesh
> >
> > OK. You shall transform your data to long format to use lm
> >
> > test <- read.table("clipboard", header=T, na.strings="N/A")
> > test.m<-melt(test)
> > Using users as id variables
> > fit<-lm(value~variable, data=test.m)
> > summary(fit)
> >
> > Call:
> > lm(formula = value ~ variable, data = test.m)
> >
> > Residuals:
> >   1234689
> >  3.0 -1.0 -2.0  1.5 -1.5  0.5 -0.5
> >
> > Coefficients:
> >   Estimate Std. Error t value Pr(>|t|)
> > (Intercept)   7.000  1.258   5.563 0.00511 **
> > variableGroup2   -3.500  1.990  -1.759 0.15336
> > variableGroup3   -3.500  1.990  -1.759 0.15336
> > ---
> > Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> >
> > Residual standard error: 2.179 on 4 degrees of freedom
> >  (2 observations deleted due to missingness)
> > Multiple R-squared: 0.525,  Adjusted R-squared: 0.2875
> > F-statistic: 2.211 on 2 and 4 DF,  p-value: 0.2256
> >
> > No difference among groups, but I am not sure if this is the correct way
> > to evaluate.
> >
> > library(ggplot2)
> > p<-ggplot(test.m, aes(x=variable, y=value, colour=users))
> > p+geom_point()
> >
> > There is some sign that user3 has lowest value in each group. However for
> > including users to fit there is not enough data.
> >
> > Regards
> > Petr
> >
> >
> > >
> > >
> > > On Mon, Oct 10, 2011 at 9:32 AM, Petr PIKAL 
> > wrote:
> > >
> > > > Hi
> > > >
> > > > I do not understand much about your equations. I think you shall look
> > to
> > > > Practical Regression and Anova Using R from J.Faraway.
> > > >
> > > > Having data frame DF with columns - users, groups, results you could
> > do
> > > >
> > > > fit <- lm(results~groups, data = DF)
> > > >
> > > > Regards
> > > > Petr
> > > >
> > > >
> > > >
> > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > > I'm a newbie to R. My knowledge of statistics is mostly
> self-taught.
> > My
> > > > > problem is how to measure the effect of users in groups. I can
> > calculate
> > > > a
> > > > > particular attribute for a user in a group. But my hypothesis is
> > that
> > > > the
> > > > > user's attribute is not independent of each other and that the
> > user's
> > > > > attribute depends on the group ie that user's behaviour change
> based
> > on
> > > > the
> > > > > group.
> > > > >
> > > > > Let me give an example:
> > > > >
> > > > > users*Group 1*Group 2*Group 3
> > > > > u1*10*5*n/a
> > > > > u2*6*n/a*4
> > > > > u3*5*2*3
> > > > >
> > > > > For example, I want to be able to prove that u1 behaviour is
> > different
> > > > in
> > > > > group 1 than other groups and the particular thing about Group 1 is
> > that
> > > > > users in Group 1 tend to have a higher value of the attribute under
> > > > > measurement.
&g

Re: [R] Multiple levelplot with title

2011-10-09 Thread Carlos Ortega
Hi,

Use function ltext() instead, also available in lattice package.

Regards,
Carlos Ortega
www.qualityexcellence.es


On Sun, Oct 9, 2011 at 6:30 PM, Richard O. Legendi <
richard.lege...@gmail.com> wrote:

> Hi all,
>
> I'm new to R and to the mailing list, so please bear with me :-)
>
> I would like to create multiple levelplots on the same chart with a nice
> main title with something like this:
>
>  print(levelplot(matrix(c(1,2,**3,4), 2, 2)), split=c(1, 1, 2, 1))
>  print(levelplot(matrix(c(1,2,**3,4), 2, 2)), split=c(2, 1, 2, 1),
>newpage=FALSE)
>
> I found a trick:
>
>  mtext("Test", outer = TRUE, cex = 1.5)
>
> here:
>
>  
> https://stat.ethz.ch/**pipermail/r-help/2008-July/**168163.html<https://stat.ethz.ch/pipermail/r-help/2008-July/168163.html>
>
> but it doesn't works for me.
>
> Could anyone please show me some pointers what should I read in order to
> get an insight why this isn't working as I expect?
>
> What I managed to find a workaround by using panel.text(), but I don't
> really like it since it requires defined x/y coordinates and not scales if
> the picture is resized.
>
>panel.text(x=20, y=110, "Test")
>
> Thanks in advance!
> Richard
>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] barplots

2011-10-09 Thread Carlos Ortega
Hi,

Another way to do that is with function barchart() in package lattice.
Barchart requires a function which relates your variables with the option to
specify groups.
Check the examples (are under xyplot help) to apply them to your case.

Regards,
Carlos Ortega
www.qualityexcellence.es


On Thu, Oct 6, 2011 at 11:16 PM, Daniel Winkler wrote:

> Hello,
>
> I have somewhat of a weird data set and am attempting to create a barplot
> with it.
>
> I have 8 columns with different variables and their percentages. I have 1
> column with representations of 4 different treatments the variables
> undergo.
> I also have 1 column with year the data was recorded. I want to create a
> bar
> plot that plots all 8 variables grouped by treatment and year.
>
> I've tried creating subsets of each of the variables, no luck.
>
> My variables are arranged similar to this:
>
> Vascular.plants Solid.rock Gravel.and.cobbles
>72.51.0  5
>   67.52.0  6
>67.52.5  9
>59.02.0 25
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] variable name question

2011-10-09 Thread Carlos Ortega
Hello,

In R you just need to take the log of the whole whole data.frame where you
have your pci* and store in a new variable.
You do not need to use a "for" loop:

log.df <- log(your_data_frame)

Regards,
Carlos Ortega
www.qualityexcellence.es


On Sun, Oct 9, 2011 at 5:34 PM, deepankar  wrote:

> Hi All,
>
> This is surely an easy question but somehow I am not being able to get it.
>
> I am using R 2.13.2 and have a data set where variable names like this
> appear:
>
> pci1990, pci1991, ... , pci2009.
>
> "pci1990" has data on per capita income for 1990, "pci1991" has data on per
> capita income for 1991, and so on.
>
> I would like to create the logarithm of per capita for each of the year and
> could do so in STATA with the following commands:
>
> forvalues number = 1990/2009 {
>gen lpci`number' = log(pci`number')
> }
>
> What would be the corresponding set of commands in R?
>
> Thanks a lot in advance.
>
> Deepankar
>
> __**
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide http://www.R-project.org/**
> posting-guide.html <http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Colour code y-axis labels on a dot plot

2011-09-16 Thread Carlos Ortega
Hi,

Sorry but I am not able to reproduce the plot with your code.
I could change two sentences which got an error (highlighted the changes):

# Change 1
key1 <-
   draw.key(list(text=list(levels(*as.factor*(Cal_dat$Cmmdty))),

# Change 2
ave_dat<-aggregate(*Rsrc_Gt ~Yr, data=cal_dat, mean*)

But even with these two corrections I got this error when creating the plot:

Error en grid.Call.graphics("L_setviewport", pvp, TRUE) :
  'getCharCE' must be called on a CHARSXP



I could get a graphic but skipping pch, fill and scales variables in the
panel function.

Regards,
Carlos Ortega
www.qualityexcellence.es

On Fri, Sep 16, 2011 at 4:13 AM, markm0705  wrote:

> Dear Carlos
>
> Attached is attempt at getting your scales suggestion to work (which at the
> moment does not)
> - I'm hoping you have the time to assist again
>
> (data file correctly attached this time).
>
>
> Thanks in advance
>
> Mark M
>
>
>
>
>
>
> On Thu, Sep 15, 2011 at 11:30 PM, Carlos Ortega [via R] <
> ml-node+s789695n3815937...@n4.nabble.com> wrote:
>
> > Hi,
> >
> > You can use scales() and parametrize it with a list where you can define
> > colors, fonts, etc.
> >
> > I could not test it on your code because variable "Commodity" is not
> > present
> > in the dataset you provided.
> >
> > Regards,
> > Carlos Ortega
> > www.qualityexcellence.es
> >
> >  On Thu, Sep 15, 2011 at 11:03 AM, markm0705 <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=3815937&i=0>>
> > wrote:
> >
> > > Dear R helpers
> > >
> > > I would like to be able to colour code the y-axis labels on a complex
> dot
> >
> > > plot by a variable known as company (of which there are only two).  The
> > > code
> > > is below and data attached.
> > >
> > > Thanks
> > >
> > > MarkM
> > >
> > > library("lattice")
> > > library(latticeExtra) # for mergedTrellisLegendGrob()
> > >
> > > # set size of the window
> > > windows(height=10, width=7,rescale=c("fixed"))
> > >
> > > ##read the data to a variable
> > >
> > >
> >
> #
> >
> > >
> > > Cal_dat <- read.table("Calibration2.dat",header = TRUE,sep = "\t",)
> > >
> > > ## set up plotting colours
> > >
> > >
> >
> #
> >
> > > # Colours for the six commodity
> > >
> > > col.pat<-c("violet","cyan","green","red","blue","black","yellow")
> > >
> > > # Circles squares and diamond symbols for the year
> > > sym.pat<-c(19,20,21)
> > >
> > > ##set up the plot key
> > >
> > >
> >
> #
> >
> > > # key for commodities
> > > # defaults
> > > bord.col<-"grey90"
> > > trans.fac<-0.9
> > > sym.siz<-1.8
> > >
> > > key1 <-
> > >   draw.key(list(text=list(levels(Cal_dat$Commodity)),
> > >title="Ore type",
> > >border =bord.col,
> > >background = bord.col,
> > >alpha.background=trans.fac,
> > >just=1,
> > >points=list(pch=22, cex=sym.siz, fill=col.pat,
> > > col="transparent")),
> > >draw = FALSE)
> > > key2 <-
> > >   draw.key(list(text=list(levels(factor(Cal_dat$Year))),
> > >title="Year",
> > >border = bord.col,
> > >background = bord.col,
> > >alpha.background=trans.fac,
> > >just=1,
> > >points = list(pch = c(21, 22, 23), cex=sym.siz,
> > > col="black")),
> > >draw = FALSE)
> > >
> > > mkey <-
> > >   mergedTrellisLegendGrob(list(fun = key2),
> > >   list(fun = key1),
> > >   vertical = FALSE
> > > )
> > >
> > &

Re: [R] Color barplots with a conditional?

2011-09-15 Thread Carlos Ortega
Hello,

There are some specific examples included in the help of barplot() that
answer your question.

Regards,
Carlos Ortega
www.qualityexcellence.es

On Wed, Sep 14, 2011 at 10:14 PM, Allie818  wrote:

> I've made a barplot that has several bars. I'd like the bars to be colored
> according to the type of category they are in. Is there a way to put a
> conditional into the color parameter in barplot?
> i.e. if data$category[i] == 1, color the bar red
>
> Do I need to generate the coloring sequence before the plot code first?
>
> Thanks!!
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Color-barplots-with-a-conditional-tp3813990p3813990.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Colour code y-axis labels on a dot plot

2011-09-15 Thread Carlos Ortega
Hi,

You can use scales() and parametrize it with a list where you can define
colors, fonts, etc.

I could not test it on your code because variable "Commodity" is not present
in the dataset you provided.

Regards,
Carlos Ortega
www.qualityexcellence.es

On Thu, Sep 15, 2011 at 11:03 AM, markm0705  wrote:

> Dear R helpers
>
> I would like to be able to colour code the y-axis labels on a complex dot
> plot by a variable known as company (of which there are only two).  The
> code
> is below and data attached.
>
> Thanks
>
> MarkM
>
> library("lattice")
> library(latticeExtra) # for mergedTrellisLegendGrob()
>
> # set size of the window
> windows(height=10, width=7,rescale=c("fixed"))
>
> ##read the data to a variable
>
> #
>
> Cal_dat <- read.table("Calibration2.dat",header = TRUE,sep = "\t",)
>
> ## set up plotting colours
>
> #
> # Colours for the six commodity
>
> col.pat<-c("violet","cyan","green","red","blue","black","yellow")
>
> # Circles squares and diamond symbols for the year
> sym.pat<-c(19,20,21)
>
> ##set up the plot key
>
> #
> # key for commodities
> # defaults
> bord.col<-"grey90"
> trans.fac<-0.9
> sym.siz<-1.8
>
> key1 <-
>   draw.key(list(text=list(levels(Cal_dat$Commodity)),
>title="Ore type",
>border =bord.col,
>background = bord.col,
>alpha.background=trans.fac,
>just=1,
>points=list(pch=22, cex=sym.siz, fill=col.pat,
> col="transparent")),
>draw = FALSE)
> key2 <-
>   draw.key(list(text=list(levels(factor(Cal_dat$Year))),
>title="Year",
>border = bord.col,
>background = bord.col,
>alpha.background=trans.fac,
>just=1,
>points = list(pch = c(21, 22, 23), cex=sym.siz,
> col="black")),
>draw = FALSE)
>
> mkey <-
>   mergedTrellisLegendGrob(list(fun = key2),
>   list(fun = key1),
>   vertical = FALSE
> )
>
> ##set some parameters for the plot
>
> #
> trellis.par.set(
>dot.line=list(col = "grey95", lty=1),
>axis.line=list(col = "grey50"),
>axis.text=list(col ="grey50", cex=0.8),
>panel.background=list(col="transparent")
> )
>
> ## Create the dot plot
>
> #
> # some mean values for reference lines first
>
> ave_dat<-aggregate(Cal_dat$Resc_Gt, by = list(Cal_dat$Year),mean)
>
> # create the plot
>
> with(Cal_dat,
>dotplot(reorder(paste(Mine,Company), Resc_Gt) ~ Resc_Gt,
>fill_var = Commodity,
>pch_var = factor(Year),
>xlab_var = factor(Company),
>pch = c(21, 22, 23),
>cex=sym.siz,
>col = "black",
>fill = col.pat,
>alpha=0.6,
>legend = list(inside = list(fun = mkey,corner = c(0.97, 0.06))),
>scales = list(x = list(log = 10)),
>xscale.components = xscale.components.log10ticks,
>origin = 0,
>type = c("p","a"),
>main = "Mineral resources",
>xlab= "Total tonnes (billions)",
>panel = function(x, y, ..., subscripts,
> fill, pch, fill_var, pch_var) {
>pch <- pch[pch_var[subscripts]]
>fill <- fill[fill_var[subscripts]]
>panel.ablineq(v=log(ave_dat[1,2]),col="grey60", lty=1,
> rotate=
> TRUE,label="2002", at=0.40)
>panel.ablineq(v=log(ave_dat[2,2]),col="grey60", lty=1,
> rotate=
> TRUE,label="2009", at=0.50)
>panel.ablineq(v=log(ave_dat[3,2]),col="grey60", lty=1,
> rotate=
> TRUE,label="2010", at=0.60)
>panel.dotplot(x, y, pch = pch, fill = fill, .

Re: [R] Need formatting help - ctree - plot.party - node_hist

2011-09-08 Thread Carlos Ortega
Hi,

You can get something better in this way:

plot(mtree,terminal_panel=node_barplot(mtree, ylines=1.2, gap=0.05))


Check node_barplot() for details, although it does not offer for barplots
the possibility to graph it horizontally.

Regards,
Carlos Ortega
www.qualityexcellence.es

On Thu, Sep 8, 2011 at 3:35 PM, Warren W. Kretzschmar
wrote:

> Hi,
> I am trying to get the terminal nodes of a plot of a ctree object to look
> nice.
>
> Using the iris data I have:
>
> library(party)
> mtree <- ctree(Species ~ ., data=iris)
> plot(mtree,terminal_panel=node_barplot(mtree))
>
> The terminal nodes don't display the species names because the names
> are displayed horizontally.  I would like to reduce the size of the
> labels and make the terminal nodes horizontal barplots or rotate the
> labels by 90 degrees, but I don't know how to do this.  Any help is
> appreciated.
>
> Warren
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] global optimisation with inequality constraints

2011-09-08 Thread Carlos Ortega
Hi,

I think this other post could help:
http://stackoverflow.com/questions/7328104/optim-with-inequality-constraint

Regards,
Carlos Ortega
www.qualityexcellence.es

On Thu, Sep 8, 2011 at 3:54 PM, Liu Evans, Gareth <
gareth.liu-ev...@liverpool.ac.uk> wrote:

> Dear All,
>
> I would like to minimise a nonlinear function subject to linear inequality
> constraints as part of an R program.  I have been using the constrOptim
> function.  I have tried all of the methods that come with Optim, but nothing
> finds the correct solution.  If I use the correct solution as the vector of
> starting values, though, my program does output the correct solution and
> optimum - the problem seems to be my choice of optimisation method.
>
> Optim includes a global optimisation method, SANN, but it doesn't make
> sense to use this in constrOptim (see
> http://tolstoy.newcastle.edu.au/R/e4/help/08/01/1328.html, also I tried it
> unsuccesfully).  Is there another global optimisation method that I can use?
>
> Regards,
> Gareth
>
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] "rpart" or "tree" function issue

2011-09-08 Thread Carlos Ortega
Hi,

Use packages "rpart.plot" or "maptree" to enhance the tree drawing.
Or another alternative, use "party" package that offers much more graphing
possibilities.

Regards,
Carlos Ortega
www.qualityexcellence.es


On Thu, Sep 8, 2011 at 5:27 PM, Brian Jensvold  wrote:

> I am trying to create a classification tree using either tree or rpart
> functions but when it comes to plotting the results the formatting I get is
> different than what I see in all the tutorials (like
> http://www.youtube.com/watch?v=9XNhqO1bu0A or
> http://www.youtube.com/watch?v=m3mLNpeke0I&feature=related or
> http://www.statmethods.net/advstats/cart.html "tree for kyphosis").  I am
> trying to take a large demographic population and create a tree which
> systematically and accurately divides them into 2 pre-defined
> classifications using multiple predictor variables.  What I would like to
> see is what I have seen in the tutorials similar to to the ones provided
> above, where it shows something like "12/2" in each leaf or stem or step of
> the tree which is meant to be interpreded as "at this step/stage there are
> 12 people of this category and 2 of the other.  Instead I am presently
> getting something like .342524 which I guess could be the result of
> divideing the two groups inorder to find some porportion but im not sure,
> and would that be 34% group a or group b?  I was also wondering how you
> know
> which side is the side of each test where the individual passes or fails?
> Is yes/pass always on the left?
>
> I'm pretty sure this is just a mater of changing some sort of default
> settings and is in no way a critique of the fine work the designers of R
> have freely provided us.
>
>
> Thank you
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] problems with function read.table

2011-09-08 Thread Carlos Ortega
Hi,

If you read carefully the help pages for read.table you get this:


na.stringsa character vector of strings which are to be interpreted as
NA<../../utils/help/NA> values.
Blank fields are also considered to be missing values in logical, integer,
numeric and complex fields.

So, both NAs and blank fields are considered as NAs directly by read.table.

Once you have imported your data, you can modify with any of the string
manipulation functions (sub() or gsub()) to change your "#DIV/0!" to the
string "NAs". Another option is to manipulate your Excel file and consider
the division by cero with a "IF" and get back a NA if that happens.

And finally, instead of using na.omits use option na.rm=T to get done your
calculations:

> mean(c(12,23,24,45,67,NA), na.rm=T)[1] 34.2



Regards,
Carlos Ortega
www.qualityexcellence.es

On Thu, Sep 8, 2011 at 4:23 PM, Samir Benzerfa  wrote:

> Hello everyone
>
>
>
> I have a couple of questions about the usage of the R function
> "read.table(.)". My point of departure is that I want to import a matrix
> (consisting of time and daily stock returns of many stocks) in R. Most of
> the data is numeric, however some values are missing (blanks) and in other
> cases I have the character "#DIV/0!" (from excel). My goal is to do some
> regression analysis with this matrix. My questions now are the following
> ones:
>
>
>
> 1.   How can I in general tell R to automatically replace some specific
> numbers or characters in tables by others? (for example to replace all
> characters "#DIV/0!" by the number 0 or simply "NA")
>
> 2.   How can I tell R to fill blanks with a number 0 or "NA"?
>
> 3.   How can I tell R to omit the "NA" fields in the calculations but
> not the whole row or column? (I realized that the function "na.omit" omits
> the whole row)
>
>
>
> Many thanks for your help!
>
>
>
> Sincerely,
>
> Samir
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] monthly boxplot

2011-08-09 Thread Carlos Ortega
Hi,

Yes. Use lines()



Regards,
Carlos Ortega
www.qualityexcellence.es

On Tue, Aug 9, 2011 at 4:17 PM, Fernando Andreacci wrote:

> It worked, thanks.
>
> Is there a way to put a trend line through the boxplots?
>
>
> On Tue, Aug 9, 2011 at 10:58 AM, David Winsemius  >wrote:
>
> >
> > On Aug 9, 2011, at 9:46 AM, Fernando Andreacci wrote:
> >
> >  I'm trying to make a monthly boxplot using this:
> >>
> >> boxplot(varmeasure ~ vardates)
> >>
> >> vardates = [1] 10/1/2010 10/1/2010 10/1/2010 10/1/2010 10/1/2010
> 10/1/2010
> >> 10/1/2010
> >> [8] 10/1/2010 10/1/2010 11/1/2010 11/1/2010 11/1/2010 11/1/2010
> 11/1/2010
> >> 
> >>
> >> varmeasure =  [1]   0.0  26.0   0.2  -0.2  -1.2  -0.8   0.0   4.4  -0.6
> >> -0.2  14.4  -0.2
> >> [13]   4.8   4.0   2.8   3.2   3.8   3.2 -11.4   0.2   0.4   3.0   0.6
> >> 6.2
> >> 
> >>
> >>
> >> they have same size.
> >>
> >>
> >> My problem is that R is ploting ordered by months and not by year and by
> >> months
> >>
> >> I'm getting 1/1/2011, 10/1/2010, 11/1/2010, 2/1/2011
> >>
> >> How can I plot it in chronological order?
> >>
> >
> > By converting those character strings to dates. At the moment you seem to
> > believe that R has the ability to "know" that you want these strings to
> be
> > dates.
> >
> > ?as.Date
> > ?Dates
> >
> > --
> >
> > David Winsemius, MD
> > West Hartford, CT
> >
> >
>
>
> --
> Fernando Andreacci
> Biólogo
> Fone +55 47 9921 4015
>+55 41 9921 3934
> fandrea...@gmail.com
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] plotting groups via density and different colors

2011-07-20 Thread Carlos Ortega
Hi,

Instead of hist you can use functions histogram() or densityplot() in
lattice package:

require(lattice)

histogram(
~ length | factor(sex), data=dene
)

densityplot(
~ length, data=dene,
groups=factor(sex),
auto.key = list(space = "bottom")
  )

Regards,
Carlos Ortega
www.qualityexcellence.es


On Mon, Jul 18, 2011 at 3:50 PM, Jacob Kasper  wrote:

> I have a data set that looks like this:
> dene <- data.frame(length =
> c(35,32,33,34,41,40,46,35,41,40,45,36,38,37,39,40,42,42,42,43,44),
> sex=c(1,1,1,1,2,2,2,1,2,2,2,1,2,2,2,2,2,2,2,2,2))
>
> I would like to plot the density (frequency of occurrence) of each length
> class but I want to have different colors for sex. I used the following:
> library(sm)
> sex.f<-factor(as.factor(dene$sex),levels=c(1,2),
> labels=c("Males","Females"))
> sm.density.compare(dene$length, dene$sex)
> yet I want the sum of the areas under the two curves to be equal to 1, not
> the sum of the area under each curve to be equal to 1.
>
> I can plot the frequency using hist, but then I do not get the two colors
> indicating the difference in sex.
>
>
> hist(dene$length, freq=F, breaks=11)
>
> any thoughts on how to approach this would be appreciated.
>
> Thank you
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] bar chart issue

2011-07-20 Thread Carlos Ortega
Hi Jeff,

One way to graph the differences between the two years for the first set of
data is via barchart(), a function equivalent to barplot in the lattice
package.

Please check if with this portion of code (and with your data) the graph you
get is quite self-explanatory.

###
require(lattice)

Lines<-"Parasite Year Infected
Leukocytozoon 2009 0.2564
Plasmodium 2009 0.3846
Hemoproteus 2009 0.0769
Leukocytozoon 2010 0.0562
Plasmodium 2010 0.7079
Hemoproteus 2010 0.3034
Any 2009 0.5128
Any 2010 0.7753
"
DF <- read.table(textConnection(Lines),  skip=1, as.is = TRUE,
   col.names=c("Parasite", "Year", "Infected")
  )


barchart(
 Infected ~ Parasite, data=DF,
 groups=as.factor(Year),
 auto.key = list(space = "bottom"),
 origin=0
     )

##

Regards,
Carlos Ortega
www.qualityexcellence.es


On Wed, Jul 20, 2011 at 5:56 AM, Stratford, Jeffrey <
jeffrey.stratf...@wilkes.edu> wrote:

> Hi everyone,
>
>
>
> I determined the presence of three types parasites in a passerine bird
> over two years. I would like to create a bar chart that shows the
> proportion infected on the y and year/parasite on the x such that each
> type of parasite is grouped together (single label) and a bar for each
> year .  This would show if there have been changes in the prevalence of
> a the parasite over two years.
>
>
>
> This is the summary data:
>
>
>
> ParasiteYear   Infected
>
> Leukocytozoon 2009   0.2564
>
> Plasmodium   2009   0.3846
>
> Hemoproteus2009   0.0769
>
> Leukocytozoon 2010   0.0562
>
> Plasmodium   2010   0.7079
>
> Hemoproteus2010   0.3034
>
> Any2009   0.5128
>
> Any2010   0.7753
>
>
>
> Here are rows 86 to 92.  Band and site were recorded differently each
> year but these are not part of any calculation.
>
>
>
>   Year   band site Plasmodium Hemoproteus Leukocytozoon Any
>
> 86 2010 2341-06597 1041  1   1 1   1
>
> 87 2010 2341-06598 1041  0   0 0   0
>
> 88 2010 2341-06599 1042  1   1 0   1
>
> 89 2010 2341-06600 1042  0   1 0   1
>
> 90 2009   6443 SOSP0901  0   0 1   1
>
> 91 2009   6444 SOSP0902  0   1 0   1
>
> 92 2009   6445 SOSP0903  0   0 0   0
>
>
>
> Any suggestions on how to create this plot would be greatly appreciated.
>
>
>
>
> Many thanks,
>
>
>
> Jeff
>
>
>
>
>
> *
>
> Jeffrey A. Stratford, Ph.D.
>
> Department of Health and Biological Sciences
>
> 84 W. South St.
>
> Wilkes Univertsity, PA 18766
>
> 570-332-2942
>
> http://web.wilkes.edu/jeffrey.stratford/
>
> *
>
>
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] RMySQL, RODBC, dbReadTable and ISO-8859-1 (Spanish data)

2011-07-18 Thread Carlos Ortega
Hola Mario,

No sé si finalmente pudiste solucionar el problema que planteaste, por si
todavía lo tienes te sugiero que incluyas el correo en la lista de ayuda de
R pero en español R-help-es.

Puedes darte de alta aquí:
https://stat.ethz.ch/mailman/listinfo/r-help-es

Saludos,
Carlos Ortega
www.qualityexcellence.es

On Fri, Jul 1, 2011 at 10:10 PM, Mario Martínez
wrote:

> Hello R users,
>
> I am reading data into R from RMySQL or SQLite databases which are in
> Spanish language. I am using RMySQL library and function dbReadTable but I
> could not get characters with ñ and tilde, instead R does put ?.
>
> In the past I could manage it modifying the R options as (using windows):
>
> op <- options()
> op$encoding <- "iso-8859-1"
> options(op)
>
> but now in ubuntu it did not work. I am working in ubuntu 10.04 and R
> 2.10.1.
>
> I hope somebody could help me to figure it out.
>
> Thanks,
>
> Mario Martínez A.
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Procesamiento paralelo

2011-06-14 Thread Carlos Ortega
Hola Javier,

Sí, mira este detalle:

http://cran.at.r-project.org/web/views/HighPerformanceComputing.html

Saludos,
Carlos Ortega
www.qualityexcellence.es

2011/6/14 Javier Alfonso Valdés 

> Hola, soy nuevo en la lista y en R, disculpen esta pregunta, pero no he
> encontrado información actualizada.
> Mi pregunta, es R capaz de realizar procesamiento paralelo?
>
>
> --
> Atentamente
> Ing. Javier Alfonso Valdés
> Universidad de las Ciencias Informáticas.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] k-nn hierarchical clustering

2011-06-10 Thread Carlos Ortega
Hi,

Yes, check for function ann in package "yaImpute".

Regards,
Carlos Ortega
www.qualityexcellence.es


On Thu, Jun 9, 2011 at 1:51 PM, Christian Hennig wrote:

> Hi there,
>
> is there any R-function for k-nearest neighbour agglomerative hierarchical
> clustering?
> By this I mean standard agglomerative hierarchical clustering as in hclust
> or agnes, but with the k-nearest neighbour distance between clusters used on
> the higher levels where there are at least k>1 distances between two
> clusters (single linkage is 1-nearest neighbour clustering)?
>
> Best regards,
> Christian
>
> *** --- ***
> Christian Hennig
> University College London, Department of Statistical Science
> Gower St., London WC1E 6BT, phone +44 207 679 1698
> chr...@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] multiple variables Y and X

2011-04-04 Thread Carlos Ortega
Hello,

You can do that like in the example included in the function step()

lm1 <- lm(Fertility ~ ., data = swiss)


But my advise is that prior to doing that, you should check this old
thread in this list:

http://tolstoy.newcastle.edu.au/R/e4/help/08/02/2842.html


Regards,
Carlos Ortega
www.qualityexcellence.es

On Mon, Apr 4, 2011 at 8:58 AM, Rosario Garcia Gil
wrote:

> Hello
>
> I have a model with several hundred Y variables, and also several 1000 X
> variables. The model is linear lm(Y ~ X). My questions are:
>
> 1.- how to avoid writing all Xs variables? is list() the right function?
>
> 2.- about the multiple Ys with dependence among some of them, how to
> incorporate that information in the linear model?
>
> Thank you
>
> Rosario
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Find Principal Component Score per year

2011-03-22 Thread Carlos Ortega
Hello,

First, you can try to split your data frame in this way:

list.year<-split(pca, unique(pca$year))

And then apply the principal component analysis over the list "list.year".

Regards,
Carlos Ortega
www.qualityexcellence.es

On Tue, Mar 22, 2011 at 12:35 PM, mathijsdevaan wrote:

> Hi,
>
> I am trying to calculate Principal Component Scores per id per year using
> the psych package. The following lines provide the scores per obeservation
>
> pca = data.frame(read.table(textConnection("id  year  A  B  C  D
> 1001  1972   64 56  14  23
> 1003  1972   60 55  62111
> 1005 197257 51  10  47
> 1007 197259 49  7   10
> 1009 197265 50  9   32
> 1011 197252 58  3   5
> 1013 197263 52  9   27
> 1001 197365 56  14  25
> 1003 197361 55  62  7
> 1005 197358 51  10  47
> 1007 197360 49  7   19
> 1009 197366 50  9   32
> 1011 197353 58  3   5
> 1013 197364 52  9   28
> 1001 197466 56  14  23
> 1003 197462 55  62  11
> 1005 197459 51  10  46
> 1007 197461 49  7   10
> 1009 197467 50  9   38
> 1011 197454 58  3   5
> 1013 197465 52  9   24
> 1001 197567 56  1   23
> 1003 197563 55  6   1
> 1005 197560 51  1   47
> 1007 197562 49  7   10
> 1009 197568 50  9   32
> 1011 197555 58  3   5
> 1013 1975  66   52  9   27"),head=TRUE))
>
> library(psych)
> pcascores<-principal(pca[,-2], nfactors=1, score=TRUE)
>
> However, the scores should be based on the observations per year rather
> than
> the full set of observations. The final output should be a data frame with
> 7
> rows (one for each id) and 4 columns (one for each year) filled with the
> Principal Component Scores per id per year. Any ideas on how to do this?
>
> Thanks!
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Find-Principal-Component-Score-per-year-tp3396132p3396132.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] fitting a distribution to a ecdf plot

2011-03-15 Thread Carlos Ortega
Hi,

One "easy" way to do that is by using the "nls" (nonlinear least square)
library.

Basically you will test with that if your distribution can be adjusted to
the distribution you say it matches (Weibull?) through the adjustment of
some parameters.

The base package includes the "nls" library, but also you can use nlwr() as
well.
Or check the library NISTnls for particular examples.

Regards,
Carlos Ortega
www.qualityexcellence.es

On Tue, Mar 15, 2011 at 5:23 PM, Lathouri, Maria <
m.lathour...@imperial.ac.uk> wrote:

> Actually I have already done a search on that but it was not much of a
> help. That is why I posted it in the r-help in case it was much more
> helpful.
>
> Thank you.
>
> Kind regards
> Maria
>
> 
> From: David Winsemius [dwinsem...@comcast.net]
> Sent: 15 March 2011 16:19
> To: Lathouri, Maria
> Cc: r-help@r-project.org
> Subject: Re: [R] fitting a distribution to a ecdf plot
>
> On Mar 15, 2011, at 12:00 PM, Lathouri, Maria wrote:
>
> > Dear all,
> >
> > I need to plot an cumulative distribution plot of a variable and
> > then to fit a distribution to that, probably a weibull or lognormal.
> >
> > I have plotted the ecdf as
> >> plot(ecdf(x))
> >
> > but I haven't managed to fit the distribution. I have as well
> > attached the data.
>
> Try a search on one of the R search sites with:
>
> "Fitting distributions with R"  # use the quotes
>
>
> >
> > I would appreciate if you could help me on that.
> >
> > Thank you.
> >
> > Kind regards
> > Maria
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> West Hartford, CT
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] trunc function

2011-03-09 Thread Carlos Ortega
Hola Felipe,

Sí, la función es round().

Por cierto, tenemos una lista de ayuda del R en español.
Te puedes suscribir aquí:

https://stat.ethz.ch/mailman/listinfo/r-help-es


Saludos,
Carlos Ortega
www.qualityexcellence.es

On Wed, Mar 9, 2011 at 10:36 AM, Luis Felipe Parra <
felipe.pa...@quantil.com.co> wrote:

> Hello. I would like to know if there exists in R a function like trunc but
> where i can choose how many decimal places can I stay with in the number I
> have (sort of the same as the trunc function in excel). I would like, for
> example if I have the number 0.974678 and I choose to stay with 3 decimal
> places to have as ouput 0.974.
>
> Thank you
>
> Felipe Parra
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] consulta

2011-03-08 Thread Carlos Ortega
Hola Valeska,

Tenemos una lista de R en español a la que te puedes suscribir:

https://stat.ethz.ch/mailman/listinfo/r-help-es

<https://stat.ethz.ch/mailman/listinfo/r-help-es>Seguro que en esta lista en
español te podemos ayudar a clarificar las dudas que tienes.

Aunque ya te adelanto que sería necesario que consultaras alguno de los
múltiples manuales (algunos en español) de introducción al R.

Saludos,
Carlos Ortega
www.qualityexcellence.es

2011/3/8 Valeska Yaitul 

> Hola
> soy novata en el programa R, pero lo encuentro súper interesante, tengo un
> par de consultas...
> 1. necesito crear una nueva base de datos.
> 2. necesito saber como se codifica el sample, subset y el rbind.
>
> Por favor agradecería sus respuesta
>
>
>
> Saludos Cordiales
>
> Valeska Yaitul Yaitul.
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Code for The R Book

2010-12-16 Thread Carlos Ortega
Hello,

You can find the code here:

http://www.bio.ic.ac.uk/research/mjcraw/therbook/index.htm

<http://www.bio.ic.ac.uk/research/mjcraw/therbook/index.htm>Regards,
Carlos Ortega.

On Thu, Dec 16, 2010 at 9:31 PM, Paul Miller  wrote:

> Hello Everyone,
>
> Does anyone have the R code for this book? I contacted the author about
> this and was told that it used to be on the book's website, but that the
> publisher had asked that it be taken down. I'm hoping that someone will have
> downloaded the code when it was available, and that they will be willing to
> share it with me.
>
> The book is almost 1,000 pages long and I'd like to be able to run the
> example programs in R without having to type them all myself.
>
> Thanks,
>
> Paul
>
>
>
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] decision tree with weighted inputs

2010-07-26 Thread Carlos Ortega
Hi,

In the R-Help history there have been similar questions to yours. As a
starting point you can check this:

http://tolstoy.newcastle.edu.au/R/e2/help/07/01/9138.html

Regrads,
Carlos.

On Thu, Jul 22, 2010 at 6:37 PM, David Shin  wrote:

> I'd like to train a decision tree on a set of weighted data points.  I
> looked into the rpart package, which builds trees but doesn't seem to offer
> the capability of weighting inputs.  (There is a weights parameter, but it
> seems to correspond to output classes rather than to input points).
>
> I'm making do for now by preprocessing my input data by adding multiple
> instances of each data point corresponding to its weight before feeding to
> rpart.  But I worry this tricks the cross-validation phase of the rpart
> building process into thinking a model generalizes better than it really
> does.  This is because a heavily-weighted point can be included in both the
> training and testing set of a cross validation split.
>
> Is there a better way to achieve my goal?
>
> 
> Note: This email is for the confidential use of the named addressee(s) only
> and may contain proprietary, confidential or privileged information. If you
> are not the intended recipient, you are hereby notified that any review,
> dissemination or copying of this email is strictly prohibited, and to please
> notify the sender immediately and destroy this email and any attachments.
> Email transmission cannot be guaranteed to be secure or error-free. Jump
> Trading, therefore, does not make any guarantees as to the completeness or
> accuracy of this email or any attachments. This email is for informational
> purposes only and does not constitute a recommendation, offer, request or
> solicitation of any kind to buy, sell, subscribe, redeem or perform any type
> of transaction of a financial product.
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Combining several plots besides a dendrogram?

2010-07-02 Thread Carlos Ortega
Hello,

Check for function "layout".
With it you can create separate plotting regions one for each graph. And
these regions can be customized depending on the size of the objects you
want to plot.

Regards,
Carlos.

On Fri, Jul 2, 2010 at 1:34 PM, Tal Galili  wrote:

> Hello all,
>
> I would like to recreate the plot shown here (from a useR 2009
> presentation):
> http://www.agrocampus-ouest.fr/math/useR-2009/abstracts/pdf/Hocking.pdf
>
> I downloaded the code for that image, and discovered that it relies on
> external web services, and also having PERL installed on the computer.
>
> I believe this could be done "locally" using the "seqLogo" function/package
> (see http://www.bioconductor.org/packages/2.2/bioc/html/seqLogo.html),
> combined with the subplot function (from the "TeachingDemos" package).
>
> So my questions are:
> 1) Might there be other packages/functions that I are more fitting for the
> task of recreating this plot ?
> 2) Can someone give some pointers on how the subplot function could be used
> to create such an image ? (I am not sure how to create such a
> layout, especially when it needs to be dynamic to the number of cluster
> choosen)
>
>
> Thanks in advance for any help,
> Best,
> Tal
>
>
>
>
>
>
>
> Contact
> Details:---
> Contact me: tal.gal...@gmail.com |  972-52-7275845
> Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
> www.r-statistics.com (English)
>
> --
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Knowledge discovery

2010-07-02 Thread Carlos Ortega
Hello,

For the first question, you can use "table" function. Read how to apply it,
it is very straitghforward.

Once you have the most common combination, you have to investigate further
this combination to apply a statistical model to it. What model?. It depends
on what are you looking for.

Regards,
Carlos.

On Fri, Jul 2, 2010 at 11:37 AM, abanero  wrote:

>
> Hi,
>
> I have 10 units with 10 attributes (attr1, attr2, attr3, etc...)
>
> For instance:
>
> unit  attr1  attr2  attr3  ...
>
> 1  a   ww 12
> 2  a   re   11
> 3  b   ww 09
> 4  c   yt   02
> 5  a   qw  02
> ...
>
> I'd like to answer to the question:
>
> a) what are the most frequent combinations of attributes?
> b) How could I describe the relations among the attributes?
> c) What are the most significative values for each attribute and how they
> are in relationship with the value of  others attributes?
>
> Do you suggest any specific method in order to answer to these questions?
>
> Thanks
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Knowledge-discovery-tp2276207p2276207.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] possible to plot number line in R?

2010-07-01 Thread Carlos Ortega
Hello,

If I understood well, you can compose that with "text" or "mtext" functions.

Regards,
Carlos.

On Thu, Jul 1, 2010 at 1:38 PM, jim holtman  wrote:

> ?segments
>
> Do provide an example of the data and what you what to do with it.
>
> On Thu, Jul 1, 2010 at 7:18 AM, Kroepfl, Julia
> (julia.kroe...@uni-graz.at)  wrote:
> > Hallo!
> >
> > Is there a possibility to plot a number line in R?
> > I would like to display 3 different Intervals on the same number line.
> Ideally, it would be possible to add a name to each number (e.g. Interval 1,
> lower cut-off...and so on). I have not found a command for this.
> >
> > Thank you for your help.
> >
> > Julia
> >
> >
> >[[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Fancy Page layout

2010-06-03 Thread Carlos Ortega
Hello,

You can the same as trellis but with the standar graphics library in the
direction you are exploring.
Use par(mfrow=c(5,2)) to display your graphics.

The size and location of the graphics can be managed with the layout()
function, present in the graphics library.
And with mtext and text functions you can write whatever text you like in
any place of your graphics page.

Regards,
Carlos.

On Wed, Jun 2, 2010 at 2:43 AM, Dejian Zhao  wrote:

> I think you can use grid.layout() to create the appropriate layout,
> allocating proper space for the upper plotting area and the bottom text
> region, and then use viewport() with the layout parameter to control the
> output by pushing the viewport at the proper region on the graphical device.
>Viewport alone can solve your three quesions, but with grid.layout the
> layout is better controlled.
>The above-mentioned functions, or grid.layout(), viewport() and
> pushViewport(), are in the grid package. Possibly the work can be done by
> combining lattice with grid.
>
>
> On 2010-6-2 1:10, Noah Silverman wrote:
>
>> Thanks Jim,
>>
>> That helps.
>>
>> Ben Bolker had a nice suggestion on how to get the lattice package to
>> easily plot all 22 variables in one window.
>>
>> Ultimately, I'd like to generate a PDF that will print on a standard
>> (8.5 x 11) page.
>>
>> A few things I'm still stuck are:
>> 1) How to use the lattice command AND leave room at the bottom for a
>> text block
>> 2) How to tell lattice the size of the window
>> 3) How to integrate all this together - draw a big window, plot
>> trellis in the top half and then text box in the bottom.
>>
>> Any thoughts?
>>
>> -N
>>
>>
>> On 6/1/10 4:53 AM, Jim Lemon wrote:
>>
>>
>>> On 06/01/2010 04:16 AM, Noah Silverman wrote:
>>>
>>>
 Hi,

 Working on a report that is going to have a large number of graphs and
 summaries.  We have 80 "groups" with 20 variables each.

 Ideally, I'd like to produce ONE page for each group.  It would have two
 columns of 10 graphs and then the 5 number summary of the variables at
 the bottom.
 So, perhaps the top 2/3 of the page has the graphs and the bottom third
 has 20 rows of data summary(maybe a table of sorts.)
 This COULD be done in Latex, but would have to be hand coded for each of
 the 80 groups which would be painfully slow.

 I can easily do the graphs with par(mfrow=c(5,2))  band then draw the
 graphs in a loop.

 But I am stuck from here:

 1) How do I control the size of the plot window.  (Ideally, it should
 print to fill an 8.5 x 11 piece of paper)
 2) Is there a way to "easily" insert a 5 number summary (summary
 command) into the lower half of the page.

 Does anybody have any ideas??



>>> Hi Noah,
>>> One easy way is to leave some space at the bottom, either by using:
>>>
>>> par(mfrow=c(6,2))
>>>
>>> or the more flexible "layout" function, and then use "text" or a
>>> fancier function (textbox, boxed.labels, addtable2plot, etc.) to add
>>> your text after:
>>>
>>> par(xpd=NA)
>>>
>>> allows you to display the text anywhere you please. If you use a
>>> bitmap graphics device, make it big:
>>>
>>> png("numberoneofeighty.png",850,1100)
>>>
>>> so that it won't look lumpy on the printed page.
>>>
>>> Jim
>>>
>>>
>>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>>
>>
>>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] OT: Software for specific visualisation of data...ideas?

2010-01-19 Thread Carlos Ortega
MS PowerPoint (version 2007 or beta 2010) although difficult for so dense
graphic.

Prefearable: MindManager although is $$. Use the Trial.

Regards,
Carlos.

On Tue, Jan 19, 2010 at 5:27 PM, Gavin Simpson wrote:

> Dear List,
>
> A student in the Department where I work would like to produce a graphic
> similar to this one:
>
>
> http://image.guardian.co.uk/sys-files/Guardian/documents/2009/09/16/Public_spending_160909.pdf
>
> Does anyone know if the figure in the pdf can be generated in a specific
> software application for example? Any suggestions would be most
> gratefully received by the student concerned.
>
> Many thanks,
>
> G
> --
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
>  Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London  [w] 
> http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] (2nd part) variable name substitution

2010-01-19 Thread Carlos Ortega
OK.
For the names of the variables you can include this code in the loop
(variable nv):


seq.dat<-c(seq(7,10,1), seq(12,17,1))
for( i in 1:length(seq.dat) ) {

j<-seq.dat[i]
nv<-names(ssfa)[j]

 with( ssfa, twoplots(TO_POS, ssfa[[j]], nv) )
 }

And this modification in the function (nm):

#defines the function for the plots (as written by Duncan Murdoch)
twoplots <- function(x, y,nm) {
 ylab <- deparse(substitute(y))  # get the expression passed as y
 xlab <- deparse(substitute(x))  # get the expression passed as x
 hist(y, main=paste("Histogram of ", nm), xlab=ylab)
 boxplot(y ~ x,  main=paste("Boxplot of", ylab, "by", xlab), xlab=xlab,
ylab=ylab)
}

Regards,
Carlos.


On Tue, Jan 19, 2010 at 5:21 PM, Ivan Calandra  wrote:

>  Thank you for your answer, I got the second part!
> Ivan
>
>
> Le 1/19/2010 17:03, Carlos Ortega a écrit :
>
> Hello,
>
> You can loop in the subset you need by storing in a variable and looping on
> that variable with indexes:
>
> seq.dat<-c(seq(7,10,1), seq(12,17,1))
> for( i in 1:length(seq.dat) ) {
>
> j<-seq.dat[i]
>  with(ssfa, twoplots(TO_POS, ssfa[[j]]))
>
> }
>
> Regards,
> Carlos.
>
> On Tue, Jan 19, 2010 at 4:53 PM, Ivan Calandra <
> ivan.calan...@uni-hamburg.de> wrote:
>
>> Hi again!
>>
>> I feel like I cannot do anything by myself but I would now like to plot
>> for all numeric variables I have (14 of them). I wanted to add a loop
>> then.
>> The code is:
>>
>> --
>> #defines the function for the plots (as written by Duncan Murdoch)
>> twoplots <- function(x, y) {
>>  ylab <- deparse(substitute(y))  # get the expression passed as y
>>  xlab <- deparse(substitute(x))  # get the expression passed as x
>>  hist(y, main=paste("Histogram of ", ylab), xlab=ylab)
>>  boxplot(y ~ x,  main=paste("Boxplot of", ylab, "by", xlab), xlab=xlab,
>> ylab=ylab)
>> }
>>
>> #run the function on ssfa with TO_POS as x and ssfa[[i]] as y, the
>> numerical variables are from column 7 to 21
>> for (i in 7:21) {
>>   with(ssfa, twoplots(TO_POS, ssfa[[i]]))
>> }
>> --
>>
>> I have therefore two questions:
>> - The code above works fine, but in the titles I get "Histogram of
>> ssfa[[i]]" instead of "Histogram of 'variable name'"
>> - What if I don't want to loop on all variables, but for example,
>> variables (=columns) 7 to 10 and 12 to 17? How do I give such breaks and
>> ranges?
>> I admit I'm thinking about it since yesterday and I don't have a clue...
>>
>> I hope you will be able to help me.
>> Thanks in advance,
>> Ivan.
>>
>>
>>
>> Duncan Murdoch a écrit :
>> > On 18/01/2010 9:02 AM, Ivan Calandra wrote:
>> >> Hi everybody!
>> >>
>> >> I'm trying to write a script to plot a histogram, a boxplot and a
>> >> qq-plot (under Windows XP, R2.10 if it matters)
>> >>
>> >> What I want to do: define the variables (x and y) to be used at the
>> >> very beginning, so that I don't have to change all occurrences in the
>> >> script when I want to plot a different variable.
>> >>
>> >> The dataset is called "ssfa". TO_POS is a categorical variable
>> >> containing the tooth position for each sample. Asfc is a numerical
>> >> variable. In my dataset, I have more variables but it wouldn't
>> >> change; I want to plot one numeric vs one category. Do I need to
>> >> supply some data? I don't think it's really necessary but let me know
>> >> if you would like to.
>> >>
>> >> The code of what I do up to now:
>> >> ---
>> >> x <- ssfa$TO_POS
>> >> y <- ssfa$Asfc
>> >> hist(y, main="Histogram of Asfc", xlab="Asfc")
>> >> boxplot(y~x, main="Boxplot of Asfc by TO_POS", xlab="TO_POS",
>> >> ylab="Asfc")
>> >> ---
>> >>
>> >> I would like something like: hist(y, main="Histogram of y", xlab="y")
>> >> but that will add "Asfc" where I write "y".
>> >> And the same for boxplot(y~x, main="Boxplot of y by x", xlab="x",
>> >> ylab="y")
>> >> I thought about something like:
>> >> ---
>> >> cat <- "TO_POS"
>> >> num <- "Asfc"
>> >> x <- paste("ssfa$", &qu

Re: [R] (2nd part) variable name substitution

2010-01-19 Thread Carlos Ortega
Hello,

You can loop in the subset you need by storing in a variable and looping on
that variable with indexes:

seq.dat<-c(seq(7,10,1), seq(12,17,1))
for( i in 1:length(seq.dat) ) {

j<-seq.dat[i]
with(ssfa, twoplots(TO_POS, ssfa[[j]]))

}

Regards,
Carlos.

On Tue, Jan 19, 2010 at 4:53 PM, Ivan Calandra  wrote:

> Hi again!
>
> I feel like I cannot do anything by myself but I would now like to plot
> for all numeric variables I have (14 of them). I wanted to add a loop then.
> The code is:
>
> --
> #defines the function for the plots (as written by Duncan Murdoch)
> twoplots <- function(x, y) {
>  ylab <- deparse(substitute(y))  # get the expression passed as y
>  xlab <- deparse(substitute(x))  # get the expression passed as x
>  hist(y, main=paste("Histogram of ", ylab), xlab=ylab)
>  boxplot(y ~ x,  main=paste("Boxplot of", ylab, "by", xlab), xlab=xlab,
> ylab=ylab)
> }
>
> #run the function on ssfa with TO_POS as x and ssfa[[i]] as y, the
> numerical variables are from column 7 to 21
> for (i in 7:21) {
>   with(ssfa, twoplots(TO_POS, ssfa[[i]]))
> }
> --
>
> I have therefore two questions:
> - The code above works fine, but in the titles I get "Histogram of
> ssfa[[i]]" instead of "Histogram of 'variable name'"
> - What if I don't want to loop on all variables, but for example,
> variables (=columns) 7 to 10 and 12 to 17? How do I give such breaks and
> ranges?
> I admit I'm thinking about it since yesterday and I don't have a clue...
>
> I hope you will be able to help me.
> Thanks in advance,
> Ivan.
>
>
>
> Duncan Murdoch a écrit :
> > On 18/01/2010 9:02 AM, Ivan Calandra wrote:
> >> Hi everybody!
> >>
> >> I'm trying to write a script to plot a histogram, a boxplot and a
> >> qq-plot (under Windows XP, R2.10 if it matters)
> >>
> >> What I want to do: define the variables (x and y) to be used at the
> >> very beginning, so that I don't have to change all occurrences in the
> >> script when I want to plot a different variable.
> >>
> >> The dataset is called "ssfa". TO_POS is a categorical variable
> >> containing the tooth position for each sample. Asfc is a numerical
> >> variable. In my dataset, I have more variables but it wouldn't
> >> change; I want to plot one numeric vs one category. Do I need to
> >> supply some data? I don't think it's really necessary but let me know
> >> if you would like to.
> >>
> >> The code of what I do up to now:
> >> ---
> >> x <- ssfa$TO_POS
> >> y <- ssfa$Asfc
> >> hist(y, main="Histogram of Asfc", xlab="Asfc")
> >> boxplot(y~x, main="Boxplot of Asfc by TO_POS", xlab="TO_POS",
> >> ylab="Asfc")
> >> ---
> >>
> >> I would like something like: hist(y, main="Histogram of y", xlab="y")
> >> but that will add "Asfc" where I write "y".
> >> And the same for boxplot(y~x, main="Boxplot of y by x", xlab="x",
> >> ylab="y")
> >> I thought about something like:
> >> ---
> >> cat <- "TO_POS"
> >> num <- "Asfc"
> >> x <- paste("ssfa$", "TO_POS", sep="")
> >> y <- paste("ssfa$", "Asfc", sep="")
> >> hist(y, main=paste("Histogram of ", cat, sep=""), xlab=num)
> >> ---
> >> but it doesn't work since y is a string. I don't know how to get the
> >> syntax correctly. I am on the right path at least?!
> >
> > I think you're on the wrong path.  You want to write a function, and
> > pass either x and y as arguments, or pass a formula containing both
> > (the former is easier).  For example,
> >
> > twoplots <- function(x, y) {
> >  ylab <- deparse(substitute(y))  # get the expression passed as y
> >  xlab <- deparse(substitute(x))  # get the expression passed as x
> >  hist(y, main=paste("Histogram of ", ylab), xlab=ylab)
> >  boxplot(y ~ x,  main=paste("Boxplot of", ylab, "by", xlab),
> > xlab=xlab, ylab=ylab)
> > }
> >
> > Then
> >
> > with(ssfa, twoplots(TO_POS, Asfc))
> >
> > will give you your plots.
> >
> > Duncan Murdoch
> >
>
>[[alternative HTML version deleted]]
>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] MatLab SimBiology

2009-10-31 Thread Carlos Ortega
Hello,

Please look here:
http://crantastic.org/search?q=biology

Regards,
Carlos.

On Fri, Oct 30, 2009 at 6:12 PM,  wrote:

> Is there any R package that implements the same capability of MatLab
> toolbox called SimBiology ?
> We are expecially interested in protein-protein interactions and network
> analysis.
> As far as I know SimBiology implements a system of ODEs reflecting the
> kinetic chemical reactions.
> We would be more interested in stochastic simulations.
> Thank you in advance.
>
> Maura
>
>
> tutti i telefonini TIM!
>
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.