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
2
Automating plot labelling in custom function in lapply() ?
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) invisible(lapply(dat, function(x) { plot(density(x), main = deparse(substitute(x))) } ) )
2001 Aug 17
0
Solved: Help plotting some data
Hi! The other day I asked a couple of questions about plotting some data. Firstly I wanted to specify the colours used for the text plotted using: > text(chem.predict[,1:2], labels = km$cluster) Matt Wiener suggested: > col.vec <- c("black", "red", "blue") > text(chem.predict[,1:2], labels = km$cluster, color = col.vec[km$clusters]) Cheers Matt, that
2012 May 09
0
serie de tiempo incompleta: rellenar sólo fechas (claudiomet)
Hola.. yo lo haría de la siguiente manera ... En excel:genero una columna con la serie de fechas continuas ... con la función buscarv, agrego las variables que tienen dato a esta serie.. en base a la fecha muy largo y mecánico para mi gusto.... En R ..de igual manera genero el vector de fechas require(chron)# crear el vector continuo de fechasfch01 <- data.frame(''fch'' =
2011 Jan 19
3
lme-post hoc
Hi all, I analysed my data with lme and after that I spent a lot of time for mean separation of treatments (post hoc). But still I couldn’t make through it. This is my data set and R scripts I tried. replication fertilizer variety plot height 1 level1 var1 1504 52 1 level1 var3 1506 59 1 level1 var4 1509 54 1 level1 var2 1510 48 2 level1 var1 2604 47 2 level1 var4 2606 51 2 level1 var3
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
2008 Sep 30
0
calculating weighted correlation coefficients
Dear Help, I'm trying to calculate a weighted correlation matrix from a data frame with 6 columns (variables) and 297 observations extracted from the regression. The last column is a weight column which I want to apply. $ model :'data.frame': 297 obs. of 6 variables: ..$ VAR1 : num [1:297] 5.21 9.82 8.08 0.33 8.7 6.82 3.94 4 0 5 ... ..$ VAR2 : num [1:297]
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
2009 Dec 02
1
Lattice: multiple data sets on same plot
Hi, I have two data sets; one is a population and the other a sample of that population. I am trying to plot both on the same trellis display. # Example data set with two numerical attributes and two categorical pop <- data.frame(var1=rnorm(2000, 2000, 500), var2=rnorm(2000, 2000, 500)) cat<-(runif(2000)<=.5)+0 for(i in 1:length(cat)){ if(cat[i] == 0){ pop[i,"cat1"] =
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
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,
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, ...) }
2008 Oct 12
1
Conditionally skip over "for(..){" and "}"??
Hi Folks, I'm wondering if there's a secret trick to achieve the following. I have some big code for analysis related to a named variable, which will be one of several in the columns of a dataframe, and I would like to be able to choose between a run for just one of these variables, or a run which loops over them all. So, for a single run, I could have the following kind of thing in a
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,
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]
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
2010 Jul 12
0
How do I convert a XML file to a data.frame?
Hi, I have a problem converting a XML file, via the XML package, to a data.frame. The XML file looks like this: <Transaction> <ID value="0044"/> <Var1 value="XYZ159"/> <Var2 value="_"/> <Var3 value="AMR1.0-INT-1005"/> <Var4 value="2010-05-25 10:44:16:673"/> <Var5 value="1"/>
2010 Jan 18
1
problem of data manipulation
Hello, See my problem below. a<-data.frame(c("s","c","c","n","n","n"),c(rep(1,3),rep(2,3)),c(rep(2,3),rep(1,3)),c("01/01/1999","10/02/2000","13/02/2000","11/02/2000","15/02/2000","23/02/2000"))
2002 Jun 20
2
cat output To data.frame.rows ?
Hi, is there a possibilty to get my function output with "cat " as data.frame.rows with variables ? Var1---------------- 8 15 1 3 Var2---------------- 0.170 0.319 0.0213 0.0638 Var3---------------- 83.8 88.6 90 75 Var4---------------- 84.3 84.3 100 83.3 Var5---------------- 62.5 56 20 53.3 function(data.frame) { .... ....
2009 Jun 04
1
[LLVMdev] Structure Alignment
struct xfirstStru { int var1; double var2; int var3; char *var4; }; %FIRSTSTRU_PLUSPLUS_TOTVS. = type { i32, double, i32, i8* } Hi, I had not applied the layout at run time, only during the emission of the .bc. Now it's running ok when I allocate the structure point at LLVM side, but, when I allocate the structure pointer in the C