similar to: Automating plot labelling in custom function in lapply() ?

Displaying 20 results from an estimated 7000 matches similar to: "Automating plot labelling in custom function in lapply() ?"

2005 Apr 29
0
Automating plot labelling in custom function in lapply( ) ?
> From: Marc Schwartz > > On Fri, 2005-04-29 at 13:00 +0100, Gavin Simpson wrote: > > Dear List, > > > > Consider the following example: > > > > dat <- data.frame(var1 = rnorm(100), var2 = rnorm(100), > > var3 = rnorm(100), var4 = rnorm(100)) > > oldpar <- par(mfrow = c(2,2), no.readonly = TRUE) > >
2004 Jun 11
2
Sweave and multiple graphs
Dear list, I am using Sweave to build a small report. I want to produce a series of figures, each figure containing a number of plots and then have them included in the Sweave file. An example would be to : postscript(file = "ANCbwplot%03d.eps", onefile = FALSE, other options...) oldpar <- par(mfrow = c(2,2)) .... do lots of plots to produce a number of eps files .... par(oldpar)
2014 Apr 11
6
crear variable en base a nombre de columnas que tienen un 1
Buenos días. Hoy ando un poco (o bastante) espeso y no doy con la tecla de una cosa que seguro que es muy simple.. Pongo un ejemplo. var1 <- c(rep(0,3),rep(1,2)) var2 <- c(rep(1,2),0,0,1) var3 <- c(rep(1,2),rep(0,3)) var4 <- c(rep(1,2),rep(0,3)) datos <- data.frame(fila=1:5,var1, var2, var3, var4) datos datos fila var1 var2 var3 var4 1 1 0 1 1 1 2 2 0
2004 Aug 17
5
Bug in colnames of data.frames?
Hi, I am using R 1.9.1 on on i686 PC with SuSE Linux 9.0. I have a data.frame, e.g.: > myData <- data.frame( var1 = c( 1:4 ), var2 = c (5:8 ) ) If I add a new column by > myData$var3 <- myData[ , "var1" ] + myData[ , "var2" ] everything is fine, but if I omit the commas: > myData$var4 <- myData[ "var1" ] + myData[ "var2" ] the name
2008 Mar 19
4
plot with diffrent colour and plotting symbols
Dear mailing list members, I am a new R user, I would like to plot the follewing data var1 <- c(1,2,1,1,2,1,2,1,2,2) var2 <- round(rgamma(10,2,1)/0.1)*0.1 var3 <- c(0,1,0,1,0,0,0,0,1,0) var4 <- c(1,2,2,2,1,1,1,1,1,1) Var <- data.frame(var1,var2,var3,var4) Var <- Var[sort(Var$var1),] tt <- Var$var1+((runif(length(Var$var1))/6)-(0.5/6)) labelname <- c("time 1",
2008 Aug 07
2
List of "occurrence" matrices
R users, I don't know if I can make myself clear but I'll give it a try. I have a data.frame like this x <- "var1,var2,var3,var4 a,b,b,a b,b,c,b c,a,a,a a,b,c,c b,a,c,a c,c,b,b a,c,a,b b,c,a,c c,a,b,c" DF <- read.table(textConnection(x), header=T, sep=",") DF and I would like to sum all the combinations/occurences by a factor (letter in this case) between
2013 Mar 25
2
Faster way of summing values up based on expand.grid
Hello! # I have 3 vectors of values: values1<-rnorm(10) values2<-rnorm(10) values3<-rnorm(10) # In real life, all 3 vectors have a length of 25 # I create all possible combinations of 4 based on 10 elements: mycombos<-expand.grid(1:10,1:10,1:10,1:10) dim(mycombos) # Removing rows that contain pairs of identical values in any 2 of these columns: mycombos<-mycombos[!(mycombos$Var1
2014 Apr 11
2
crear variable en base a nombre de columnas que tienen un 1
Carlos, en principio si sería algo así, sólo que en vez de quedarme con todas las columnas var1 a var4 tuviera sólo 3, ya que en mis datos no hay ningún caso que tenga el valor 1 en más de 3 variables.. Había llegado a una solución (mucho menos elegante que usando reshape), que implicaba un for sobre las filas. Jorge, creo que tu solución me vale. Muchas gracias a los dos.. Saludos El
2009 Sep 21
5
More elegant way of excluding rows with equal values in any 2 columns?
Hello, dear R-ers! I built a data frame "grid" (below) with 4 columns. I want to exclude all rows that have equal values in ANY 2 columns. Here is how I am doing it: index<-expand.grid(1:4,1:4,1:4,1:4) dim(index) # Deleting rows that have identical values in any two columns (1 line of code):
2012 Oct 17
2
loop of quartile groups
Greetings R users, My goal is to generate quartile groups of each variable in my data set. I would like each experiment to have its designated group added as a subsequent column. I can accomplish this individually with the following code: brks <- with(data_variables, cut2(var2, g=4)) #I don't want the actual numbers, I need a numbered group data$test1=factor(brks,
2011 Apr 04
4
merging data list in to single data frame
Dear R community members I did find a good way to merge my 200 text data files in to a single data file with one column added will show indicator for that file. filelist = list.files(pattern = "K*cd.txt") # the file names are K1cd.txt .................to K200cd.txt data_list <-lapply(filelist, read.table, header=T, comment=";", fill=T) This will create list,
2011 Apr 04
2
reading from text file that have different rowlength and create a data frame
Hi R-experts I have many text files to read and combined them into one into R that are output from other programs. My textfile have unbalanced number of rows for example: ;this is example ; r help Var1 Var2 Var3 Var4 Var5 0 0.05 0.01 12 1 0.04 0.06 18 A 2 0.05 0.08 14 3 0.01 0.06
2012 Jan 10
4
Sum of a couple of variables of which a few have NA values
Dear everyone, I have looked all over the internet but I cannot find a way to solve my problem. In my data I want to sum a couple of variables. Some of these variables have NA values, and when I add them together, the result is NA dat <- data.frame( id = gl(5,1), var1 = rnorm(5, 10), var2 = rnorm(5, 7), var3 = rnorm(5, 6), var4 = rnorm(5, 3), var5 = rnorm(5, 8) ) dat[3,3] <- NA dat[4,5]
2012 Mar 10
1
Use different panel functions with lattice
Hi, I have a data.frame df with names(df) = c("Var1", "Var2", "Var3", "Var4") and I plot data with xyplot(Var1+Var2~Var3|Var4, data=df) I want to use different panel functions for Var1 and Var2. How can I do ? Something like : panel.mypanel = function(x, y, ...) { if (Var1) panel.Var1Panel(x, y, ...) else panel.Var2Panel(x, y, ...) }
2006 Jan 11
1
updating formula inside function
Dear R-Helpers Given a function like foo <- function(data,var1,var2,var3) { f <- formula(paste(var1,'~',paste(var2,var3,sep='+'),sep='')) linmod <- lm(f) return(linmod) } By typing foo(mydata,'a','b','c') I get the result of the linear model a~b+c. How can I rewrite the function so that the formula can be updated inside the function,
2011 Aug 29
2
splitting into multiple dataframes and then create a loop to work
Dear All Sorry for this simple question, I could not solve it by spending days. My data looks like this: # data set.seed(1234) clvar <- c( rep(1, 10), rep(2, 10), rep(3, 10), rep(4, 10)) # I have 100 level for this factor var; yvar <- rnorm(40, 10,6); var1 <- rnorm(40, 10,4); var2 <- rnorm(40, 10,4); var3 <- rnorm(40, 5, 2); var4 <- rnorm(40, 10, 3); var5 <- rnorm(40, 15,
2017 Oct 10
1
About multiple panels with limited space in-between
Hi R users, I have a question about plotting. The following two datasets are an example. What I have in mind is like the attached figure, but just have two rows, top row is for DF1, bottom row is for DF2. The top and bottom rows, have x-axis as var1, var2, var3, etc, while the y-axis represents A. For each row, only the leftmost panel has y-axis ticks and label. For the two rows, only the bottom
2012 Jul 05
4
Exclude missing values on only 1 variable
Hello, I have many hundred variables in my longitudinal dataset and lots of missings. In order to plot data I need to remove missings. If I do > data <- na.omit(data) that will reduce my dataset to 2% of its original size ;) So I only need to listwise delete missings on 3 variables (the ones I am plotting). data$variable1 <-na.omit(data$variable1) does not work. Thank you
2010 Nov 08
2
Several lattice plots on one page
Dear all, I am trying (!!!) to generate pdfs that have 8 plots on one page: df = data.frame( day = c(1,2,3,4), var1 = c(1,2,3,4), var2 = c(100,200,300,4000), var3 = c(10,20,300,40000), var4 = c(100000,20000,30000,4000), var5 = c(10,20,30,40), var6 = c(0.001,0.002,0.003,0.004), var7 = c(123,223,123,412), var8 = c(213,123,234,435), all = as.factor(c(1,1,1,1)))
2007 Oct 15
2
Variable which has the maximum value of DF
Hi, Suppose I have a data.frame like this Lines <- "var1 var2 var3 var4 var5 var6 0 2 1 2 0 0 2 3 7 6 0 1 1.5 4 9 9 6 0 1.0 6 10 22 3 3 " DF <- read.table(textConnection(Lines), skip=1) names(DF) <- scan(textConnection(Lines), what = "", nlines = 1) How do I find the