[R] R-help Digest, Vol 154, Issue 1
13351275265
13351275265 at 163.com
Tue Dec 1 14:37:59 CET 2015
I have the same question about the following strings:
sub("^([0-9]*).*$", "\\1", fields)
could you explain them in detail .
I would lookforward to your wonderful reply.
2015-12-01
13351275265
发件人：r-help-request at r-project.org
发送时间：2015-12-01 19:00
主题：R-help Digest, Vol 154, Issue 1
收件人："r-help"<r-help at r-project.org>
抄送：
Send R-help mailing list submissions to
r-help at r-project.org
To subscribe or unsubscribe via the World Wide Web, visit
https://stat.ethz.ch/mailman/listinfo/r-help
or, via email, send a message with subject or body 'help' to
r-help-request at r-project.org
You can reach the person managing the list at
r-help-owner at r-project.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of R-help digest..."
Today's Topics:
1. Re: Extracting part of alpha numeric string
(phgrosjean at sciviews.org)
2. Re: Extracting part of alpha numeric string (Abhinaba Roy)
3. Re: Error in 'Contrasts<-' while using GBM. (peter dalgaard)
4. Re: Extracting part of alpha numeric string (S Ellison)
5. Re: Extracting part of alpha numeric string
(phgrosjean at sciviews.org)
6. PCA plot of variable names only (debra ragland)
7. Re: PCA plot of variable names only (Boris Steipe)
8. Re: PCA plot of variable names only (S Ellison)
9. Re: PCA plot of variable names only (Boris Steipe)
10. Re: Extracting part of alpha numeric string (Berend Hasselman)
11. Re: PCA plot of variable names only (David L Carlson)
12. Re: PCA plot of variable names only (debra ragland)
13. General copula model with heterogeneous marginals
(Justin Balthrop)
14. Re: rjags cannot find JAGS-4.0.0 (Martyn Plummer)
15. summation equation whose numerator has subscript (Sherouk Moawad)
16. Re: summation equation whose numerator has subscript
(Jeff Newmiller)
17. Re: summation equation whose numerator has subscript
(David Winsemius)
18. Graphing a subset of data (Alexandra Hua)
19. Re: Graphing a subset of data (David Winsemius)
20. filled circle with a black line on the rim in pch function
(Christine Lee)
21. Re: filled circle with a black line on the rim in pch
function (Jim Lemon)
22. ??? filled circle with a black line on the rim in pch
function (Christine Lee)
23. Re: Graphing a subset of data (Jim Lemon)
24. Metanalysis in R using MAVIS (Ernesto Villarino)
----------------------------------------------------------------------
Message: 1
Date: Mon, 30 Nov 2015 12:17:52 +0100
From: phgrosjean at sciviews.org
To: Abhinaba Roy <abhinabaroy09 at gmail.com>
Cc: r-help <r-help at r-project.org>
Subject: Re: [R] Extracting part of alpha numeric string
Message-ID: <524A0581-C4DE-4C41-A8C9-D4F7C40906C0 at sciviews.org>
Content-Type: text/plain; charset=us-ascii
fields <- c("2154333b-3208-4519-8b76-acaef5b5a479", "980958a0-103b-4ba9-afaf-27b2f5c24e69",
"00966654-0dea-4899-b8cf-26e8300b262d")
sub("^([0-9]*).*$", "\\1", fields)
Best,
Philippe Grosjean
> On 30 Nov 2015, at 11:39, Abhinaba Roy <abhinabaroy09 at gmail.com> wrote:
>
> Hi,
>
> I have a field with alpha numeric codes like,
>
> 2154333b-3208-4519-8b76-acaef5b5a479 980958a0-103b-4ba9-afaf-27b2f5c24e69
> 00966654-0dea-4899-b8cf-26e8300b262d
> I want a derived field which will contain ONLY the numeric part before the
> first alphabet and the first '-',
>
> for example the derived field from the sample above will give me
>
> 2154333
> 980958
> 00966654
>
> How can this be achieved in R?
>
> P.S. I do not have much knowledge on regex. It would be of great help if
> you could suggest some reading for beginners.
>
> Thanks,
> Abhinaba
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
------------------------------
Message: 2
Date: Mon, 30 Nov 2015 17:39:00 +0530
From: Abhinaba Roy <abhinabaroy09 at gmail.com>
To: phgrosjean at sciviews.org
Cc: r-help <r-help at r-project.org>
Subject: Re: [R] Extracting part of alpha numeric string
Message-ID:
<CANtKHPX+SK20N48O_u53DOQhZsDZ1rWpvCK3H=Uh-QHF6XFa-Q at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
Hey,
worked like a charm! :)
Could you please explain about
sub("^([0-9]*).*$", "\\1", fields)
Thanks,
Abhinaba
On Mon, Nov 30, 2015 at 4:47 PM, <phgrosjean at sciviews.org> wrote:
> fields <- c("2154333b-3208-4519-8b76-acaef5b5a479",
> "980958a0-103b-4ba9-afaf-27b2f5c24e69",
> "00966654-0dea-4899-b8cf-26e8300b262d")
> sub("^([0-9]*).*$", "\\1", fields)
>
> Best,
>
> Philippe Grosjean
>
> > On 30 Nov 2015, at 11:39, Abhinaba Roy <abhinabaroy09 at gmail.com> wrote:
> >
> > Hi,
> >
> > I have a field with alpha numeric codes like,
> >
> > 2154333b-3208-4519-8b76-acaef5b5a479 980958a0-103b-4ba9-afaf-27b2f5c24e69
> > 00966654-0dea-4899-b8cf-26e8300b262d
> > I want a derived field which will contain ONLY the numeric part before
> the
> > first alphabet and the first '-',
> >
> > for example the derived field from the sample above will give me
> >
> > 2154333
> > 980958
> > 00966654
> >
> > How can this be achieved in R?
> >
> > P.S. I do not have much knowledge on regex. It would be of great help if
> > you could suggest some reading for beginners.
> >
> > Thanks,
> > Abhinaba
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at 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]]
------------------------------
Message: 3
Date: Mon, 30 Nov 2015 14:20:17 +0100
From: peter dalgaard <pdalgd at gmail.com>
To: Max Kuhn <mxkuhn at gmail.com>
Cc: Karteek Pradyumna Bulusu <kartikpradyumna92 at gmail.com>,
"r-help at r-project.org" <r-help at r-project.org>
Subject: Re: [R] Error in 'Contrasts<-' while using GBM.
Message-ID: <AB946621-4F94-4353-BECC-30038BE7104B at gmail.com>
Content-Type: text/plain; charset=windows-1252
On 30 Nov 2015, at 02:59 , Max Kuhn <mxkuhn at gmail.com> wrote:
> Providing a reproducible example and the results of `sessionInfo` will help
> get your question answered.
>
> My only guess is that one or more of your predictors are factors and that
> the in-sample data (used to build the model during resampling) have
> different levels than the holdout samples.
Another guess is that there's a factor in your (Karteek's) data that has only one level and that "ID ~ ." is pullling more variables into the model than you actually want.
-pf
>
> Max
>
> On Sat, Nov 28, 2015 at 10:04 PM, Karteek Pradyumna Bulusu <
> kartikpradyumna92 at gmail.com> wrote:
>
>> Hey,
>>
>> I was trying to implement Stochastic Gradient Boosting in R. Following is
>> my code in rstudio:
>>
>>
>>
>> library(caret);
>>
>> library(gbm);
>>
>> library(plyr);
>>
>> library(survival);
>>
>> library(splines);
>>
>> library(mlbench);
>>
>> set.seed(35);
>>
>> stack = read.csv("E:/Semester 3/BDA/PROJECT/Sample_SO.csv", head
>> =TRUE,sep=",");
>>
>> dim(stack); #displaying dimensions of the dataset
>>
>>
>>
>> #SPLITTING TRAINING AND TESTING SET
>>
>> totraining <- createDataPartition(stack$ID, p = .6, list = FALSE);
>>
>> training <- stack[ totraining,]
>>
>> test <- stack[-totraining,]
>>
>>
>>
>> #PARAMETER SETTING
>>
>> t_control <- trainControl(method = "cv", number = 10);
>>
>>
>>
>>
>>
>> # GLM
>>
>> start <- proc.time();
>>
>>
>>
>> glm = train(ID ~ ., data = training,
>>
>> method = "gbm",
>>
>> metric = "ROC",
>>
>> trControl = t_control,
>>
>> verbose = FALSE)
>>
>>
>>
>> When I am compiling last line, I am getting following error:
>>
>>
>>
>> Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
>>
>> contrasts can be applied only to factors with 2 or more levels
>>
>>
>>
>>
>>
>> Can anyone tell me where I am going wrong and How to rectify it. It?ll be
>> greatful.
>>
>>
>>
>> Thank you. Looking forward to it.
>>
>>
>>
>> Regards,
>> Karteek Pradyumna Bulusu.
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at 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 at 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.
--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
------------------------------
Message: 4
Date: Mon, 30 Nov 2015 13:28:46 +0000
From: S Ellison <S.Ellison at LGCGroup.com>
To: r-help <r-help at r-project.org>
Subject: Re: [R] Extracting part of alpha numeric string
Message-ID:
<1A8C1289955EF649A09086A153E2672403C942461B at GBTEDVPEXCMB04.corp.lgc-group.com>
Content-Type: text/plain; charset="us-ascii"
> Could you please explain about
>
> sub("^([0-9]*).*$", "\\1", fields)
See ?regex and the extensive online literature on regular expressions.
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
------------------------------
Message: 5
Date: Mon, 30 Nov 2015 14:57:58 +0100
From: phgrosjean at sciviews.org
To: Abhinaba Roy <abhinabaroy09 at gmail.com>
Cc: r-help <r-help at r-project.org>
Subject: Re: [R] Extracting part of alpha numeric string
Message-ID: <CDA2C92B-B32E-4BEA-AAAA-96342F70B0BC at sciviews.org>
Content-Type: text/plain; charset="UTF-8"
> On 30 Nov 2015, at 13:09, Abhinaba Roy <abhinabaroy09 at gmail.com> wrote:
>
> Hey,
>
> worked like a charm! :)
>
> Could you please explain about
>
> sub("^([0-9]*).*$", "\\1", fields)
>
Yes.
sub() replaces substrings. The first argument captures the interesting part of the string:
^ = start of the string,
([0-9]*) = capture of the interesting part of the string. [0-9] means any figure from 0 to 9. * means 1 or more of these characters, and () is used to capture the substring,
.* = all the rest. Dot (.) means any character, and * means again one or more of these characters,
$ = the end of the string.
The whole regular expression matches the whole string and captures the interesting part inside the ().
The second argument is the replacement. //1 means the first captured substring.
Thus, globally, we replace the whole string by the captured substring.
Best,
Philippe Grosjean
> Thanks,
> Abhinaba
>
> On Mon, Nov 30, 2015 at 4:47 PM, <phgrosjean at sciviews.org <mailto:phgrosjean at sciviews.org>> wrote:
> fields <- c("2154333b-3208-4519-8b76-acaef5b5a479", "980958a0-103b-4ba9-afaf-27b2f5c24e69",
> "00966654-0dea-4899-b8cf-26e8300b262d")
> sub("^([0-9]*).*$", "\\1", fields)
>
> Best,
>
> Philippe Grosjean
>
> > On 30 Nov 2015, at 11:39, Abhinaba Roy <abhinabaroy09 at gmail.com <mailto:abhinabaroy09 at gmail.com>> wrote:
> >
> > Hi,
> >
> > I have a field with alpha numeric codes like,
> >
> > 2154333b-3208-4519-8b76-acaef5b5a479 980958a0-103b-4ba9-afaf-27b2f5c24e69
> > 00966654-0dea-4899-b8cf-26e8300b262d
> > I want a derived field which will contain ONLY the numeric part before the
> > first alphabet and the first '-',
> >
> > for example the derived field from the sample above will give me
> >
> > 2154333
> > 980958
> > 00966654
> >
> > How can this be achieved in R?
> >
> > P.S. I do not have much knowledge on regex. It would be of great help if
> > you could suggest some reading for beginners.
> >
> > Thanks,
> > Abhinaba
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
> > 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]]
------------------------------
Message: 6
Date: Mon, 30 Nov 2015 13:56:40 +0000 (UTC)
From: debra ragland <ragland.debra at yahoo.com>
To: R-help <r-help at r-project.org>
Subject: [R] PCA plot of variable names only
Message-ID:
<1464521238.12631664.1448891800674.JavaMail.yahoo at mail.yahoo.com>
Content-Type: text/plain; charset="UTF-8"
Hello,?
A colleague of mine prepared a PCA plot of my data and I have no clue how he did it. My original data set contains 15 variables and 64 observations. I have been trying to figure out how he did it on my own, and I have asked but he's swamped so his response is taking longer than usual. Anywho, the plot is simply of PC1 vs. PC2 and in the area of the plot there are just the variable names aligned with values I'm guessing are the loadings (?) I have been searching around and I do not think that this was done via biplot. I am also not sure what is normally plotted on a PCA plot of this type (e.g. loadings, scores, sdevs -- no clue). ?Again, the 15 variable names (var1, var2, var3 etc) are all that is contained in this plot, aligned with their respective values projected onto the first 2 PCs.?
Any idea on how to generate such a plot based on this description?
[[alternative HTML version deleted]]
------------------------------
Message: 7
Date: Mon, 30 Nov 2015 09:25:28 -0500
From: Boris Steipe <boris.steipe at utoronto.ca>
To: debra ragland <ragland.debra at yahoo.com>
Cc: R-help <r-help at r-project.org>
Subject: Re: [R] PCA plot of variable names only
Message-ID: <E9AD124D-758C-457A-BA56-D69EB8442028 at utoronto.ca>
Content-Type: text/plain; charset=us-ascii
Your description is obscure but the following may get you started. The function prcomp() returns a list in which the matrix x contains the rotated values of your input. Assuming that your "variable names" are the rownames of your input, you can plot them with text().
Something like (untested):
myPCA <- prcomp(someData)
plot(myPCA$x[,1], myPCA$x[,2], type = "n")
text(myPCA$x[,1], myPCA$x[,2], rownames(someData))
B.
On Nov 30, 2015, at 8:56 AM, debra ragland via R-help <r-help at r-project.org> wrote:
> Hello,
>
> A colleague of mine prepared a PCA plot of my data and I have no clue how he did it. My original data set contains 15 variables and 64 observations. I have been trying to figure out how he did it on my own, and I have asked but he's swamped so his response is taking longer than usual. Anywho, the plot is simply of PC1 vs. PC2 and in the area of the plot there are just the variable names aligned with values I'm guessing are the loadings (?) I have been searching around and I do not think that this was done via biplot. I am also not sure what is normally plotted on a PCA plot of this type (e.g. loadings, scores, sdevs -- no clue). Again, the 15 variable names (var1, var2, var3 etc) are all that is contained in this plot, aligned with their respective values projected onto the first 2 PCs.
>
> Any idea on how to generate such a plot based on this description?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
------------------------------
Message: 8
Date: Mon, 30 Nov 2015 14:26:13 +0000
From: S Ellison <S.Ellison at LGCGroup.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Subject: Re: [R] PCA plot of variable names only
Message-ID:
<1A8C1289955EF649A09086A153E2672403C9424662 at GBTEDVPEXCMB04.corp.lgc-group.com>
Content-Type: text/plain; charset="utf-8"
> Any idea on how to generate such a plot based on this description?
One simple way of suppressing the individual points in biplot() is to give the labels a colour of 0.
Adapting the biplot.princomp example:
biplot(princomp(USArrests), col=c(0,1))
But that retains the point plot axes. If it's not what you meant, you'll need to provide the picture.
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use, copying or
disclosure other than by the intended recipient is unauthorised. If
you have received this message in error, please notify the sender
immediately via +44(0)20 8943 7000 or notify postmaster at lgcgroup.com
and delete this message and any copies from your computer and network.
LGC Limited. Registered in England 2991879.
Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK
------------------------------
Message: 9
Date: Mon, 30 Nov 2015 10:00:32 -0500
From: Boris Steipe <boris.steipe at utoronto.ca>
To: debra ragland <ragland.debra at yahoo.com>
Cc: r-help <r-help at r-project.org>
Subject: Re: [R] PCA plot of variable names only
Message-ID: <D60958F9-CF69-4B53-AFFE-FE14A552D7CB at utoronto.ca>
Content-Type: text/plain; charset=us-ascii
Please keep communications on list.
This is too confused to continue productively.
See here: http://adv-r.had.co.nz/Reproducibility.html
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
... and please read the posting guide and don't post in HTML.
On Nov 30, 2015, at 9:49 AM, debra ragland <ragland.debra at yahoo.com> wrote:
> Hi,
>
> I've tried this -- before your suggestion -- R throws an error at the plot argument stating that the figure margins are too large and the text argument staring that there is an invalid graphics state.
>
> The figure that I am referring to is similar to figure 4 here;
> Computing and visualizing PCA in R
>
>
>
>
>
>
>
>
>
> Computing and visualizing PCA in R
> Following my introduction to PCA, I will demonstrate how to apply and visualize PCA in R. There are many packages and functions that can apply PCA in R. In this po...
> View on www.r-bloggers.com
> Preview by Yahoo
>
> Without the circle (or gray background, but this is minor) enclosing the variables. I am currently trying to figure out how to the adapt the code to my needs but I am struggling.
>
>
>
> On Monday, November 30, 2015 9:25 AM, Boris Steipe <boris.steipe at utoronto.ca> wrote:
>
>
> Your description is obscure but the following may get you started. The function prcomp() returns a list in which the matrix x contains the rotated values of your input. Assuming that your "variable names" are the rownames of your input, you can plot them with text().
>
> Something like (untested):
>
> myPCA <- prcomp(someData)
> plot(myPCA$x[,1], myPCA$x[,2], type = "n")
> text(myPCA$x[,1], myPCA$x[,2], rownames(someData))
>
> B.
>
>
>
> On Nov 30, 2015, at 8:56 AM, debra ragland via R-help <r-help at r-project.org> wrote:
>
> > Hello,
> >
> > A colleague of mine prepared a PCA plot of my data and I have no clue how he did it. My original data set contains 15 variables and 64 observations. I have been trying to figure out how he did it on my own, and I have asked but he's swamped so his response is taking longer than usual. Anywho, the plot is simply of PC1 vs. PC2 and in the area of the plot there are just the variable names aligned with values I'm guessing are the loadings (?) I have been searching around and I do not think that this was done via biplot. I am also not sure what is normally plotted on a PCA plot of this type (e.g. loadings, scores, sdevs -- no clue). Again, the 15 variable names (var1, var2, var3 etc) are all that is contained in this plot, aligned with their respective values projected onto the first 2 PCs.
> >
> > Any idea on how to generate such a plot based on this description?
>
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at 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.
>
>
>
------------------------------
Message: 10
Date: Mon, 30 Nov 2015 16:34:35 +0100
From: Berend Hasselman <bhh at xs4all.nl>
To: phgrosjean at sciviews.org
Cc: r-help <r-help at r-project.org>, Abhinaba Roy
<abhinabaroy09 at gmail.com>
Subject: Re: [R] Extracting part of alpha numeric string
Message-ID: <7E3147A0-1296-4440-95C9-24EAEBC73297 at xs4all.nl>
Content-Type: text/plain; charset=us-ascii
> On 30 Nov 2015, at 14:57, phgrosjean at sciviews.org wrote:
>
>
>> On 30 Nov 2015, at 13:09, Abhinaba Roy <abhinabaroy09 at gmail.com> wrote:
>>
>> Hey,
>>
>> worked like a charm! :)
>>
>> Could you please explain about
>>
>> sub("^([0-9]*).*$", "\\1", fields)
>>
>
> Yes.
>
> sub() replaces substrings. The first argument captures the interesting part of the string:
>
> ^ = start of the string,
>
> ([0-9]*) = capture of the interesting part of the string. [0-9] means any figure from 0 to 9. * means 1 or more of these characters, and () is used to capture the substring,
>
> .* = all the rest. Dot (.) means any character, and * means again one or more of these characters,
>
> $ = the end of the string.
Small correction:
* means zero or more characters
according to ?regex.
Berend
------------------------------
Message: 11
Date: Mon, 30 Nov 2015 15:48:09 +0000
From: David L Carlson <dcarlson at tamu.edu>
To: Boris Steipe <boris.steipe at utoronto.ca>, debra ragland
<ragland.debra at yahoo.com>
Cc: r-help <r-help at r-project.org>
Subject: Re: [R] PCA plot of variable names only
Message-ID:
<53BF8FB63FAF2E4A9455EF1EE94DA7262D6E54EE at mb02.ads.tamu.edu>
Content-Type: text/plain; charset="us-ascii"
If it is just a plot of the variables by their loadings on the first two components, this should do it:
> dat <- data.frame(matrix(rnorm(100), 10, 5))
> dat.pca <- prcomp(dat)
> plot(dat.pca$rotation[, 1:2])
> text(dat.pca$rotation[, 1:2], colnames(dat), pos=3)
Or if you don't want the symbols just the names, change the last two lines:
> plot(dat.pca$rotation[, 1:2], type="n")
> text(dat.pca$rotation[, 1:2], colnames(dat))
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Boris Steipe
Sent: Monday, November 30, 2015 9:01 AM
To: debra ragland
Cc: r-help
Subject: Re: [R] PCA plot of variable names only
Please keep communications on list.
This is too confused to continue productively.
See here: http://adv-r.had.co.nz/Reproducibility.html
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
... and please read the posting guide and don't post in HTML.
On Nov 30, 2015, at 9:49 AM, debra ragland <ragland.debra at yahoo.com> wrote:
> Hi,
>
> I've tried this -- before your suggestion -- R throws an error at the plot argument stating that the figure margins are too large and the text argument staring that there is an invalid graphics state.
>
> The figure that I am referring to is similar to figure 4 here;
> Computing and visualizing PCA in R
>
>
>
>
>
>
>
>
>
> Computing and visualizing PCA in R
> Following my introduction to PCA, I will demonstrate how to apply and visualize PCA in R. There are many packages and functions that can apply PCA in R. In this po...
> View on www.r-bloggers.com
> Preview by Yahoo
>
> Without the circle (or gray background, but this is minor) enclosing the variables. I am currently trying to figure out how to the adapt the code to my needs but I am struggling.
>
>
>
> On Monday, November 30, 2015 9:25 AM, Boris Steipe <boris.steipe at utoronto.ca> wrote:
>
>
> Your description is obscure but the following may get you started. The function prcomp() returns a list in which the matrix x contains the rotated values of your input. Assuming that your "variable names" are the rownames of your input, you can plot them with text().
>
> Something like (untested):
>
> myPCA <- prcomp(someData)
> plot(myPCA$x[,1], myPCA$x[,2], type = "n")
> text(myPCA$x[,1], myPCA$x[,2], rownames(someData))
>
> B.
>
>
>
> On Nov 30, 2015, at 8:56 AM, debra ragland via R-help <r-help at r-project.org> wrote:
>
> > Hello,
> >
> > A colleague of mine prepared a PCA plot of my data and I have no clue how he did it. My original data set contains 15 variables and 64 observations. I have been trying to figure out how he did it on my own, and I have asked but he's swamped so his response is taking longer than usual. Anywho, the plot is simply of PC1 vs. PC2 and in the area of the plot there are just the variable names aligned with values I'm guessing are the loadings (?) I have been searching around and I do not think that this was done via biplot. I am also not sure what is normally plotted on a PCA plot of this type (e.g. loadings, scores, sdevs -- no clue). Again, the 15 variable names (var1, var2, var3 etc) are all that is contained in this plot, aligned with their respective values projected onto the first 2 PCs.
> >
> > Any idea on how to generate such a plot based on this description?
>
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at 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 at 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.
------------------------------
Message: 12
Date: Mon, 30 Nov 2015 15:59:18 +0000 (UTC)
From: debra ragland <ragland.debra at yahoo.com>
To: David L Carlson <dcarlson at tamu.edu>, Boris Steipe
<boris.steipe at utoronto.ca>
Cc: r-help <r-help at r-project.org>
Subject: Re: [R] PCA plot of variable names only
Message-ID:
<818125085.12595190.1448899158984.JavaMail.yahoo at mail.yahoo.com>
Content-Type: text/plain; charset="UTF-8"
Thanks David!!! You have helped me tremendously! Thanks to all others for their input. I'll get out of your hair now :)
On Monday, November 30, 2015 10:48 AM, David L Carlson <dcarlson at tamu.edu> wrote:
If it is just a plot of the variables by their loadings on the first two components, this should do it:
> dat <- data.frame(matrix(rnorm(100), 10, 5))
> dat.pca <- prcomp(dat)
> plot(dat.pca$rotation[, 1:2])
> text(dat.pca$rotation[, 1:2], colnames(dat), pos=3)
Or if you don't want the symbols just the names, change the last two lines:
> plot(dat.pca$rotation[, 1:2], type="n")
> text(dat.pca$rotation[, 1:2], colnames(dat))
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Boris Steipe
Sent: Monday, November 30, 2015 9:01 AM
To: debra ragland
Cc: r-help
Subject: Re: [R] PCA plot of variable names only
Please keep communications on list.
This is too confused to continue productively.
See here: http://adv-r.had.co.nz/Reproducibility.html
http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
... and please read the posting guide and don't post in HTML.
> Hi,
>
> I've tried this -- before your suggestion -- R throws an error at the plot argument stating that the figure margins are too large and the text argument staring that there is an invalid graphics state.
>
> The figure that I am referring to is similar to figure 4 here;
> Computing and visualizing PCA in R
>
>?
>?
>
>?
>?
>?
>?
>?
> Computing and visualizing PCA in R
> Following my introduction to PCA, I will demonstrate how to apply and visualize PCA in R. There are many packages and functions that can apply PCA in R. In this po...
> View on www.r-bloggers.com
> Preview by Yahoo
>?
> Without the circle (or gray background, but this is minor) enclosing the variables. I am currently trying to figure out how to the adapt the code to my needs but I am struggling.
>
>
>
> On Monday, November 30, 2015 9:25 AM, Boris Steipe <boris.steipe at utoronto.ca> wrote:
>
>
> Your description is obscure but the following may get you started. The function prcomp() returns a list in which the matrix x contains the rotated values of your input. Assuming that your "variable names" are the rownames of your input, you can plot them with text().?
>
> Something like (untested):
>
> myPCA <- prcomp(someData)
> plot(myPCA$x[,1], myPCA$x[,2], type = "n")
> text(myPCA$x[,1], myPCA$x[,2], rownames(someData))
>
> B.
>
>
>
> On Nov 30, 2015, at 8:56 AM, debra ragland via R-help <r-help at r-project.org> wrote:
>
> > Hello,
> >
> > A colleague of mine prepared a PCA plot of my data and I have no clue how he did it. My original data set contains 15 variables and 64 observations. I have been trying to figure out how he did it on my own, and I have asked but he's swamped so his response is taking longer than usual. Anywho, the plot is simply of PC1 vs. PC2 and in the area of the plot there are just the variable names aligned with values I'm guessing are the loadings (?) I have been searching around and I do not think that this was done via biplot. I am also not sure what is normally plotted on a PCA plot of this type (e.g. loadings, scores, sdevs -- no clue).? Again, the 15 variable names (var1, var2, var3 etc) are all that is contained in this plot, aligned with their respective values projected onto the first 2 PCs.
> >
> > Any idea on how to generate such a plot based on this description?
>
> >
> >? ? [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at 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 at 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]]
------------------------------
Message: 13
Date: Mon, 30 Nov 2015 09:19:59 -0600
From: Justin Balthrop <justin.balthrop at rice.edu>
To: r-help at r-project.org
Subject: [R] General copula model with heterogeneous marginals
Message-ID:
<20151130091959.Horde.etl0ALdkrzuzZzZI4khTIg1 at webmail.rice.edu>
Content-Type: text/plain; charset=UTF-8; format=flowed; DelSp=Yes
I am looking to model the sum of a number of random variables with
arbitrary gamma distributions and an empirical dependence structure
that I obtain from data. Basically I observe all of the individual
pieces but I want to model their sum, as opposed to many copula
questions which observe a single outcome of a multivariate process and
seek to fit possible marginal and covariance structure.
It has been years since I coded in R, but this is what I have thus far:
library(copula)
library(scatterplot3d)
library(psych)
set.seed(1)
myCop<-
normalCopula(param=c(.1,.1,.1,.1,.1,.2,.2,.2,.2,.2,.2,.2,.4,.4,.4,.4,.4,.5,.5,.5,.5), dim=7,
dispstr="un")
myMvd<-mvdc(copula=myCop, margins=rep("gamma",7),
paramMargins=list(list(shape=3,scale=4),
list(shape=2, scale=5),
list(shape=2, scale=5),
list(shape=2, scale=5),
list(shape=2, scale=5),
list(shape=3, scale=5),
list(shape=3, scale=5)))
simulation<- rMvdc(20000,myMvd)
colnames(simulation)<-c("P1","P2","P3","P4","P5","P6","P7")
total =
simulation[,1]+simulation[,2]+simulation[,3]+simulation[,4]+simulation[,5]+simulation[,6]+simulation[,7]
As you can see, I have forced 7 gamma distributions with a placeholder
covariance matrix input. The problem is that I am looking to
generalize this to the order of ~150 different marginals with
potentially differing distributions and parameters.
Ultimately I will have the following input:
? matrix of 150 marginal distributions with family and parameters
? 150x150 covariance matrix
And what I need to produce is the following:
An empirical CDF/PDF of the sum of realizations from 5-10 of the
underlying marginal distributions. To be more clear, assume each
marginal distribution is a person's response to a treatment, and I
need to calculate the cumulative treatment effect for a sub-group of
the population of 150. So, I will have a vector of 0s and 1s to
identify which members of the population are grouped together for a
trial. Then I will have a separate vector for the next group. Each
group vector will have dim=150 but have between 5 and 10 1s with the
rest 0s. I need a different empirical CDF for each vector.
Any help?
------------------------------
Message: 14
Date: Mon, 30 Nov 2015 18:09:16 +0000
From: Martyn Plummer <plummerm at iarc.fr>
To: "dwinsemius at comcast.net" <dwinsemius at comcast.net>
Cc: "r-help at r-project.org" <r-help at r-project.org>,
"merricks.merricks at gmail.com" <merricks.merricks at gmail.com>
Subject: Re: [R] rjags cannot find JAGS-4.0.0
Message-ID: <1448906956.4643.259.camel at iarc.fr>
Content-Type: text/plain; charset="utf-8"
On Fri, 2015-11-27 at 11:27 -0800, David Winsemius wrote:
> > On Nov 26, 2015, at 4:59 PM, Margaret Donald <merricks.merricks at gmail.com> wrote:
> >
> > 1. Despite being in R with administrative rights the library "rjags" loads
> > in a temporary location.
> >
> >> install.packages("rjags", dependencies=TRUE,
> > + lib= "C:/Users/Margaret Donald/Documents/R/win-library/3.2")
> > trying URL 'https://cran.r-project.org/bin/windows/contrib/3.2/rjags_4-4.zip
> > '
> > Content type 'application/zip' length 525871 bytes (513 KB)
> > downloaded 513 KB
> >
> > package ?rjags? successfully unpacked and MD5 sums checked
> >
> > The downloaded binary packages are in
> > C:\Users\Margaret
> > Donald\AppData\Local\Temp\RtmpMzv76s\downloaded_packages
>
> That?s not an indication of an error. The installation process always does that.
>
>
> > #-----------------------------------------------------------------------------------------------------------------
> >
> > 2. Cannot find JAGS-4.0.0 which is in C;\programs\JAGS\JAGS-4.0.0. How do
> > I get R to see JAGS-4.0.0
The Windows installer writes some keys in the Windows registry. These
keys are then read by the rjags package when it is loaded to locate the
JAGS DLL.
I don't know why this is not working in your case. You might try
uninstalling and reinstalling JAGS (and by this I mean that the user who
installed it should uninstall it from the Control Panel).
Otherwise, as David says, you can set the environment variable
JAGS_HOME. Note that if you previously set JAGS_HOME in .Rprofile and
have upgraded to a new version of JAGS, then JAGS_HOME will be pointing
to the wrong place. This might explain why rjags cannot find JAGS and
this is why I do not recommend this solution except as a last resort.
> You might try to use Sys.setenv to create a properly directed JAGS_HOME
>
> Sys.setenv(JAGS_HOME=?C:\programs\JAGS\JAGS-4.0.0?)
>
> (I corrected the semi-colon.)
> >> library(rjags)
> > Error : .onLoad failed in loadNamespace() for 'rjags', details:
> > call: fun(libname, pkgname)
> > error: Failed to locate any version of JAGS version 4
> >
> > The rjags package is just an interface to the JAGS library
> > Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from
> > http://www.sourceforge.net/projects/mcmc-jags/files
>
> I?m was having a perhaps similar problem on a Mac. The binary version
> 3-15 of rjags installed today from CRAN was trying to
> access /usr/local/lib/libjags.3.dylib, but since I have installed JAGS
> version 4.0.1 installed from the SourceForge repository, there is no
> ligjags.3.dylib, but instead there was only
> a /usr/local/lib/libjags.4.dylib
rjags_4-4 requires JAGS 4.x.y and the previous version rjags_3-15 is not
compatible with JAGS 4.0.0. Unfortunately the Mac OS X binaries on CRAN
are not up to date. I have no control over this but Matt Denwood has
made a binary for Mavericks or later available on Sourceforge:
http://sourceforge.net/projects/mcmc-jags/files/rjags/4/rjags_4-4.tgz
Martyn
> Going back to SourceForge and tracking down the older version of JAGS
> and installing version 3.4.0 was successful in getting rjags to load
> correctly. I suspect that with the release of JAGS v4 that there is
> some mismatch among the various editions of rjags and JAGS.
>
> ?
> David
> >
> > Error: package or namespace load failed for ?rjags?
> >> library(R2jags)
> > Loading required package: rjags
> > Error : .onLoad failed in loadNamespace() for 'rjags', details:
> > call: fun(libname, pkgname)
> > error: Failed to locate any version of JAGS version 4
> >
> > The rjags package is just an interface to the JAGS library
> > Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from
> > http://www.sourceforge.net/projects/mcmc-jags/files
> >
> > Error: package ?rjags? could not be loaded
> >>
> >
> > Regards,
> > Margaret Donald
> > --
> > Margaret Donald
> > Post Doctoral researcher
> > University of New South Wales
> > margaret.donald at unsw.edu.au
> > 0405 834 550
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at 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.
>
> David Winsemius
> Alameda, CA, USA
>
------------------------------
Message: 15
Date: Mon, 30 Nov 2015 21:20:34 +0000 (UTC)
From: Sherouk Moawad <sheroukmoawad at yahoo.com>
To: R-help Mailing List <r-help at r-project.org>
Subject: [R] summation equation whose numerator has subscript
Message-ID:
<944655747.7652698.1448918434492.JavaMail.yahoo at mail.yahoo.com>
Content-Type: text/plain; charset=UTF-8
Dear R experts
Please do you have any idea about how this summation can be written in R(the equation can be viewed in the following link):
http://s16.postimg.org/or2km30ph/equation.jpg
I've tried out out this code but it gave me error for writing brackets in function of summation:
>>>
x=matrix(c(6,2,1),3,1)
for (l in 1:3){
sum(sapply(1:3, function(j[l]){if(l>1){sum(sapply(1:j[l-1], function(j[l]){x[j[l]]*(j[l]<j[l-1])}))}}))}>>>Thank you
------------------------------
Message: 16
Date: Mon, 30 Nov 2015 14:17:55 -0800
From: Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
To: Sherouk Moawad <sheroukmoawad at yahoo.com>, Sherouk Moawad via
R-help <r-help at r-project.org>, R-help Mailing List
<r-help at r-project.org>
Subject: Re: [R] summation equation whose numerator has subscript
Message-ID: <731B7B27-F965-44B2-8892-771D3D7A57EA at dcn.davis.ca.us>
Content-Type: text/plain; charset="UTF-8"
I cannot understand that summation at all, much less translate it to R. Do you have an original citation for this thing?
As for putting subscripts in parameter lists, that is not going to happen. You have to accept that the code that calls your function needs to do any necessary subscripting before it gives that piece to your function. Keep in mind that apply functions do this by their nature without the mess of specifying it yourself. If you know that the automatic subscripting that sapply does is not going to get the result you want then don't use that function.
--
Sent from my phone. Please excuse my brevity.
On November 30, 2015 1:20:34 PM PST, Sherouk Moawad via R-help <r-help at r-project.org> wrote:
>Dear R experts
>Please do you have any idea about how this summation can be written in
>R(the equation can be viewed in the following link):
>http://s16.postimg.org/or2km30ph/equation.jpg
>
>I've tried out out this code but it gave me error for writing brackets
>in function of summation:
>
>>>>
>x=matrix(c(6,2,1),3,1)
>
>for (l in 1:3){
>sum(sapply(1:3, function(j[l]){if(l>1){sum(sapply(1:j[l-1],
>function(j[l]){x[j[l]]*(j[l]<j[l-1])}))}}))}>>>Thank you
>
>______________________________________________
>R-help at 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]]
------------------------------
Message: 17
Date: Mon, 30 Nov 2015 14:27:46 -0800
From: David Winsemius <dwinsemius at comcast.net>
To: Sherouk Moawad <sheroukmoawad at yahoo.com>
Cc: R-help Mailing List <r-help at r-project.org>
Subject: Re: [R] summation equation whose numerator has subscript
Message-ID: <954081E4-C3D2-4029-A90F-044C636395A2 at comcast.net>
Content-Type: text/plain; charset=utf-8
> On Nov 30, 2015, at 1:20 PM, Sherouk Moawad via R-help <r-help at r-project.org> wrote:
>
> Dear R experts
> Please do you have any idea about how this summation can be written in R(the equation can be viewed in the following link):
> http://s16.postimg.org/or2km30ph/equation.jpg
Can you explain in natural language the goals of this expression. It makes little sense to me to start with an index of j_sub_l = 0 and to then iterate to up to j_sub_(l-1) -1 . How can there be a value for j_sub(l-1) with a starting point of zero. The notation saying to do something for l = 2:n is not helpful since values of ?l? doesn?t really appear in the looped expression (noting that j_sub_l starts at 0, so it's not being determined by ?l".
I believe the confused notation was the cause of this question being closed after it appeared last week on SO:
http://stackoverflow.com/questions/33882285/summation-equation-whose-numerator-has-subscript
And what intent is meant for the indices of the outer summation? The expression j_sub_1 = 0 seems to have no corresponding reference point inside the looped expression. So you would simply be summing the same value N times, but since N is not defined we cannot write any code.
>
> I've tried out out this code but it gave me error for writing brackets in function of summation:
You should _always_, _always_, _always_ post the entire results of an error. We have no way of seeing your console. Error messages are usually informative.
>
>>>>
> x=matrix(c(6,2,1),3,1)
>
> for (l in 1:3){
> sum(sapply(1:3, function(j[l]){if(l>1){sum(sapply(1:j[l-1], function(j[l]){x[j[l]]*(j[l]<j[l-1])}))}}))}
You have three nested loops in the code above, but at least it appears you do understand that R is a 1-based language. But since the image-expression goes from 0 to some cryptic value (minus one) then the R version ought to go from one to "one more? than that expression.
> >>>Thank you
>
> ______________________________________________
> R-help at 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.
David Winsemius
Alameda, CA, USA
------------------------------
Message: 18
Date: Mon, 30 Nov 2015 21:44:45 -0500
From: Alexandra Hua <alexandra.hua at yale.edu>
To: r-help at r-project.org
Subject: [R] Graphing a subset of data
Message-ID:
<CADoPJut5vjp35v5HTo=V8skJAhdtszg+PpH-hrdXcfTPr9whFg at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
I am trying to write a function that will graph a variable of a dataset or
a variable from a subset of the data. My function is as follows:
graphics<-function(dat, var, graph, varname, val, subset){
if(subset==1) {
data<-mySubset(dat=dat,varname=varname,val=val)
}else if(subset!=1){
data<-(dat)
}
if(graph==1) {
with(data, boxplot(var), main = paste("Vertical box plot of",
myfunc(dat), "variable", myfunc(var), xlab = myfunc(var)))
}else if(graph==2){
with(data, boxplot(var), horizontal=TRUE, main = paste("Horizontal
box plot of", myfunc(dat), "variable", myfunc(var), xlab =
myfunc(var)))
}else if(graph==3){
hist(var, main="Histogram of", myfunc(var))
}}
I included "subset" as a parameter for the function, so that subset=1 would
tell the function to subset, and any other value will use the full dataset.
However, when I run the function with the following expression (bolts is
the dataset, SPEED1 is the variable, value=3)
graphics(bolts, bolts$SPEED1, graph=3, bolts$SPEED1, 3, 1)
I receive this error message: Error in eval(substitute(expr), data, enclos
= parent.frame()) : invalid 'envir' argument of type 'logical'
Does anyone know why this is, or if there is something wrong with my code?
Thanks!
--
*Alexandra Hua *
Yale University | MPH Candidate Class of 2016
Chronic Disease Epidemiology
[[alternative HTML version deleted]]
------------------------------
Message: 19
Date: Mon, 30 Nov 2015 19:15:19 -0800
From: David Winsemius <dwinsemius at comcast.net>
To: Alexandra Hua <alexandra.hua at yale.edu>
Cc: r-help at r-project.org
Subject: Re: [R] Graphing a subset of data
Message-ID: <D0762336-1CB5-465B-A487-C48EEC6D70EE at comcast.net>
Content-Type: text/plain; charset=us-ascii
Dear Alex (as you are signing yourself on StackOverflow);
It is considered poor manners to cross-post identical questions in multiple venues.
http://stackoverflow.com/questions/34011669/graphing-function-based-on-subset-of-data
You should choose one or the other of SO and Rhelp. If you do not get a satisfying answer in your first choice, you should wait an appropriate number of hours before posting at the other venue. And when you do end up cross-posting, your should stated where else the question was asked so that potential respondents can check to see if you have already gotten an answer.
You should also read the the posting guide where it is clearly stated the rhelp responders expect that you include a dataset built with R code for purposes of illustration.
> On Nov 30, 2015, at 6:44 PM, Alexandra Hua <alexandra.hua at yale.edu> wrote:
>
> I am trying to write a function that will graph a variable of a dataset or
> a variable from a subset of the data. My function is as follows:
>
> graphics<-function(dat, var, graph, varname, val, subset){
> if(subset==1) {
> data<-mySubset(dat=dat,varname=varname,val=val)
> }else if(subset!=1){
> data<-(dat)
> }
> if(graph==1) {
> with(data, boxplot(var), main = paste("Vertical box plot of",
> myfunc(dat), "variable", myfunc(var), xlab = myfunc(var)))
> }else if(graph==2){
> with(data, boxplot(var), horizontal=TRUE, main = paste("Horizontal
> box plot of", myfunc(dat), "variable", myfunc(var), xlab =
> myfunc(var)))
> }else if(graph==3){
> hist(var, main="Histogram of", myfunc(var))
> }}
>
Generally the use of `with` inside functions is ill-advised. Sometimes it succeeds but nmany times it will fail with puzzling error messages.
> I included "subset" as a parameter for the function, so that subset=1 would
> tell the function to subset, and any other value will use the full dataset.
> However, when I run the function with the following expression (bolts is
> the dataset, SPEED1 is the variable, value=3)
>
> graphics(bolts, bolts$SPEED1, graph=3, bolts$SPEED1, 3, 1)
>
> I receive this error message: Error in eval(substitute(expr), data, enclos
> = parent.frame()) : invalid 'envir' argument of type 'logical'
>
> Does anyone know why this is, or if there is something wrong with my code?
> Thanks!
>
> --
> *Alexandra Hua *
> Yale University | MPH Candidate Class of 2016
> Chronic Disease Epidemiology
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
David Winsemius
Alameda, CA, USA
------------------------------
Message: 20
Date: Tue, 1 Dec 2015 06:20:44 +0000 (UTC)
From: Christine Lee <leptostracan at yahoo.com>
To: <r-help at r-project.org>
Subject: [R] filled circle with a black line on the rim in pch
function
Message-ID:
<456635539.12433643.1448950844348.JavaMail.yahoo at mail.yahoo.com>
Content-Type: text/plain; charset=UTF-8
Dear All,
I have an embarssing question, I want to put a black line as a rim on the grey symbol in the xyplot, to no avail.
. I thought it was easy, by changing the pch code from 16 to 21. I was surpised that I ran into difficulty.
My original script is as follows:
library(lattice)
xyplot(Abun~Date1|Station, data=Raw,
groups = culr,
par.settings = list(strip.background = list(col = "transparent"),
superpose.symbol = list(cex = rep(2, 2),
col=c("grey","black"),
pch = rep(16,2))),
type="p",
xlab=list("Month",cex=1.5),
ylab=list("Abundance",cex=1.5),
index.cond=list(c(1,2,3,4)),
auto.key = T,
layout=c(4,1))
I have changed pch number into 21, the symbols did show a black rim, but the filled circle colours became blue and pink, instead of the designated grey and black. This puzzles me.
My data is as follows:
Raw<-structure(list(Date = structure(c(6L, 7L, 2L, 4L, 12L, 9L, 7L,
2L, 4L, 12L, 6L, 15L, 14L, 3L, 6L, 1L, 16L, 5L, 11L, 8L, 4L,
10L, 13L, 6L, 1L, 16L, 5L, 11L, 8L, 4L, 10L, 13L, 6L, 1L, 16L,
5L, 11L, 8L, 4L, 10L, 13L, 11L, 8L, 4L, 10L, 13L), .Label = c("1/10",
"1/11", "11/11", "12/11", "13/10", "19/9", "2/10", "2/11", "20/9",
"26/11", "29/10", "29/11", "30/11", "31/10", "4/10", "6/10"), class = "factor"),
Year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Y2002", "Y2014"), class = "factor"),
Station = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 4L, 4L, 4L, 4L, 4L), .Label = c("E", "F", "H", "I"
), class = "factor"), Abun = c(3.42, 1.33, 3.67, 3.67, 3.92,
2.17, 2.5, 1.67, 6.33, 0.67, 1, 1, 1.33, 2.08, 0, 0, 0.33,
0.08, 0.08, 0, 0.5, 0.17, 0.67, 0.67, 0, 1, 0.58, 1.5, 2.67,
0.67, 1.33, 3, 0.58, 1.17, 1.25, 0.75, 1.25, 1.75, 0.92,
1.5, 0.83, 0.75, 2.33, 0.67, 1.33, 1.58), Date1 = structure(c(16697,
16710, 16740, 16751, 16768, 16698, 16710, 16740, 16751, 16768,
16697, 16712, 16739, 16750, 16697, 16709, 16714, 16721, 16737,
16741, 16751, 16765, 16769, 16697, 16709, 16714, 16721, 16737,
16741, 16751, 16765, 16769, 16697, 16709, 16714, 16721, 16737,
16741, 16751, 16765, 16769, 16737, 16741, 16751, 16765, 16769
), class = "Date")), .Names = c("Date", "Year", "Station",
"Abun", "Date1"), row.names = c(NA, -46L), class = "data.frame")
Can any one help me please?
With best regards,
Christine
------------------------------
Message: 21
Date: Tue, 1 Dec 2015 19:01:27 +1100
From: Jim Lemon <drjimlemon at gmail.com>
To: Christine Lee <leptostracan at yahoo.com>
Cc: r-help mailing list <r-help at r-project.org>
Subject: Re: [R] filled circle with a black line on the rim in pch
function
Message-ID:
<CA+8X3fWuW4vJpc95eY=z-Krk-UR0tY4Zjsxn2uTK=KyA8xeYyA at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
Hi Christine,
When I try to run your script, the plot fails:
Error in eval(expr, envir, enclos) : object 'culr' not found
> names(Raw)
[1] "Date" "Year" "Station" "Abun" "Date1"
so I changed the second line to:
groups=Year,
and it did work. The default (pink, gray) background colors for the symbols
do appear when the symbol is changed to pch=21. The arguments
col="black",bg=c("gray","black"),
would produce the symbols you want in base graphics, but do not seem to do
so in lattice. I do get sort of what you want by modifying your code pretty
radically:
xyplot(Abun~Date1|Station, data=Raw,
groups = Year,
par.settings = list(strip.background = list(col = "transparent")),
type="p",
pch = rep(21,2),
col="black",
fill=c("gray","black"),
xlab=list("Month",cex=1.5),
ylab=list("Abundance",cex=1.5),
index.cond=list(c(1,2,3,4)),
auto.key = T,
layout=c(4,1))
Jim
On Tue, Dec 1, 2015 at 5:20 PM, Christine Lee via R-help <
r-help at r-project.org> wrote:
> Dear All,
>
> I have an embarssing question, I want to put a black line as a rim on the
> grey symbol in the xyplot, to no avail.
> . I thought it was easy, by changing the pch code from 16 to 21. I was
> surpised that I ran into difficulty.
>
> My original script is as follows:
> library(lattice)
> xyplot(Abun~Date1|Station, data=Raw,
> groups = culr,
> par.settings = list(strip.background = list(col = "transparent"),
> superpose.symbol = list(cex = rep(2, 2),
> col=c("grey","black"),
> pch = rep(16,2))),
> type="p",
> xlab=list("Month",cex=1.5),
> ylab=list("Abundance",cex=1.5),
> index.cond=list(c(1,2,3,4)),
> auto.key = T,
> layout=c(4,1))
>
>
> I have changed pch number into 21, the symbols did show a black rim, but
> the filled circle colours became blue and pink, instead of the designated
> grey and black. This puzzles me.
>
> My data is as follows:
> Raw<-structure(list(Date = structure(c(6L, 7L, 2L, 4L, 12L, 9L, 7L,
> 2L, 4L, 12L, 6L, 15L, 14L, 3L, 6L, 1L, 16L, 5L, 11L, 8L, 4L,
> 10L, 13L, 6L, 1L, 16L, 5L, 11L, 8L, 4L, 10L, 13L, 6L, 1L, 16L,
> 5L, 11L, 8L, 4L, 10L, 13L, 11L, 8L, 4L, 10L, 13L), .Label = c("1/10",
> "1/11", "11/11", "12/11", "13/10", "19/9", "2/10", "2/11", "20/9",
> "26/11", "29/10", "29/11", "30/11", "31/10", "4/10", "6/10"), class =
> "factor"),
> Year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
> 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
> 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Y2002", "Y2014"), class =
> "factor"),
> Station = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
> 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
> 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
> 3L, 3L, 4L, 4L, 4L, 4L, 4L), .Label = c("E", "F", "H", "I"
> ), class = "factor"), Abun = c(3.42, 1.33, 3.67, 3.67, 3.92,
> 2.17, 2.5, 1.67, 6.33, 0.67, 1, 1, 1.33, 2.08, 0, 0, 0.33,
> 0.08, 0.08, 0, 0.5, 0.17, 0.67, 0.67, 0, 1, 0.58, 1.5, 2.67,
> 0.67, 1.33, 3, 0.58, 1.17, 1.25, 0.75, 1.25, 1.75, 0.92,
> 1.5, 0.83, 0.75, 2.33, 0.67, 1.33, 1.58), Date1 = structure(c(16697,
> 16710, 16740, 16751, 16768, 16698, 16710, 16740, 16751, 16768,
> 16697, 16712, 16739, 16750, 16697, 16709, 16714, 16721, 16737,
> 16741, 16751, 16765, 16769, 16697, 16709, 16714, 16721, 16737,
> 16741, 16751, 16765, 16769, 16697, 16709, 16714, 16721, 16737,
> 16741, 16751, 16765, 16769, 16737, 16741, 16751, 16765, 16769
> ), class = "Date")), .Names = c("Date", "Year", "Station",
> "Abun", "Date1"), row.names = c(NA, -46L), class = "data.frame")
>
> Can any one help me please?
>
> With best regards,
> Christine
>
> ______________________________________________
> R-help at 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]]
------------------------------
Message: 22
Date: Tue, 1 Dec 2015 08:19:54 +0000 (UTC)
From: Christine Lee <leptostracan at yahoo.com>
To: Jim Lemon <drjimlemon at gmail.com>
Cc: r-help mailing list <r-help at r-project.org>
Subject: [R] ??? filled circle with a black line on the rim in pch
function
Message-ID:
<495496469.12506923.1448957994844.JavaMail.yahoo at mail.yahoo.com>
Content-Type: text/plain; charset="UTF-8"
Sorry all,?My mistake!? The?missing parts are?as follows:?Raw$Date1<-as.Date(Raw$Date,"%d/%m")
culr<-ifelse(Raw$Year=="Y2002","Year 2002","Year 2014")
library(lattice)?Many thanks.? ?With best regards,Christine
Jim Lemon <drjimlemon at gmail.com> ? 2015?12?1? (??) 4:01 PM ???
Hi Christine,When I try to run your script, the plot fails:
Error in eval(expr, envir, enclos) : object 'culr' not found> names(Raw)[1] "Date" ? ?"Year" ? ?"Station" "Abun" ? ?"Date1" ?
so I changed the second line to:
groups=Year,
and it did work. The default (pink, gray) background colors for the symbols do appear when the symbol is changed to pch=21. The arguments?
col="black",bg=c("gray","black"),
would produce the symbols you want in base graphics, but do not seem to do so in lattice. I do get sort of what you want by modifying your code pretty radically:
xyplot(Abun~Date1|Station, data=Raw,? ? ? ? groups = Year,? ? ? ? par.settings = list(strip.background = list(col = "transparent")),? ? ? ? type="p",? ? ? ? pch = rep(21,2),? ? ? ? col="black",? ? ? ? fill=c("gray","black"),? ? ? ? xlab=list("Month",cex=1.5),? ? ? ? ylab=list("Abundance",cex=1.5),? ? ? ? index.cond=list(c(1,2,3,4)),? ? ? ? auto.key = T,? ? ? ? layout=c(4,1))
Jim
On Tue, Dec 1, 2015 at 5:20 PM, Christine Lee via R-help <r-help at r-project.org> wrote:
Dear All,
I have an embarssing question, I want to put a black line as a rim on the grey symbol in the xyplot, to no avail.
.? I thought it was easy, by changing the pch code from 16 to 21.? I was surpised that I ran into difficulty.
My original script is as follows:
library(lattice)
xyplot(Abun~Date1|Station, data=Raw,
? ? ? ? groups = culr,
? ? ? ? par.settings = list(strip.background = list(col = "transparent"),
? ? ? ? ? ? ? ? ? ? ? ? ? ? superpose.symbol = list(cex = rep(2, 2),
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? col=c("grey","black"),
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? pch = rep(16,2))),
? ? ? ? type="p",
? ? ? ? xlab=list("Month",cex=1.5),
? ? ? ? ylab=list("Abundance",cex=1.5),
? ? ? ? index.cond=list(c(1,2,3,4)),
? ? ? ? auto.key = T,
? ? ? ? layout=c(4,1))
I have changed pch number into 21, the symbols did show a black rim, but the filled circle colours became blue and pink, instead of the designated grey and black.? This puzzles me.
My data is as follows:
Raw<-structure(list(Date = structure(c(6L, 7L, 2L, 4L, 12L, 9L, 7L,
2L, 4L, 12L, 6L, 15L, 14L, 3L, 6L, 1L, 16L, 5L, 11L, 8L, 4L,
10L, 13L, 6L, 1L, 16L, 5L, 11L, 8L, 4L, 10L, 13L, 6L, 1L, 16L,
5L, 11L, 8L, 4L, 10L, 13L, 11L, 8L, 4L, 10L, 13L), .Label = c("1/10",
"1/11", "11/11", "12/11", "13/10", "19/9", "2/10", "2/11", "20/9",
"26/11", "29/10", "29/11", "30/11", "31/10", "4/10", "6/10"), class = "factor"),
? ? Year = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
? ? 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
? ? 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
? ? 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Y2002", "Y2014"), class = "factor"),
? ? Station = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
? ? 2L, 3L, 3L, 3L, 3L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
? ? 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
? ? 3L, 3L, 4L, 4L, 4L, 4L, 4L), .Label = c("E", "F", "H", "I"
? ? ), class = "factor"), Abun = c(3.42, 1.33, 3.67, 3.67, 3.92,
? ? 2.17, 2.5, 1.67, 6.33, 0.67, 1, 1, 1.33, 2.08, 0, 0, 0.33,
? ? 0.08, 0.08, 0, 0.5, 0.17, 0.67, 0.67, 0, 1, 0.58, 1.5, 2.67,
? ? 0.67, 1.33, 3, 0.58, 1.17, 1.25, 0.75, 1.25, 1.75, 0.92,
? ? 1.5, 0.83, 0.75, 2.33, 0.67, 1.33, 1.58), Date1 = structure(c(16697,
? ? 16710, 16740, 16751, 16768, 16698, 16710, 16740, 16751, 16768,
? ? 16697, 16712, 16739, 16750, 16697, 16709, 16714, 16721, 16737,
? ? 16741, 16751, 16765, 16769, 16697, 16709, 16714, 16721, 16737,
? ? 16741, 16751, 16765, 16769, 16697, 16709, 16714, 16721, 16737,
? ? 16741, 16751, 16765, 16769, 16737, 16741, 16751, 16765, 16769
? ? ), class = "Date")), .Names = c("Date", "Year", "Station",
"Abun", "Date1"), row.names = c(NA, -46L), class = "data.frame")
Can any one help me please?
With best regards,
Christine
______________________________________________
R-help at 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]]
------------------------------
Message: 23
Date: Tue, 1 Dec 2015 21:28:52 +1100
From: Jim Lemon <drjimlemon at gmail.com>
Cc: r-help mailing list <r-help at r-project.org>, Alexandra Hua
<alexandra.hua at yale.edu>
Subject: Re: [R] Graphing a subset of data
Message-ID:
<CA+8X3fVC_=maxb2zX1Q8xR5sOyyX5adR4RX7fmJiHPXKQ57dXw at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
Hi Alexandra,
I think you are going about this in an excessively difficult way. Here is a
rough example:
graphit<-function(x,var,type,subset=NA,...){
if(!is.na(subset[1])) x<-subset(x,subset)
do.call(type,list(x=x[[var]],...))
}
# assume that the data are measurements of penetration by crossbow bolts at
specified speeds
bolts<-data.frame(SPEED1=rep(1:3,each=30),
penetration=c(runif(30,10,15),runif(30,15,20),runif(30,20,25)))
# note the lazy way of adding arguments to the function call
graphit(bolts,"SPEED1",boxplot,main="Boxplot of SPEED1")
graphit(bolts,"penetration",boxplot,subset=bolts$SPEED1==3,
main="Boxplot of SPEED1 == 3")
graphit(bolts,"SPEED1",hist,main="Histogram of SPEED1")
Jim
[[alternative HTML version deleted]]
------------------------------
Message: 24
Date: Tue, 1 Dec 2015 11:41:59 +0100
From: Ernesto Villarino <villarino.ernesto at gmail.com>
To: r-help at r-project.org
Subject: [R] Metanalysis in R using MAVIS
Message-ID:
<CAAmrVFpttyU34wRNXhcFa=6nW7OmB51cE0J=_WceSdqQJzNxRA at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"
I am Ernesto, a Phd student from Bilbao working with climate related
plankton dynamics. I am trying to perform a MAVIS metanalysis (any other
meta techcnique to be applied in R) to see if there is a significant
difference between the moderators in my dataset. Is there any option to do
an ANOVA analysis using MAVIS among groups?
In the Moderator (subgroup) analysis we have one variable per study,
instead of having two (M1,M2).
*Study*
*Response variable*
*N*
*Moderator*
Study-01
-0.1111
8
Dispersing
Study-02
-0.2557
8
Dispersing
Study-03
0.06667
4
Zooplankton
Study-04
0.1956
5
Phytoplankton
Study-05
0.025
5
Phytoplankton
Study-06
0.7768
4
Phytoplankton
Study-07
0.3511
6
Dispersing
Study-08
-0.09821
6
Dispersing
Study-09
0.4286
3
NDL
Study-10
0.5638
7
Dispersing
?
?
?
?
I appreciate your help,
[[alternative HTML version deleted]]
------------------------------
Subject: Digest Footer
_______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
------------------------------
End of R-help Digest, Vol 154, Issue 1
**************************************
[[alternative HTML version deleted]]
More information about the R-help
mailing list