Displaying 20 results from an estimated 30000 matches similar to: "calculating time interval distributions"
2009 Sep 26
1
renaming intercept column when retrieving coeficients from lme using coef function
I am still fairly new to R and have a fairly rudimentary question. I am
trying to name a vector of coefficients retrieved from a multilevel model
using the coef function. I guess the default name is "Intercept" and I
cannot figure out how to rename it.
I have tried the using the code below to name the column of coefficients
ind.y derived from an lme model. Unfortunately, the
2008 Apr 19
1
resampling from distributions
Hello All,
Once again thanks for all of the help to date. I am climbing my R learning
curve. I've got a few more questions that I hope I can get some guidance on
though. I am not sure whether the etiquette is to break up multiple
questions or not but I'll keep them together here for now as it may help put
the questions in context despite the fact that the post may get a little
long.
2011 Mar 01
1
tricky (for me) merging of data...more clarity
Hi Again,
Thanks very much for your response. It seems my example got rearranged
(transposed?) after I posted it. Hopefully this example will be more
clear. I have one file (ex. sheet 1) that will have a column for
individuals (ind) and a column for the date (date). I would like to merge
this with another file (ex. sheet 2) that has both the 'ind' and date column
as well as associated
2009 Feb 12
3
get top 50 correlated item from a correlation matrix for each item
Hi,
I have a correlation matrix of about 3000 items, i.e., a 3000*3000
matrix. For each of the 3000 items, I want to get the top 50 items that
have the highest correlation with it (excluding itself) and generate a
data frame with 3 columns like ("ID", "ID2", "cor"), where ID is those
3000 items each repeat 50 times, and ID2 is the top 50 correlated items
with ID,
2007 Jul 05
1
getting values from arrays using which()
Dear R-Help,
I have an array 1260x1260, upper triangle consisting of numbers between 0 and 100, and lower triangle all NA. I can extract the index of those values say above 99 using the following code:
which(myArray>=99 , ind.arr=T)
which returns:
row col
5475 252 253
45423 764 765
46902 777 778
34146 611 962
50681 1220 1221
Now I would like to if poss print the actual value
2008 Dec 10
1
convert dataframe to matrix for cmdscale
I have a dataframe like this (toy example):
x y z
"a" "a" 0
"a" "b" 1
"a" "c" 2
"b" "a" .9
"b" "b" 0
"b" "c" 1.3
"c" "a" 2.2
"c" "b" 1.1
"c" "c" 0
The observations are from a matrix like this:
c 2.2 1.1 0.0
b 0.9 0.0
2011 Feb 27
1
tricky (for me) merging of data
Dear List,
I am having trouble with a tricky merging task. I have one data sheet that
has dates (continuous) that radio collared individuals were monitored via
telemetry. I have a different sheet containing data from instances where
individuals were recaptured and associated body condition data was recorded
(sheet 2). I would like to merge the two sheets by individual and date (I
can do this
2010 Feb 02
1
ggplot/time series with indicators question
Hello, I am trying to plot time-series data with certain weeks highlighted using symbols.
require(ggplot2)
#plotting time series data
timescale <- seq(as.Date("01/01/09","%m/%d/%y"), length.out=12, by=7)
data.all <- data.frame(
id = c(rep('111',12),rep('222',12),rep('333',12)),
week=c(timescale,timescale,timescale),
2008 Apr 06
1
row by row similarity
Hello all and thanks in advance for any advice.
I am very new to R and have searched my question but have not come up with
anything quite like what I would like to do.
My problem is:
I have a data set for individuals (rows) and values for behaviours
(columns). I would like to know the proportion of shared behaviours for all
possible pairs of individuals. The sum of shared behaviours divided by
2009 May 30
1
arithmetic problem
Hello list
I have a problem with a dataset (see toy example below) where I am trying to find the difference between two (or more numbers) and discard those observations which fall outside a set interval.
An example and further explanation:
values ind
1 2655 7A5
2 3028 7A5
3 689 ABBA-1
4 1336 ABBA-1
5 1560 ABBA-1
6 2820 ABLIM1
7 3339 ABLIM1
8
2012 Aug 17
1
Linear mixed model using R
Dear all,
I am trying to use R to fit mixed models.
Take the following example, where ind is a random effect and
sample is fixed. I wanted to fit
Model 1: values = ind + sample
Model 2: values =ind * sample
Model 3: values=ind(sample) + sample
Tried to use the below for mod1, but it did not work. Can anyone give
some help on this. Thanks so much.
mod1 <- lme(values ~ sample +
2011 Dec 16
1
optim with simulated annealing SANN for combinatorial optimization
Hi all
I am trying to solve a combinatorial optimization problem. Basically, I can
reduce my problem into the next problem:
1.- Given a NxN grid of points, with some values in each cell
2.- Find the combination of K points on the grid such that, the maximum
mean value is obtained
I took the Travel SalesMan problem example in ?optim documentation. I am
not sure if I have understood correctly
2004 May 27
2
block diagonal matrix function
Hello List
I have just written a little function that takes two matrices as
arguments and returns a large matrix that is composed of the two input
matrices in upper-left position and lower-right position with a padding
value everywhere else. (function definition and toy example below). I
need nonsquare matrices and rowname() and colname() inherited appropriately.
Two questions:
(1) Is there a
2013 Jan 03
1
interpreting results of regression using ordinal predictors in R
Dear friends,
Being very new to this, I was wondering if I could get some pointers
and guidance to interpreting the results of performing a linear
regression with ordinal predictors in R.
Here is a simple, toy example:
y <- c(-0.11, -0.49, -1.10, 0.08, 0.31, -1.21, -0.05, -0.40, -0.01,
-0.12, 0.55, 1.34, 1.00, -0.31, -0.73, -1.68, 0.38, 1.22,
-1.11, -0.20)
x <-
2011 Apr 21
1
problem subsetting of a reference class
I am trying to define subset operator for a reference class and hitting some
problem i am unable to diagnose.To give an example, here is a toy class
generator that is a wrapper around a list
tmpGEN<-setRefClass("TMP", fields=list(
namelist="list"
))
tmpGEN$methods('add'=function(obj, name){
namelist[[name]]<<-obj
})
2008 Aug 27
2
problems formating scientific collaboration data
Hello all and thanks in advance for any help or direction. I have
co-authorship data that looks like:
Paper Author Year
1 SmithKK JonesSD 2008
2 WallaceAR DarwinCA 1999
3 HawkingS 2003
I would like:
Paper Author Year
1 SmithKK 2008
1 JonesSD 2008
2
2011 Apr 28
2
changing a specific column name
Hi,
Can someone please tell me how to change the column name of a specific
column. How do I change the name of the column 'Species'?
Thanks in advance
d <- iris
colnames(d)
[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
ind <- which(names(d)=='Species')
ind
[1] 5
colnames(d[ind])
[1]
2013 Mar 13
1
calculating column difference in a matrix
Dear R users;
Consider the following toy example:
a <- matrix(c(2,3,4,NA,NA,5,8,NA,8,NA), 5, 2)
b <- cbind(a,apply(a, 1, diff, na.rm = TRUE))
What I would like be able to get is:
c <- matrix(c(2,3,4,NA,NA,5,8,NA,8,NA,3,5,-4,8,NA), 5, 3)
i.e., for each row if both values (column 1 and 2) are NA then the
difference must return NA, but if any of those two values is different
from NA
2010 Dec 10
2
survival package - calculating probability to survive a given time
Dear R users,
i try to calculate the probabilty to survive a given time by using the
estimated survival curve by kaplan meier.
What is the right way to do that? as far as is see i cannot use the
predict-methods from the survival package?
library(survival)
set.seed(1)
time <- cumsum(rexp(1000)/10)
status <- rbinom(1000, 1, 0.5)
## kaplan meier estimates
fit <- survfit(Surv(time,
2018 Mar 29
0
Creating the right table from lapply list
Perhaps this toy example will help:
## example data
output <- list(1:5, 1:7, 1:4)
lens <- lapply(output, length)
maxlen <- max(unlist(lens))
outputmod <- lapply(output, function(x, maxl) c(x, rep(NA, maxl-length(x))), maxl=maxlen)
outputmat <- do.call(cbind, outputmod)
write.csv(outputmat, na='')
The idea is to pad the shorter vectors with NA (missing) before converting