Re: [R] ggplot2: less than equal sign

2013-03-28 Thread soon yi
list of expressions as its argument. > This approach gives you more control over the legend and choice of > fill colors at the expense of a couple of lines of code. To change the > axis and legend titles, one can use the labs() function; e.g., > > last_plot() + labs(x = "Visibili

[R] ggplot2: less than equal sign

2013-03-28 Thread soon yi
Hi I am trying to add a less than equal sign to a plot. I have previously done this using unicode but is not working in this instance. Any suggestions would be great thanks example code: library(ggplot2) df<-data.frame(vis=c(0,0,1,1) , count=c(10,15,20,10) , grp=c(0,1,0,1)) df$grp <-factor(df$g

Re: [R] Reassign Multiple Factors to same Factor Value

2013-03-25 Thread soon yi
or just levels(df$y)[5:7]<-"others" Ista Zahn wrote > Hi Lorenzo, > > On Mon, Mar 25, 2013 at 6:18 PM, Lorenzo Isella > < > lorenzo.isella@ > > wrote: >> Dear All, >> Probably something very easy, but I am looking for the most efficient >> ways >> to achieve this. >> Consider the following sn

Re: [R] Ordering a matrix by row value in R2.15

2013-03-24 Thread soon yi
or this with Pete's example orig[,order(orig[2,])] Pete Brecknock wrote > > fitz_ra wrote >> I know this is posted a lot, I've been through about 40 messages reading >> how to do this so let me apologize in advance because I can't get this >> operation to work unlike the many examples shown.

Re: [R] Combining boxplot

2013-02-25 Thread soon yi
does this work for you? df1 = data.frame(x = rnorm(100)) df1$type = ifelse(df1$x <= 0 , "type1", "type2") df1$group<-1 df2 = data.frame(x = rnorm(50,0,2)) df2$type = ifelse(df2$x <= 0 , "type1", "type2") df2$group<-2 combined.df<-rbind(df1,df2) boxplot(combined.df$x ~ combined.df$group *co

Re: [R] How can I plot graphs together?

2013-02-15 Thread soon yi
look at dev.new() to specify plot window size and then ?layout to specify number and size of each plot in the window Jiaqi.Zhang wrote > Hi, all, > > I am working on the following code to learn how to plot graphs together. I > used the par(mfrow=c(1,3)) function to try to put all three plot()

Re: [R] Why replacement has length zero? And How can I fix it?

2013-02-02 Thread soon yi
Hi for the loop section runif needs curved brackets Try IAP <-NA for (i in 1:Sample.Size){ if (DataSet$SES[i]>0) { IAP[i] <- ifelse(runif(1)>0.75, 1, 0) # High SES, higher chance to be in Treatment # } else { IAP[i] <- if

Re: [R] table of list objects

2013-01-03 Thread soon yi
perfect. thanks for the quick reply soon yi wrote > Hi > > I have a list such as this > > list(c("q","w"),"r",c("r","w"),c("q","w")) > > How do i create a table to include the count of groups

[R] table of list objects

2013-01-03 Thread soon yi
Hi I have a list such as this list(c("q","w"),"r",c("r","w"),c("q","w")) How do i create a table to include the count of groups of terms please? ie so output is like / similar to q","w""r" "r","w" 211 thanks for any help -- View this message in contex

Re: [R] ggplot geom_smooth colour

2012-12-17 Thread soon yi
Thank you. Rather embarrassed. Its fair to say i had rather over comlicated my attempts to do this. sy soon yi wrote > Hi > > I am using geom_smooth to fit linear regression lines over a scatterplot > for two treatment groups. The default colour for the two lines are blue. I > h

Re: [R] ggplot geom_smooth colour

2012-12-17 Thread soon yi
them to be black. Adding colour="black" into the geom_smooth aesthetic does not change the line colour to black. thanks, sy soon yi wrote > Hi > > I am using geom_smooth to fit linear regression lines over a scatterplot > for two treatment groups. The default colour for

[R] ggplot geom_smooth colour

2012-12-17 Thread soon yi
Hi I am using geom_smooth to fit linear regression lines over a scatterplot for two treatment groups. The default colour for the two lines are blue. I have been unable to change this with the usual options. A search online has not suggested any solution / work around. Is there a solution to this?

[R] ggplot - adding regression lines

2012-12-12 Thread soon yi
Hi I am using ggplot to overlay two regression lines on a scatter plot each corresponding to a treatment group. The default plot gives a different slope for each treatment group. However, in some cases i want the lines to be parallel -ie no significant interaction. My code: ggplot(data=df,X,Y,

Re: [R] update fit (removing insignificant variables)

2012-11-21 Thread soon yi
170 predictors - perhaps try lasso regression -- View this message in context: http://r.789695.n4.nabble.com/Re-update-fit-removing-insignificant-variables-tp4650379p4650394.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-pr

Re: [R] using ifelse to remove NA's from specific columns of a data frame containing strings and numbers

2012-11-15 Thread soon yi
#Data df<-data.frame(id=letters[1:10],var1=rnorm(10,10,5),var2=rnorm(10,5,2),var3=rnorm(10,1,1)) #Missing df$var1[2]<-df$var2[c(2,6)]<-df$var3[c(2,5)]<-NA na.replace<-seq(1:ncol(df))-1 df[,names(df)]<-sapply(1:dim(df)[2], function(ii) {ifelse(is.na(df[,ii]),na.replace[ii],df[,ii])} ) David Ro

[R] structural equations using sem package

2012-11-05 Thread Soon Yi
Hello I am using sem to look at the direct effect of one variable on another but i am uncertain if i am progressing correctly. An example: covar1<-  matrix(c(0.4,-0.2,3,-0.2 , 0.3,-2 , 3 ,-2 , 60), nrow=3,byrow=T) rownames(covar1)<-colnames(covar1)<-c("endo","exo","med") path1<-matrix(c(    "