Displaying 20 results from an estimated 800 matches similar to: "Subsetting a data frame with multiple values and exclusions."
2011 Dec 05
1
Subsetting a data frame
Hi R users,
I really need help with subsetting data frames:
I have a large database of medical records and I want to be able to match
patterns from a list of search terms .
I've used this simplified data frame in a previous example:
db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1,
2, 1.3, 3), test2 = c(56L, 27L, 58L,
2011 Mar 10
2
within group sequential subtraction
Hi Everyone,
I would like to do sequential subtractions within a group so that I know the
time between separate observations for a group of individuals.
My data:
data <- structure(list(group = c("IND1", "IND1", "IND2",
"IND2", "IND2", "IND3", "IND4", "IND5",
"IND6", "IND6"), date_obs =
2011 Mar 09
2
Cleaning date columns
Hi Everyone,
I have the following problem:
data <- structure(list(prochi = c("IND1", "IND1", "IND1",
"IND2", "IND2", "IND2", "IND2", "IND3",
"IND4", "IND5"), date_admission = structure(c(6468,
6470, 7063, 9981, 9983, 14186, 14372, 5129, 9767, 11168), class = "Date")),
.Names =
2012 Jul 17
1
Stats question: Comparison of the same individuals during two exposure times
Hi,
I'm hoping that someone will be able to help. I would like to compare how
covariates associate with the risk of a binary outcome during two periods.
Period 1 will be non-exposure to a treatment and period 2 will be exposure
to a treatment. The same individuals will be examined in each group but I
want to be able to compare the association of certain covariates between the
two groups to
2010 Mar 12
7
sqldf not joining all the fields
Dear R users,
I have two data frames that were read from text files as follows:
x_data <- read.table("x.txt", header = TRUE, sep = "|", quote = "\"'",
dec = ".",as.is = TRUE,na.strings = "NA",colClasses = NA,
nrows = 3864284,
skip = 0, check.names = TRUE,fill=TRUE,
strip.white = TRUE,
2010 Feb 20
3
Rearranging a data frame for multiple observations
Hi there,
I think I'm struggling with a fairly simple problem but can't seem to solve
it. I have multiple observations for one unique identifier. Ultimately I
want to end up with one line per identifier with multiple observations in
rows. I'm really stuck any help would be really appreciated.
CAO0337134 05/09/95
CAO0337134 27/09/05
CAO0347741 10/10/04
CAO0347741 12/10/04
2009 Sep 11
2
Accumulating results from "for" loop in a list/array
Dear R users,
I would like to accumulate objects generated from 'for' loop to a list or
array.
To illustrate the problem, arbitrary data set and script is shown below,
x <- data.frame(a = c(rep("n",3),rep("y",2),rep("n",3),rep("y",2)), b =
c(rep("y",2),rep("n",4),rep("y",3),"n"), c =
2011 Aug 10
2
choosing selective data with permutations
Hello,
I am a R beginner and hoping to obtain some hints or suggestions about
using permutations to sort a data set I have.
Here is an example dataset:
Ind1 11 00 12 15 28
Ind2 21 33 22 67 52
Ind3 22 45 21 22 56
Ind4 11 25 74 77 42
Ind5 41 32 67 45 22
This will be read into a variable using read.table. What I want to do
is permute these individuals and every
2011 Jul 25
1
Cox's regression analysis with Left truncated data
Hi,
I have a fairly simple question. I would like to use the survival package
to perform an analysis on data where an event can have occurred before
individuals were recruited into a study. I'm not sure how to do this using
the Surv() function. I would have a date of an event and then the enrolment
date would be after that. How do I put these two dates into the survival
function?
Thank
2010 Mar 03
1
Subset using partial values
Hi everyone,
I would like to subset a data.frame using partial values.
For example I have the following data.frame:
PROCHI Main_condition
1234 411
1235 4110
1236 4111
1237 I20
1238 I201
1239 I202
Now let's say that I use the Subset function. Ordinarily I would use it as
follows Subset(x, Main_condition=="411"|Main_condition=="4110" etc to get
2009 Aug 09
1
problem adding columns to matrix
Hi all, i purchased a copy of the book Morphometrics with R by Springer.
at the end of each chapter there are exercises to train what you just
read and (hope) learned...
so i have this problem:
Define a hypothetical data frame containing five measurments normally
distributed(size,head,pectoral,area,weight) for four individuals
(named ind1, ind2, etc). ADD A COLUMN corresponding to the
2010 Sep 06
3
Finding the two most recent dates
Dear R help,
I have the following data frame:
structure(list(prochi = c("ind_1", "ind_1", "ind_1",
"ind_1", "ind_1", "ind_1", "ind_1", "ind_1",
"ind_1", "ind_1"), date_1st_event = structure(c(14784,
14784, 14784, 14784, 14784, 14784, 14784, 14784, 14784, 14784
), class = "Date"),
2010 Mar 15
1
inner join sqldf
Hi,
I have two dataframes that have some common columns. I would like to join
them by the common columns prochi and prescribed_date as there are duplicate
prochis but they will be made unique by date. I tried doing an inner join
but that just duplicated the columns whereas I would like the information
from the test_sql_tsf to fill the NAs in the test_sql_psd common columns.
require(sqldf)
2008 Oct 29
1
Subsetting data in a loop
I need some help with sub-setting my data. I am trying to divide a data frame into multiple data frames based on the year collected, and stored in a list with each new data frame labeled with "year X" where X is the year the data was collected. When I run my current code I get nine error messages stating
"In one_year[name] <- myear : number of items to replace is not a
2001 Jul 25
2
using compiled fortran in R
Hi,
I would like to use a Fortran subroutine in R. I have checked the R
docs and Newsletter,
but..., I am unable to load an object file into R.
The steps I have taken are (on Debian Linux/recent Intel-type chip ):
1. g77 -c hello.f
to create hello.o
2. mymachine> R
to start R
3. > dyn.load("hello.o")
at which point I am getting the error msg:
Error in
2012 Jun 18
6
Trying to speed up an if/else statement in simulations
Dear R-help,
I am trying to write a function to simulate datasets of size n which contain
two time-to-event outcome variables with associated 'Event'/'Censored'
indicator variables (flag1 and flag2 respectively). One of these indicator
variables needs to be dependent on the other, so I am creating the first and
trying to use this to create the second using an if/else statement.
2009 Apr 29
3
2 way ANOVA with possible pseudoreplication
Hi,
I have an experiment with 2 independant factors which I have been trying to
analyse in R. The problem is that there are several data points recorded on
the same animal. However, no combination of treatments is repeated on the
same animal. All possible combinations of treatments are done in a random
order with as many points as possible being done on 1 animal before moving
onto the next.
The
2010 May 07
2
glm contrasts
Hi,
I have some data on the effect of cycle shape (categorical) and
frequency (continuous) on the efficiency of muscle contraction. My
minimum adequate model is:
m15<-glm(efficiency~cycle.shape*freq, family=quasipoisson)
However, I wish to know where significant differences lie between
specific combinations of treatments. I guess I want an equivalent of a
post hoc test following an
2011 Dec 09
2
Error using function MVN in package MCLUST: Fortran symbol name not in DLL for package
Hi All,
I need to fit a mutlivariate normal model to a dataset in order to obtain the mean and covariance parameters. I see that the MVN function in the MCLUST package can do this, however when I try to run even the simplest example provided in the documentation, as below, I get the following error:
n <- 1000
set.seed(0)
x <- rnorm(n, mean = -1, sd = 2)
mvn(modelName = "X", x)
2003 Jan 22
3
brian.casey@mscsoftware.com - Out of office
Is it possible to suspend this user from getting mail for a week otherwise we are going to get loads of "out of office" reports???????
Cheers
-----Original Message-----
From: brian.casey@mscsoftware.com [mailto:brian.casey@mscsoftware.com]
Sent: 22 January 2003 13:34
To: samba@lists.samba.org
Subject: [Samba] I am out of the office.
I will be out of the office starting 01/21/2003