Re: [R] detecting any element in a vector of strings, appearing anywhere in any of several character variables in a dataframe

2015-07-10 Thread Christopher W Ryan
Thanks everyone. John's original solution worked great. And with 27,000 records, 65 alarm.words, and 6 columns to search, it takes only about 15 seconds. That is certainly adequate for my needs. But I will try out the other strategies too. And thanks also for lot's of new R things to

Re: [R] sum some columns for each row

2015-07-10 Thread Jim Lemon
Hi Dawn, Your data are a bit messed up, but try the following: colSums(dat[,grep(ABC,names(dat),fixed=TRUE)],na.rm=TRUE) colSums(dat[,grep(XYZ,names(dat),fixed=TRUE)],na.rm=TRUE) I'm assuming that you want to discard the NA values. Jim On Fri, Jul 10, 2015 at 6:52 AM, Rui Barradas

Re: [R] color2D.matplot with anchored color scale

2015-07-10 Thread Jim Lemon
Hi Phong, This is a common problem with using color to represent numeric values. What you want is a reference scale. Whenever you call color2D.matplot, use the cellcolors argument to specify the colors of each cell. You can directly call color.scale in this argument, using the xrange argument of

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, David Winsemius wrote: #Generally one needs to complete a pdf() call with: dev.off() # And an empty file is the symptom os such a failure. David, I did leave that off the example file, but it make no difference. The attached is the compiled example.pdf Rich

Re: [R] sum some columns for each row

2015-07-10 Thread Dawn
Thank you all and sorry for the data messing. It has worked! Best, Dawn On Fri, Jul 10, 2015 at 4:15 AM, Jim Lemon drjimle...@gmail.com wrote: Hi Dawn, Your data are a bit messed up, but try the following: colSums(dat[,grep(ABC,names(dat),fixed=TRUE)],na.rm=TRUE)

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Yihui Xie
Your LyX example has two problems: 1) We don't have your .RData; 2) You didn't library(reshape) and library(lattice). Hence it is not a self-contained reproducible example. After fixing these two issues, I don't see why lattice graphics can be problematic with knitr. There is no need to print()

Re: [R] Time series exercise (was: (no subject)).

2015-07-10 Thread Rolf Turner
On 10/07/15 21:17, Lia LEE wrote: Hello forum members, I am taking this R course which I have to admit that it is beyond my capability. I am asked to analyze the following data(file attached) according to the question provided below: 1. The file [data_13-9.txt] contains a data of length 225,

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread David Winsemius
On Jul 10, 2015, at 2:57 PM, Rich Shepard wrote: On Fri, 10 Jul 2015, Hadley Wickham wrote: Have you tried explicitly print()ing the lattice graphics in your knitr doc? Hadley, Only now. Had not thought of trying this before. pdf('carlin-1-descriptive.pdf') print(xyplot(value ~

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
I'd recommend starting with a simpler .Rmd or .Rnw file, rather than using it with lyx. The basic .Rmd file below works for me without any further adjustments: # Lattice test ```{r} library(lattice) xyplot(mpg ~ wt, data = mtcars) ``` Hadley On Fri, Jul 10, 2015 at 3:39 PM, Rich Shepard

Re: [R] (no subject)

2015-07-10 Thread Jeff Newmiller
I was under the impression that different instructional environments have different standards for ethical conduct, so we list members cannot in general know whether we would be condoning/assisting in cheating. However, if you are taking a class, then the instructor/institution should be

Re: [R] Embed fonts in an R graph

2015-07-10 Thread David Winsemius
On Jul 10, 2015, at 8:45 AM, David Winsemius wrote: On Jul 10, 2015, at 7:40 AM, Edwin Sun wrote: Hello all, I cannot embed a common font type into an R graph. I did it successfully in December 2014 with the previous R version. However, with R 3.2.1 in July 2015, the following sample

[R] Embed fonts in an R graph

2015-07-10 Thread Edwin Sun
Hello all, I cannot embed a common font type into an R graph. I did it successfully in December 2014 with the previous R version. However, with R 3.2.1 in July 2015, the following sample codes do not work anymore. pdf(file = c:/testA.pdf, family = serif) plot(x = 1:10, y = rnorm(10)) dev.off()

Re: [R] Embed fonts in an R graph

2015-07-10 Thread David Winsemius
On Jul 10, 2015, at 7:40 AM, Edwin Sun wrote: Hello all, I cannot embed a common font type into an R graph. I did it successfully in December 2014 with the previous R version. However, with R 3.2.1 in July 2015, the following sample codes do not work anymore. pdf(file = c:/testA.pdf,

Re: [R] Corrected: approaches tpmatrix multiplication of each layer of 3-d array with different matrix

2015-07-10 Thread Jeff Newmiller
Strictly speaking, the answer is yes because you can unroll the loop, but that probably is not what you really want or need to do. Your example seems about right, but it is not clear how you plan to make 44 conform with 5500.

Re: [R] Corrected: approaches to matrix multiplication of each layer of 3-d array with different matrix

2015-07-10 Thread Ranjan Maitra
What does it mean to unroll the loop? Thanks! Ranjan On Fri, 10 Jul 2015 07:07:15 -0700 Jeff Newmiller jdnew...@dcn.davis.ca.us wrote: Strictly speaking, the answer is yes because you can unroll the loop, but that probably is not what you really want or need to do. Your example seems

[R] approaches tpmatrix multiplication of each layer of 3-d array with different matrix

2015-07-10 Thread Ranjan Maitra
Dear friends, I have two 3-d arrays of appropriate dimensions. I want to postmultiply the 2-D matrix layers of the first with the 2-D matrix layers of the second. Can I do this easily in R avoiding loops? As an example: --- begin R code --- AA - array(1:60, dim = c(5500,44,33)) BB -

[R] Corrected: approaches tpmatrix multiplication of each layer of 3-d array with different matrix

2015-07-10 Thread Ranjan Maitra
Hi, Sorry to post again, but there is a careless error in my first R code snippet: --- begin R code --- AA - array(1:60, dim = c(5500,44,33)) BB - array(1:60, dim = c(44,44,33)) arraymatprod - function(A, B) { EE - array(dim=dim(A)); for (i in 1:dim(A)[3]) EE[,,i] - A[,,i] %*%

[R] cointegration and VECM, urca package and Eviews

2015-07-10 Thread mrrox
Hello, I estimated a VECM in Eviews and R using urca package's ca.jo(), cajorl() and vec2var() functions. Specifications are 'no trend' in Eviews and 'none' in R (no theory, just testing, feel free to make changes). Results are different, ecm and cointegrating vectors are completely different.

[R] [R-pkgs] interplot: a new package for visualizing interactive effects

2015-07-10 Thread Hu, Yue
Dear colleagues, We just published a package, interplot, in CRAN. It can be used to plots the conditional coefficients (marginal effects) of variables included in multiplicative interaction terms for various models. The installation instruction and more details about the package are

Re: [R] clm funtion and CI

2015-07-10 Thread Luciane Maria Pilotto
I am using the commands bellow. ## load(file.choose())#dataframe:id3.rda attach(id3) dput(head(id3,10)) structure(list(regiao = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c(Norte, Nordeste, Sudeste, Sul, Centro-Oeste), class =

Re: [R] detecting any element in a vector of strings, appearing anywhere in any of several character variables in a dataframe

2015-07-10 Thread Bert Gunter
Yes. This is one of the fundamental challenges in text searching -- defining exactly what text defines a match and what doesn't. So, continuing your example, one might imagine that heroin and heroine might both be matches, but maybe heroines shouldn't be (e.g. if the text contains movie reviews).

[R] (no subject)

2015-07-10 Thread Lia LEE
Hello forum members, I am taking this R course which I have to admit that it is beyond my capability. I am asked to analyze the following data(file attached) according to the question provided below: 1. The file [data_13-9.txt] contains a data of length 225, which seems to have some cycle

[R] Reading the non delimited file with no particular patterns in the data to R

2015-07-10 Thread jagadishpchary
I am beginner in R and I want to read a ASCII file to R environment. However, the ASCII file is a non delimited and the data is not continuous (have some blank spaces between the variables) so in order to read the data i have used the below syntax i.e test - read.fwf(D:/R_process/ASCII.txt, width

[R] how to embed a 3D plot created by ??rgl?? into gWidgets ggraphics device???

2015-07-10 Thread just_rookie
I created some 3D cubes by using rgl package. The next step is to embed the 3D plot(rgl device) into ggraphics device from the gWidgets package, but I have no idea how to implement it. Is there a way to implement by gWidgets or other package? Any help? Thank you in advance! My code:

Re: [R] How to assign value to a variable dynamically constructed

2015-07-10 Thread Bert Gunter
I'll let Bill respond in detail if he cares to(he is both more knowledgable and fluent at this than I), but as a nearly unbreakable rule, get() and assign() should not be used in R. Basically, they represent a macro (script)-oriented strategy for handling R's objects, whereas R is designed to use

Re: [R] Reading the non delimited file with no particular patterns in the data to R

2015-07-10 Thread Clint Bowman
Is this what your are expecting? test - read.fwf(test.dat, width = c(10, 4, 1, 4, 9, 12,26,1,1,1,1,1,1,3,8)) test V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 1 1 2015 1 4 0.766696 1 1 0 0 0 0 0 0 0 10 2 2 2015 1 4 1.458186 1 1 0 0 0 1 0 0 0

[R] predict.poly for multivariate data

2015-07-10 Thread Keith Jewell
A recent stackoverflow post http://stackoverflow.com/questions/31134985 How do you make R poly() evaluate (or “predict”) multivariate new data (orthogonal or raw)? made me look at poly and polym again. predict.poly doesn't work with multivariate data because for such data poly calls polym

Re: [R] How to assign value to a variable dynamically constructed

2015-07-10 Thread Bastien Tran
Dear all, Provided I understood correctly, shouldn't assign() do the trick? Most similar threads seem to include this approach (among others, indeed). Regards, Bastien On Wednesday, July 8, 2015 at 7:30:04 PM UTC+2, William Dunlap wrote: You can use an environment instead of a list using the

Re: [R] (no subject)

2015-07-10 Thread Bert Gunter
Sorry Lia. We don't do homework on this list. You can imagine how clogged it would be if we did. Maybe you'll get lucky and someone will answer you privately. Otherwise, seek help from your teachers, fellow students, and/or course homework forums. Cheers, Bert Bert Gunter Data is not

Re: [R] tcltk2 entry box

2015-07-10 Thread Matthew
Thank you very much, Greg, for the tkwait commands. I am just starting to try out examples on the sciviews web page to get a feel for tcltk in R and the tkwait.variable and tkwait.window seem like they could be very useful to me. I will add these in to my practice scripts and see what I can

Re: [R] how to embed a 3D plot created by “rgl” into gWidgets ggraphics device“?

2015-07-10 Thread Duncan Murdoch
On 10/07/2015 8:43 AM, just_rookie wrote: I created some 3D cubes by using rgl package. The next step is to embed the 3D plot(rgl device) into ggraphics device from the gWidgets package, but I have no idea how to implement it. Is there a way to implement by gWidgets or other package? Any

Re: [R] Corrected: approaches to matrix multiplication of each layer of 3-d array with different matrix

2015-07-10 Thread Jeff Newmiller
EE[,,1] - A[,,1] %*% B[,,1] EE[,,2] - A[,,2] %*% B[,,2] EE[,,3] - A[,,3] %*% B[,,3] etc. --- Jeff NewmillerThe . . Go Live... DCN:jdnew...@dcn.davis.ca.usBasics: ##.#.

Re: [R] How to assign value to a variable dynamically constructed

2015-07-10 Thread William Dunlap
Yes, assign() and get() can do this, but I think the [[]] syntax is simpler and makes it easier to switch between lists and environments for data organization. E.g., the translation of myData[[varName]][4] - myData[[varName]][4] * 100 where myData is an environment to the get/assign style

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, Roy Mendelssohn - NOAA Federal wrote: Don’t know for certain but might this help: It's very interesting, but does not appear to resolve the immediate need to write the R code in a knitr chunk for incorporation into the compiled LyX document. The gridGraphics package

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
Have you tried explicitly print()ing the lattice graphics in your knitr doc? Hadley On Friday, July 10, 2015, Rich Shepard rshep...@appl-ecosys.com wrote: Hadley's ggplot2 book is quite old and a new version is in the works, but not yet out. I've been using lattice graphics but the knitr

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, Hadley Wickham wrote: Have you tried explicitly print()ing the lattice graphics in your knitr doc? Hadley, Only now. Had not thought of trying this before. pdf('carlin-1-descriptive.pdf') print(xyplot(value ~ sampdate | variable, data=carlin.1.melt, rm.na = T)) No

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Jeff Newmiller
I don't actually use lattice very much, but I have no difficulty setting up a lattice plot in a knitr/rmarkdown file, and can think of no reason why you might have concluded that knitr does not support lattice. Sorry, not going to translate your non-reproducible example... please go the extra

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Roy Mendelssohn - NOAA Federal
Don’t know for certain but might this help: http://journal.r-project.org/archive/2015-1/murrell.pdf From the latest issue of R Journal. Abstract The gridGraphics package provides a function, grid.echo(), that can be used to convert a plot drawn with the graphics package to a visually

[R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
Hadley's ggplot2 book is quite old and a new version is in the works, but not yet out. I've been using lattice graphics but the knitr package doesn't support lattice, only basic plots and ggplot2. My Web searches for Trellis plots in ggplot2 equivalent to those in lattice have not been

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, Roy Mendelssohn - NOAA Federal wrote: Don’t know for certain but might this help: http://journal.r-project.org/archive/2015-1/murrell.pdf From the latest issue of R Journal. Roy, Thanks. I'll certainly read that article. Carpe weekend, Rich

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
You shouldn't be explicitly opening a device in a knitr document. I think maybe you should post a minimal document so we can figure out what's going wrong. Hadley On Friday, July 10, 2015, Rich Shepard rshep...@appl-ecosys.com wrote: On Fri, 10 Jul 2015, Hadley Wickham wrote: Have you tried

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, Hadley Wickham wrote: You shouldn't be explicitly opening a device in a knitr document. Hadley, Didn't think so. I think maybe you should post a minimal document so we can figure out what's going wrong. Agreed. Attached are the raw data (carlin.csv) and a