Displaying 20 results from an estimated 6000 matches similar to: "summary.formula and continuous variables"
2010 Nov 08
7
How to rbind list of vectors with unequal vector lengths?
Hi,
How to rbind these vectors from a list?:
> l <- list(a = c(1, 2), b = c(1, 2, 3))
> l
$a
[1] 1 2
$b
[1] 1 2 3
> do.call(rbind, l)
[,1] [,2] [,3]
a 1 2 1
b 1 2 3
Warning message:
In function (..., deparse.level = 1) :
number of columns of result is not a multiple of vector length (arg 1)
>
-J
2010 Aug 11
4
Arbitrary number of covariates in a formula
Hello!
I have something like this:
test1 <- data.frame(intx=c(4,3,1,1,2,2,3),
status=c(1,1,1,0,1,1,0),
x1=c(0,2,1,1,1,0,0),
x2=c(1,1,0,0,2,2,0),
sex=c(0,0,0,0,1,1,1))
and I can easily fit a cox model:
library(survival)
coxph(Surv(intx,status) ~ x1 + x2 + strata(sex),test1)
However, I want to
2010 May 23
4
creating a reverse geometric sequence
Hello,
Can anyone think of a non-iterative way to generate a decreasing geometric
sequence in R?
For example, for a hypothetical function dg, I would like:
> dg(20)
[1] 20 10 5 2 1
where I am using integer division by 2 to get each subsequent value in the
sequence.
There is of course:
dg <- function(x) {
res <- integer()
while(x >= 1) {
res <- c(res, x)
x
2007 Nov 08
2
mapply, coxph, and model formula
Hello -
I am wanting to create some Cox PH models with coxph (in package
survival) using different datasets.
The code below illustrates my current approach and problem with
completing this.
### BEGIN R SAMPLE CODE ##############################
library(survival)
#Define a function to make test data
makeTestDF <- function(n) {
times <- sample(1:200, n, replace = TRUE)
event
2009 Apr 27
3
Formatting numbers
I've been trough the R documentation for about half an hour and it's not
clear to me how to do this:
I need to format to character a series of integers from 1 to 1000, and I
like them to look like
"0001" "0002", "0059", "0123" and so on. Padded with zeroes to have four
digits.
Cheers!
Mario.
r-help-request at r-project.org wrote:
> Send
2009 Jan 30
1
From z to Rho
Hi,
when performing a spearman_test stratified by a given factor in package "coin", how is it possible to obtain the value of Rho, the Spearman correlation coefficient ?
Thanks in advance
Gilles (F)
[[alternative HTML version deleted]]
2010 Sep 18
3
How to check the available of a package on R repo
Hi folks,
Debian 504 64-bit
What is the correct syntax to check the available of a package on R repo?
> available.packages("emacs", "OS_type=linux")
Warning: unable to access index for repository emacs
Package Version Priority Depends Imports LinkingTo Suggests Enhances
OS_type License File Repository
> available.packages("emacs")
Warning: unable
2009 Mar 28
1
stratified variables in a cox regression
>Hello,
I am hoping for assistance in regards to examining the contribution
of stratified variables in a cox regression. A previous post by Terry
Therneau noted that "That is the point of a strata; you are declaring
a variable to NOT be proportional hazards, and thus there is no
single "hazard ratio" that describes it". Given this purpose of
stratification, in the
2010 Mar 08
0
page boundaries for latex printing of summary.formula objects in Hmisc
Hello,
Warning, I'm guessing only those who have used the Hmisc package's
summary.formula function with LaTeX will be able to offer much help here.
I am using the Hmisc package's summary.formula function to produce
tables for a LaTeX report. The "latex" function in the same package
supports longtables in LaTeX. Ideally, I would like for page breaks in
the LaTeX output
2010 May 31
0
Put two plots side by side
Two different ways:
library(ggplot2)
x=5
size=50
A=data.frame(X=sample(x, size, replace=T), Y=sample(x, size, replace=T),a=rep(1:2,each=25));A
# Facetting
qplot(X,Y,data=A) + geom_jitter(position=position_jitter(width=.03)) + facet_grid(.~a)
# Or with vp
p=qplot(X, Y, data=A) + geom_jitter(position=position_jitter(width=.03))
ggsave(p, file='main.png')
p1=qplot(X, Y, data=A) +
2010 Oct 25
2
Question on passing the subset argument to an lm wrapper
Hello,
How would you go about handling the following situation?
This is on R 2.12.0 on Ubuntu 32-bit.
I have a wrapper function to lm. I want to pass in a
subset argument. First, I just thought I'd use "...".
## make example reproducible
set.seed(123)
df1 <- data.frame(age = rnorm(100, 50, 10),
bmi = rnorm(100, 30, sd = 2))
## create a wrapper using
2008 Jul 02
1
Hmisc latex function with longtable option
Hello -
I'm trying to use Hmisc's latex function to produce a postscript file of
a data.frame, using the longtable = TRUE option. When I run, for example,
## sample R code
dvips(latex(data.frame(a = rnorm(100), b = rnorm(100)),
longtable = TRUE), file = "test.ps")
latex runs successfully and a test.ps file is produced. However, I see
the following in the
2010 Feb 16
3
Keyboard
All,
I installed R-2.10.1 with Readline=no. Now for some reason R does not recognize some key strokes like the directional arrows.
I am not sure if Readline is the problem or not.
I have tried .Cofigure with Readline = yes but it doesn't fix the problem nor do I really know if readline is the problem to start with.
Has anybody else run into similar problems?
Thanks,
Steve
[[alternative
2010 Oct 05
4
R editor in ubuntu!
Hello R-Users!
I am looking for an editor to be able to execute commands into R in Linux ubuntu. Is there any suggestion?
Thanks.
[[alternative HTML version deleted]]
2010 Jun 16
3
Function argument as string
Hi,
Suppose a write a function
a_fn<-function(arg1)
{
return(table(arg1));
}
I have a column called AGE. Now I call the function c = a_fn(AGE);
When a_fn is called, AGE is received in arg1. My question is, how do I
access the actual name of the argument arg1? i.e, inside the
function, i need to know that the actual name of arg1 is "AGE" in this
case.
Thanks in advance,
2008 May 16
2
Integer / floating point question
Dear R-help -
I have thought about this question for a bit, and come up with no
satisfactory answer.
Say I have the numeric vector t1, given as
t1 <- c(1.0, 1.5, 2.0, 2.5, 3.0)
I simply want to reliably extract the unique integers from t1, i.e., the
vector c(1, 2, 3). This is of course superficially simple to carry out.
However, my question is related to R FAQ 7.31, "Why
2012 Jun 01
1
Stratified Sampling with randomForest Regression
Hi All,
I'm using R's randomForest package (and it's quite awesome!) but I'd
really like to do some stratified sampling with a regression problem.
However, it appears that the package was designed to only accommodate
stratified sampling for classification purposes (see
https://stat.ethz.ch/pipermail/r-help/2006-November/117477.html). As
Andy suggests in the link just
2011 Mar 23
3
Compare three or more values?
Is there a less cryptic way to compare three or more values?
allTheSame<-c("red","red","red","red")
notAllTheSame<-c(132,132,132,999)
all.identical <- function(vectorToTest){
cIdentical=sum(vectorToTest %in% vectorToTest[1])
return(cIdentical==length(vectorToTest))
}
all.identical(allTheSame)
all.identical(notAllTheSame)
Thanks in
2013 Apr 24
2
Regression on stratified count data
Hi all:
For stratified count data,how to perform regression analysis?
My data:
age case oc count
1 1 1 21
1 1 2 26
1 2 1 17
1 2 2 59
2 1 1 18
2 1 2 88
2 2 1 7
2 2 2 95
age:
1:<40y
2:>40y
case:
1:patient
2:health
oc:
1:use drug
2:not use drug
My purpose:
Anaysis whether case and
2010 Apr 27
1
Randomization for block random clinical trials
Hi,
I’m new to R (just installed today) and I’m trying to figure out how to do
stratified randomisation using it. My google search expedition has lead me
to believe that blockrand package will most probably be the answer to it.
I’ve played around with blockrand for awhile and tried the sample code:
library(blockrand)
##stratified by sex
male <- blockrand(n=100,