Displaying 20 results from an estimated 66 matches for "batholdi".
Did you mean:
batholdy
2012 Dec 25
5
aggregate / collapse big data frame efficiently
Hi,
I need to aggregate rows of a data.frame by computing the mean for rows with the same factor-level on one factor-variable;
here is the sample code:
x <- data.frame(rep(letters,2), rnorm(52), rnorm(52), rnorm(52))
aggregate(x, list(x[,1]), mean)
Now my problem is, that the actual data-set is much bigger (120 rows and approximately 100.000 columns) ? and it takes very very long
2013 Feb 26
4
cut a vector in equal parts
Hi,
I would like to cut a vector of values in parts.
Each part should have an equal number of elements.
for example:
x <- (rnorm(500)^2)
now I want 5 vectors each with 100 elements.
The first vector should include the 100 lowest values of x and so on
(so that the fifth vector contains the 100 highest values of x).
thanks for any help!
2013 Jan 11
3
aggregate data.frame based on column class
Hi,
When using the aggregate function to aggregate a data.frame by one or more grouping variables I often have the problem, that I want the mean for some numeric variables but the unique value for factor variables.
So for example in this data-frame:
data <- data.frame(x = rnorm(10,1,2), group = c(rep(1,5), rep(2,5)), gender =c(rep('m',5), rep('f',5)))
aggregate(data,
2011 Sep 09
3
split variable / create categories
Hi,
is there a function or an easy way to convert a variable with continuous values into a categorial variable (with x levels)?
here is what I mean:
I want to transform x:
x <- c(3.2, 1.5, 6.8, 6.9, 8.5, 9.6, 1.1, 0.6)
into a 'categorial'-variable with four levels so that I get:
[1] 2 2 3 3 4 4 1 1
so each element is converted into its rank- value / categorial-value
(in
2011 Aug 22
2
test if vector contains elements of another vector (disregarding the position)
Hi,
I have the following problem:
I have two vectors:
i <- c('a','c','g','h','b','d','f','k','l','e','i')
j <- c('a', 'b', 'c')
now I would like to generate a vector with the length of i that
has zeros where i[x] != any element of j
and 1 where i[x] == any element of j.
2012 Jan 29
2
apply lm() to each row of a matrix
Hi,
I would like to fit lm-models to a matrix with 'samples' of a dependent variable (each row represents one sample of the dependent variable).
The independent variable is a vector that stays the same:
y <- c(1:10)
x <- matrix(rnorm(5*10,0,1), 5, 10)
now I would like to avoid looping over the rows, since my original matrix is much larger;
for(t in 1:dim(x)[1]) {
2009 Nov 18
2
error message; ylim + log="y"
Hi,
I get a lot of error messages with this command, but I don't understand why;
plot(c(),c(), xlim=c(1,10), ylim=c(0,10000), log="y")
thanks for any help!
[[alternative HTML version deleted]]
2011 Oct 11
2
replicate data.frame n times
Hi,
is there a way to replicate a data.frame like you can replicate the entries of a vector (with the repeat-function)?
I want to do this:
x <- data.frame(x, x)
(where x is a data.frame).
but n times.
And it should be as cpu / memory efficient as possible, since n is pretty big in my case.
thanks for any suggestions!
2011 Oct 05
2
mean of 3D arrays
Hi,
I have multiple three dimensional arrays.
Like this:
x1 <- array(rnorm(1000, 1, 2), dim=c(10, 10, 10))
x2 <- array(rnorm(1000, 1, 2), dim=c(10, 10, 10))
x3 <- array(rnorm(1000, 1, 2), dim=c(10, 10, 10))
Now I would like to compute the mean for each corresponding cell.
As a result I want to get one 3D array (10 x 10 x 10) in which at position x, y, z is the mean of the
2010 Feb 09
3
split strings in a vector and convert it to a data.frame
hi,
I have a vector full of strings like;
xy_100_ab xy_101_ab xy_102_ab xy_103_ab
I want to seperate each string in three pieces and the separator should be the "_"
at the end I want a data.frame like:
column1 column2 column3
xy 100 ab
xy 101 ab
xy 102 ab
xy 103 ab
I tried strsplit but I couldn't figure out how to convert the list I get into a data.frame.
I just
2009 Sep 17
3
latex code in R -> convert to pdf
hi,
is it possible to convert latex code to pdf in R (like a latex-program
would do it)?
Is there a package that comes with this capabilities?
My problem is that I want to generate tables automatically -
and I can't use a latex editor at that computer ...
Besides latex ... are there good ways to generate tables in R?
thanks for any suggestions!
2011 Oct 05
3
do calculations as defined by a string / expand mathematical statements in R
Dear R-group,
is there a way to perform calculations that are defined in a string format?
for example I have different variables:
x1 <- 3
x2 <- 1
x4 <- 1
and a string-variable:
do <- 'x1 + x2 + x3'
Is there any way to perform what the variable 'do'-describes
(just like the formula-element but more elemental)?
Perhaps my idea to solve my problem is a little
2009 Mar 05
3
text at the upper left corner outside of the plot region
Hi,
is there a way to place text at the upper left corner (or another
corner) of the plot?
I want to place it really at the upper left corner of the whole plot
(the file I get),
not at the upper left corner of the plot-region.
I tried text() and mtext(), and corner.label() of the plotrix package
but it didn't work out.
thanks!
2009 Jul 11
2
mann-whitney U-test - U-value
Hi,
I know that I can perform a Mann-Whitney U test with wilcox.test(x,y)
But instead of an U-value I get a W-Value.
Is it possible to change this?
2009 Aug 26
2
find numbers in a line with letters
hi,
is there an easy way to extract numbers from a string?
for example I have;
"this Item costs 3.32 Dollars"
is there an easy way to extract the 3.32 as a number?
thanks!
2010 Mar 30
2
open help files in browser
Hi,
Is there a way to open help files in the default web browser instead of a new R-window
when I use the help-functions (like ?, help.search() etc.)?
thanks!
2012 Jan 21
2
sequentially summing up a elements of a vector
Hi,
I have a somewhat abstract and tricky problem (at least for me).
Perhaps someone here can help me:
I would like to convert:
x <- c(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0)
into
x <- c(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4)
every 1 in x marks kind of a 'border' which is separated in different 'regions' in the
2012 Sep 14
2
compare different data-formats
Hi,
I have two data-frames which I want to match by a date-variable.
The problem now is, that the date-variable has a different format in this two data-frames.
So simply matching by this variable wouldn't work.
In the one data-frame the date-variable contains strings that look like this:
14.Aug.2012-16:32
3.Sep.2012-16:50
etc.
in the other data-frame the date-variable looks like this:
2012 Dec 19
2
create stratified splits
Hi,
I have a vector like:
r <- runif(100)
Now I would like to split r into 10 pieces (each with 10 elements) ?
but the 'pieces' should be roughly similar with regard to mean and sd.
what is an efficient way to do this in R?
thanks!
2011 Oct 18
2
control the conversion of factor to numeric
Dear R-list,
I currently have to convert a data.frame with several factor-variables to a numeric matrix.
Now the problem is, that the order of the factor-labels don't match the order I would like to use.
for example, let's assume I have this factor-variable in my data-frame:
x <- factor(rep(1:4, 5), labels=c("slightly disagree", "disagree", "agree",