[R] New to R

2014-12-15 Thread Lalitha Kristipati
Hi I'm learning R language from past one month .As R is used highly for data analysis ,mining and modeling ,I want to know few real time examples in R in order to make my learning fun filled and practical .Any quick suggestions are appreciated . Regards, Lalitha Kristipati Associate

[R] keep only the first value of a numeric sequence

2014-12-15 Thread jeff6868
Hello dear R-helpers, I have a small problem in my algorithm. I have sequences of 0 and 1 values in a column of a huge data frame, and I just would like to keep the first value of each sequences of 1 values, such like in this example: data -

Re: [R] keep only the first value of a numeric sequence

2014-12-15 Thread Jorge I Velez
Dear jeff6868, Here is one way: ifelse(with(data, c(0, diff(mydata))) != 1, 0, 1) You could also take a look at ?rle HTH, Jorge.- On Mon, Dec 15, 2014 at 9:33 PM, jeff6868 geoffrey_kl...@etu.u-bourgogne.fr wrote: Hello dear R-helpers, I have a small problem in my algorithm. I have

Re: [R] Two-tailed exact binomial test with binom.test and sum(dbinom(...))

2014-12-15 Thread Andrews, Chris
If you are testing H0: p = 0.6 vs H1: p != 0.6 with a sample of size 10 and you observe X=2, then Pr(X = 2) + Pr(X = 8) is not what you want. You can argue that you want Pr(X = 2) + Pr(X = 10). Both 2 and 10 are 4 away from the null. binom.test(2, 10, 0.6, alternative=two.sided) # 0.01834

Re: [R] keep only the first value of a numeric sequence

2014-12-15 Thread Richard M. Heiberger
we can speed this up a lot system.time(for (i in 1:2000) ifelse(c(0, diff(data$mydata)) != 1, 0, 1)) user system elapsed 0.122 0.012 0.132 system.time(for (i in 1:2000) as.numeric( c(0, diff(data$mydata))==1)) user system elapsed 0.073 0.007 0.078 ifelse(c(0,

Re: [R] create matrices with constraint

2014-12-15 Thread John McKown
On Fri, Dec 12, 2014 at 11:00 AM, Kathryn Lord kathryn.lord2...@gmail.com wrote: Dear all, Suppose that I have natural numbers 1 through 28. Based on these numbers, choose 4 numbers 7 times without replacement and make a 4 by 7 matrix, for example, ​After a relaxing weekend, it came to me

Re: [R] New to R

2014-12-15 Thread Mark Sharp
I would recommend finding some tutorials on line in areas that you enjoy, read http://r-bloggers.com every day, find introductory texts in the statistical areas of interest, and study some texts on R programming. I really enjoyed The Art of R Programming: A Tour of Statistical Software Design

[R] dotplot axes labelling

2014-12-15 Thread rl
Subscribers, What is my mistake with the following example: library(lattice) testmatrix-matrix(c(1,2,3,4,3,6,12,24),nrow=4,ncol=2) testylabels-c('w1','x1','y1','z1') dotplot(testmatrix, scales=list(y=list(testylabels)), xlab=NULL) #testylabels not shown, instead 'D' 'C' 'B' 'A' Thanks in

Re: [R] create matrices with constraint

2014-12-15 Thread David L Carlson
Actually there are not so many matrices as you suggest. comb - combn(28, 4) dim(comb) [1] 4 20475 sum(comb[1,]==1) [1] 2925 comb[, 1] [1] 1 2 3 4 There are 20,475 combinations, but you cannot choose any four to make a 4x7 matrix since each value can be used only once. The combn()

Re: [R] create matrices with constraint

2014-12-15 Thread John McKown
On Mon, Dec 15, 2014 at 10:06 AM, David L Carlson dcarl...@tamu.edu wrote: Actually there are not so many matrices as you suggest. comb - combn(28, 4) dim(comb) [1] 4 20475 sum(comb[1,]==1) [1] 2925 comb[, 1] [1] 1 2 3 4 There are 20,475 combinations, but you cannot choose any

Re: [R] dotplot axes labelling

2014-12-15 Thread David L Carlson
You are very close. The argument scales(list(y=list())) supports multiple arguments for the y axis so you need to tell lattice how to use testylabels: dotplot(testmatrix, scales=list(y=list(labels=testylabels), xlab=NULL)) - David L Carlson Department of

Re: [R] keep only the first value of a numeric sequence

2014-12-15 Thread jeff6868
Great! Both ways works well for my whole data! Thanks guys! -- View this message in context: http://r.789695.n4.nabble.com/keep-only-the-first-value-of-a-numeric-sequence-tp4700774p4700783.html Sent from the R help mailing list archive at Nabble.com.

[R] circlize package: different font size for axis labels

2014-12-15 Thread Fix Ace
Hi, Dr. Gu, I am trying to highlight some axis labels, for example, 72hL3 as bold, using the following command: circos.initialize(factors=female.f, xlim=c(1.8,6.2)) circos.trackPlotRegion(factors=female.f,

Re: [R] Comparing Latin characters with and without accents?

2014-12-15 Thread Prof Brian Ripley
On 15/12/2014 05:33, Spencer Graves wrote: Hello, All: What do people do to strip accents from latin characters, returning vanilla ASCII? I think the devil is the detail here: what is Latin? Latin-1 has characters for which this is unclear, let alone Latin-2 or Latin-7. What I

[R] How do I interpret linear mixed model contrast estimates from multcomp::glht()?

2014-12-15 Thread scoyoc
​​ How do the rows in the summary (e.g. 1 == 0) correspond to the model? The answer is buried *contrast::contrast()*, but I can't figure it out. Consider this modified example I stole from here https://stat.ethz.ch/pipermail/r-sig-mixed-models/2009q4/003061.html... options(contrasts = c(factor =

[R] No visible bindings and assignement to the global environment

2014-12-15 Thread Fabien Fivaz
Hi everyone, I'm sure this question has been asked before, but I'm unable to find a definitive answer (if there is any). I've been trying to put back to CRAN a package (grasp-r). The package uses many functions that share a lot of common variables. For instance, a model call is created by the

Re: [R] Why would something work in R but not Rscript?

2014-12-15 Thread Jeff Hansen
Thanks Henrik! Adding the line library(methods) to the list of required libraries did indeed solve the problem. My next comment will show my naivety when it comes to R dependency management, but I noticed that including `library(rJava)` in place of methods also solves the problem. This confuses

Re: [R] No visible bindings and assignement to the global environment

2014-12-15 Thread Duncan Murdoch
On 15/12/2014 12:28 PM, Fabien Fivaz wrote: Hi everyone, I'm sure this question has been asked before, but I'm unable to find a definitive answer (if there is any). I've been trying to put back to CRAN a package (grasp-r). The package uses many functions that share a lot of common variables.

Re: [R] Comparing Latin characters with and without accents?

2014-12-15 Thread Ista Zahn
On Mon, Dec 15, 2014 at 12:33 AM, Spencer Graves spencer.gra...@prodsyse.com wrote: Hello, All: What do people do to strip accents from latin characters, returning vanilla ASCII? I find the stringi package works well for this sort of thing, e.g., library(stringi) x - c(!, \, #,

Re: [R] circlize package: different font size for axis labels

2014-12-15 Thread David Winsemius
On Dec 15, 2014, at 8:41 AM, Fix Ace wrote: Hi, Dr. Gu, I am trying to highlight some axis labels, for example, 72hL3 as bold, using the following command: circos.initialize(factors=female.f, xlim=c(1.8,6.2)) circos.trackPlotRegion(factors=female.f,

Re: [R] No visible bindings and assignement to the global environment

2014-12-15 Thread Fabien Fivaz
Thanks for the quick answer. Your second guess was right, I only need one environment. I learned one thing: I can create a .R file in my package that is NOT a function. Something that contains just dummyEnv - new-env(parent=emptyenv()) And it works! Thanks again Le 15. 12. 14 19:47, Duncan

Re: [R] circlize package: different font size for axis labels

2014-12-15 Thread Gu, Zuguang
Hi, In current version, `labels.font` in `circos.axis` can only be a scalar ( a vector with length one). But you can first add axes with no labels and then add labels by `circos.text`: female.f = c(a, b) circos.initialize(factors=female.f, xlim=c(1.8,6.2))

Re: [R] Assistance converting to R a python function that extracts from an XML file

2014-12-15 Thread MacQueen, Don
Duncan, Thank you very much. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 12/13/14, 1:06 PM, Duncan Temple Lang dtemplel...@ucdavis.edu wrote: Hi Don library(XML) readxmldate = function(xmlfile) { doc =

Re: [R] Assistance converting to R a python function that extracts from an XML file

2014-12-15 Thread MacQueen, Don
Thanks! -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 12/13/14, 1:22 PM, Boris Steipe boris.ste...@utoronto.ca wrote: Or ... txt - docCreaDate20120627/CreaDateCreaTime07322600/CreaTime/doc if (!require(XML)) {

Re: [R] Why would something work in R but not Rscript?

2014-12-15 Thread Henrik Bengtsson
On Mon, Dec 15, 2014 at 9:44 AM, Jeff Hansen dsche...@gmail.com wrote: Thanks Henrik! Adding the line library(methods) to the list of required libraries did indeed solve the problem. My next comment will show my naivety when it comes to R dependency management, but I noticed that including

Re: [R] New to R

2014-12-15 Thread billy am
Hi , As the OP was asking for examples , I would also recommend Modeling Techniques in Predictive Analytics by Thomas Miller. That book is full of examples + R scripts. Its on Amazon. Regards Billy -- |