Displaying 20 results from an estimated 7000 matches similar to: "Newbie Question on making subsets for every element of a table column"
2011 Jan 20
4
subsets
Dear R people
Could you please help.
Basically, there are two variables in my data set. Each patient ('id')
may have one or more diseases ('diagnosis'). It looks like
id diagnosis
1 ah
2 ah
2 ihd
2 im
3 ah
3 stroke
4 ah
4 ihd
4 angina
5 ihd
..............
Q: How to make three data sets:
1. Patients with ah and ihd
2. Patients with ah but no ihd
3. Patients with ihd but no
2012 Mar 08
4
Correlation between 2 matrices but with subset of variables
Dear All,
I have two matrices A (40 x 732) and B (40 x 1230) and would like to calculate correlation between them. I can use: cor(A,B, method="pearson") to calculate correlation between all possible pairs. But the issue is that there is one-many specific mappings between A and B and I just need to calculate correlations for those pairs (not all). Some variables in A (proteins, say p1)
2012 Feb 18
4
assigning NULL to a list element
Hi everyone,
For reasons beyond the scope of this message, I'd like to append a
NULL element to the end of a list.
tmp0 <- list(a=1, b=NULL, c=3)
append(tmp0, c(d=4)) ## works as expected
append(tmp0, c(d=NULL)) ## list with a/b/c only
Given that I could use
tmp0$a <- NULL
to remove 'a', I seem to understand why appending NULL returns me the
original list... But how should I
2012 Apr 27
6
Returning the coef from two coordinates
Thank you to everyone in this forum that has been helping me with the basic R
skills while I learn to apply them.
I would like to take the coefficient of two coordinates. One of them comes
from two different columns in a table:
>A
x y
a 1 3
b 2 2
c 3 1
the other is set and for this question I'll just call it (1,1)
I've been trying to find a way to return the
2013 Apr 29
2
Adding elements in data.frame subsets and also subtracting an element from the rest elements in data.frame
Dear R forum
I have a data.frame as
cashflow_df = data.frame(instrument = c("ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC","ABC", "ABC", "PQR", "PQR",
2011 Jan 16
2
how to add a derived column to a data frame?
I have a data frame with 10 columns: A:J and I want to have the output as a data frame with 11 columns, the value of 11th column is£º
for each row, if any column can be divided by 13, then the 11th column has a values of 1, otherwise, it has a value of 0. How to do that?
input is
a=matrix(1:10000,1000,10)
dimnames(a)=list(NULL,LETTERS[1:10])
[[alternative HTML version deleted]]
2012 Aug 24
6
updating elements of a vector sequentially - is there a faster way?
I would like to know whether there is a faster way to do the below
operation (updating vec1).
My objective is to update the elements of a vector (vec1), where a
particular element i is dependent on the previous one. I need to do this on
vectors that are 1 million or longer and need to repeat that process
several hundred times. The for loop works but is slow. If there is a faster
way, please let
2011 Jan 27
2
help for a loop procedure
Hello everybody!
I’m trying to define the optimal number of surveys to detect the highest
number of species within a monitoring season/session.
To do this I want to run all the possible combinations between a set of
samples and to calculate the total number of species for each combination of
2, 3, 4 …n samples events, so that at the end I will be able to define which
is the lowest number of
2012 Feb 20
3
How to determine a subset of a binary strings?
Hi,
I need some neat ways of determing a subset of binary strings. For example,
x=c(0,0,1), y=c(0,1,1), z=c(0,1,0). So x is a subset of y and z is also a
subset of y, but x is not a subset of z.
I tried to search R functions and packages but no hits. Any ideas?
Best,
Jing
--
Jing Tang, PhD
Senior Researcher
Finnish Institute of Molecular Medicine (FIMM)
FI-00014 University of
2007 Apr 28
4
pure R code package for Windows
Dear R developers,
I am using R under Linux, but I would like to share
an extension package with some Windows users. The package
contains only data and .R scripts. There is no src directory.
So, I think I do not need a Windows machine with C compiler,
"make", "sh" and "perl". If I am wrong, please tell me.
I tried the following approaches (after verifying the
2006 Oct 11
2
expression as a parameter of binom.test (PR#9288)
Full_Name: Petr Savicky
Version: 2.4.0
OS: Fedora Core release 2
Submission from: (NULL) (62.24.91.47)
the error is
> binom.test(0.56*10000,10000)
Error in binom.test(0.56 * 10000, 10000) :
'x' must be nonnegative and integer
while
> binom.test(5600,10000)
yields correct result.
The same error occurrs for
> binom.test(0.57*10000,10000)
2009 May 03
1
suggestion for extending ?as.factor
In R-2.10.0, the development version, function as.factor() uses 17 digit
precision for conversion of numeric values to character type. This
is very good for the consistency of the resulting factor, however,
i expect that people will complain about, for example, as.factor(0.3)
being
[1] 0.29999999999999999
Levels: 0.29999999999999999
I suggest to extend the "Warning" section of
2011 Mar 18
4
subset data frame with condition
Hello,
One more question.. I have the data.frame "pop":
xloc yloc gonad ind Ene W Area
1 23 20 516.74 1 0.02 20.21 1
2 23 20 1143.20 1 0.02 20.21 1
3 23 20 250.00 1 0.02 20.21 1
4 22 15 251.98 1 0.02 18.69 2
5 22 15 598.08 1 0.02 18.69 2
6 21 19 250.00 1 0.02 20.21 3
7 22 20 251.98 1
2002 Jun 20
1
tree construction crashes (PR#1698)
Full_Name: Petr Savicky
Version: 1.5.0
OS: SuSE 7.2
Submission from: (NULL) (147.231.6.1)
The function tree() from the tree package crashes for certain input data.
All the information needed to reproduce the error (data, script, expected
error message) may be found at
http://www.cs.cas.cz/~savicky/tree_error/tree_error.tgz
Exactly the same error appeared at another computer running some RedHat
2012 Mar 22
2
Randomly select elements based on criteria
Hi,
I want to randomly pick 2 fish born the same day but I need those
individuals to be from different families. My table includes 1787 fish
distributed in 948 families. An example of a subset of fish born in one
specific day would look like:
>fish
fam born spawn
25 46 43
25 46 56
26 46 50
43 46 43
131 46 43
133 46 64
136 46 43
136 46 42
136 46 50
136 46 85
137 46 64
142 46 85
144 46 56
2012 Feb 16
2
help with e+01 number abbreviations
Dear List,
I will appreciate any advice regarding how to convert the following numbers
[I got in return by taxondive()] in numeric integers without the e.g.
6.4836e+01
abbreviations.
Thank you very much in advance,
Gian
> taxa_dive
Species Delta Delta* Lambda+ Delta+ S
Delta+
Nat1 5.0000e+00 6.4836e+01 9.5412e+01 6.7753e+02 8.7398e+01
436.99
Nat2
2012 Feb 28
7
indexing??
Hello All,
My algorithm as follows;
y <- c(1,1,1,0,0,1,0,1,0,0)
x <- c(1,0,0,1,1,0,0,1,1,0)
n <- length(x)
t <- matrix(cbind(y,x), ncol=2)
z = x+y
for(j in 1:length(x)) {
out <- vector("list", )
for(i in 1:10) {
t.s <- t[sample(n,n,replace=T),]
y.s <- t.s[,1]
x.s <- t.s[,2]
z.s <- y.s+x.s
out[[i]] <- list(ff <- (z.s), finding=any (y.s==y[j]))
kk
2011 Jun 02
4
generating random covariance matrices (with a uniform distribution of correlations)
List members,
Via searches I've seen similar discussion of this topic but have not seen
resolution of the particular issue I am experiencing. If my search on this
topic failed, I apologize for the redundancy. I am attempting to generate
random covariance matrices but would like the corresponding correlations to
be uniformly distributed between -1 and 1.
The approach I have been using is:
2012 Feb 25
5
which is the fastest way to make data.frame out of a three-dimensional array?
foo <- rnorm(30*34*12)
dim(foo) <- c(30, 34, 12)
I want to make a data.frame out of this three-dimensional array. Each dimension will be a variabel (column) in the data.frame.
I know how this can be done in a very slow way using for loops, like this:
x <- rep(seq(from = 1, to = 30), 34)
y <- as.vector(sapply(1:34, function(x) {rep(x, 30)}))
month <- as.vector(sapply(1:12,
2010 Dec 19
0
Hclust - Number of branch operations for every element
Hello everybody,
I need to know how often every element in an hierarchical cluster was
"branched" - just imagine a watering pot on the top of the hierarchical
tree -> the leafs should get water according to the number of branches
that lie before them.
For example:
a <- list() # initialize empty object
a$merge <- matrix(c(-1, -2,
-3, -4,