[R] Error using betamix function
Hi all, I'm trying to use the betamix function (betareg package) to create a beta mixture model but get this error that I don't understand: "Error in lm.wfit(x, linkfun(y), weights, offset = offset[[1L]]) : NA/NaN/Inf in 'y' Error in lm.wfit(x, linkfun(y), weights, offset = offset[[1L]]) : NA/NaN/Inf in 'y' Error in lm.wfit(x, linkfun(y), weights, offset = offset[[1L]]) : NA/NaN/Inf in 'y' Error in flexmix::stepFlexmix(fullformula, data = mf, k = k, nrep = nstart, : no convergence to a suitable mixture" The code I wrote was: "beta_mix_model <- betamix(formula = def_relat ~ data_roads, k = 2)" I'm making the hypothesis that def_relat (ie the level of deforestation) is a function of data_roads (ie distance to roads). When a pixel is far from a road, its probability of deforestation is very close to zero with very low uncertainty. Closer to roads however, deforestation is possible (with very high uncertainty of the intensity of deforestation) but occurences of deforestation also occur. This is why I'm considering to groups of observations, with a beta distribution of probability for modelling a probability of deforestation between 0 and 1. I don't understand the error message, because none of the data I'm using includes NA or Inf. Does anyone has an idea of the reason why I get this error, or can tell me if I'm using the function betamix the wrong way? Thanks, Camille [[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] To build a new Df from 2 Df
Thank you David Now, the problem is to list all the combinations which verify the condition III (ie every Rapporteur has to have more or less the same number of demandeur) Have you any idea ? Michel Le 14/10/2014 13:18, david.kaeth...@dlr.de a écrit : Hello, here's a draft of a solution. I hope it's not overly complicated. # find all possible combinations combi <- expand.grid(Dem$Nom, Rap$Nom); names(combi) <- c("Dem", "Rap") # we need the corresponding departments and units combi$DemDep <- apply(combi, 1, function(x) Dem$Departement[x[1] == Dem$Nom]) combi$DemUni <- apply(combi, 1, function(x) Dem$Unite[x[1] == Dem$Nom]) combi$RapDep <- apply(combi, 1, function(x) Rap$Departement[x[2] == Rap$Nom]) combi$RapUni <- apply(combi, 1, function(x) Rap$Unite[x[2] == Rap$Nom]) # we exclude the combinations that we don't want dep <- combi[combi$DemDep != combi$RapDep, c("Dem", "Rap")] dep$id <- as.numeric(dep$Rap) uni <- combi[combi$DemUni != combi$RapUni, c("Dem", "Rap")] uni$id <- as.numeric(uni$Rap) # preliminary result resDep <- reshape(dep, timevar = "id", idvar = "Dem", direction = "wide" ) resUni <- reshape(uni, timevar = "id", idvar = "Dem", direction = "wide" ) In resDep and resUni you find the results for Rapporteur1 and Rapporteur2. NAs indicate where conditions did not match. For Rap1/Rap2 you can now choose any column from resDep and resUni that is not NA for that specific Demandeur. I wasn't exactly sure about your third condition, so I'll leave that to you. But with the complete possible matches, you have a more general solution. Btw, you can construct data.frames just like this: Dem <- data.frame( Nom = c("John", "Jim", "Julie", "Charles", "Michel", "Emma", "Sandra", "Elodie", "Thierry", "Albert", "Jean", "Francois", "Pierre", "Cyril", "Damien", "Jean-Michel", "Vincent", "Daniel", "Yvan", "Catherine"), Departement = c("D", "A", "A", "C", "D", "B", "D", "B", "C", "D", "B", "B", "B", "A", "C", "D", "B", "A", "D", "D"), Unite = c("Unite8", "Unite4", "Unite4", "Unite7", "Unite9", "Unite1", "Unite6", "Unite5", "Unite7", "Unite3", "Unite2", "Unite6", "Unite8", "Unite8", "Unite3", "Unite8", "Unite9", "Unite7", "Unite9", "Unite5") ) -dk -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Arnaud Michel Gesendet: Dienstag, 14. Oktober 2014 10:46 An: r-help@r-project.org Betreff: [R] To build a new Df from 2 Df Hello I have 2 df Dem and Rap. I would want to build all the df (dfnew) by associating these two df (Dem and Rap) in the following way : For each value of Dem$Nom (dfnew$Demandeur), I associate 2 different values of Rap$Nom (dfnew$Rapporteur1 and dfnew$Rapporteur2) in such a way * for each dfnew$Demandeur, dfnew$Rapporteur1 does not have the same value for Departement as Dem$Departement * for each dfnew$Demandeur, dfnew$Rapporteur2 does not have the same value for Unite as Dem$Unite * the value of table(dfnew$Rapporteur1) and the value of table(dfnew$Rapporteur2) must be balanced and not too different (Accepted differences : 1) table(dfnew$Rapporteur1) Rapporteur01 Rapporteur02 Rapporteur03 Rapporteur04 Rapporteur05 4 4 4 4 4 Thanks for your help Michel Dem <- structure(list(Nom = c("John", "Jim", "Julie", "Charles", "Michel", "Emma", "Sandra", "Elodie", "Thierry", "Albert", "Jean", "Francois", "Pierre", "Cyril", "Damien", "Jean-Michel", "Vincent", "Daniel", "Yvan", "Catherine"), Departement = c("D", "A", "A", "C", "D", "B", "D", "B", "C", "D", "B", "B", "B", "A", "C", "D", "B", "A", "D", "D"), Unite = c("Unite8", "Unite4", "Unite4", "Unite7", "Unite9", "Unite1", "Unite6", "Unite5", "Unite7", "Unite3", "Unite2", "Unite6", "Unite8", "Unite8", "Unite3", "Unite8", "Unite9", "Unite7", "Unite9", "Unite5")), .Names = c("Nom", "Departement", "Unite" ), row.names = c(NA, -20L), class = "data.frame") Rap <- structure(list(Nom = c("Rapporteur01", "Rapporteur02", "Rapporteur03", "Rapporteur04", "Rapporteur05"), Departement = c("C", "D", "C", "C", "D"), Unite = c("Unite10", "Unite6", "Unite5", "Unite5", "Unite4")), .Names = c("Nom", "Departement", "Unite"), row.names = c(NA, -5L), class = "data.frame") dfnew <- structure(list(Demandeur = structure(c(13L, 12L, 14L, 3L, 15L, 8L, 17L, 7L, 18L, 1L, 10L, 9L, 16L, 4L, 5L, 11L, 19L, 6L, 20L, 2L), .Label = c("Albert", "Catherine", "Charles", "Cyril", "Damien", "Daniel", "Elodie", "Emma", "Francois", "Jean", "Jean-Michel", "Jim", "John", "Julie", "Michel", "Pierre", "Sandra", "Thierry", "Vincent", "Yvan"), class = "factor"), Rapporteur1 = structure(c(3L, 1L, 3L, 5L, 1L, 5L, 1L, 2L, 5L, 4L, 2L, 4L, 2L, 3L, 5L, 4L, 4L, 2L, 3L, 1L), .Label = c("Rapporteur01", "Rapporteur02", "Rapporteur03", "Rapporteur04", "Rapporteur05"), class = "factor"), Rapporteur2 = structure(c(1L, 3L, 4L, 4L, 2L, 4L
[R] r-help@r-project.org
[I sent this email to Rich and to the list after some private communication with Rich. However it got held up for being too big, presumably because of the pdf attachment. So I am re-sending it to the list *without* the attachment.] I resorted to actually trying the expedient of installing "compositions" and running your code. It works just fine. I attach the "winters-pdf.pdf" file that was produced. I thus have no idea what's causing the problem that you are experiencing. It is indeed *not* an FAQ 7.22 problem. Something weird is going on in your system. cheers, Rolf -- Rolf Turner Technical Editor ANZJS __ 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] Ternary Plots Do Not Display Ellipses in PDF
On Wed, 15 Oct 2014, Rolf Turner wrote: In all probability this is FAQ 7.22. I.e. use: print(ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE,col='red', lwd=2)) Rolf, Thank you. Didn't occur to me to look in the FAQ for this issue. P. S. See also fortune(123). OK. Regards, Rich __ 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] Ternary Plots Do Not Display Ellipses in PDF
In all probability this is FAQ 7.22. I.e. use: print(ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE,col='red', lwd=2)) cheers, Rolf Turner P. S. See also fortune(123). R. T. On 15/10/14 11:00, Rich Shepard wrote: A rather strange situation here and I've not found the source of the problem. The point is to print a ternary plot matrix of compositional data with ellipses enclosing 95% of the variance in each plot. The ellipses display on the monitor, dev = x11cairo, but not when sent directly to a file, dev = pdf. Here's winters.acomp: structure(c(0.0667, 0.0612244897959184, 0.0434782608695652, 0.043956043956044, 0.05, 0.0161290322580645, 0.6, 0.571428571428571, 0.623188405797101, 0.593406593406593, 0.433, 0.629032258064516, 0.0667, 0.0612244897959184, 0.101449275362319, 0.0659340659340659, 0.0667, 0.032258064516129, 0.244, 0.26530612244898, 0.217391304347826, 0.263736263736264, 0.367, 0.290322580645161, 0.0222, 0.0408163265306122, 0.0144927536231884, 0.032967032967033, 0.0833, 0.032258064516129), .Dim = c(6L, 5L), .Dimnames = list( NULL, c("filter", "gather", "graze", "predate", "shred")), class = "acomp") And this is the command sequence: library(compositions) plot(winters.acomp, main="Winters Creek", cex=0.5) r <- sqrt(qchisq(p=0.95, df=4)) mn <- mean(winters.acomp) vr <- var(winters.acomp) plot(winters.acomp, main="Winters Creek", cex=0.5) ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE, col='red', lwd=2) # monitor plot window is manually closed. pdf("winters-pdf.pdf") plot(winters.acomp, main="Winters Creek", cex=0.5) ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE, col='red', lwd=2) dev.off() What am I not seeing here that causes the different outputs? -- Rolf Turner Technical Editor ANZJS __ 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] Ternary Plots Do Not Display Ellipses in PDF
A rather strange situation here and I've not found the source of the problem. The point is to print a ternary plot matrix of compositional data with ellipses enclosing 95% of the variance in each plot. The ellipses display on the monitor, dev = x11cairo, but not when sent directly to a file, dev = pdf. Here's winters.acomp: structure(c(0.0667, 0.0612244897959184, 0.0434782608695652, 0.043956043956044, 0.05, 0.0161290322580645, 0.6, 0.571428571428571, 0.623188405797101, 0.593406593406593, 0.433, 0.629032258064516, 0.0667, 0.0612244897959184, 0.101449275362319, 0.0659340659340659, 0.0667, 0.032258064516129, 0.244, 0.26530612244898, 0.217391304347826, 0.263736263736264, 0.367, 0.290322580645161, 0.0222, 0.0408163265306122, 0.0144927536231884, 0.032967032967033, 0.0833, 0.032258064516129), .Dim = c(6L, 5L), .Dimnames = list( NULL, c("filter", "gather", "graze", "predate", "shred")), class = "acomp") And this is the command sequence: library(compositions) plot(winters.acomp, main="Winters Creek", cex=0.5) r <- sqrt(qchisq(p=0.95, df=4)) mn <- mean(winters.acomp) vr <- var(winters.acomp) plot(winters.acomp, main="Winters Creek", cex=0.5) ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE, col='red', lwd=2) # monitor plot window is manually closed. pdf("winters-pdf.pdf") plot(winters.acomp, main="Winters Creek", cex=0.5) ellipses(mean=mn, var=vr, r=r, steps=72, thinRatio=NULL, aspanel=FALSE, col='red', lwd=2) dev.off() What am I not seeing here that causes the different outputs? Rich __ 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] grep won't work finding one column
On 15/10/14 04:09, Kate Ignatius wrote: In the sense - it does not work. it works when there are 50 samples in the file, but it does not work when there is one. The usual headings are: sample1.at sample1.dp sample1.fg sample2.at sample2.dp sample2.fg and so on to a max of sample50.at sample50.dp sample50.fg using this greps out all the .at columns perfectly: df[,grep(".at",colnames(df))] When I come across a file when there is one sample: sample1.at sample1.dp sample1.fg Using this: df[,grep(".at",colnames(df))] returns nothing. Oh - AT/at was just an example... thats not my problem... You are being (deliberately?) obtuse. It's *all* your problem. You have to be precise when working with computers and when providing examples. Don't build examples with confusing red herrings. Your assertion that "df[,grep(".at",colnames(df))] returns nothing" is simple ***INCORRECT***. It works just fine. See the (tidy, completely reproducible) example in the attached file "kate.txt". Note that, with a single ".at" column in your data frame, what is returned is ***NOT*** a data frame but rather a vector. If you want a (one-column) data frame you need to use "drop=FALSE" in your subscripting call. You need to study up on R and learn how it works (read the Introduction to R) and stop going off half-cocked. cheers, Rolf Turner P.S. It is a ***bad*** idea to use "df" as the name of a data frame. The string "df" is the name of a *function* in base R (it is the probability density function for the F distribution). Although R is clever enough to distinguish functions from data objects in *most* circumstances, at the very least confusion could arise. R. T. -- Rolf Turner Technical Editor ANZJS # # Check it out. # # Data frame with one ".at" column. d1 <- as.data.frame(matrix(1,ncol=3,nrow=10)) n1 <- c("sample1.at","sample1.dp","sample1.g") names(d1) <- n1 # Data frame with many ".at" columns. d2 <- as.data.frame(matrix(1,ncol=50,nrow=10)) set.seed(42) n2 <- paste("sample",1:50,sample(c(".at",".dp",".fg"),50,TRUE),sep="") names(d2) <- n2 # Extract the ".at" columns. print(d1[,grep(".at",colnames(d1))]) print(d2[,grep(".at",colnames(d2))]) __ 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] apply function to multiple list arguments
Hello, Have you tried mapply(f, list_df, list_par, MoreArgs = list(z = fix), SIMPLIFY = FALSE) ? Hope this helps, Rui Barradas Em 14-10-2014 19:42, Carlos Nasher escreveu: Hi R helpers, I'm struggling how to apply a function to multiple lists. My function uses a dataframe, a list of parameters and a fixed value as arguments. Now I want to apply that function to several dataframes contained in list, with several lists of parameters (also contained in a list) and the fixed value. Here's an example: # fix <- 2 # fixed value x <- c(1,2,3) y <- c(4,5,6) df_1 <- data.frame(x,y) # first dataframe df_2 <- 2*df_1 # second dataframe list_df <- list(df_1,df_2) # list containing dataframes par_1 <- list(a=5,b=10) # first list of parameters par_2 <- list(a=6,b=11) # second list of parameters list_par <- list(par_1,par_2) # list of lists of parameters f <- function(data,params,z){ res <- (data$x*params$a+data$y*params$b)*z return(res) } res_1 <- f(data = df_1, params = par_1, z = fix) # result of applying function to first dataframe and first list of parameters res_2 <- f(data = df_2, params = par_2, z = fix) # result of applying function to second dataframe and second list of parameters # I got the list of dataframes and parameters from a former use of lapply. I was hoping to get the desired results (res_1, res_2) again in a list. I tried mapply, but I don't get it running. Can anybody help? Thanks and best regards, Carlos __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with functions - printing a variables name
Hello, Maybe something like data<-c(1,5,10) func1<-function(x) { nm <- deparse(substitute(x)) y<-x^2 z<-x^3 out<-data.frame(nm,y,z) return(out) } #function func1(data[1]) Hope this helps, Rui Barradas Em 14-10-2014 19:12, Evan Kransdorf escreveu: Hello Everyone, I was wondering if someone could help me implement a function in R. I want to pass a vector x to my function, peform some math, then output the data. However, I want the output for x to be the *name of the vector I am *using as input. For example, data<-c(1,5,10) func1<-function(x) { y<-x^2 z<-x^3 out<-cbind(x,y,z) return(out) } #function Desired output: data, 1, 1 data, 25, 125 data, 100, 1000 Thanks very much for your help, Evan [[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.
[R] apply function to multiple list arguments
Hi R helpers, I'm struggling how to apply a function to multiple lists. My function uses a dataframe, a list of parameters and a fixed value as arguments. Now I want to apply that function to several dataframes contained in list, with several lists of parameters (also contained in a list) and the fixed value. Here's an example: # fix <- 2 # fixed value x <- c(1,2,3) y <- c(4,5,6) df_1 <- data.frame(x,y) # first dataframe df_2 <- 2*df_1 # second dataframe list_df <- list(df_1,df_2) # list containing dataframes par_1 <- list(a=5,b=10) # first list of parameters par_2 <- list(a=6,b=11) # second list of parameters list_par <- list(par_1,par_2) # list of lists of parameters f <- function(data,params,z){ res <- (data$x*params$a+data$y*params$b)*z return(res) } res_1 <- f(data = df_1, params = par_1, z = fix) # result of applying function to first dataframe and first list of parameters res_2 <- f(data = df_2, params = par_2, z = fix) # result of applying function to second dataframe and second list of parameters # I got the list of dataframes and parameters from a former use of lapply. I was hoping to get the desired results (res_1, res_2) again in a list. I tried mapply, but I don't get it running. Can anybody help? Thanks and best regards, Carlos -- - Carlos Nasher Buchenstr. 12 22299 Hamburg tel:+49 (0)40 67952962 mobil:+49 (0)175 9386725 mail: carlos.nas...@gmail.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with functions - printing a variables name
Hello Everyone, I was wondering if someone could help me implement a function in R. I want to pass a vector x to my function, peform some math, then output the data. However, I want the output for x to be the *name of the vector I am *using as input. For example, data<-c(1,5,10) > func1<-function(x) { y<-x^2 z<-x^3 out<-cbind(x,y,z) return(out) } #function Desired output: data, 1, 1 data, 25, 125 data, 100, 1000 Thanks very much for your help, Evan [[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] package installation failure virtualisation environment
Prevent graphic menues with: options(menu.graphics = FALSE) or and define repositories: options(repos = c(CRAN = "http://cran.r-project.org";)) On 14 October 2014 17:00, wrote: > Subscribers, > > A version of R is installed in a virtual machine, which has complete > internet access via the host. > > The following error occurs when a package is selected: > > install.packages([packagename], dependencies=TRUE) > --- Please select a CRAN mirror for use in this session --- > Killed > > The error also occurs with: > > install.packages() > > The process is killed as shown previously (but not the R session), after > selection of a package in the Tcl/tk dialogue window. > > The error occurs both as root and normal user. > > Any suggestions please to solve? > > R.version >_ > platform i686-pc-linux-gnu > arch i686 > os linux-gnu > system i686, linux-gnu > status > major 3 > minor 1.1 > year 2014 > month 07 > day10 > svn rev66115 > language R > version.string R version 3.1.1 (2014-07-10) > nickname Sock it to Me > > __ > 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] grep won't work finding one column
In the sense - it does not work. it works when there are 50 samples in the file, but it does not work when there is one. The usual headings are: sample1.at sample1.dp sample1.fg sample2.at sample2.dp sample2.fg and so on to a max of sample50.at sample50.dp sample50.fg using this greps out all the .at columns perfectly: df[,grep(".at",colnames(df))] When I come across a file when there is one sample: sample1.at sample1.dp sample1.fg Using this: df[,grep(".at",colnames(df))] returns nothing. Oh - AT/at was just an example... thats not my problem... On Tue, Oct 14, 2014 at 10:57 AM, Jeff Newmiller wrote: > Your question is missing a reproducible example, and you don't say how it > does not work, so we cannot tell what is going on. > > Two things do come to mind, though. > > A) Data frame subsets with only one column by default return a vector, which > is a different type of object than a single-column data frame. You would need > to read ?"[.data.frame" about the "drop" argument if you wanted to > consistently get a data frame from this expression. > > B) The period is a wildcard in regular expressions. If you expect to limit > your search to literal ".at" at the end of the name then you should use the > search pattern "\\.at$" instead (the first slash allows the second one to be > stored by R in the string, and the second one is the only one seen by grep, > which it reads as making the period not act like a wildcard). You really > should read about regular expressions before using them. There are many > tutorials on the web about this topic. > > --- > Jeff NewmillerThe . . Go Live... > DCN:Basics: ##.#. ##.#. Live Go... > Live: OO#.. Dead: OO#.. Playing > Research Engineer (Solar/BatteriesO.O#. #.O#. with > /Software/Embedded Controllers) .OO#. .OO#. rocks...1k > --- > Sent from my phone. Please excuse my brevity. > > On October 14, 2014 7:23:55 AM PDT, Kate Ignatius > wrote: >>I'm having an issue with grep: >> >>I have numerous columns that end with .at... when I use grep like so: >> >>df[,grep(".at",colnames(df))] >> >>it works fine. When I have one column that ends with .at, it does not >>work. Why is that? As this is loop with varying number of columns >>ending in .at I would like some code that would work with 1 to n >>number of columns. >> >>Is there something more optimal than grep? >> >>Thanks! >> >>__ >>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] grep won't work finding one column
You're right. I don't use regexps in R very much. In most other languages, a single \ is needed. The R parser is different and I forgot. Thanks for the heads up. On Tue, Oct 14, 2014 at 10:01 AM, Ivan Calandra wrote: > Shouldn't it be > grep("\\.at$",colnames(df)) > with double back slash? > > Ivan > > -- > Ivan Calandra > University of Reims Champagne-Ardenne > GEGENA² - EA 3795 > CREA - 2 esplanade Roland Garros > 51100 Reims, France > +33(0)3 26 77 36 89 > ivan.calan...@univ-reims.fr > https://www.researchgate.net/profile/Ivan_Calandra > > Le 14/10/14 16:38, John McKown a écrit : >> >> On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius >> wrote: >>> >>> I'm having an issue with grep: >>> >>> I have numerous columns that end with .at... when I use grep like so: >>> >>> df[,grep(".at",colnames(df))] >>> >>> it works fine. When I have one column that ends with .at, it does not >>> work. Why is that? As this is loop with varying number of columns >>> ending in .at I would like some code that would work with 1 to n >>> number of columns. >>> >>> Is there something more optimal than grep? >>> >>> Thanks! >> >> I can't answer your direct question. But do you realize that your code >> does not match your words? The grep show does not _only_ match columns >> who name end with the characters '.at'. It matches all column names >> which contain any character followed by the characters "at". To do the >> match with only columns whose names end with the characters ".at", you >> need: grep("\.at$",colnames(df)). >> >> You might want to post an example which fails. Just to be complete, be >> sure to use the dput() function so that it is easy for members of the >> group to cut'n'paste to get your data into our own R workspace. >> > > __ > 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. -- There is nothing more pleasant than traveling and meeting new people! Genghis Khan Maranatha! <>< John McKown __ 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] grep won't work finding one column
AT and at are not the same. If you want an case insensitive compare for the characters "at" you need the "ignore.case=TRUE" added. E.g.: df[,grep(".at",colnames(df),ignore.case=TRUE) That should match the column name you gave. Which does not match your initial description which said "ending with .at". That has an embedded AT. So I am still a bit confused about your needs. On Tue, Oct 14, 2014 at 9:55 AM, Kate Ignatius wrote: > For example, > > DF will usually have numerous columns with sample1.at sample1.dp > sample1.fg sample2.at sample2.dp sample2.fg and so on > > I'm running this code in R as part of a shell script which runs over > several different file sizes so sometimes it will come across a file > with one sample in it: i.e. sample1: when the R code runs through this > file... trying to grep out the "sample1.at" column does not work and > it will halt and stop. > > Here is some sample data... say I want to get out the AT_ only column > > > Sample_1 AT_1 > A/A RR > G/G AA > T/T AA > G/A RA > G/G RR > C/C AA > C/C AA > C/T RA > A/A AA > T/G RA > > it will have a problem grepping out this single column. > > On Tue, Oct 14, 2014 at 10:38 AM, John McKown > wrote: >> On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius >> wrote: >>> I'm having an issue with grep: >>> >>> I have numerous columns that end with .at... when I use grep like so: >>> >>> df[,grep(".at",colnames(df))] >>> >>> it works fine. When I have one column that ends with .at, it does not >>> work. Why is that? As this is loop with varying number of columns >>> ending in .at I would like some code that would work with 1 to n >>> number of columns. >>> >>> Is there something more optimal than grep? >>> >>> Thanks! >> >> I can't answer your direct question. But do you realize that your code >> does not match your words? The grep show does not _only_ match columns >> who name end with the characters '.at'. It matches all column names >> which contain any character followed by the characters "at". To do the >> match with only columns whose names end with the characters ".at", you >> need: grep("\.at$",colnames(df)). >> >> You might want to post an example which fails. Just to be complete, be >> sure to use the dput() function so that it is easy for members of the >> group to cut'n'paste to get your data into our own R workspace. >> >> -- >> There is nothing more pleasant than traveling and meeting new people! >> Genghis Khan >> >> Maranatha! <>< >> John McKown -- There is nothing more pleasant than traveling and meeting new people! Genghis Khan Maranatha! <>< John McKown __ 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] grep won't work finding one column
Shouldn't it be grep("\\.at$",colnames(df)) with double back slash? Ivan -- Ivan Calandra University of Reims Champagne-Ardenne GEGENA² - EA 3795 CREA - 2 esplanade Roland Garros 51100 Reims, France +33(0)3 26 77 36 89 ivan.calan...@univ-reims.fr https://www.researchgate.net/profile/Ivan_Calandra Le 14/10/14 16:38, John McKown a écrit : On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius wrote: I'm having an issue with grep: I have numerous columns that end with .at... when I use grep like so: df[,grep(".at",colnames(df))] it works fine. When I have one column that ends with .at, it does not work. Why is that? As this is loop with varying number of columns ending in .at I would like some code that would work with 1 to n number of columns. Is there something more optimal than grep? Thanks! I can't answer your direct question. But do you realize that your code does not match your words? The grep show does not _only_ match columns who name end with the characters '.at'. It matches all column names which contain any character followed by the characters "at". To do the match with only columns whose names end with the characters ".at", you need: grep("\.at$",colnames(df)). You might want to post an example which fails. Just to be complete, be sure to use the dput() function so that it is easy for members of the group to cut'n'paste to get your data into our own R workspace. __ 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] package installation failure virtualisation environment
Subscribers, A version of R is installed in a virtual machine, which has complete internet access via the host. The following error occurs when a package is selected: install.packages([packagename], dependencies=TRUE) --- Please select a CRAN mirror for use in this session --- Killed The error also occurs with: install.packages() The process is killed as shown previously (but not the R session), after selection of a package in the Tcl/tk dialogue window. The error occurs both as root and normal user. Any suggestions please to solve? R.version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 3 minor 1.1 year 2014 month 07 day10 svn rev66115 language R version.string R version 3.1.1 (2014-07-10) nickname Sock it to Me __ 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] grep won't work finding one column
Your question is missing a reproducible example, and you don't say how it does not work, so we cannot tell what is going on. Two things do come to mind, though. A) Data frame subsets with only one column by default return a vector, which is a different type of object than a single-column data frame. You would need to read ?"[.data.frame" about the "drop" argument if you wanted to consistently get a data frame from this expression. B) The period is a wildcard in regular expressions. If you expect to limit your search to literal ".at" at the end of the name then you should use the search pattern "\\.at$" instead (the first slash allows the second one to be stored by R in the string, and the second one is the only one seen by grep, which it reads as making the period not act like a wildcard). You really should read about regular expressions before using them. There are many tutorials on the web about this topic. --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On October 14, 2014 7:23:55 AM PDT, Kate Ignatius wrote: >I'm having an issue with grep: > >I have numerous columns that end with .at... when I use grep like so: > >df[,grep(".at",colnames(df))] > >it works fine. When I have one column that ends with .at, it does not >work. Why is that? As this is loop with varying number of columns >ending in .at I would like some code that would work with 1 to n >number of columns. > >Is there something more optimal than grep? > >Thanks! > >__ >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] grep won't work finding one column
For example, DF will usually have numerous columns with sample1.at sample1.dp sample1.fg sample2.at sample2.dp sample2.fg and so on I'm running this code in R as part of a shell script which runs over several different file sizes so sometimes it will come across a file with one sample in it: i.e. sample1: when the R code runs through this file... trying to grep out the "sample1.at" column does not work and it will halt and stop. Here is some sample data... say I want to get out the AT_ only column Sample_1 AT_1 A/A RR G/G AA T/T AA G/A RA G/G RR C/C AA C/C AA C/T RA A/A AA T/G RA it will have a problem grepping out this single column. On Tue, Oct 14, 2014 at 10:38 AM, John McKown wrote: > On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius > wrote: >> I'm having an issue with grep: >> >> I have numerous columns that end with .at... when I use grep like so: >> >> df[,grep(".at",colnames(df))] >> >> it works fine. When I have one column that ends with .at, it does not >> work. Why is that? As this is loop with varying number of columns >> ending in .at I would like some code that would work with 1 to n >> number of columns. >> >> Is there something more optimal than grep? >> >> Thanks! > > I can't answer your direct question. But do you realize that your code > does not match your words? The grep show does not _only_ match columns > who name end with the characters '.at'. It matches all column names > which contain any character followed by the characters "at". To do the > match with only columns whose names end with the characters ".at", you > need: grep("\.at$",colnames(df)). > > You might want to post an example which fails. Just to be complete, be > sure to use the dput() function so that it is easy for members of the > group to cut'n'paste to get your data into our own R workspace. > > -- > There is nothing more pleasant than traveling and meeting new people! > Genghis Khan > > Maranatha! <>< > John McKown __ 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] grep won't work finding one column
On Tue, Oct 14, 2014 at 9:23 AM, Kate Ignatius wrote: > I'm having an issue with grep: > > I have numerous columns that end with .at... when I use grep like so: > > df[,grep(".at",colnames(df))] > > it works fine. When I have one column that ends with .at, it does not > work. Why is that? As this is loop with varying number of columns > ending in .at I would like some code that would work with 1 to n > number of columns. > > Is there something more optimal than grep? > > Thanks! I can't answer your direct question. But do you realize that your code does not match your words? The grep show does not _only_ match columns who name end with the characters '.at'. It matches all column names which contain any character followed by the characters "at". To do the match with only columns whose names end with the characters ".at", you need: grep("\.at$",colnames(df)). You might want to post an example which fails. Just to be complete, be sure to use the dput() function so that it is easy for members of the group to cut'n'paste to get your data into our own R workspace. -- There is nothing more pleasant than traveling and meeting new people! Genghis Khan Maranatha! <>< John McKown __ 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] grep won't work finding one column
I'm having an issue with grep: I have numerous columns that end with .at... when I use grep like so: df[,grep(".at",colnames(df))] it works fine. When I have one column that ends with .at, it does not work. Why is that? As this is loop with varying number of columns ending in .at I would like some code that would work with 1 to n number of columns. Is there something more optimal than grep? Thanks! __ 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] Storing vectors as vectors in a list without losing each individual vector
If you just want to plot the various combinations of a set of variables/columns, you don't need a list, just another data frame/matrix with the combinations of the column numbers you want to plot: > df <- matrix(rnorm(100), 10, 10) > df <- data.frame(df) > comb <- expand.grid(7:10, 7:10) > comb <- comb[comb[,1] < comb[,2],] > rownames(comb) <- NULL > comb Var1 Var2 178 279 389 47 10 58 10 69 10 > windows(record=TRUE) > apply(comb, 1, function(x) plot(df[,x[1]], df[,x[2]], + main=paste("Plot of", x[1], "with", x[2]))) NULL - David L Carlson Department of Anthropology Texas A&M 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 Patricia Seo Sent: Monday, October 13, 2014 6:28 PM To: r-help@r-project.org Subject: [R] Storing vectors as vectors in a list without losing each individual vector Hi everyone, My help request is similar to what was asked by Ken Termiso on April 18th, 2005. Link here: https://stat.ethz.ch/pipermail/r-help/2005-April/069729.html Matt Wiener answered with suggesting a vector list where you hand type each of the vectors. This is not what I want to do. What I want to do is automate the process. So, in other words creating a list through a loop. For example: My data frame is called "df" and I have four variables/vectors that are v7, v8, v9, 10. Each variable/vector is an integer (no character strings). I want to create a list called "Indexes" so that I can use this list for "for-in" loops to SEPARATELY plot each and every variable/vector. If I followed Matt Wiener's suggestion, I would input this: Indexes = list() Indexes[[1]] = df$v7 Indexes[[2]] = df$v8 Indexes[[3]] = df$v9 Indexes[[4]] = df$v10 But if I want to include more than four variable/vectors (let's say I want to include 25 of them!), I do not want to have to type all of it. If I do the following command: Indexes <- c(df$v7, df$v8, df$v9, df$v10) then I run into the same problem as Ken Termiso with having all the integers in one vector. I need to keep the variables/vectors separate. Is this just not possible in R? Any help would be great. Thank you! __ 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] To build a new Df from 2 Df
Hello, here's a draft of a solution. I hope it's not overly complicated. # find all possible combinations combi <- expand.grid(Dem$Nom, Rap$Nom); names(combi) <- c("Dem", "Rap") # we need the corresponding departments and units combi$DemDep <- apply(combi, 1, function(x) Dem$Departement[x[1] == Dem$Nom]) combi$DemUni <- apply(combi, 1, function(x) Dem$Unite[x[1] == Dem$Nom]) combi$RapDep <- apply(combi, 1, function(x) Rap$Departement[x[2] == Rap$Nom]) combi$RapUni <- apply(combi, 1, function(x) Rap$Unite[x[2] == Rap$Nom]) # we exclude the combinations that we don't want dep <- combi[combi$DemDep != combi$RapDep, c("Dem", "Rap")] dep$id <- as.numeric(dep$Rap) uni <- combi[combi$DemUni != combi$RapUni, c("Dem", "Rap")] uni$id <- as.numeric(uni$Rap) # preliminary result resDep <- reshape(dep, timevar = "id", idvar = "Dem", direction = "wide" ) resUni <- reshape(uni, timevar = "id", idvar = "Dem", direction = "wide" ) In resDep and resUni you find the results for Rapporteur1 and Rapporteur2. NAs indicate where conditions did not match. For Rap1/Rap2 you can now choose any column from resDep and resUni that is not NA for that specific Demandeur. I wasn't exactly sure about your third condition, so I'll leave that to you. But with the complete possible matches, you have a more general solution. Btw, you can construct data.frames just like this: Dem <- data.frame( Nom = c("John", "Jim", "Julie", "Charles", "Michel", "Emma", "Sandra", "Elodie", "Thierry", "Albert", "Jean", "Francois", "Pierre", "Cyril", "Damien", "Jean-Michel", "Vincent", "Daniel", "Yvan", "Catherine"), Departement = c("D", "A", "A", "C", "D", "B", "D", "B", "C", "D", "B", "B", "B", "A", "C", "D", "B", "A", "D", "D"), Unite = c("Unite8", "Unite4", "Unite4", "Unite7", "Unite9", "Unite1", "Unite6", "Unite5", "Unite7", "Unite3", "Unite2", "Unite6", "Unite8", "Unite8", "Unite3", "Unite8", "Unite9", "Unite7", "Unite9", "Unite5") ) -dk -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Arnaud Michel Gesendet: Dienstag, 14. Oktober 2014 10:46 An: r-help@r-project.org Betreff: [R] To build a new Df from 2 Df Hello I have 2 df Dem and Rap. I would want to build all the df (dfnew) by associating these two df (Dem and Rap) in the following way : For each value of Dem$Nom (dfnew$Demandeur), I associate 2 different values of Rap$Nom (dfnew$Rapporteur1 and dfnew$Rapporteur2) in such a way * for each dfnew$Demandeur, dfnew$Rapporteur1 does not have the same value for Departement as Dem$Departement * for each dfnew$Demandeur, dfnew$Rapporteur2 does not have the same value for Unite as Dem$Unite * the value of table(dfnew$Rapporteur1) and the value of table(dfnew$Rapporteur2) must be balanced and not too different (Accepted differences : 1) table(dfnew$Rapporteur1) Rapporteur01 Rapporteur02 Rapporteur03 Rapporteur04 Rapporteur05 4 4 4 4 4 Thanks for your help Michel Dem <- structure(list(Nom = c("John", "Jim", "Julie", "Charles", "Michel", "Emma", "Sandra", "Elodie", "Thierry", "Albert", "Jean", "Francois", "Pierre", "Cyril", "Damien", "Jean-Michel", "Vincent", "Daniel", "Yvan", "Catherine"), Departement = c("D", "A", "A", "C", "D", "B", "D", "B", "C", "D", "B", "B", "B", "A", "C", "D", "B", "A", "D", "D"), Unite = c("Unite8", "Unite4", "Unite4", "Unite7", "Unite9", "Unite1", "Unite6", "Unite5", "Unite7", "Unite3", "Unite2", "Unite6", "Unite8", "Unite8", "Unite3", "Unite8", "Unite9", "Unite7", "Unite9", "Unite5")), .Names = c("Nom", "Departement", "Unite" ), row.names = c(NA, -20L), class = "data.frame") Rap <- structure(list(Nom = c("Rapporteur01", "Rapporteur02", "Rapporteur03", "Rapporteur04", "Rapporteur05"), Departement = c("C", "D", "C", "C", "D"), Unite = c("Unite10", "Unite6", "Unite5", "Unite5", "Unite4")), .Names = c("Nom", "Departement", "Unite"), row.names = c(NA, -5L), class = "data.frame") dfnew <- structure(list(Demandeur = structure(c(13L, 12L, 14L, 3L, 15L, 8L, 17L, 7L, 18L, 1L, 10L, 9L, 16L, 4L, 5L, 11L, 19L, 6L, 20L, 2L), .Label = c("Albert", "Catherine", "Charles", "Cyril", "Damien", "Daniel", "Elodie", "Emma", "Francois", "Jean", "Jean-Michel", "Jim", "John", "Julie", "Michel", "Pierre", "Sandra", "Thierry", "Vincent", "Yvan"), class = "factor"), Rapporteur1 = structure(c(3L, 1L, 3L, 5L, 1L, 5L, 1L, 2L, 5L, 4L, 2L, 4L, 2L, 3L, 5L, 4L, 4L, 2L, 3L, 1L), .Label = c("Rapporteur01", "Rapporteur02", "Rapporteur03", "Rapporteur04", "Rapporteur05"), class = "factor"), Rapporteur2 = structure(c(1L, 3L, 4L, 4L, 2L, 4L, 5L, 1L, 2L, 3L, 3L, 3L, 5L, 5L, 1L, 1L, 2L, 5L, 4L, 2L), .Label = c("Rapporteur01", "Rapporteur02", "Rapporteur03", "Rapporteur04", "Rapporteur05"), class = "factor")), .Names = c("Demandeur", "Rapporteur1", "Rapporteur2"), row.names = c(NA, -
Re: [R] ggplot "scale_x_date" : to plot quarterly scale?
On Tue, Oct 14, 2014 at 3:36 AM, jpm miao wrote: > Hi, > > I am plotting time series by ggplot2, but I believe that my question > applies to other plotting tool as well. > > I want to make my x-axis the quarterly scale, e.g: > 2000Q1 2000Q2. > >However, scale_x_date and date_format("%m/%d") support all time formats > BUT QUARTERs > > library(scales) # to access breaks/formatting functions > dt + scale_x_date() > dt + scale_x_date(labels = date_format("%m/%d")) > 1. zoo has a "yearqtr" class and its ggplot2 interface includes scale_x_yearqtr() so: library(zoo) library(ggplot2) library(scales) # test data DF <- data.frame(date = seq(as.Date("2014-01-01"), length = 4, by = "3 months"), y = c(1, 4, 2, 3)) # convert date to yearmon class DF2 <- transform(DF, date = as.yearqtr(date)) ggplot(DF2, aes(date, y)) + geom_line() + scale_x_yearqtr(format = "%YQ%q") 2. zoo also has a zoo method for ggplot2's autoplot generic so we could just convert DF to zoo and write: z <- zoo(DF$y, as.yearqtr(DF$date)) autoplot(z) + scale_x_yearqtr(format = "%YQ%q") In both cases if the format argument is omitted one gets a default of format = "%Y-%q". -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to ajust y-axis values in plot() ?
> I want to plot( 11:20 ) in a plot. > if i just type the code above, the y value will be from 11 to 20, now i > want the > value from a given range like 0 to 40, how can i do it? See the ylim= argument to plot.default; eg plot(x, y, ylim=c(0,40)) Also look at ?par and note that plot() and other things often take many of par's arguments. > Actually, the qustion is founded when i already plot a plot like plot(11:20) > , but > when i abline(h=40), i found it will go out of the plot even after i used > abline(h=40,xpd=T). Um, yes. A horizontal line at y=40 would not even be inside the plot window if the plot region is scaled to c(11,20). Where did you expect/want the line to appear? S *** This email and any attachments are confidential. Any use, copying or disclosure other than by the intended recipient is unauthorised. If you have received this message in error, please notify the sender immediately via +44(0)20 8943 7000 or notify postmas...@lgcgroup.com and delete this message and any copies from your computer and network. LGC Limited. Registered in England 2991879. Registered office: Queens Road, Teddington, Middlesex, TW11 0LY, UK __ 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 ajust y-axis values in plot() ?
Hello, Use the argument ylim. See ?par instead of plot. plot(11:20, ylim = c(0, 40)) abline(h=40) Hope this helps, Rui Barradas Em 14-10-2014 10:33, PO SU escreveu: Dear helpeRs, I want to plot( 11:20 ) in a plot. if i just type the code above, the y value will be from 11 to 20, now i want the value from a given range like 0 to 40, how can i do it? I read ?plot for a while but still can't solve it. Actually, the qustion is founded when i already plot a plot like plot(11:20) , but when i abline(h=40), i found it will go out of the plot even after i used abline(h=40,xpd=T). SO, may you help me? -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU __ 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] SOLVED: evaluate NA to FALSE instead of NA?
> Thanks Joshua and Sven - I completely forgot about which() . Also na.omit(p[p<=0.05]) #and p[p<=0.05 & !is.na(p)] S. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] ggplot - start axis label with superscript
> I'm stuck trying to begin an axis label in ggplot with a superscript. For a crude work-round, you could try ggplot(mydata) + aes(x = x, y = y) + geom_line() + ylab(expression(paste(' '^{14}, "C", sep = ""))) S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ 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] SOLVED: evaluate NA to FALSE instead of NA?
Thanks Joshua and Sven - I completely forgot about which() . Pascal - I never new about complete.cases - interesting function. Thanks, Rainer Rainer M Krug writes: > Hi > > I want to evaluate NA and NaN to FALSE (for indexing) so I would like to > have the result as indicated here: > > , > | > p <- c(1:10/100, NA, NaN) > | > p > | [1] 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 NA NaN > | > p[p<=0.05] > | [1] 0.01 0.02 0.03 0.04 0.05 NA NA > | > p[sapply(p<=0.05, isTRUE)] > | [1] 0.01 0.02 0.03 0.04 0.05 <<<=== I want this > ` > > Is there a way that I can do this more easily then in my example above? > It works, but it strikes me that there is not a better way of doing > this - am I missing a command or option? > > Thanks, > > Rainer -- Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 pgpyM4JmyuLsK.pgp Description: PGP signature __ 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] evaluate NA to FALSE instead of NA?
Hi, Perhaps still not as short as you want, but I normally use which(): p <- c(1:10/100, NA, NaN) p[which(p <= .05)] [1] 0.01 0.02 0.03 0.04 0.05 Cheers, Josh On Tue, Oct 14, 2014 at 8:51 PM, Rainer M Krug wrote: > Hi > > I want to evaluate NA and NaN to FALSE (for indexing) so I would like to > have the result as indicated here: > > , > | > p <- c(1:10/100, NA, NaN) > | > p > | [1] 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 NA NaN > | > p[p<=0.05] > | [1] 0.01 0.02 0.03 0.04 0.05 NA NA > | > p[sapply(p<=0.05, isTRUE)] > | [1] 0.01 0.02 0.03 0.04 0.05 <<<=== I want this > ` > > Is there a way that I can do this more easily then in my example above? > It works, but it strikes me that there is not a better way of doing > this - am I missing a command or option? > > Thanks, > > Rainer > > -- > Rainer M. Krug > email: Rainerkrugsde > PGP: 0x0F52F982 > > __ > 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. > > -- Joshua F. Wiley Ph.D. Student, UCLA Department of Psychology http://joshuawiley.com/ Senior Analyst, Elkhart Group Ltd. http://elkhartgroup.com Office: 260.673.5518 [[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] evaluate NA to FALSE instead of NA?
Hi Rainer, As "complete.cases()" does? p <- c(1:10/100, NA, NaN) complete.cases(p) [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE Regards, Pascal On Tue, Oct 14, 2014 at 6:51 PM, Rainer M Krug wrote: > Hi > > I want to evaluate NA and NaN to FALSE (for indexing) so I would like to > have the result as indicated here: > > , > | > p <- c(1:10/100, NA, NaN) > | > p > | [1] 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 NA NaN > | > p[p<=0.05] > | [1] 0.01 0.02 0.03 0.04 0.05 NA NA > | > p[sapply(p<=0.05, isTRUE)] > | [1] 0.01 0.02 0.03 0.04 0.05 <<<=== I want this > ` > > Is there a way that I can do this more easily then in my example above? > It works, but it strikes me that there is not a better way of doing > this - am I missing a command or option? > > Thanks, > > Rainer > > -- > Rainer M. Krug > email: Rainerkrugsde > PGP: 0x0F52F982 > > __ > 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. > -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan __ 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] evaluate NA to FALSE instead of NA?
use: which(p<=.05) this will not yield logical, but integer indices without NA On 14 October 2014 11:51, Rainer M Krug wrote: > Hi > > I want to evaluate NA and NaN to FALSE (for indexing) so I would like to > have the result as indicated here: > > , > | > p <- c(1:10/100, NA, NaN) > | > p > | [1] 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 NA NaN > | > p[p<=0.05] > | [1] 0.01 0.02 0.03 0.04 0.05 NA NA > | > p[sapply(p<=0.05, isTRUE)] > | [1] 0.01 0.02 0.03 0.04 0.05 <<<=== I want this > ` > > Is there a way that I can do this more easily then in my example above? > It works, but it strikes me that there is not a better way of doing > this - am I missing a command or option? > > Thanks, > > Rainer > > -- > Rainer M. Krug > email: Rainerkrugsde > PGP: 0x0F52F982 > > __ > 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] ggplot "scale_x_date" : to plot quarterly scale?
Dear jpm, have attached a simpler example, hope this helps. Regards. plot(0:100,pch="",xaxt="n",) axis(1, at=1,lab=c("abcd"),cex.axis=1,font=4) axis(1, at=20,lab=c("efgh"),cex.axis=1,font=4) axis(1, at=60,lab=c("ijkl"),cex.axis=1,font=4) On Tuesday, October 14, 2014 11:48 AM, Franklin Mairura wrote: Try this code, this may get a solution close to what you need. The advantage with this code is that you specify the text you want to appear on the xaxis. The dates have to be supplied as text formats, and located on the xaxis using the axis and at commands. the at command allows for customised location whether intervals are equal or not. The matplot command draws the lineplot, which is basically what a time series is. Using excel makes customised syntax building for R easier, by the CONCATENATE Excel worksheet functuion. Canopy<-(factor(c(1,2,3))) a<-c(0.336,0.852,0.794) b<-c(0.21,0.353,0.878) c<-c(0.443,0.65,1.188333) d<-c(0.052,0.106,0.142) e<-c(0.275,0.203,0.633) f<-c(0.35,0.365,0.797) g<-c(0.16,0.467,0.697) h<-c(0.587,0.873,2.29) i<-c(0.837,2.55625,2.675) j<-c(0.537,1.68,2.52) k<-c(0.163,0.137,0.157) l<-c(0.187,0.228,0.447) m<-c(0.175,0.265,0.755) n<-c(0.536,1.834,2.378) o<-c(0.248,1.056667,1.606667) p<-c(1.07,0.9275,2.05) q<-c(0.1225,0.5975,0.6075) r<-c(0.155,0.325,1.635) s<-c(0.418,1.82,3.68) t<-c(1.25,1.2925,2.3925) u<-c(1.416,2.304,2.258) v<-c(0.447,1.235,2.85) RUST<-data.frame(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) matplot(ylim=c(0,5),Canopy,RUST,type="o",pch=c(1:23),lty=c(1:23),col=c(1:23),xaxt="n",lwd=2,cex=1.5,ylab="Rust Score",xlab="Canopy level") axis(1, at=1:3,lab=c("Top","Middle","Lower"),cex.axis=1,font=4) #mtext("Canopy level",side=1,line=3,) legend("topleft",col=c(1:23),cex=0.6,ncol=2,pch=c(1:23),lwd=2,lty=c(1:23),c("a","b","c","d","e","f","g", "h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w")) segments(1,1.71535,1,2.28465) segments(2,2.868,2,3.532) segments(3,4.169,3,5.031) segments(0.99,1.71535,1.01,1.71535) segments(0.99,2.28465,1.01,2.28465) segments(1.99,2.868,2.01,2.868) segments(1.99,3.532,2.01,3.532) segments(2.99,5.031,3.01,5.031) segments(2.99,4.169,3.01,4.169) On Tuesday, October 14, 2014 10:37 AM, jpm miao wrote: Hi, I am plotting time series by ggplot2, but I believe that my question applies to other plotting tool as well. I want to make my x-axis the quarterly scale, e.g: 2000Q1 2000Q2. However, scale_x_date and date_format("%m/%d") support all time formats BUT QUARTERs library(scales) # to access breaks/formatting functions dt + scale_x_date() dt + scale_x_date(labels = date_format("%m/%d")) Is there any solution? 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. [[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] evaluate NA to FALSE instead of NA?
Hi I want to evaluate NA and NaN to FALSE (for indexing) so I would like to have the result as indicated here: , | > p <- c(1:10/100, NA, NaN) | > p | [1] 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 NA NaN | > p[p<=0.05] | [1] 0.01 0.02 0.03 0.04 0.05 NA NA | > p[sapply(p<=0.05, isTRUE)] | [1] 0.01 0.02 0.03 0.04 0.05 <<<=== I want this ` Is there a way that I can do this more easily then in my example above? It works, but it strikes me that there is not a better way of doing this - am I missing a command or option? Thanks, Rainer -- Rainer M. Krug email: Rainerkrugsde PGP: 0x0F52F982 pgpeDC3NRUhbX.pgp Description: PGP signature __ 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] ggplot - start axis label with superscript
Dear help, I’m stuck trying to begin an axis label in ggplot with a superscript. While I’m fine using expression to insert them in between normal text in an axis label, this doesn’t appear to work at the start of an expression. For example: mydata <- data.frame(x = 1:10, y = 10:1) # this works: ggplot(mydata) + aes(x = x, y = y) + geom_line() + ylab(expression(paste(Incorrect^{14}, "C", sep = ""))) # this doesn’t work (and is what I would like to be able to do): ggplot(mydata) + aes(x = x, y = y) + geom_line() + ylab(expression(paste(^{14}, "C", sep = ""))) Any help on this issue would be much appreciated! Many thanks, Tom __ 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] how to ajust y-axis values in plot() ?
Dear helpeRs, I want to plot( 11:20 ) in a plot. if i just type the code above, the y value will be from 11 to 20, now i want the value from a given range like 0 to 40, how can i do it? I read ?plot for a while but still can't solve it. Actually, the qustion is founded when i already plot a plot like plot(11:20) , but when i abline(h=40), i found it will go out of the plot even after i used abline(h=40,xpd=T). SO, may you help me? -- PO SU mail: desolato...@163.com Majored in Statistics from SJTU __ 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] Storing vectors as vectors in a list without losing each individual vector
On Oct 13, 2014 11:58 PM, "Patricia Seo" wrote: > > Hi everyone, > > My help request is similar to what was asked by Ken Termiso on April 18th, 2005. Link here: https://stat.ethz.ch/pipermail/r-help/2005-April/069729.html > > Matt Wiener answered with suggesting a vector list where you hand type each of the vectors. This is not what I want to do. What I want to do is automate the process. So, in other words creating a list through a loop. > > For example: > > My data frame is called "df" and I have four variables/vectors that are v7, v8, v9, 10. Each variable/vector is an integer (no character strings). I want to create a list called "Indexes" so that I can use this list for "for-in" loops to SEPARATELY plot each and every variable/vector. > > If I followed Matt Wiener's suggestion, I would input this: > > > Indexes = list() > Indexes[[1]] = df$v7 > Indexes[[2]] = df$v8 > Indexes[[3]] = df$v9 > Indexes[[4]] = df$v10 > > But if I want to include more than four variable/vectors (let's say I want to include 25 of them!), I do not want to have to type all of it. If I do the following command: > > Indexes <- c(df$v7, df$v8, df$v9, df$v10) > > then I run into the same problem as Ken Termiso with having all the integers in one vector. I need to keep the variables/vectors separate. Does Indexes <- list(df$v7, df$v8, df$v9, df$v10) do what you want? Henrik > > Is this just not possible in R? Any help would be great. Thank you! > > __ > 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] Help with a function [along columns]
On Mon, 13 Oct 2014 08:54:51 PM Kate Ignatius wrote: > Just an update to this: > > gtal <- function(d) { > alleles <- sapply(d, function(.) strsplit(as.character(.), "/")) > gt <- unlist(lapply(alleles, function(x) >ifelse(identical(x[[1]], vcf[,3]) & identical(x[[2]], vcf[,3]), > 'RR', ifelse(identical(x[[1]], vcf[,4]) & identical(x[[2]], vcf[,4]), 'AA', > ifelse(identical(x[[1]], vcf[,3]) & identical(x[[2]], vcf[,4]), 'RA', > ifelse(identical(x[[1]], vcf[,4]) & identical(x[[2]], > vcf[,3]), 'RA', '')) > } > > I've got something working but I'm having trouble with the gt part... > I'm getting the error: object of type 'closure' is not subsettable. > The vcf is my original file that I want to match with so not sure > whether this a problem. > Hi Kate, Unless you have passed "vcf" to your function, it is unlikely to recognize it. As you are working with genome data, I suspect that there is a function named "vcf" somewhere in the parent environment and you can't subset a function. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot "scale_x_date" : to plot quarterly scale?
Try this code, this may get a solution close to what you need. The advantage with this code is that you specify the text you want to appear on the xaxis. The dates have to be supplied as text formats, and located on the xaxis using the axis and at commands. the at command allows for customised location whether intervals are equal or not. The matplot command draws the lineplot, which is basically what a time series is. Using excel makes customised syntax building for R easier, by the CONCATENATE Excel worksheet functuion. Canopy<-(factor(c(1,2,3))) a<-c(0.336,0.852,0.794) b<-c(0.21,0.353,0.878) c<-c(0.443,0.65,1.188333) d<-c(0.052,0.106,0.142) e<-c(0.275,0.203,0.633) f<-c(0.35,0.365,0.797) g<-c(0.16,0.467,0.697) h<-c(0.587,0.873,2.29) i<-c(0.837,2.55625,2.675) j<-c(0.537,1.68,2.52) k<-c(0.163,0.137,0.157) l<-c(0.187,0.228,0.447) m<-c(0.175,0.265,0.755) n<-c(0.536,1.834,2.378) o<-c(0.248,1.056667,1.606667) p<-c(1.07,0.9275,2.05) q<-c(0.1225,0.5975,0.6075) r<-c(0.155,0.325,1.635) s<-c(0.418,1.82,3.68) t<-c(1.25,1.2925,2.3925) u<-c(1.416,2.304,2.258) v<-c(0.447,1.235,2.85) RUST<-data.frame(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) matplot(ylim=c(0,5),Canopy,RUST,type="o",pch=c(1:23),lty=c(1:23),col=c(1:23),xaxt="n",lwd=2,cex=1.5,ylab="Rust Score",xlab="Canopy level") axis(1, at=1:3,lab=c("Top","Middle","Lower"),cex.axis=1,font=4) #mtext("Canopy level",side=1,line=3,) legend("topleft",col=c(1:23),cex=0.6,ncol=2,pch=c(1:23),lwd=2,lty=c(1:23),c("a","b","c","d","e","f","g", "h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w")) segments(1,1.71535,1,2.28465) segments(2,2.868,2,3.532) segments(3,4.169,3,5.031) segments(0.99,1.71535,1.01,1.71535) segments(0.99,2.28465,1.01,2.28465) segments(1.99,2.868,2.01,2.868) segments(1.99,3.532,2.01,3.532) segments(2.99,5.031,3.01,5.031) segments(2.99,4.169,3.01,4.169) On Tuesday, October 14, 2014 10:37 AM, jpm miao wrote: Hi, I am plotting time series by ggplot2, but I believe that my question applies to other plotting tool as well. I want to make my x-axis the quarterly scale, e.g: 2000Q1 2000Q2. However, scale_x_date and date_format("%m/%d") support all time formats BUT QUARTERs library(scales) # to access breaks/formatting functions dt + scale_x_date() dt + scale_x_date(labels = date_format("%m/%d")) Is there any solution? 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. [[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] To build a new Df from 2 Df
Hello I have 2 df Dem and Rap. I would want to build all the df (dfnew) by associating these two df (Dem and Rap) in the following way : For each value of Dem$Nom (dfnew$Demandeur), I associate 2 different values of Rap$Nom (dfnew$Rapporteur1 and dfnew$Rapporteur2) in such a way * for each dfnew$Demandeur, dfnew$Rapporteur1 does not have the same value for Departement as Dem$Departement * for each dfnew$Demandeur, dfnew$Rapporteur2 does not have the same value for Unite as Dem$Unite * the value of table(dfnew$Rapporteur1) and the value of table(dfnew$Rapporteur2) must be balanced and not too different (Accepted differences : 1) table(dfnew$Rapporteur1) Rapporteur01 Rapporteur02 Rapporteur03 Rapporteur04 Rapporteur05 4 4 4 4 4 Thanks for your help Michel Dem <- structure(list(Nom = c("John", "Jim", "Julie", "Charles", "Michel", "Emma", "Sandra", "Elodie", "Thierry", "Albert", "Jean", "Francois", "Pierre", "Cyril", "Damien", "Jean-Michel", "Vincent", "Daniel", "Yvan", "Catherine"), Departement = c("D", "A", "A", "C", "D", "B", "D", "B", "C", "D", "B", "B", "B", "A", "C", "D", "B", "A", "D", "D"), Unite = c("Unite8", "Unite4", "Unite4", "Unite7", "Unite9", "Unite1", "Unite6", "Unite5", "Unite7", "Unite3", "Unite2", "Unite6", "Unite8", "Unite8", "Unite3", "Unite8", "Unite9", "Unite7", "Unite9", "Unite5")), .Names = c("Nom", "Departement", "Unite" ), row.names = c(NA, -20L), class = "data.frame") Rap <- structure(list(Nom = c("Rapporteur01", "Rapporteur02", "Rapporteur03", "Rapporteur04", "Rapporteur05"), Departement = c("C", "D", "C", "C", "D"), Unite = c("Unite10", "Unite6", "Unite5", "Unite5", "Unite4")), .Names = c("Nom", "Departement", "Unite"), row.names = c(NA, -5L), class = "data.frame") dfnew <- structure(list(Demandeur = structure(c(13L, 12L, 14L, 3L, 15L, 8L, 17L, 7L, 18L, 1L, 10L, 9L, 16L, 4L, 5L, 11L, 19L, 6L, 20L, 2L), .Label = c("Albert", "Catherine", "Charles", "Cyril", "Damien", "Daniel", "Elodie", "Emma", "Francois", "Jean", "Jean-Michel", "Jim", "John", "Julie", "Michel", "Pierre", "Sandra", "Thierry", "Vincent", "Yvan"), class = "factor"), Rapporteur1 = structure(c(3L, 1L, 3L, 5L, 1L, 5L, 1L, 2L, 5L, 4L, 2L, 4L, 2L, 3L, 5L, 4L, 4L, 2L, 3L, 1L), .Label = c("Rapporteur01", "Rapporteur02", "Rapporteur03", "Rapporteur04", "Rapporteur05"), class = "factor"), Rapporteur2 = structure(c(1L, 3L, 4L, 4L, 2L, 4L, 5L, 1L, 2L, 3L, 3L, 3L, 5L, 5L, 1L, 1L, 2L, 5L, 4L, 2L), .Label = c("Rapporteur01", "Rapporteur02", "Rapporteur03", "Rapporteur04", "Rapporteur05"), class = "factor")), .Names = c("Demandeur", "Rapporteur1", "Rapporteur2"), row.names = c(NA, -20L), class = "data.frame") -- Michel ARNAUD Cirad Montpellier [[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] ggplot "scale_x_date" : to plot quarterly scale?
Hi, I am plotting time series by ggplot2, but I believe that my question applies to other plotting tool as well. I want to make my x-axis the quarterly scale, e.g: 2000Q1 2000Q2. However, scale_x_date and date_format("%m/%d") support all time formats BUT QUARTERs library(scales) # to access breaks/formatting functions dt + scale_x_date() dt + scale_x_date(labels = date_format("%m/%d")) Is there any solution? 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.
Re: [R] How to Install R 3.1.0 on ubuntu 12.0.4
Hi, Thanks for your help.I got it installed. Madhvi On Tuesday 14 October 2014 12:50 PM, Pascal Oettli wrote: The support for RStudio is located here: https://support.rstudio.com Regards, Pascal On Tue, Oct 14, 2014 at 4:08 PM, madhvi wrote: Hi, How to install RStudio after downloading debian package Madhvi On Tuesday 14 October 2014 12:09 PM, Pascal Oettli wrote: Please reply to the list, not only to me. RStudio is for Ubuntu 10.04+ (please note the "+"). About R 3.1.0, you probably will have to compile from the source. Regards, Pascal On Tue, Oct 14, 2014 at 3:31 PM, madhvi wrote: Hi, I have followed these links but it is giving R version 3.1.1 and R studio for ubuntu 10.04 Madhvi On Tuesday 14 October 2014 11:58 AM, Pascal Oettli wrote: Hi, http://cran.r-project.org/bin/linux/ubuntu/ http://www.rstudio.com/products/rstudio/download/ Enjoy, Pascal On Tue, Oct 14, 2014 at 3:17 PM, madhvi wrote: Hi, Can anyone tell me the steps to install R 3.1.0 and rstudio on ubuntu 12.0.4. Thanks Madhvi __ 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] How to Install R 3.1.0 on ubuntu 12.0.4
The support for RStudio is located here: https://support.rstudio.com Regards, Pascal On Tue, Oct 14, 2014 at 4:08 PM, madhvi wrote: > Hi, > How to install RStudio after downloading debian package > > Madhvi > > On Tuesday 14 October 2014 12:09 PM, Pascal Oettli wrote: >> >> Please reply to the list, not only to me. >> >> RStudio is for Ubuntu 10.04+ (please note the "+"). >> >> About R 3.1.0, you probably will have to compile from the source. >> >> Regards, >> Pascal >> >> >> On Tue, Oct 14, 2014 at 3:31 PM, madhvi wrote: >>> >>> Hi, >>> I have followed these links but it is giving R version 3.1.1 and R studio >>> for ubuntu 10.04 >>> >>> Madhvi >>> >>> On Tuesday 14 October 2014 11:58 AM, Pascal Oettli wrote: Hi, http://cran.r-project.org/bin/linux/ubuntu/ http://www.rstudio.com/products/rstudio/download/ Enjoy, Pascal On Tue, Oct 14, 2014 at 3:17 PM, madhvi wrote: > > Hi, > Can anyone tell me the steps to install R 3.1.0 and rstudio on ubuntu > 12.0.4. > > Thanks > Madhvi > > __ > 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. >> >> > -- Pascal Oettli Project Scientist JAMSTEC Yokohama, Japan __ 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 Install R 3.1.0 on ubuntu 12.0.4
Hi, How to install RStudio after downloading debian package Madhvi On Tuesday 14 October 2014 12:09 PM, Pascal Oettli wrote: Please reply to the list, not only to me. RStudio is for Ubuntu 10.04+ (please note the "+"). About R 3.1.0, you probably will have to compile from the source. Regards, Pascal On Tue, Oct 14, 2014 at 3:31 PM, madhvi wrote: Hi, I have followed these links but it is giving R version 3.1.1 and R studio for ubuntu 10.04 Madhvi On Tuesday 14 October 2014 11:58 AM, Pascal Oettli wrote: Hi, http://cran.r-project.org/bin/linux/ubuntu/ http://www.rstudio.com/products/rstudio/download/ Enjoy, Pascal On Tue, Oct 14, 2014 at 3:17 PM, madhvi wrote: Hi, Can anyone tell me the steps to install R 3.1.0 and rstudio on ubuntu 12.0.4. Thanks Madhvi __ 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.