Displaying 20 results from an estimated 8000 matches similar to: "longitudinal study"
2012 Nov 13
4
for loop
HI,
You can do this in many ways:
dat1<-read.table(text="
med1,med2,med3????
?1,0,1??????
0,1,1???
2,0,0
",sep=",",header=TRUE)??
#1st method
library(reshape)
dat2<-melt(dat1)
dat3<-aggregate(dat2$value,by=list(dat2$variable),sum)
?colnames(dat3)<-c("name","sum(n11)")
?dat3
#? name sum(n11)
#1 med1??????? 3
#2 med2??????? 1
#3 med3??????? 2
2013 Feb 23
5
Selecting First Incidence from Longitudinal Data
I have a longitudinal competing risk data of the form:
ID COMPL SEX HEREDITY
1 0 1 2
1 0 1 2
1 3 1 2
2 0 0 1
2 1 0 1
2 2 0 1
2 2 0 1
3 0 0 1
3 0 0 1
3 0 0 1
3 0 0 1
3 2 0 1
4 0 1 2
4 0 1
2012 Oct 01
3
(no subject)
Hello,
I am a new R -user and request your help for the following problem.
I need to merge two dataset of longitudinal study which has two column
(id and respose) common. when I used merge option to join the datas
side be side, because of the repeated subject id, I got larger data
set which is not accurate.
I would like to connect twi data sets by id and response in such a
way that data are
2013 May 07
4
create unique ID for each group
Hey All,
I have a dataset(dat1) like this:
ObsNumber ID Weight
1 0001 12
2 0001 13
3 0001 14
4 0002 16
5 0002 17
And another dataset(dat2) like this:
ID Height
0001 3.2
0001 2.6
0001
2013 Jan 04
2
Can you help me please
HI Fares,
You could try this:
dat1<- read.table(text="
date????? donation
3jan2003?? 20235
4jan2003?? 25655
5jan2003?? 225860
6jan2003?? 289658
7jan2003?? 243889
8jan2003?? 244338
9jan2003?? 243889
",sep="",header=TRUE,stringsAsFactors=FALSE)
The post is not very specific as to what you need.? I hope this works for you.
library(xts)
2013 Mar 27
9
conditional Dataframe filling
Hi everyone:
This may be trivial but I just have not been able to figure it out.
Imagine the following dataframe:
a b c d
TRUE TRUE TRUE TRUE
FALSE FALSE FALSE TRUE
FALSE TRUE FALSE FALSE
I would like to create a new dataframe, in which TRUE gets 0 but if
false then add 1 to the cell to the left. So the results for the
example above should be something like:
a b c
2013 Apr 29
4
expanding a presence only dataset into presence/absence
Hello,
I'm working with a very large dataset (250,000+ lines in its' current form)
that includes presence only data on various species (which is nested within
different sites and sampling dates). I need to convert this into a dataset
with presence/absence for each species. For example, I would like to expand
"My current data" to "Desired data":
My current data
2012 Jul 24
5
First value in a row
Hi.
This is likely a trivial problem but have not found a solution.
Imagine the following dataframe:
Lat Lon x1 x2 x3
01 10 NA NA .1
01 11 NA .2 .3
01 12 .4 .5 .6
I want to generate another column that consist of the first value in
each row from columns x1 to x3. That is
NewColumn
.1
.2
.4
Any input greatly appreciated,
Thanks,
Camilo
Camilo Mora, Ph.D.
2013 Feb 17
6
histogram
HI Elisa,
You could use ?cut()
vec1<-c(33,18,13,47,30,10,6,21,39,25,40,29,14,16,44,1,41,4,15,20,46,32,38,5,31,12,48,27,36,24,34,2,35,11,42,9,8,7,26,22,43,17,19,28,23,3,49,37,50,45)
label1<-unlist(lapply(mapply(c,lapply(seq(0,45,5),function(x) x),lapply(seq(5,50,5),function(x) x),SIMPLIFY=FALSE),function(i) paste(i[1],"<x<=",i[2],sep="")))
2013 Jun 10
4
Combining CSV data
Hello R community,
I am trying to combine two CSV files that look like this:
File A
Row_ID_CR, Data1, Data2, Data3
1, aa, bb, cc
2, dd, ee, ff
File B
Row_ID_N, Src_Row_ID, DataN1
1a, 1, This is comment 1
2a, 1, This is comment 2
3a,
2013 May 07
4
how to calculate the mean in a period of time?
Hi,
Your question is still not clear.
May be this helps:
dat2<- read.table(text="
patient_id????? t???????? scores
1????????????????????? 0??????????????? 1.6
1????????????????????? 1??????????????? 2.6
1????????????????????? 2???????????????? 2.2
1????????????????????? 3???????????????? 1.8
2????????????????????? 0????????????????? 2.3
2?????????????????????? 2???????????????? 2.5
2012 Aug 13
4
if else elseif for data frames
Hi all,
It seems like I cannot use normal 'if' for data frames. What would be the
best way to do the following.
if data$col1='high'
data$col2='H'
else if data$col1='Neutral'
data$col2='N'
else if data$col='low'
data$col2='L'
else
#chuch a warning?
Note that col2 was not an existing column and was newly assigned for this
2013 Apr 12
2
split date and time
Hi R experts,
For example I have a dataset looks like this:
Number TimeStamp Value
1 1/1/2013 0:00 1
2 1/1/2013 0:01 2
3 1/1/2013 0:03 3
How can I split the "TimeStamp" Column into two and return a new table like
this:
Number Date Time Value
1 1/1/2013 0:00 1
2 1/1/2013 0:01 2
3 1/1/2013 0:03 3
Thank!
[[alternative HTML version
2013 Mar 19
4
Copying rows in data frames
Hi,
I'm trying to copy the first row of one data frame to another. This is the
statement I am using :
df2[1,]<-df1[1,];
I have printed them out separately:
df1[1,] = A C D E F
But after copying:
df2[1,] = 96 29 88 122 68
Why isn't it copying? They are both data frames, and "as.character" isn't
working either.
Thanks for your input :)
[[alternative HTML version
2012 Aug 07
5
summing and combining rows
Hello,
I have a data set that needs to be combined so that rows are summed by a
group based on a certain variable. I'm pretty sure rowsum() or rowsums()
can do this but it's difficult for me to figure out how it will work for
my data based on the examples I've read.
My data are structured like this:
Plot SizeClass Stems
12 Class3 1
12 Class4
2013 Mar 22
3
Distance calculation
Hi Elisa,
I hope this is what you wanted.
dat1<-read.csv("peaks.csv",sep=",")
#Subset
dat2<-dat1[1:5,]
res1<-do.call(cbind,lapply(seq_len(nrow(dat2)),function(i) do.call(rbind,lapply(split(rbind(dat2[i,],dat2[-i,]),1:nrow(rbind(dat2[i,],dat2[-i,]))), function(x) {x1<-rbind(dat2[i,],x);
2013 Aug 29
4
Add new calculated column to data frame
Hi,
I have a following data set:
id event time (in sec)
1 add 1373502892
2 add 1373502972
3 delete 1373502995
4 view 1373503896
5 add 1373503996
...
I'd like to add new column "time on task" which is time elapsed between two
events (id2 - id1...). What would be the best approach to do that?
Thanks,
Srecko
[[alternative HTML
2012 Sep 01
5
R_closest date
Hi,
I have encountered an issue about finding a date closest to another date
So this is how the data frame looks like:
PT_ID IDX_DT OBS_DATE DAYS_DIFF OBS_VALUE CATEGORY
13 4549 2002-08-21 2002-08-20 -1 183 2
14 4549 2002-08-21 2002-11-14 85 91 1
15 4549 2002-08-21 2003-02-18 181 89 1
16 4549 2002-08-21 2003-05-15
2013 Apr 04
3
summing vectors
Hi All,
Year Area Q Bin FD
I have a large dataset I need to re-structure. It looks something
like this: 2000 1 1 5 0 2000 1 1 10 1 2000 1 1 15 23 2000 1 1 20 12 2000
1 1 25 1 2000 2 1 5 1 2000 2 1 10 3 2000 2 1 15 15 2000 2 1 20 11 2000
2 1 25 3 2000 1 2 5 0 2000 1 2 10 1 2000 1 2 15 23 2000 1 2 20 12 2000
1 2 25 1 2000 2 2 5 1 2000 2 2 10 3 2000 2 2 15 15 2000 2 2 20 11
2013 Jun 06
2
generating a bar chart with two axis for co-linear variable
Hello Dimitris,
I was goggling for some help on Sensitivity vs 1-specificity and saw your link.
I hope you can be of help to me in one of the issue that I am facing in generating combo chart(bar chart and plot). I am a novice and have some difficulty in getting this logic correct.
I am give a dataset (I am attaching a sample dataset).
I am using a barplot() and passing values for