[R] plotting decision tree from Mapreduce output
Respect R veterans, I am just starting with R and I am having a difficulty in plotting a rule based decision tree in R. The problem is, I already have an output from hadoop MapReduce and it is in the form of a simple text file. Now I want to use this output from Hadoop and represent it graphically on R. The output file looks something like this. 1 overcast yes1 rain 3 strong no1 rain 3 weak yes1 sunny 2 high no1 sunny 2 normal yes Is there a way that I can represent this graphically in R in something like, http://web.cs.swarthmore.edu/~meeden/cs63/f05/figure3.1.jpg Any help will be much appreciated. Thanks [[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.
[R] converting time data in R
Respected R veterans and experts, I have a column representing time in a data frame in R. when I call the str() function on the column it says something like this str(df2$Time) Factor w/ 1441 levels ,00:01,00:02,00:03,..: 1086 1096 and so on The thing is I want to conver this column into string type such that if the time is less than 12:00, it should get modified to the string moring , if time is between 12:00 and 6:00 , it is daylight and so on. The first step I thought was to convert this vector to time type of column of data frame, so I used chron function. I typed the following command, df2$Time-chron(times=df2$Time,format=c('h:m')) Error in convert.times(times., fmt) : format h:m may be incorrect In addition: Warning message:In is.na(out$s) : is.na() applied to non-(list or vector) of type 'NULL so I guessed I should have added second parameter in format so I tried the following : df2$Time-chron(time=df2$Time,format=c('h:m:s')) But still got the same error I know this is just the first step, may be my approach too is wrong. Can anyone suggest me how to convert these time data cells to morning, evening , night etc. Any help is much appreciated. [[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.
[R] TS: Calculating the mean by month
I have the following (monthly) ts time-series: t Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2002 5.3 9.4 12.1 14.4 17.9 23.5 24.3 23.6 19.3 16.3 13.9 9.0 2003 7.5 5.4 10.4 13.3 19.9 25.6 26.2 27.6 20.6 15.5 12.5 8.0 2004 6.3 7.8 9.6 13.6 16.5 22.0 24.3 24.6 21.3 18.1 11.7 9.0 2005 5.7 5.4 9.7 13.0 18.9 22.9 25.0 23.4 21.4 16.5 11.3 6.7 I would like to calculate the mean of data by month. How can I do it with a ts time series? Many thanks Vittorio __ 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] TS: Calculating the mean by month
Hi tt-ts((1:(4*12)), frequency=12) tapply(tt,cycle(tt), mean) However you could find it yourself more quickly just browsing docs as I did. Regards Petr -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of Victor Sent: Tuesday, February 18, 2014 9:48 AM To: r-help@r-project.org Subject: [R] TS: Calculating the mean by month I have the following (monthly) ts time-series: t Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec 2002 5.3 9.4 12.1 14.4 17.9 23.5 24.3 23.6 19.3 16.3 13.9 9.0 2003 7.5 5.4 10.4 13.3 19.9 25.6 26.2 27.6 20.6 15.5 12.5 8.0 2004 6.3 7.8 9.6 13.6 16.5 22.0 24.3 24.6 21.3 18.1 11.7 9.0 2005 5.7 5.4 9.7 13.0 18.9 22.9 25.0 23.4 21.4 16.5 11.3 6.7 I would like to calculate the mean of data by month. How can I do it with a ts time series? Many thanks Vittorio __ 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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient. __ 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] association of multiple variables
Dear all, Please, is there a way in R to calculate association statistics over more than 2 categorical (binary) variables? I mean something similar what cor(my.dataframe) does for continuous variables, i.e. to have a matrix of statistics and/or p-values as an output. Many thanks! Zdenek - - Zdenìk Skála INCOMA GfK [[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] converting time data in R
Hi -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org] On Behalf Of R Novice Sent: Tuesday, February 18, 2014 9:44 AM To: r-help@r-project.org Subject: [R] converting time data in R Respected R veterans and experts, I have a column representing time in a data frame in R. when I call the str() function on the column it says something like this str(df2$Time) Factor w/ 1441 levels ,00:01,00:02,00:03,..: 1086 1096 and so on You have some empty levels (cells) and it seems that not all data are in xx:yy format, so you need to repair it. The thing is I want to conver this column into string type such that if the time is less than 12:00, it should get modified to the string moring , if time is between 12:00 and 6:00 , it is daylight and so on. You could transfer it to POSIX class and manipulate with logical operations. Maybe chron object can also be used for such comparisons. The first step I thought was to convert this vector to time type of column of data frame, so I used chron function. I typed the following command, df2$Time-chron(times=df2$Time,format=c('h:m')) Error in convert.times(times., fmt) : format h:m may be incorrect In addition: Warning message:In is.na(out$s) : is.na() applied to non- (list or vector) of type 'NULL see my first comment. Regards Petr so I guessed I should have added second parameter in format so I tried the following : df2$Time-chron(time=df2$Time,format=c('h:m:s')) But still got the same error I know this is just the first step, may be my approach too is wrong. Can anyone suggest me how to convert these time data cells to morning, evening , night etc. Any help is much appreciated. [[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. Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům. Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému. Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat. Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu. V případě, že je tento e-mail součástí obchodního jednání: - vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu. - a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou. - trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech. - odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá. This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients. If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system. If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner. The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email. In case that this e-mail forms part of business dealings: - the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning. - if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation. - the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects. - the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the
Re: [R] plot a list of trellis objects
Hi Santosh for more control on size and position ?lattice::print.trellis Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh Sent: Tuesday, 18 February 2014 10:41 To: r-help Subject: [R] plot a list of trellis objects Dear Rxperts Is there a way to control the display order (or simplistically control panel layout) of a list of trellis objects without using a for loop (or whatever)? I just realize that gridExtra has that feature.. (grid.arrange)... But, converting each of those elements of the list of trellis objects into an argument to grid.arrange seems to negate the simplicity.. In addition, if I were to use grid.arrange on a list of trellis objects, is there a way to pass the list elements as arguments to grid.arrange? If you have other suggestions, please do.. Regards, Santosh [[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. __ 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] association of multiple variables
You might modify this function which computes Cramer's V using the assocstats() function in package vcd: catcor - function(x) { require(vcd) nc - ncol(x) v - expand.grid(1:nc, 1:nc) matrix(mapply(function(i1, i2) assocstats(table(x[,i1], x[,i2]))$cramer, v[,1], v[,2]), nc, nc) } e.g. dat - data.frame(v1=sample(LETTERS[1:5], 15, replace=TRUE), + v2=sample(LETTERS[1:5], 15, replace=TRUE), + v3=sample(LETTERS[1:5], 15, replace=TRUE)) catcor(dat) [,1] [,2] [,3] [1,] 1.000 0.5633481 0.5773503 [2,] 0.5633481 1.000 0.6831301 [3,] 0.5773503 0.6831301 1.000 - David L Carlson Department of Anthropology Texas AM University College Station, TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Skála, Zdenek (INCOMA GfK) Sent: Tuesday, February 18, 2014 3:33 AM To: r-help@r-project.org Subject: [R] association of multiple variables Dear all, Please, is there a way in R to calculate association statistics over more than 2 categorical (binary) variables? I mean something similar what cor(my.dataframe) does for continuous variables, i.e. to have a matrix of statistics and/or p-values as an output. Many thanks! Zdenek - - Zdenlk Skala INCOMA GfK [[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] count and sum simultaneously in R pivot table
A.K., thanks for your reply. I'm getting an error at res2: Error: unexpected symbol in res2 - within(as.data.frame(res1),`Count of Case ID` - dcast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, length, margins=TRUE)[,3])[,c(4,1:3)] colnames I've tried a couple of modifications, but obviously don't know what I'm doing because I haven't fixed it. If anything comes to you in the meantime, please advise. Thanks. -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: Tuesday, February 18, 2014 2:28 AM To: r-help@r-project.org Cc: Crombie, Burnette N Subject: Re: [R] count and sum simultaneously in R pivot table Hi, Check if this works: library(reshape2) res1 - acast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, sum, margins=TRUE)[,-4] res2 - within(as.data.frame(res1),`Count of Case ID` - dcast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, length, margins=TRUE)[,3])[,c(4,1:3)] colnames(res2)[2:4] - paste(Sum of,colnames(res2)[2:4]) rownames(res2)[length(rownames(res2))] - Grand Total indx - grepl(all,rownames(res2)) ord1 - unlist(tapply(seq_len(nrow(res2)),list(cumsum(c(TRUE,diff(indx)0))),FUN=function(x) c(tail(x,1),head(x,-1)) ),use.names=FALSE) res3 - res2[ord1,] rownames(res3) - gsub(\\_\\(all\\),,rownames(res3)) A.K. __ 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] How to calculate moving average without using filter()?
Thanks everyone. For 5 point moving average, filter(x, side=2, filter=rep(1/5, 5)), versus, filter(x, side=2, filter=rep(1, 5) Do they have the same effect, since the total needs to be 1. Gabor Rui: I am aware of the zoo package, I did not want to install a package for one function. Same reason for sos package. David, thanks, that is what I am looking for. Mike On Mon, Feb 17, 2014 at 2:07 PM, Rui Barradas ruipbarra...@sapo.pt wrote: Hello, Many packages have a movind average function. For instance package forecast. Or library(sos) findFn(moving average) In your example, what you compute is not exactly a moving average, but in can be computed with something like the following. s - (seq_along(dat) - 1) %/% 3 sapply(split(dat, s), mean) Hope this helps, Rui Barradas Em 17-02-2014 18:45, C W escreveu: Hi list, How do I calculate a moving average without using filter(). filter() does not seem to give weighted averages. I am looking into apply(), tapply,... But nothing moves. For example, dat-c(1:20) mean(dat[1:3]) mean(dat[4:6]) mean(dat[7:9]) mean(dat[10:12]) etc... I understand the point of apply is to avoid loops, how should I incorporate this idea into using an apply()? Thanks, Mike [[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] minor version upgrade requires library refresh?
On Fri, 2014-02-14 at 17:47 -0800, David Winsemius wrote: On Feb 13, 2014, at 11:36 AM, Ross Boylan wrote: If R changes from 3.0.1 to 3.0.2, or more generally from m.n.p to m.n.q, is it necessary to refresh libraries to match the version, e.g., with update.packages(checkBuilt=TRUE, ask=FALSE)? The R Windows FAQ 2.8 says For those with a personal library (folder R\win-library\x.y of your home directory, R\win64-library\x.y on 64-bit builds), you will need to update that too when the minor version of R changes (e.g. from 3.0.2 to 3.1.0). When n changes you need to update any existing library. This suggests that in m.n.q n is the minor version (which would make q the release?), and that the minor version does not change between 3.0.1 and 3.0.1. Huh? The FAQ refers to the minor version but does not define it, except by example. I'm trying to figure out if a change in p in m.n.p counts as a change in the minor version number, and hence requires a library update. I considered p a minor version number (e.g., in the subject line of the message) and so found the FAQ ambiguous. Both your rule (when n changes...) and the docs suggest p does not count as a minor version number, though neither is explicit. Logically, the fact that a change in n requires library updates provides no information about a change in p, though the usual reading is p doesn't matter or when m.n stays the same no update is necessary. Ross __ 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] Updating a data frame based on if condition
I have a subset of data that I have identified as suspect (for example, the first name has excessive spaces, is longer than 35 characters or has a number). What I want to do is update the FNAME_SUSPECT field in mydata to TRUE if any of those conditions are met. Here's my data: dput(mydata) structure(list(PERSON_FIRST_NAME = c(1298530, JULIA, TAYLOR, CS AND JEFF, 88, 4465891170098562, 1124211, LEWIS MARY KAY, KARL R O S, 5466181820076010, JULI0 C, WAYNE T., 1124211, 1124211, ROBERT B VIONA D, DENNIS and MARY SUE, BRIAN JOANNE, 1124211, RONALD and GAIL, Mike and Mary Lou, 31763006, 7, 11460735, Paul and Mary Beth, JIMMY and RUTH MARIE, 1124211, WAYNE LU ANN, SCOTT ANNA MARIE, 1124211, 1124211, 952714, DAVID, RHONDA and NATALIE, VIRGINIA S, 707069, 4397836190001917, MARIA DE LA LUZ, MARIA DE LA LUZ, G S COMPUTERIZED GRADING, 1124211, 1124211, 1124211, 1124211, MARIA DE LA LUZ, ED AND JANICE KISHI, 1124211, Garrett A. and Jenny E., 1124211, 1124211, Hiram T. and A. Judith, MA DE LA LUZ, STEVE, Bev, and Caleb, MR AND MRS EVER), FNAME_SUSPECT = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), FNAME_LENGTH = c(7L, 26L, 2L, 16L, 7L, 16L, 10L, 16L, 7L, 10L, 7L, 7L, 18L, 19L, 14L, 7L, 16L, 17L, 8L, 1L, 8L, 18L, 20L, 7L, 14L, 18L, 7L, 7L, 6L, 25L, 12L, 6L, 16L, 15L, 15L, 26L, 7L, 7L, 7L, 7L, 15L, 19L, 7L, 23L, 7L, 7L, 22L, 12L, 21L, 15L), FNAME_PATTERN = c(999, A,_AA,_AA_AAA_, 99, , 999, A___AAA, _A_A_A, , 9_A, A___A., 999, 999, AA_A__A_A, AA_AAA__AAA, A___AA, 999, AA_AAA__, _AAA__AAA, , 9, , _AAA__, A_AAA__A, 999, A__AA_AAA, A___A, 999, 999, 99, A,_AA_AAA_AAA, ___A, 99, , A_AA_AA_AAA, A_AA_AA_AAA, A__A__AAA, 999, 999, 999, 999, A_AA_AA_AAA, AA_AAA_AA_A, 999, AAA_A._AAA_A_A., 999, 999, A_A._AAA_A._AA, AA_AA_AA_AAA, A,_AAA,_AAA_A, AA_AAA_AAA_ ), FNAME_TOKEN_COUNT = c(1L, 5L, 1L, 1L, 1L, 4L, 4L, 1L, 2L, 4L, 1L, 1L, 5L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 1L, 4L, 4L, 5L, 1L, 1L, 1L, 1L, 4L, 4L, 1L, 5L, 1L, 1L, 5L, 4L, 4L, 4L)), .Names = c(PERSON_FIRST_NAME, FNAME_SUSPECT, FNAME_LENGTH, FNAME_PATTERN, FNAME_TOKEN_COUNT ), row.names = c(6717L, 11035L, 11626L, 14965L, 17874L, 24341L, 25582L, 25834L, 26851L, 30134L, 36385L, 45244L, 46947L, 61449L, 67564L, 71465L, 73782L, 75278L, 78977L, 79037L, 80577L, 81644L, 84427L, 86286L, 89963L, 91208L, 94054L, 99518L, 114658L, 128305L, 129082L, 137492L, 137573L, 138556L, 139489L, 148757L, 153956L, 155546L, 160533L, 162386L, 162681L, 165220L, 168063L, 173003L, 175322L, 179935L, 180991L, 181215L, 183787L, 184573L), class = data.frame) Note I defaulted all of the FNAME_SUSPECT to FALSE. I plan to change that later. I've tried running this: if(mydata$FNAME_TOKEN_COUNT 3 | mydata$FNAME_LENGTH 35 | regexpr(9, mydata$FNAME_PATTERN) 0) mydata$FNAME_SUSPECT - TRUE however I get the error: Warning message: In if (mydata$FNAME_TOKEN_COUNT 3 | mydata$FNAME_LENGTH 35 | : the condition has length 1 and only the first element will be used Would I be better doing this in a for loop? I had once heard that if you're doing a for loop in R, you're doing something wrong. -- Jeff [[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] plot a list of trellis objects
Thanks for all your suggestions.. santosh On Tue, Feb 18, 2014 at 4:11 AM, Duncan Mackay dulca...@bigpond.com wrote: Hi Santosh for more control on size and position ?lattice::print.trellis Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mac...@northnet.com.au -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh Sent: Tuesday, 18 February 2014 10:41 To: r-help Subject: [R] plot a list of trellis objects Dear Rxperts Is there a way to control the display order (or simplistically control panel layout) of a list of trellis objects without using a for loop (or whatever)? I just realize that gridExtra has that feature.. (grid.arrange)... But, converting each of those elements of the list of trellis objects into an argument to grid.arrange seems to negate the simplicity.. In addition, if I were to use grid.arrange on a list of trellis objects, is there a way to pass the list elements as arguments to grid.arrange? If you have other suggestions, please do.. Regards, Santosh [[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.
[R] party::ctree
Would you mind to help me how to extract coefficients of significant variables using ctree model? How to implement the model like logistic and others. Thank you. Amrit This electronic message may contain information that is confidential and/or legally privileged. It is intended only for the use of the individual(s) and entity named as recipients in the message. If you are not an intended recipient of this message, please notify the sender immediately and delete the material from any computer. Do not deliver, distribute or copy this message, and do not disclose its contents or take any action in reliance on the information it contains. 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.
[R] Errorbar
Hi All, Can anyone show me how to add a error bar to my graphs. I am currently using this code g-ggplot(means,aes(x=variable,y=value)) g-g+geom_bar(stat=identity)+facet_wrap(~Site+Season) g Thanks, Akaalz [[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] count and sum simultaneously in R pivot table
The script works nicely, Arun. You were right, I pasted code from email instead of Rhelp and didn't reformat properly in R. I appreciate your time with this! -Original Message- It seems like part of the next line is also being run (in the end 'colnames'). For e.g. res2 - within(as.data.frame(res1),`Count of Case ID` - dcast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, length, margins=TRUE)[,3])[,c(4,1:3)] colnames #Error: unexpected symbol in res2 - within(as.data.frame(res1),`Count of Case ID` - #dcast(FLSAdata_melt, ViolationDesc + ReasonDesc ~ variable, length, margins=TRUE)#[,3])[,c(4,1:3)] colnames __ 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] Convergence problem
Hi all, I am a facing a convergence problem when I test for variability of a slope among groups in lme. a) How do I know how many iterations the program is running? b) How do I increase the # of iterations c) Do I include the command to increase iterations in my equation? Thanks for your help! Amanuel -- Amanuel G. Tekleab, Ph.D. Associate Professor of Organizational Behavior School of Business Administration Wayne State University 304 Prentis Bldg. Detroit, MI 48202 Phone: 313-577-9211 Fax: 313-577-5486 [[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] Convergence problem
On Feb 18, 2014, at 9:47 AM, Amanuel Tekleab wrote: Hi all, I am a facing a convergence problem when I test for variability of a slope among groups in lme. a) How do I know how many iterations the program is running? b) How do I increase the # of iterations c) Do I include the command to increase iterations in my equation? There seems to be consensus among authors of iterative routines in R to issue control parameters to functions in lists with names like control. Looking at the help page for 'lme' suggests its authors have followed that pattern. This is a question that would get a wider audience of knowledgeable minds regarding lme and cousins if it were directed to the sig-ME mailing list. Thanks for your help! Amanuel -- Amanuel G. Tekleab, Ph.D. Associate Professor of Organizational Behavior School of Business Administration Wayne State University 304 Prentis Bldg. Detroit, MI 48202 Phone: 313-577-9211 Fax: 313-577-5486 [[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. David Winsemius Alameda, CA, USA __ 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] party::ctree
On Tue, 18 Feb 2014, Karki, Amrit B wrote: Would you mind to help me how to extract coefficients of significant variables using ctree model? How to implement the model like logistic and others. Thank you. ctree() is a nonparametric model and there are no significant coefficients. Some variables are selected for splits, others are not, and there are certain methods that try to derive so-called importance measures. However, for single trees these are used less often than for forests (such as cforest()). If you want to combine decision trees with parametric models such as logistic regressions (that do have coefficients), you could consider the mob() function in the same package. hth, Z Amrit This electronic message may contain information that is confidential and/or legally privileged. It is intended only for the use of the individual(s) and entity named as recipients in the message. If you are not an intended recipient of this message, please notify the sender immediately and delete the material from any computer. Do not deliver, distribute or copy this message, and do not disclose its contents or take any action in reliance on the information it contains. 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. __ 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] Updating a data frame based on if condition
Not always true, but it is in this case: ?ifelse David C -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Johnson Sent: Tuesday, February 18, 2014 11:24 AM To: R help Subject: [R] Updating a data frame based on if condition I have a subset of data that I have identified as suspect (for example, the first name has excessive spaces, is longer than 35 characters or has a number). What I want to do is update the FNAME_SUSPECT field in mydata to TRUE if any of those conditions are met. Here's my data: dput(mydata) structure(list(PERSON_FIRST_NAME = c(1298530, JULIA, TAYLOR, CS AND JEFF, 88, 4465891170098562, 1124211, LEWIS MARY KAY, KARL R O S, 5466181820076010, JULI0 C, WAYNE T., 1124211, 1124211, ROBERT B VIONA D, DENNIS and MARY SUE, BRIAN JOANNE, 1124211, RONALD and GAIL, Mike and Mary Lou, 31763006, 7, 11460735, Paul and Mary Beth, JIMMY and RUTH MARIE, 1124211, WAYNE LU ANN, SCOTT ANNA MARIE, 1124211, 1124211, 952714, DAVID, RHONDA and NATALIE, VIRGINIA S, 707069, 4397836190001917, MARIA DE LA LUZ, MARIA DE LA LUZ, G S COMPUTERIZED GRADING, 1124211, 1124211, 1124211, 1124211, MARIA DE LA LUZ, ED AND JANICE KISHI, 1124211, Garrett A. and Jenny E., 1124211, 1124211, Hiram T. and A. Judith, MA DE LA LUZ, STEVE, Bev, and Caleb, MR AND MRS EVER), FNAME_SUSPECT = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), FNAME_LENGTH = c(7L, 26L, 2L, 16L, 7L, 16L, 10L, 16L, 7L, 10L, 7L, 7L, 18L, 19L, 14L, 7L, 16L, 17L, 8L, 1L, 8L, 18L, 20L, 7L, 14L, 18L, 7L, 7L, 6L, 25L, 12L, 6L, 16L, 15L, 15L, 26L, 7L, 7L, 7L, 7L, 15L, 19L, 7L, 23L, 7L, 7L, 22L, 12L, 21L, 15L), FNAME_PATTERN = c(999, A,_AA,_AA_AAA_, 99, , 999, A___AAA, _A_A_A, , 9_A, A___A., 999, 999, AA_A__A_A, AA_AAA__AAA, A___AA, 999, AA_AAA__, _AAA__AAA, , 9, , _AAA__, A_AAA__A, 999, A__AA_AAA, A___A, 999, 999, 99, A,_AA_AAA_AAA, ___A, 99, , A_AA_AA_AAA, A_AA_AA_AAA, A__A__AAA, 999, 999, 999, 999, A_AA_AA_AAA, AA_AAA_AA_A, 999, AAA_A._AAA_A_A., 999, 999, A_A._AAA_A._AA, AA_AA_AA_AAA, A,_AAA,_AAA_A, AA_AAA_AAA_ ), FNAME_TOKEN_COUNT = c(1L, 5L, 1L, 1L, 1L, 4L, 4L, 1L, 2L, 4L, 1L, 1L, 5L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 1L, 4L, 4L, 5L, 1L, 1L, 1L, 1L, 4L, 4L, 1L, 5L, 1L, 1L, 5L, 4L, 4L, 4L)), .Names = c(PERSON_FIRST_NAME, FNAME_SUSPECT, FNAME_LENGTH, FNAME_PATTERN, FNAME_TOKEN_COUNT ), row.names = c(6717L, 11035L, 11626L, 14965L, 17874L, 24341L, 25582L, 25834L, 26851L, 30134L, 36385L, 45244L, 46947L, 61449L, 67564L, 71465L, 73782L, 75278L, 78977L, 79037L, 80577L, 81644L, 84427L, 86286L, 89963L, 91208L, 94054L, 99518L, 114658L, 128305L, 129082L, 137492L, 137573L, 138556L, 139489L, 148757L, 153956L, 155546L, 160533L, 162386L, 162681L, 165220L, 168063L, 173003L, 175322L, 179935L, 180991L, 181215L, 183787L, 184573L), class = data.frame) Note I defaulted all of the FNAME_SUSPECT to FALSE. I plan to change that later. I've tried running this: if(mydata$FNAME_TOKEN_COUNT 3 | mydata$FNAME_LENGTH 35 | regexpr(9, mydata$FNAME_PATTERN) 0) mydata$FNAME_SUSPECT - TRUE however I get the error: Warning message: In if (mydata$FNAME_TOKEN_COUNT 3 | mydata$FNAME_LENGTH 35 | : the condition has length 1 and only the first element will be used Would I be better doing this in a for loop? I had once heard that if you're doing a for loop in R, you're doing something wrong. -- Jeff [[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. __ 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] Updating a data frame based on if condition
This is my first time with ifelse, but I've tried: mydata$FNAME_SUSPECT - ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, FALSE, ifelse(mydata$FNAME_LENGTH 35, TRUE, FALSE, ifelse(regexpr(9, mydata$FNAME_PATTERN) 0, TRUE, FALSE ) ) ) Error in ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, FALSE, ifelse(mydata$FNAME_LENGTH : unused argument (ifelse(mydata$FNAME_LENGTH 35, TRUE, FALSE, ifelse(regexpr(9, mydata$FNAME_PATTERN) 0, TRUE, FALSE))) I have the R for Dummies book which covers it a bit, but I just ordered the R Cookbook. On Tue, Feb 18, 2014 at 10:16 AM, David Carlson dcarl...@tamu.edu wrote: Not always true, but it is in this case: ?ifelse David C -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Johnson Sent: Tuesday, February 18, 2014 11:24 AM To: R help Subject: [R] Updating a data frame based on if condition I have a subset of data that I have identified as suspect (for example, the first name has excessive spaces, is longer than 35 characters or has a number). What I want to do is update the FNAME_SUSPECT field in mydata to TRUE if any of those conditions are met. Here's my data: dput(mydata) structure(list(PERSON_FIRST_NAME = c(1298530, JULIA, TAYLOR, CS AND JEFF, 88, 4465891170098562, 1124211, LEWIS MARY KAY, KARL R O S, 5466181820076010, JULI0 C, WAYNE T., 1124211, 1124211, ROBERT B VIONA D, DENNIS and MARY SUE, BRIAN JOANNE, 1124211, RONALD and GAIL, Mike and Mary Lou, 31763006, 7, 11460735, Paul and Mary Beth, JIMMY and RUTH MARIE, 1124211, WAYNE LU ANN, SCOTT ANNA MARIE, 1124211, 1124211, 952714, DAVID, RHONDA and NATALIE, VIRGINIA S, 707069, 4397836190001917, MARIA DE LA LUZ, MARIA DE LA LUZ, G S COMPUTERIZED GRADING, 1124211, 1124211, 1124211, 1124211, MARIA DE LA LUZ, ED AND JANICE KISHI, 1124211, Garrett A. and Jenny E., 1124211, 1124211, Hiram T. and A. Judith, MA DE LA LUZ, STEVE, Bev, and Caleb, MR AND MRS EVER), FNAME_SUSPECT = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), FNAME_LENGTH = c(7L, 26L, 2L, 16L, 7L, 16L, 10L, 16L, 7L, 10L, 7L, 7L, 18L, 19L, 14L, 7L, 16L, 17L, 8L, 1L, 8L, 18L, 20L, 7L, 14L, 18L, 7L, 7L, 6L, 25L, 12L, 6L, 16L, 15L, 15L, 26L, 7L, 7L, 7L, 7L, 15L, 19L, 7L, 23L, 7L, 7L, 22L, 12L, 21L, 15L), FNAME_PATTERN = c(999, A,_AA,_AA_AAA_, 99, , 999, A___AAA, _A_A_A, , 9_A, A___A., 999, 999, AA_A__A_A, AA_AAA__AAA, A___AA, 999, AA_AAA__, _AAA__AAA, , 9, , _AAA__, A_AAA__A, 999, A__AA_AAA, A___A, 999, 999, 99, A,_AA_AAA_AAA, ___A, 99, , A_AA_AA_AAA, A_AA_AA_AAA, A__A__AAA, 999, 999, 999, 999, A_AA_AA_AAA, AA_AAA_AA_A, 999, AAA_A._AAA_A_A., 999, 999, A_A._AAA_A._AA, AA_AA_AA_AAA, A,_AAA,_AAA_A, AA_AAA_AAA_ ), FNAME_TOKEN_COUNT = c(1L, 5L, 1L, 1L, 1L, 4L, 4L, 1L, 2L, 4L, 1L, 1L, 5L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 1L, 4L, 4L, 5L, 1L, 1L, 1L, 1L, 4L, 4L, 1L, 5L, 1L, 1L, 5L, 4L, 4L, 4L)), .Names = c(PERSON_FIRST_NAME, FNAME_SUSPECT, FNAME_LENGTH, FNAME_PATTERN, FNAME_TOKEN_COUNT ), row.names = c(6717L, 11035L, 11626L, 14965L, 17874L, 24341L, 25582L, 25834L, 26851L, 30134L, 36385L, 45244L, 46947L, 61449L, 67564L, 71465L, 73782L, 75278L, 78977L, 79037L, 80577L, 81644L, 84427L, 86286L, 89963L, 91208L, 94054L, 99518L, 114658L, 128305L, 129082L, 137492L, 137573L, 138556L, 139489L, 148757L, 153956L, 155546L, 160533L, 162386L, 162681L, 165220L, 168063L, 173003L, 175322L, 179935L, 180991L, 181215L, 183787L, 184573L), class = data.frame) Note I defaulted all of the FNAME_SUSPECT to FALSE. I plan to change that later. I've tried running this: if(mydata$FNAME_TOKEN_COUNT 3 | mydata$FNAME_LENGTH 35 | regexpr(9, mydata$FNAME_PATTERN) 0) mydata$FNAME_SUSPECT - TRUE however I get the error: Warning message: In if (mydata$FNAME_TOKEN_COUNT 3 | mydata$FNAME_LENGTH 35 | : the condition has length 1 and only the first element will be used Would I be better doing this in a for loop? I had once heard that if you're doing a for loop in R, you're doing something wrong. -- Jeff [[alternative HTML
Re: [R] Errorbar
Have you seen the examples at docs.ggplot2.org/0.9.3.1/geom_errorbar.html ? On Feb 18, 2014, at 10:57, Alzahrani, Ahmad K A aka...@essex.ac.uk wrote: Hi All, Can anyone show me how to add a error bar to my graphs. I am currently using this code g-ggplot(means,aes(x=variable,y=value)) g-g+geom_bar(stat=identity)+facet_wrap(~Site+Season) g Thanks, Akaalz [[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. __ 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] Updating a data frame based on if condition
Ahh, I was specifying the second argument FALSE incorrectly. Works now as: mydata$FNAME_SUSPECT - ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, ifelse(mydata$FNAME_LENGTH 55, TRUE, ifelse(regexpr(9, mydata$FNAME_PATTERN) == 0, TRUE, FALSE ) ) ) On Tue, Feb 18, 2014 at 10:21 AM, Jeff Johnson mrjeffto...@gmail.comwrote: This is my first time with ifelse, but I've tried: mydata$FNAME_SUSPECT - ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, FALSE, ifelse(mydata$FNAME_LENGTH 35, TRUE, FALSE, ifelse(regexpr(9, mydata$FNAME_PATTERN) 0, TRUE, FALSE ) ) ) Error in ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, FALSE, ifelse(mydata$FNAME_LENGTH : unused argument (ifelse(mydata$FNAME_LENGTH 35, TRUE, FALSE, ifelse(regexpr(9, mydata$FNAME_PATTERN) 0, TRUE, FALSE))) I have the R for Dummies book which covers it a bit, but I just ordered the R Cookbook. On Tue, Feb 18, 2014 at 10:16 AM, David Carlson dcarl...@tamu.edu wrote: Not always true, but it is in this case: ?ifelse David C -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Johnson Sent: Tuesday, February 18, 2014 11:24 AM To: R help Subject: [R] Updating a data frame based on if condition I have a subset of data that I have identified as suspect (for example, the first name has excessive spaces, is longer than 35 characters or has a number). What I want to do is update the FNAME_SUSPECT field in mydata to TRUE if any of those conditions are met. Here's my data: dput(mydata) structure(list(PERSON_FIRST_NAME = c(1298530, JULIA, TAYLOR, CS AND JEFF, 88, 4465891170098562, 1124211, LEWIS MARY KAY, KARL R O S, 5466181820076010, JULI0 C, WAYNE T., 1124211, 1124211, ROBERT B VIONA D, DENNIS and MARY SUE, BRIAN JOANNE, 1124211, RONALD and GAIL, Mike and Mary Lou, 31763006, 7, 11460735, Paul and Mary Beth, JIMMY and RUTH MARIE, 1124211, WAYNE LU ANN, SCOTT ANNA MARIE, 1124211, 1124211, 952714, DAVID, RHONDA and NATALIE, VIRGINIA S, 707069, 4397836190001917, MARIA DE LA LUZ, MARIA DE LA LUZ, G S COMPUTERIZED GRADING, 1124211, 1124211, 1124211, 1124211, MARIA DE LA LUZ, ED AND JANICE KISHI, 1124211, Garrett A. and Jenny E., 1124211, 1124211, Hiram T. and A. Judith, MA DE LA LUZ, STEVE, Bev, and Caleb, MR AND MRS EVER), FNAME_SUSPECT = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), FNAME_LENGTH = c(7L, 26L, 2L, 16L, 7L, 16L, 10L, 16L, 7L, 10L, 7L, 7L, 18L, 19L, 14L, 7L, 16L, 17L, 8L, 1L, 8L, 18L, 20L, 7L, 14L, 18L, 7L, 7L, 6L, 25L, 12L, 6L, 16L, 15L, 15L, 26L, 7L, 7L, 7L, 7L, 15L, 19L, 7L, 23L, 7L, 7L, 22L, 12L, 21L, 15L), FNAME_PATTERN = c(999, A,_AA,_AA_AAA_, 99, , 999, A___AAA, _A_A_A, , 9_A, A___A., 999, 999, AA_A__A_A, AA_AAA__AAA, A___AA, 999, AA_AAA__, _AAA__AAA, , 9, , _AAA__, A_AAA__A, 999, A__AA_AAA, A___A, 999, 999, 99, A,_AA_AAA_AAA, ___A, 99, , A_AA_AA_AAA, A_AA_AA_AAA, A__A__AAA, 999, 999, 999, 999, A_AA_AA_AAA, AA_AAA_AA_A, 999, AAA_A._AAA_A_A., 999, 999, A_A._AAA_A._AA, AA_AA_AA_AAA, A,_AAA,_AAA_A, AA_AAA_AAA_ ), FNAME_TOKEN_COUNT = c(1L, 5L, 1L, 1L, 1L, 4L, 4L, 1L, 2L, 4L, 1L, 1L, 5L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 1L, 4L, 4L, 5L, 1L, 1L, 1L, 1L, 4L, 4L, 1L, 5L, 1L, 1L, 5L, 4L, 4L, 4L)), .Names = c(PERSON_FIRST_NAME, FNAME_SUSPECT, FNAME_LENGTH, FNAME_PATTERN, FNAME_TOKEN_COUNT ), row.names = c(6717L, 11035L, 11626L, 14965L, 17874L, 24341L, 25582L, 25834L, 26851L, 30134L, 36385L, 45244L, 46947L, 61449L, 67564L, 71465L, 73782L, 75278L, 78977L, 79037L, 80577L, 81644L, 84427L, 86286L, 89963L, 91208L, 94054L, 99518L, 114658L, 128305L, 129082L, 137492L, 137573L, 138556L, 139489L, 148757L, 153956L, 155546L, 160533L, 162386L, 162681L, 165220L, 168063L, 173003L, 175322L, 179935L, 180991L, 181215L, 183787L, 184573L), class = data.frame) Note I defaulted all of the FNAME_SUSPECT to FALSE. I plan to change that later. I've tried running this: if(mydata$FNAME_TOKEN_COUNT 3 | mydata$FNAME_LENGTH
[R] 3D graphics
Hi I have a large data set that consists of a time series of data captured from a device that has three dimensions. I'd like to plot the data such that I have a time series of a point, say, in 3 space. So far the documentation I've seen on 3d graphics (wireframes, topos, etc) don't seem to be appropriate for what I'd like to do. Any suggestions? thanks Lou Schreier __ 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] plot a list of trellis objects
Thanks for the suggestion.. Is there a way I can include arguments to the *grid.arrange* function? I tried in your example something like... gridar - function(x,ncol=2,...) grid.arrange(x,...) do.call(gridar, lattice.plots); I could not make it work when I try to control number of columns/rows and have multiple pages the way possible using print.trellis Regards, Santosh On Mon, Feb 17, 2014 at 10:38 PM, Frede Aakmann Tøgersen fr...@vestas.comwrote: How about lattice.plots - list(xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b)) do.call(grid.arrange, lattice.plots) There is most likely a loop hidden somewhere in the do.call function ;-) Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh Sent: 18. februar 2014 01:41 To: r-help Subject: [R] plot a list of trellis objects Dear Rxperts Is there a way to control the display order (or simplistically control panel layout) of a list of trellis objects without using a for loop (or whatever)? I just realize that gridExtra has that feature.. (grid.arrange)... But, converting each of those elements of the list of trellis objects into an argument to grid.arrange seems to negate the simplicity.. In addition, if I were to use grid.arrange on a list of trellis objects, is there a way to pass the list elements as arguments to grid.arrange? If you have other suggestions, please do.. Regards, Santosh [[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] plot a list of trellis objects
I forgot to add.. printltrellis seems to take in only one trellis object at a time.. so.. I think I would need to use a loop for varying the column/row indices, etc... Is that the only way (other than grid.arrange)? Is column/row/page control possible through grid.arrange..? On Tue, Feb 18, 2014 at 11:59 AM, Santosh santosh2...@gmail.com wrote: Thanks for the suggestion.. Is there a way I can include arguments to the *grid.arrange* function? I tried in your example something like... gridar - function(x,ncol=2,...) grid.arrange(x,...) do.call(gridar, lattice.plots); I could not make it work when I try to control number of columns/rows and have multiple pages the way possible using print.trellis Regards, Santosh On Mon, Feb 17, 2014 at 10:38 PM, Frede Aakmann Tøgersen fr...@vestas.com wrote: How about lattice.plots - list(xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b)) do.call(grid.arrange, lattice.plots) There is most likely a loop hidden somewhere in the do.call function ;-) Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Santosh Sent: 18. februar 2014 01:41 To: r-help Subject: [R] plot a list of trellis objects Dear Rxperts Is there a way to control the display order (or simplistically control panel layout) of a list of trellis objects without using a for loop (or whatever)? I just realize that gridExtra has that feature.. (grid.arrange)... But, converting each of those elements of the list of trellis objects into an argument to grid.arrange seems to negate the simplicity.. In addition, if I were to use grid.arrange on a list of trellis objects, is there a way to pass the list elements as arguments to grid.arrange? If you have other suggestions, please do.. Regards, Santosh [[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] Updating a data frame based on if condition
Hi, I don't know whether the 'mydata object was updated or not before you run the table. mydata - within(mydata,FNAME_SUSPECT - FNAME_TOKEN_COUNT 10|FNAME_LENGTH45|regexpr(9,FNAME_PATTERN)==0) table(mydata$FNAME_SUSPECT) # #FALSE # 50 Now, your second condition (reply to David). indx - with(mydata,FNAME_TOKEN_COUNT 3| FNAME_LENGTH55|regexpr(9,FNAME_PATTERN)==0) indx1 - ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, ifelse(mydata$FNAME_LENGTH 55, TRUE, ifelse(regexpr(9, mydata$FNAME_PATTERN) == 0, TRUE, FALSE ) ) ) identical(indx,indx1) #[1] TRUE A.K. On Tuesday, February 18, 2014 12:57 PM, Jeff Johnson mrjeffto...@gmail.com wrote: Hmm, I don't think as constructed the within clause is yielding the desired results. The test case you suggested works. However, if I try another test case: within(mydata,FNAME_SUSPECT - FNAME_TOKEN_COUNT 10|FNAME_LENGTH45|regexpr(9,FNAME_PATTERN)==0) which I read as if any row has more than 10 tokens, longer than 45 characters OR does not have a number (9), it should assign the result (FALSE in this case) to FNAME_SUSPECT. table(mydata$FNAME_SUSPECT) TRUE 50 On Tue, Feb 18, 2014 at 9:38 AM, arun smartpink...@yahoo.com wrote: I think it doesn't even need ifelse() within(mydata,FNAME_SUSPECT - FNAME_TOKEN_COUNT 3|FNAME_LENGTH35|regexpr(9,FNAME_PATTERN)0) A.K. On , arun smartpink...@yahoo.com wrote: Hi, Try ?ifelse() A.K. On Tuesday, February 18, 2014 12:26 PM, Jeff Johnson mrjeffto...@gmail.com wrote: I have a subset of data that I have identified as suspect (for example, the first name has excessive spaces, is longer than 35 characters or has a number). What I want to do is update the FNAME_SUSPECT field in mydata to TRUE if any of those conditions are met. Here's my data: dput(mydata) structure(list(PERSON_FIRST_NAME = c(1298530, JULIA, TAYLOR, CS AND JEFF, 88, 4465891170098562, 1124211, LEWIS MARY KAY, KARL R O S, 5466181820076010, JULI0 C, WAYNE T., 1124211, 1124211, ROBERT B VIONA D, DENNIS and MARY SUE, BRIAN JOANNE, 1124211, RONALD and GAIL, Mike and Mary Lou, 31763006, 7, 11460735, Paul and Mary Beth, JIMMY and RUTH MARIE, 1124211, WAYNE LU ANN, SCOTT ANNA MARIE, 1124211, 1124211, 952714, DAVID, RHONDA and NATALIE, VIRGINIA S, 707069, 4397836190001917, MARIA DE LA LUZ, MARIA DE LA LUZ, G S COMPUTERIZED GRADING, 1124211, 1124211, 1124211, 1124211, MARIA DE LA LUZ, ED AND JANICE KISHI, 1124211, Garrett A. and Jenny E., 1124211, 1124211, Hiram T. and A. Judith, MA DE LA LUZ, STEVE, Bev, and Caleb, MR AND MRS EVER), FNAME_SUSPECT = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), FNAME_LENGTH = c(7L, 26L, 2L, 16L, 7L, 16L, 10L, 16L, 7L, 10L, 7L, 7L, 18L, 19L, 14L, 7L, 16L, 17L, 8L, 1L, 8L, 18L, 20L, 7L, 14L, 18L, 7L, 7L, 6L, 25L, 12L, 6L, 16L, 15L, 15L, 26L, 7L, 7L, 7L, 7L, 15L, 19L, 7L, 23L, 7L, 7L, 22L, 12L, 21L, 15L), FNAME_PATTERN = c(999, A,_AA,_AA_AAA_, 99, , 999, A___AAA, _A_A_A, , 9_A, A___A., 999, 999, AA_A__A_A, AA_AAA__AAA, A___AA, 999, AA_AAA__, _AAA__AAA, , 9, , _AAA__, A_AAA__A, 999, A__AA_AAA, A___A, 999, 999, 99, A,_AA_AAA_AAA, ___A, 99, , A_AA_AA_AAA, A_AA_AA_AAA, A__A__AAA, 999, 999, 999, 999, A_AA_AA_AAA, AA_AAA_AA_A, 999, AAA_A._AAA_A_A., 999, 999, A_A._AAA_A._AA, AA_AA_AA_AAA, A,_AAA,_AAA_A, AA_AAA_AAA_ ), FNAME_TOKEN_COUNT = c(1L, 5L, 1L, 1L, 1L, 4L, 4L, 1L, 2L, 4L, 1L, 1L, 5L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 1L, 4L, 4L, 5L, 1L, 1L, 1L, 1L, 4L, 4L, 1L, 5L, 1L, 1L, 5L, 4L, 4L, 4L)), .Names = c(PERSON_FIRST_NAME, FNAME_SUSPECT, FNAME_LENGTH, FNAME_PATTERN, FNAME_TOKEN_COUNT ), row.names = c(6717L, 11035L, 11626L, 14965L, 17874L, 24341L, 25582L, 25834L, 26851L, 30134L, 36385L, 45244L, 46947L, 61449L, 67564L, 71465L, 73782L, 75278L, 78977L, 79037L, 80577L, 81644L, 84427L, 86286L, 89963L, 91208L, 94054L, 99518L, 114658L, 128305L, 129082L, 137492L, 137573L, 138556L, 139489L, 148757L, 153956L, 155546L, 160533L, 162386L, 162681L, 165220L, 168063L, 173003L, 175322L, 179935L, 180991L, 181215L, 183787L, 184573L), class = data.frame) Note I defaulted all of the FNAME_SUSPECT to FALSE. I plan to change that later. I've
Re: [R] plot a list of trellis objects
Yes of course (why didn't you yourself read the man/help pages? That's the way I learned R). If you see the help to grid.arrange: arrangeGrob package:gridExtra R Documentation arrangeGrob Description: arrange ggplot2, lattice, and grobs on a page Usage: arrangeGrob(..., as.table = FALSE, clip = TRUE, main = NULL, sub = NULL, left = NULL, legend = NULL) Arguments: ...: plots of class ggplot2, trellis, or grobs, and valid arguments to grid.layout For the ellipses: The arguments to to grid.layout is your savior: (here is the help to grid.layout): grid.layoutpackage:gridR Documentation Create a Grid Layout Description: This function returns a Grid layout, which describes a subdivision of a rectangular region. Usage: grid.layout(nrow = 1, ncol = 1, widths = unit(rep(1, ncol), null), heights = unit(rep(1, nrow), null), default.units = null, respect = FALSE, just=centre) Arguments: nrow: An integer describing the number of rows in the layout. And then for the call to do.call do.call package:base R Documentation Execute a Function Call Description: 'do.call' constructs and executes a function call from a name or a function and a list of arguments to be passed to it. Usage: do.call(what, args, quote = FALSE, envir = parent.frame()) Arguments: what: either a function or a non-empty character string naming the function to be called. args: a _list_ of arguments to the function call. The 'names' attribute of 'args' gives the argument names. The args argument saves you: This suggests me to do: lattice.plots - list(xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b)) do.call(grid.arrange, list(lattice.plots, ncol = 1)) That does NOT WORK, damn someone, even though the help to do.call says that args should be a _list_ (damn you isn't that a LIST) However this works: do.call(grid.arrange,c(lattice.plots, ncol = 1)) WHAT IS THE DIFFERNCE BETWEEN c() and list() Have a nice day to all of you. And thank you all developers for R. I cannot live without it. Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.commailto:fr...@vestas.com http://www.vestas.comhttp://www.vestas.com/ Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/noticehttp://www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. From: Santosh [mailto:santosh2...@gmail.com] Sent: 18. februar 2014 20:59 To: Frede Aakmann Tøgersen Cc: r-help Subject: Re: [R] plot a list of trellis objects Thanks for the suggestion.. Is there a way I can include arguments to the grid.arrange function? I tried in your example something like... gridar - function(x,ncol=2,...) grid.arrange(x,...) do.call(gridar, lattice.plots); I could not make it work when I try to control number of columns/rows and have multiple pages the way possible using print.trellis Regards, Santosh On Mon, Feb 17, 2014 at 10:38 PM, Frede Aakmann Tøgersen fr...@vestas.commailto:fr...@vestas.com wrote: How about lattice.plots - list(xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b)) do.call(grid.arrange, lattice.plots) There is most likely a loop hidden somewhere in the do.call function ;-) Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.commailto:fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/noticehttp://www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.orgmailto:r-help-boun...@r-project.org] On Behalf Of Santosh Sent: 18. februar 2014 01:41 To: r-help Subject: [R] plot a list of trellis objects Dear Rxperts Is there a way to control the display order (or simplistically control panel layout) of a list of trellis objects without using a for loop (or whatever)? I just realize
Re: [R] Updating a data frame based on if condition
What you have can work, but it will be hard to maintain and debug. Easier to follow is cond1 - mydata$FNAME_TOKEN_COUNT 3 cond2 - mydata$FNAME_LENGTH 55 cond3 - regexpr(9, mydata$FNAME_PATTERN) == 0 mydata$FNAME_SUSPECT - apply(cbind(cond1, cond2, cond3), 1, any) mydata$FNAME_SUSPECT [1] FALSE TRUE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE FALSE FALSE [13] TRUE TRUE TRUE FALSE TRUE TRUE FALSE FALSE FALSE TRUE TRUE FALSE [25] TRUE TRUE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE [37] FALSE FALSE FALSE FALSE TRUE TRUE FALSE TRUE FALSE FALSE TRUE TRUE [49] TRUE TRUE And adding or changing a condition is pretty simple David C From: Jeff Johnson [mailto:mrjeffto...@gmail.com] Sent: Tuesday, February 18, 2014 12:54 PM To: dcarl...@tamu.edu Cc: R help Subject: Re: [R] Updating a data frame based on if condition Ahh, I was specifying the second argument FALSE incorrectly. Works now as: mydata$FNAME_SUSPECT - ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, ifelse(mydata$FNAME_LENGTH 55, TRUE, ifelse(regexpr(9, mydata$FNAME_PATTERN) == 0, TRUE, FALSE ) ) ) On Tue, Feb 18, 2014 at 10:21 AM, Jeff Johnson mrjeffto...@gmail.com wrote: This is my first time with ifelse, but I've tried: mydata$FNAME_SUSPECT - ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, FALSE, ifelse(mydata$FNAME_LENGTH 35, TRUE, FALSE, ifelse(regexpr(9, mydata$FNAME_PATTERN) 0, TRUE, FALSE ) ) ) Error in ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, FALSE, ifelse(mydata$FNAME_LENGTH : unused argument (ifelse(mydata$FNAME_LENGTH 35, TRUE, FALSE, ifelse(regexpr(9, mydata$FNAME_PATTERN) 0, TRUE, FALSE))) I have the R for Dummies book which covers it a bit, but I just ordered the R Cookbook. On Tue, Feb 18, 2014 at 10:16 AM, David Carlson dcarl...@tamu.edu wrote: Not always true, but it is in this case: ?ifelse David C -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Johnson Sent: Tuesday, February 18, 2014 11:24 AM To: R help Subject: [R] Updating a data frame based on if condition I have a subset of data that I have identified as suspect (for example, the first name has excessive spaces, is longer than 35 characters or has a number). What I want to do is update the FNAME_SUSPECT field in mydata to TRUE if any of those conditions are met. Here's my data: dput(mydata) structure(list(PERSON_FIRST_NAME = c(1298530, JULIA, TAYLOR, CS AND JEFF, 88, 4465891170098562, 1124211, LEWIS MARY KAY, KARL R O S, 5466181820076010, JULI0 C, WAYNE T., 1124211, 1124211, ROBERT B VIONA D, DENNIS and MARY SUE, BRIAN JOANNE, 1124211, RONALD and GAIL, Mike and Mary Lou, 31763006, 7, 11460735, Paul and Mary Beth, JIMMY and RUTH MARIE, 1124211, WAYNE LU ANN, SCOTT ANNA MARIE, 1124211, 1124211, 952714, DAVID, RHONDA and NATALIE, VIRGINIA S, 707069, 4397836190001917, MARIA DE LA LUZ, MARIA DE LA LUZ, G S COMPUTERIZED GRADING, 1124211, 1124211, 1124211, 1124211, MARIA DE LA LUZ, ED AND JANICE KISHI, 1124211, Garrett A. and Jenny E., 1124211, 1124211, Hiram T. and A. Judith, MA DE LA LUZ, STEVE, Bev, and Caleb, MR AND MRS EVER), FNAME_SUSPECT = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), FNAME_LENGTH = c(7L, 26L, 2L, 16L, 7L, 16L, 10L, 16L, 7L, 10L, 7L, 7L, 18L, 19L, 14L, 7L, 16L, 17L, 8L, 1L, 8L, 18L, 20L, 7L, 14L, 18L, 7L, 7L, 6L, 25L, 12L, 6L, 16L, 15L, 15L, 26L, 7L, 7L, 7L, 7L, 15L, 19L, 7L, 23L, 7L, 7L, 22L, 12L, 21L, 15L), FNAME_PATTERN = c(999, A,_AA,_AA_AAA_, 99, , 999, A___AAA, _A_A_A, , 9_A, A___A., 999, 999, AA_A__A_A, AA_AAA__AAA, A___AA, 999, AA_AAA__, _AAA__AAA, , 9, , _AAA__, A_AAA__A, 999, A__AA_AAA, A___A, 999, 999, 99, A,_AA_AAA_AAA, ___A, 99, , A_AA_AA_AAA, A_AA_AA_AAA, A__A__AAA, 999, 999, 999, 999, A_AA_AA_AAA, AA_AAA_AA_A, 999, AAA_A._AAA_A_A., 999, 999, A_A._AAA_A._AA, AA_AA_AA_AAA, A,_AAA,_AAA_A, AA_AAA_AAA_ ), FNAME_TOKEN_COUNT = c(1L, 5L, 1L, 1L, 1L, 4L, 4L, 1L, 2L, 4L, 1L, 1L, 5L, 4L, 4L, 1L, 4L, 4L, 1L, 1L, 1L, 4L, 4L, 1L, 4L, 4L,
Re: [R] plot a list of trellis objects
Well to be in control: Please read carefully the help to grid.layout Create a Grid Layout Description: This function returns a Grid layout, which describes a subdivision of a rectangular region. Usage: grid.layout(nrow = 1, ncol = 1, widths = unit(rep(1, ncol), null), heights = unit(rep(1, nrow), null), default.units = null, respect = FALSE, just=centre) to control your settings more carefully. Please read the help to lattice::print C_05_print.trellis package:lattice R Documentation Plot and Summarize Trellis Objects Description: The 'print' and 'plot' methods produce a graph from a 'trellis' object. The 'print' method is necessary for automatic plotting. 'plot' method is essentially an alias, provided for convenience. The 'summary' method gives a textual summary of the object. 'dim' and 'dimnames' describe the cross-tabulation induced by conditioning. 'panel.error' is the default handler used when an error occurs while executing the panel function. Usage: ## S3 method for class 'trellis' plot(x, position, split, more = FALSE, newpage = TRUE, packet.panel = packet.panel.default, draw.in = NULL, panel.height = lattice.getOption(layout.heights)$panel, panel.width = lattice.getOption(layout.widths)$panel, save.object = lattice.getOption(save.object), panel.error = lattice.getOption(panel.error), prefix, ...) To be in superior control. Happy plotting. Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh Sent: 18. februar 2014 21:12 Cc: r-help Subject: Re: [R] plot a list of trellis objects I forgot to add.. printltrellis seems to take in only one trellis object at a time.. so.. I think I would need to use a loop for varying the column/row indices, etc... Is that the only way (other than grid.arrange)? Is column/row/page control possible through grid.arrange..? On Tue, Feb 18, 2014 at 11:59 AM, Santosh santosh2...@gmail.com wrote: Thanks for the suggestion.. Is there a way I can include arguments to the *grid.arrange* function? I tried in your example something like... gridar - function(x,ncol=2,...) grid.arrange(x,...) do.call(gridar, lattice.plots); I could not make it work when I try to control number of columns/rows and have multiple pages the way possible using print.trellis Regards, Santosh On Mon, Feb 17, 2014 at 10:38 PM, Frede Aakmann Tøgersen fr...@vestas.com wrote: How about lattice.plots - list(xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b)) do.call(grid.arrange, lattice.plots) There is most likely a loop hidden somewhere in the do.call function ;-) Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- project.org ] On Behalf Of Santosh Sent: 18. februar 2014 01:41 To: r-help Subject: [R] plot a list of trellis objects Dear Rxperts Is there a way to control the display order (or simplistically control panel layout) of a list of trellis objects without using a for loop (or whatever)? I just realize that gridExtra has that feature.. (grid.arrange)... But, converting each of those elements of the list of trellis objects into an argument to grid.arrange seems to negate the simplicity.. In addition, if I were to use grid.arrange on a list of trellis objects, is there a way to pass the list elements as arguments to grid.arrange? If you have other suggestions, please do.. Regards, Santosh [[alternative HTML version deleted]] __ R-help@r-project.org
Re: [R] plot a list of trellis objects
Sorry this should of course be for all on R-help. Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: Frede Aakmann Tøgersen Sent: 18. februar 2014 21:55 To: 'arun' Subject: RE: [R] plot a list of trellis objects So are you saying that the coder of do.call do not know the difference between _list_ and _c_?? Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: 18. februar 2014 21:50 To: Frede Aakmann Tøgersen Subject: Re: [R] plot a list of trellis objects If you look at the structure: str(list(lattice.plots,ncol=1)) #List of 2 $ :List of 4 ..$ :List of 45 -- str(c(lattice.plots,ncol=1)) #List of 5 # $ :List of 45 A.K. On Tuesday, February 18, 2014 3:34 PM, Frede Aakmann Tøgersen fr...@vestas.com wrote: Yes of course (why didn't you yourself read the man/help pages? That's the way I learned R). If you see the help to grid.arrange: arrangeGrob package:gridExtra R Documentation arrangeGrob Description: arrange ggplot2, lattice, and grobs on a page Usage: arrangeGrob(..., as.table = FALSE, clip = TRUE, main = NULL, sub = NULL, left = NULL, legend = NULL) Arguments: ...: plots of class ggplot2, trellis, or grobs, and valid arguments to grid.layout For the ellipses: The arguments to to grid.layout is your savior: (here is the help to grid.layout): grid.layout package:grid R Documentation Create a Grid Layout Description: This function returns a Grid layout, which describes a subdivision of a rectangular region. Usage: grid.layout(nrow = 1, ncol = 1, widths = unit(rep(1, ncol), null), heights = unit(rep(1, nrow), null), default.units = null, respect = FALSE, just=centre) Arguments: nrow: An integer describing the number of rows in the layout. And then for the call to do.call do.call package:base R Documentation Execute a Function Call Description: 'do.call' constructs and executes a function call from a name or a function and a list of arguments to be passed to it. Usage: do.call(what, args, quote = FALSE, envir = parent.frame()) Arguments: what: either a function or a non-empty character string naming the function to be called. args: a _list_ of arguments to the function call. The 'names' attribute of 'args' gives the argument names. The args argument saves you: This suggests me to do: lattice.plots - list(xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b)) do.call(grid.arrange, list(lattice.plots, ncol = 1)) That does NOT WORK, damn someone, even though the help to do.call says that args should be a _list_ (damn you isn't that a LIST) However this works: do.call(grid.arrange,c(lattice.plots, ncol = 1)) WHAT IS THE DIFFERNCE BETWEEN c() and list() Have a nice day to all of you. And thank you all developers for R. I cannot live without it. Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.commailto:fr...@vestas.com http://www.vestas.comhttp://www.vestas.com/ Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/noticehttp://www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. From: Santosh [mailto:santosh2...@gmail.com] Sent: 18. februar 2014 20:59 To:
Re: [R] 3D graphics
Perhaps this in package: scatterplot3d package:scatterplot3d R Documentation 3D Scatter Plot Description: Plots a three dimensional (3D) point cloud. Usage: scatterplot3d(x, y=NULL, z=NULL, color=par(col), pch=par(pch), main=NULL, sub=NULL, xlim=NULL, ylim=NULL, zlim=NULL, xlab=NULL, ylab=NULL, zlab=NULL, scale.y=1, angle=40, axis=TRUE, tick.marks=TRUE, label.tick.marks=TRUE, x.ticklabs=NULL, y.ticklabs=NULL, z.ticklabs=NULL, y.margin.add=0, grid=TRUE, box=TRUE, lab=par(lab), lab.z=mean(lab[1:2]), type=p, highlight.3d=FALSE, mar=c(5,3,4,3)+0.1, bg=par(bg), col.axis=par(col.axis), col.grid=grey, col.lab=par(col.lab), cex.symbols=par(cex), cex.axis=0.8 * par(cex.axis), cex.lab=par(cex.lab), font.axis=par(font.axis), font.lab=par(font.lab), lty.axis=par(lty), lty.grid=par(lty), lty.hide=NULL, lty.hplot=par(lty), log=, ...) Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Louis Schreierlc Sent: 18. februar 2014 19:20 To: r-help@r-project.org Subject: [R] 3D graphics Hi I have a large data set that consists of a time series of data captured from a device that has three dimensions. I'd like to plot the data such that I have a time series of a point, say, in 3 space. So far the documentation I've seen on 3d graphics (wireframes, topos, etc) don't seem to be appropriate for what I'd like to do. Any suggestions? thanks Lou Schreier __ 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.
Re: [R] plot a list of trellis objects
Thanks for suggestions! I am just getting familiarized with these grid and extra businesses! Now I understand a bit better to find and scour through man/help pages :) santosh On Tue, Feb 18, 2014 at 1:00 PM, Frede Aakmann Tøgersen fr...@vestas.comwrote: Sorry this should of course be for all on R-help. Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: Frede Aakmann Tøgersen Sent: 18. februar 2014 21:55 To: 'arun' Subject: RE: [R] plot a list of trellis objects So are you saying that the coder of do.call do not know the difference between _list_ and _c_?? Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: 18. februar 2014 21:50 To: Frede Aakmann Tøgersen Subject: Re: [R] plot a list of trellis objects If you look at the structure: str(list(lattice.plots,ncol=1)) #List of 2 $ :List of 4 ..$ :List of 45 -- str(c(lattice.plots,ncol=1)) #List of 5 # $ :List of 45 A.K. On Tuesday, February 18, 2014 3:34 PM, Frede Aakmann Tøgersen fr...@vestas.com wrote: Yes of course (why didn't you yourself read the man/help pages? That's the way I learned R). If you see the help to grid.arrange: arrangeGrob package:gridExtra R Documentation arrangeGrob Description: arrange ggplot2, lattice, and grobs on a page Usage: arrangeGrob(..., as.table = FALSE, clip = TRUE, main = NULL, sub = NULL, left = NULL, legend = NULL) Arguments: ...: plots of class ggplot2, trellis, or grobs, and valid arguments to grid.layout For the ellipses: The arguments to to grid.layout is your savior: (here is the help to grid.layout): grid.layoutpackage:gridR Documentation Create a Grid Layout Description: This function returns a Grid layout, which describes a subdivision of a rectangular region. Usage: grid.layout(nrow = 1, ncol = 1, widths = unit(rep(1, ncol), null), heights = unit(rep(1, nrow), null), default.units = null, respect = FALSE, just=centre) Arguments: nrow: An integer describing the number of rows in the layout. And then for the call to do.call do.call package:base R Documentation Execute a Function Call Description: 'do.call' constructs and executes a function call from a name or a function and a list of arguments to be passed to it. Usage: do.call(what, args, quote = FALSE, envir = parent.frame()) Arguments: what: either a function or a non-empty character string naming the function to be called. args: a _list_ of arguments to the function call. The 'names' attribute of 'args' gives the argument names. The args argument saves you: This suggests me to do: lattice.plots - list(xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b)) do.call(grid.arrange, list(lattice.plots, ncol = 1)) That does NOT WORK, damn someone, even though the help to do.call says that args should be a _list_ (damn you isn't that a LIST) However this works: do.call(grid.arrange,c(lattice.plots, ncol = 1)) WHAT IS THE DIFFERNCE BETWEEN c() and list() Have a nice day to all of you. And thank you all developers for R. I cannot live without it. Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050
Re: [R] 3D graphics
For an exploratory look at the data, the package rgl (that uses OpenGL) is great. On 19 February 2014 05:20, Louis Schreierlc schreie...@gmail.com wrote: Hi I have a large data set that consists of a time series of data captured from a device that has three dimensions. I'd like to plot the data such that I have a time series of a point, say, in 3 space. So far the documentation I've seen on 3d graphics (wireframes, topos, etc) don't seem to be appropriate for what I'd like to do. Any suggestions? thanks Lou Schreier __ 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. -- Yvan Richard DRAGONFLY Science Physical address: Level 5, 158 Victoria St, Te Aro, Wellington Postal address: PO Box 27535, Wellington 6141 New Zealand Ph: 04.385.9285 web page __ 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] Updating a data frame based on if condition
Thanks David, that's a great improvement. On Tue, Feb 18, 2014 at 12:36 PM, David Carlson dcarl...@tamu.edu wrote: What you have can work, but it will be hard to maintain and debug. Easier to follow is cond1 - mydata$FNAME_TOKEN_COUNT 3 cond2 - mydata$FNAME_LENGTH 55 cond3 - regexpr(9, mydata$FNAME_PATTERN) == 0 mydata$FNAME_SUSPECT - apply(cbind(cond1, cond2, cond3), 1, any) mydata$FNAME_SUSPECT [1] FALSE TRUE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE FALSE FALSE [13] TRUE TRUE TRUE FALSE TRUE TRUE FALSE FALSE FALSE TRUE TRUE FALSE [25] TRUE TRUE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE [37] FALSE FALSE FALSE FALSE TRUE TRUE FALSE TRUE FALSE FALSE TRUE TRUE [49] TRUE TRUE And adding or changing a condition is pretty simple David C From: Jeff Johnson [mailto:mrjeffto...@gmail.com] Sent: Tuesday, February 18, 2014 12:54 PM To: dcarl...@tamu.edu Cc: R help Subject: Re: [R] Updating a data frame based on if condition Ahh, I was specifying the second argument FALSE incorrectly. Works now as: mydata$FNAME_SUSPECT - ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, ifelse(mydata$FNAME_LENGTH 55, TRUE, ifelse(regexpr(9, mydata$FNAME_PATTERN) == 0, TRUE, FALSE ) ) ) On Tue, Feb 18, 2014 at 10:21 AM, Jeff Johnson mrjeffto...@gmail.com wrote: This is my first time with ifelse, but I've tried: mydata$FNAME_SUSPECT - ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, FALSE, ifelse(mydata$FNAME_LENGTH 35, TRUE, FALSE, ifelse(regexpr(9, mydata$FNAME_PATTERN) 0, TRUE, FALSE ) ) ) Error in ifelse(mydata$FNAME_TOKEN_COUNT 3, TRUE, FALSE, ifelse(mydata$FNAME_LENGTH : unused argument (ifelse(mydata$FNAME_LENGTH 35, TRUE, FALSE, ifelse(regexpr(9, mydata$FNAME_PATTERN) 0, TRUE, FALSE))) I have the R for Dummies book which covers it a bit, but I just ordered the R Cookbook. On Tue, Feb 18, 2014 at 10:16 AM, David Carlson dcarl...@tamu.edu wrote: Not always true, but it is in this case: ?ifelse David C -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Jeff Johnson Sent: Tuesday, February 18, 2014 11:24 AM To: R help Subject: [R] Updating a data frame based on if condition I have a subset of data that I have identified as suspect (for example, the first name has excessive spaces, is longer than 35 characters or has a number). What I want to do is update the FNAME_SUSPECT field in mydata to TRUE if any of those conditions are met. Here's my data: dput(mydata) structure(list(PERSON_FIRST_NAME = c(1298530, JULIA, TAYLOR, CS AND JEFF, 88, 4465891170098562, 1124211, LEWIS MARY KAY, KARL R O S, 5466181820076010, JULI0 C, WAYNE T., 1124211, 1124211, ROBERT B VIONA D, DENNIS and MARY SUE, BRIAN JOANNE, 1124211, RONALD and GAIL, Mike and Mary Lou, 31763006, 7, 11460735, Paul and Mary Beth, JIMMY and RUTH MARIE, 1124211, WAYNE LU ANN, SCOTT ANNA MARIE, 1124211, 1124211, 952714, DAVID, RHONDA and NATALIE, VIRGINIA S, 707069, 4397836190001917, MARIA DE LA LUZ, MARIA DE LA LUZ, G S COMPUTERIZED GRADING, 1124211, 1124211, 1124211, 1124211, MARIA DE LA LUZ, ED AND JANICE KISHI, 1124211, Garrett A. and Jenny E., 1124211, 1124211, Hiram T. and A. Judith, MA DE LA LUZ, STEVE, Bev, and Caleb, MR AND MRS EVER), FNAME_SUSPECT = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), FNAME_LENGTH = c(7L, 26L, 2L, 16L, 7L, 16L, 10L, 16L, 7L, 10L, 7L, 7L, 18L, 19L, 14L, 7L, 16L, 17L, 8L, 1L, 8L, 18L, 20L, 7L, 14L, 18L, 7L, 7L, 6L, 25L, 12L, 6L, 16L, 15L, 15L, 26L, 7L, 7L, 7L, 7L, 15L, 19L, 7L, 23L, 7L, 7L, 22L, 12L, 21L, 15L), FNAME_PATTERN = c(999, A,_AA,_AA_AAA_, 99, , 999, A___AAA, _A_A_A, , 9_A, A___A., 999, 999, AA_A__A_A, AA_AAA__AAA, A___AA, 999, AA_AAA__, _AAA__AAA, , 9, , _AAA__, A_AAA__A, 999, A__AA_AAA, A___A, 999, 999, 99, A,_AA_AAA_AAA, ___A, 99, , A_AA_AA_AAA, A_AA_AA_AAA, A__A__AAA, 999, 999, 999, 999, A_AA_AA_AAA, AA_AAA_AA_A, 999, AAA_A._AAA_A_A., 999, 999, A_A._AAA_A._AA,
Re: [R] plot a list of trellis objects
Hopefully good suggestions from our side. Well, is it not feasible to point people to man pages that thinks _list_ is the same as _c_ , so tomorrow I will file a bug (what is that called for instructions) report (if I can remember). Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh Sent: 18. februar 2014 22:23 To: r-help Subject: Re: [R] plot a list of trellis objects Thanks for suggestions! I am just getting familiarized with these grid and extra businesses! Now I understand a bit better to find and scour through man/help pages :) santosh On Tue, Feb 18, 2014 at 1:00 PM, Frede Aakmann Tøgersen fr...@vestas.comwrote: Sorry this should of course be for all on R-help. Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: Frede Aakmann Tøgersen Sent: 18. februar 2014 21:55 To: 'arun' Subject: RE: [R] plot a list of trellis objects So are you saying that the coder of do.call do not know the difference between _list_ and _c_?? Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: arun [mailto:smartpink...@yahoo.com] Sent: 18. februar 2014 21:50 To: Frede Aakmann Tøgersen Subject: Re: [R] plot a list of trellis objects If you look at the structure: str(list(lattice.plots,ncol=1)) #List of 2 $ :List of 4 ..$ :List of 45 -- str(c(lattice.plots,ncol=1)) #List of 5 # $ :List of 45 A.K. On Tuesday, February 18, 2014 3:34 PM, Frede Aakmann Tøgersen fr...@vestas.com wrote: Yes of course (why didn't you yourself read the man/help pages? That's the way I learned R). If you see the help to grid.arrange: arrangeGrob package:gridExtra R Documentation arrangeGrob Description: arrange ggplot2, lattice, and grobs on a page Usage: arrangeGrob(..., as.table = FALSE, clip = TRUE, main = NULL, sub = NULL, left = NULL, legend = NULL) Arguments: ...: plots of class ggplot2, trellis, or grobs, and valid arguments to grid.layout For the ellipses: The arguments to to grid.layout is your savior: (here is the help to grid.layout): grid.layoutpackage:gridR Documentation Create a Grid Layout Description: This function returns a Grid layout, which describes a subdivision of a rectangular region. Usage: grid.layout(nrow = 1, ncol = 1, widths = unit(rep(1, ncol), null), heights = unit(rep(1, nrow), null), default.units = null, respect = FALSE, just=centre) Arguments: nrow: An integer describing the number of rows in the layout. And then for the call to do.call do.call package:base R Documentation Execute a Function Call Description: 'do.call' constructs and executes a function call from a name or a function and a list of arguments to be passed to it. Usage: do.call(what, args, quote = FALSE, envir = parent.frame()) Arguments: what: either a function or a non-empty character string naming the function to be called. args: a _list_ of arguments to the function call. The 'names' attribute of 'args' gives the
[R] calculate probability of union of independent events
Dear all, I am looking for a way to calculate the probability of the union of k independent events in R. Is there a function that takes a k-dimensional probability vector as input and returns p(A_1 U A_2 U...U A_k)? Thanks, Florian ___ Dr. Florian Meinfelder Otto-Friedrich-Universität Bamberg Lehrstuhl für Statistik und Ökonometrie Feldkirchenstraße 21, D-96052 Bamberg Telefon: +49 (0)951/863-2741 Fax: +49 (0)951/863-2532 email: florian.meinfel...@uni-bamberg.demailto:florian.meinfel...@uni-bamberg.de www: http://www.uni-bamberg.de/stat-oek/ [[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] 3D graphics
Frede thanks for the help. I'll give it a try best Lou Schreier On Feb 18, 2014, at 1:22 PM, Frede Aakmann Tøgersen fr...@vestas.com wrote: Perhaps this in package: scatterplot3d package:scatterplot3d R Documentation 3D Scatter Plot Description: Plots a three dimensional (3D) point cloud. Usage: scatterplot3d(x, y=NULL, z=NULL, color=par(col), pch=par(pch), main=NULL, sub=NULL, xlim=NULL, ylim=NULL, zlim=NULL, xlab=NULL, ylab=NULL, zlab=NULL, scale.y=1, angle=40, axis=TRUE, tick.marks=TRUE, label.tick.marks=TRUE, x.ticklabs=NULL, y.ticklabs=NULL, z.ticklabs=NULL, y.margin.add=0, grid=TRUE, box=TRUE, lab=par(lab), lab.z=mean(lab[1:2]), type=p, highlight.3d=FALSE, mar=c(5,3,4,3)+0.1, bg=par(bg), col.axis=par(col.axis), col.grid=grey, col.lab=par(col.lab), cex.symbols=par(cex), cex.axis=0.8 * par(cex.axis), cex.lab=par(cex.lab), font.axis=par(font.axis), font.lab=par(font.lab), lty.axis=par(lty), lty.grid=par(lty), lty.hide=NULL, lty.hplot=par(lty), log=, ...) Yours sincerely / Med venlig hilsen Frede Aakmann Tøgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Louis Schreierlc Sent: 18. februar 2014 19:20 To: r-help@r-project.org Subject: [R] 3D graphics Hi I have a large data set that consists of a time series of data captured from a device that has three dimensions. I'd like to plot the data such that I have a time series of a point, say, in 3 space. So far the documentation I've seen on 3d graphics (wireframes, topos, etc) don't seem to be appropriate for what I'd like to do. Any suggestions? thanks Lou Schreier __ 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.
Re: [R] plot a list of trellis objects
Hi for print.trellis you could make a function and supply the plots as arguments ?list and then print them There are various ways of doing it and you could have a matrix as an argument with the proportions and access them Regards Duncan -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Santosh Sent: Wednesday, 19 February 2014 06:12 Cc: r-help Subject: Re: [R] plot a list of trellis objects I forgot to add.. printltrellis seems to take in only one trellis object at a time.. so.. I think I would need to use a loop for varying the column/row indices, etc... Is that the only way (other than grid.arrange)? Is column/row/page control possible through grid.arrange..? On Tue, Feb 18, 2014 at 11:59 AM, Santosh santosh2...@gmail.com wrote: Thanks for the suggestion.. Is there a way I can include arguments to the *grid.arrange* function? I tried in your example something like... gridar - function(x,ncol=2,...) grid.arrange(x,...) do.call(gridar, lattice.plots); I could not make it work when I try to control number of columns/rows and have multiple pages the way possible using print.trellis Regards, Santosh On Mon, Feb 17, 2014 at 10:38 PM, Frede Aakmann Txgersen fr...@vestas.com wrote: How about lattice.plots - list(xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b), xyplot(rnorm(10) ~ 1:10, type = b)) do.call(grid.arrange, lattice.plots) There is most likely a loop hidden somewhere in the do.call function ;-) Yours sincerely / Med venlig hilsen Frede Aakmann Txgersen Specialist, M.Sc., Ph.D. Plant Performance Modeling Technology Service Solutions T +45 9730 5135 M +45 2547 6050 fr...@vestas.com http://www.vestas.com Company reg. name: Vestas Wind Systems A/S This e-mail is subject to our e-mail disclaimer statement. Please refer to www.vestas.com/legal/notice If you have received this e-mail in error please contact the sender. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Santosh Sent: 18. februar 2014 01:41 To: r-help Subject: [R] plot a list of trellis objects Dear Rxperts Is there a way to control the display order (or simplistically control panel layout) of a list of trellis objects without using a for loop (or whatever)? I just realize that gridExtra has that feature.. (grid.arrange)... But, converting each of those elements of the list of trellis objects into an argument to grid.arrange seems to negate the simplicity.. In addition, if I were to use grid.arrange on a list of trellis objects, is there a way to pass the list elements as arguments to grid.arrange? If you have other suggestions, please do.. Regards, Santosh [[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] calculate probability of union of independent events
On 18-Feb-2014 22:08:38 Meinfelder, Florian wrote: Dear all, I am looking for a way to calculate the probability of the union of k independent events in R. Is there a function that takes a k-dimensional probability vector as input and returns p(A_1 U A_2 U...U A_k)? Thanks, Florian I don't know (off-hand); but it is very easy to write one's own! Since P(A1 U A2 U ... U Ak ) = 1 - P(not(A1 U A2 U ... u Ak)) = 1 - P((not A1) (not A2) ... (not Ak)) = 1 - P(not A1)*P(not A2)* ... *P(not Ak) [by independence] = 1 - (1-p1)*(1-p2)* ... *(1-pk) where pj is P(Aj). Hence punion - function(p){1 - prod(1-p)} should do it! Ted. - E-Mail: (Ted Harding) ted.hard...@wlandres.net Date: 18-Feb-2014 Time: 23:51:31 This message was sent by XFMail __ 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] Aggregation
Hi, May be this helps: DataA - read.table(text=ID,Var1,Var2 1,A,100 1,B,50 2,A,200 2,B,100 2,B,50,sep=,,header=TRUE,stringsAsFactors=FALSE) dcast(DataA,ID~Var1,value.var=Var2) ## I guess this is what you mentioned #Aggregation function missing: defaulting to length # ID A B #1 1 1 1 #2 2 1 2 DataB - ddply(DataA,.(ID,Var1),transform,Var1ID=paste0(ID,seq_along(Var1))) dcast(DataB,ID+Var1ID~Var1,value.var=Var2)[,-2] # ID A B #1 1 100 50 #2 2 200 100 #3 2 NA 50 A.K. On Tuesday, February 18, 2014 6:08 PM, farnoosh sheikhi farnoosh...@yahoo.com wrote: For some reason, I get frequency not the values although I have var2 as numeric and no missing values. Why is that? Regards, Farnoosh Sheikhi On Thursday, February 13, 2014 1:29 PM, arun smartpink...@yahoo.com wrote: Sorry, the library should be library(reshape2) On Thursday, February 13, 2014 4:27 PM, arun smartpink...@yahoo.com wrote: HI Farnoosh, You can use ?dcast() library(plyr) dcast(DataA,ID~Var1,value.var=Var2) # ID A B #1 1 100 50 #2 2 200 100 A.K. On Thursday, February 13, 2014 2:59 PM, farnoosh sheikhi farnoosh...@yahoo.com wrote: Hi Arun, I hope all is well. I need to aggregate a data like below: DataA ID Var1 Var2 1 A100 1B50 2 A200 2B100 The transformed data should be like below: ID AB 1100 50 2200100 Thanks a lot. Regards, Farnoosh Sheikhi __ 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] Writing Unicode Text into Text File from R (in Windows)
On Tue, Feb 4, 2014 at 4:18 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote: On 14-02-04 5:49 AM, Majid Einian wrote: Dear R Helpers, See the Code: a - intToUtf8(1777) show(a) zz - file(description=test.txt,open=w,encoding=UTF-8) cat(a, file = zz) close(zz) in a Unicode aware environment (such as RGui console or RStudio Console) you will see this as output: [1] ۱ but the character is not written correctly in the file test.txt (which is encoded in UTF-8 without BOM) : U+06F1 The problem seems to be this: R changes text to the locale of system (for me this is Arabic Windows (Codepage 1256) that does not have a relevant code for U+06F1, then changes it back to UTF-8 and writes it into file. What do I miss here? How can I write a Unicode string into a text file correctly? There are a lot of places in R where it converts strings to the local encoding, perhaps too many. On the other hand, maybe Windows should be offering UTF-8 locales by now. I would like to see that happen too! I have no such problem on Linux. I haven't tested in your locale, but I believe writeLines() to a connection declared to be in a UTF-8 encoding will maintain the encoding. writeLines() does change the encoding to system encoding and then back to unicode just like cat(). You can declare a file to be in encoding UTF-8-BOM if you want to ignore a BOM on input; I forget whether it will write one on output. If it doesn't, you can always write one explicitly. I have no problem with BOM being there or not. I was hoping to make some progress on this before R 3.1.0 so that more cases of writing strings to UTF-8 files would work, but time is running out. I hope we see this happen soon :) Majid Einian Duncan Murdoch Majid Einian, Economics Researcher, Monetary and Banking Research Institute, Central Bank of Islamic Republic of Iran, Tehran, IRAN and PhD Candidate in Economics, Graduate School of Management and Economics, Sharif University of Technology, Tehran, IRAN [[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. __ 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.