Displaying 20 results from an estimated 8000 matches similar to: "Averaging dataframes that are stored in a list"
2011 Jun 23
2
Merging multiple data sets
Hi,
I am trying to merge data similar to the example data below
> dat0
id var1 var2 var3
2 1 0 1
3 1 0 1
4 0 1 1
5 0 1 1
> dat1
id var4 var5 var6
2 1 0 1
3 1 0 1
6 0 1 1
7 0 1 1
> dat2
id
2009 Dec 15
1
Changing Column names in (Output) csv file
Dear R helpers
Following is a part of R code.
data_lab <- expand.grid(c("R11", "R12", "R13"), c("R21", "R22", "R23"), c("R31", "R32", "R33"), c("R41", "R42", "R43"), c("R51", "R52", "R53"), c("R61", "R62", "R63"),
2009 Mar 09
3
How to write a function that accepts unlimited number of input arguments?
Dear R-helpers:
I am an R newbie and have a question related to writing functions that
accept unlimited number of input arguments.
(I tried to peek into functions such as paste and cbind, but failed, I
cannot see their codes..)
Can someone kindly show me through a summation example?
Say, we have input scalar, 1 2 3 4 5
then the ideal function, say sum.test, can do
2010 Jan 25
5
Data transformation
Dear all,
I have a dataset that looks like this:
x <- read.table(textConnection("col1 col2
3 1
2 2
4 7
8 6
5 10"), header=TRUE)
I want to rewrite it as below:
var1 var2 var3 var4 var5 var6 var7 var8 var9 var10
1 0 1 0 0 0 0 0 0 0
0 2 0 0 0 0 0 0 0 0
0 0 0 1 0 0
2009 Apr 16
3
segment between points on different plots
Hi,
I need to draw a line segment between two points on different plots in the
same multigraph.I've tried looking at the zoominplot function in plotrix but
havent understood much.any help is appreciated
~Aks
[[alternative HTML version deleted]]
2009 Sep 14
2
Which "apply" function to use?
Dear All,
I have a problem which *should* be pretty straightforward to resolve - but I can't work out how!
I have a list of 3 coefficient estimates for 4 different datasets:
Coefs<-list(c(1,0.6,0.5),c(0.98,0.65,0.4),c(1.05,0.55,0.45),c(0.99,0.50,0.47))
All I want to do is take the sum (or mean) of each coefficient across the 4 datasets.
I can do this using a "for" loop, but
2009 Jun 25
3
grid.polygon() + color gradient
Hi,
I wonder whether there is a way to generate a polygon (a triangle in
my case) with color gradient using grid.polygon() in package grid?
I tried something like
library(grid)
grid.polygon(x=c(0, 0.5, 1), y=c(0.5, 1, 0.5), gp=gpar(col=NA,
fill=colorRampPalette(c("green", "lightgray"),
space="Lab")(200)))
But am only
2009 Sep 14
2
how to recode with an if-type statement
I'm sure this is easy, but I'm having a hard time figuring out how to
recode some data in R.
I have a variable "numpeers" which is valued 1, 2, or 3. I also have
three other variables called "w9zd9_1," "w9zd9_2," and "w9zd9_3." I
want to use these variables to create a new item called "distot."
Specifically, here is what I want to do:
2008 Dec 30
3
Componentwise means of a list of matrices?
Dear useRs,
I have a list, each entry of which is a matrix of constant dimensions.
Is there a good way (i.e., not using a for loop) to apply a mean to each
matrix entry *across list entries*?
Example:
foo <- list(rbind(c(1,2,3),c(4,5,6)),rbind(c(7,8,9),c(10,11,12)))
some.sort.of.apply(foo,FUN=mean)
I'm looking for a componentwise mean across the two entries of foo,
i.e., the
2006 Feb 21
6
How to sum values across multiple variables using a wildcard?
I have a dataframe called "data" with 5 records (in rows) each of
which has been scored on each of many variables (in columns).
Five of the variables are named var1, var2, var3, var4, var5 using
headers. The other variables are named using other conventions.
I can create a new variable called var6 with the value 15 for each
record with this code:
> var6=var1+var2+var3+var4+var5
2009 Dec 07
2
How to apply five lines of code to ten dataframes?
Hello R-helpers,
I have 10 dataframes (named data1, data2, ... data10) and I would like to
add 5 new columns to each dataframe using the following code:
data1$LogDepth<-log10(data1[,2]/data1[,4])
data1$LogArea<-log10(data1[,3]/data1[,5])
data1$p<-2*data1[,6]/data1[,7]
data1$Exp<-data1[,2]^(2/data1[,8])
data1$s<-data1[,3]/data1[,9]
...but I would prefer not to repeat this chunk of
2009 Jun 01
1
Fwd: subset dataframe/list
--- the forwarded message follows ---
-------------- next part --------------
An embedded message was scrubbed...
From: "Cecilia Carmo" <cecilia.carmo at ua.pt>
Subject: Re: [R] subset dataframe/list
Date: Mon, 01 Jun 2009 21:33:15 +0100
Size: 3657
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090601/921f7638/attachment-0002.mht>
2011 Nov 04
1
How to use 'prcomp' with CLUSPLOT?
Hello,
I have a large data set that has more columns than rows (sample data below). I am trying to perform a partitioning cluster analysis and then plot that using pca. I have tried using CLUSPLOT(), but that only allows for 'princomp' where I need 'prcomp' as I do not want to reduce my columns. Is there a way to edit the CLUSPLOT() code to use 'prcomp', please?
#
2012 Oct 25
1
cut point in ROC
var1
var2
var3
var4
var5
var6
var7
var8
var9
var10
gold
2
3
1
2
4
0
1
4
4
3
2
2
4
2
4
3
4
2
4
4
4
2
3
3
0
0
4
1
0
2
4
4
2
1
4
0
3
2
0
0
2
4
4
2
3
4
0
2
2
0
0
0
3
4
2
2
2
3
2
2
0
0
0
2
4
2
2
4
1
1
2
0
0
3
3
3
2
3
4
1
4
0
0
0
0
3
4
2
3
1
0
2
2
1
0
2
3
3
2
0
3
1
1
1
1
2
1
2
3
2
1
2004 Jan 08
1
(no subject)
Hello,
I have trouble converting a character string to a R object. Let me describe this by an example;
> dim(a)
[1] 270 14
> dim("a")
NULL
> names(a)
[1] "Var1" "Var2" "Var3" "Var4" "Var5" "Var6" "Var7" "Var8" "Var9"
[10] "Var10" "Var11" "Var12"
2009 Jun 23
4
Apply as.factor (or as.numeric etc) to multiple columns
Hi R-helpers,
I have a dataframe with 60columns and I would like to convert several
columns to factor, others to numeric, and yet others to dates. Rather
than having 60 lines like this:
data$Var1<-as.factor(data$Var1)
I wonder if it's possible to write one line of code (per data type,
e.g. factor) that would apply a function (e.g., as.factor) to several
(non-contiguous) columns. So, I
2008 Aug 27
2
averaging pairs of columns in a dataframe
Dear all,
I have a dataframe with 132 columns and 100 rows. Every 2nd column is a
repeat measurement so that the columns could be titled, a a b b c c d d etc.
I would like to average the repeats such that I am left with a data frame of
66 columns (of means) and 100 rows.
I have been trying to use rowMeans but have not been able to average the
pairs of columns, only the whole dataframe.
Any
2009 Jul 21
1
legend title in qplot
Hi,
I've used the following command in qplot
qplot(a$V1,geom="histogram",binwidth=0.15,fill =
factor(a$V2),ylab="Frequency",xlab="Rate");
but the title in the legend shows up as factor(a$V2)...how can i change
this?
--
Rajesh.J
[[alternative HTML version deleted]]
2009 Jul 04
2
Shading the area between lines
Hi,
I have a graph with seven parallel horizontal lines. Is it possible to
shade the area between two adjacent lines?
Thank you in advance,
Hannu
2009 Sep 02
1
get function to return object "name"?
Dear list,
I've written a function that plots subjects. Something like:
myplot <- function(subject) { plot(subject) }
Subjects are vectors, e.g. ...
s1 <- c(200,200,190,180)
... and plotting them works fine, e.g. ...
myplot(s1)
Now I want to have "s1" etc appear in the plot title, but I don't know
how to refer to this generically (the object "name"? I tried