Displaying 20 results from an estimated 2000 matches similar to: "Number above the bar?"
2007 Jun 14
4
question about formula for lm
Dear all;
Is there any way to make this to work?:
.x<-rnorm(50,10,3)
.y<-.x+rnorm(50,0,1)
X<-data.frame(.x,.y)
colnames(X)<-c("Xvar","Yvar")
Ytext<-"Yvar"
lm(Ytext~Xvar,data=X) # doesn't run
lm(Yvar~Xvar,data=X) # does run
The main idea is to use Ytext as input in a function, so you just type
"Yvar" and the model should fit....
2009 Apr 21
6
Sampling in R
[This email is either empty or too large to be displayed at this time]
2005 Jul 05
1
by (tapply) and for loop differences
I am getting a difference in results when running some analysis using by and
tapply compare to using a for loop. I've tried searching the web but had no
luck with the keywords I used.
I've attached a simple example below to illustrates my problem. I get a
difference in the mean of yvar, diff and the p-value using tapply & by
compared to a for loop. I cannot see what I am doing wrong.
2012 Aug 11
1
using eval to handle column names in function calling scatterplot graph function
I am running R version 2.15.1 in Windows XP
I am having problems with a function I'm trying to create to:
1. subset a data.frame based on function arguments (colname & parmname)
2. rename the PARMVALUE column in the data.frame based on function
argument (xvar)
3. generate charts
plotvar <- function(parentdf,colname, parmname,xvar,yvar ){
subdf <-
2009 May 14
1
text() to label points in ggplot
is there a way to label points in a graph using text(locator(1),"text")
after ggplot() or qplot() ?
> qplot(date, psavert, data = economics, geom = "line",main="jhdjd")->p
> p+opts(text(locator(1),"HHHH"),new=T)
does not work.
--
View this message in context: http://www.nabble.com/text%28%29-to-label-points-in-ggplot-tp23545135p23545135.html
Sent
2011 Apr 01
3
programming: telling a function where to look for the entered variables
Hi there,
Could someone help me with the following programming problem..?
I have written a function that works for my intended purpose, but it
is quite closely tied to a particular dataframe and the names of the
variables in this dataframe. However, I'd like to use the same
function for different dataframes and variables. My problem is that
I'm not quite sure how to tell my function in
2011 Feb 25
1
speed up process
Dear users,
I have a double for loop that does exactly what I want, but is quite
slow. It is not so much with this simplified example, but IRL it is slow.
Can anyone help me improve it?
The data and code for foo_reg() are available at the end of the email; I
preferred going directly into the problematic part.
Here is the code (I tried to simplify it but I cannot do it too much or
else it
2007 Nov 15
1
Writing a helper function that takes in the dataframe and variable names and then does a subset and plot
Hi,
I have a large dataframe than I'm writing functions to explore, and to
reduce cut and paste I'm trying to write a function that does a subset
and then a plot.
Firstly, I can write a wrapper around a plot:
plotwithfits <- function(formula, data, xylabels=c('','')) {
xyplot(formula, data, panel =
function(x,y, ...) {
panel.xyplot(x,y,
2010 Feb 22
3
gsub patterns from vector elements w/out loop?
Dear list,
I have two vectors:
x <- c("one","two")
y <- paste(rep(x,2),"blah")
I want to replace all occurrences of each element of x in y with
something else, so that y looks like this:
y
[1] "something else blah" "something else blah" "something else blah"
[4] "something else blah"
I can do this using a loop:
for (
2019 May 25
3
Increasing number of observations worsen the regression model
I have the following code:
```
rm(list=ls())
N = 30000
xvar <- runif(N, -10, 10)
e <- rnorm(N, mean=0, sd=1)
yvar <- 1 + 2*xvar + e
plot(xvar,yvar)
lmMod <- lm(yvar~xvar)
print(summary(lmMod))
domain <- seq(min(xvar), max(xvar))??? # define a vector of x values to
feed into model
lines(domain, predict(lmMod, newdata = data.frame(xvar=domain)))??? #
add regression line, using
2010 Nov 29
1
cross tabulate variables by subject id
Dear list,
I have data like this:
dat1 <- data.frame(subject=rep(1:10,2),
cond1=rep(c("A","B"),each=5),
cond2=rep(c("C","D"),each=10),
choice=sample(0:1,10,replace=TRUE))
I would like to compare subjects' "choice" for (cond1=="A" &
cond2=="C") vs
2011 Oct 12
2
Nonlinear regression aborting due to error
Colleagues,
I am fitting an Emax model using nls. The code is:
START <- list(EMAX=INITEMAX, EFFECT=INITEFFECT, C50=INITC50)
CONTROL <- list(maxiter=1000, warnOnly=T)
#FORMULA <- as.formula(YVAR ~ EMAX - EFFECT * XVAR^GAMMA / (XVAR^GAMMA + C50^GAMMA)) ## alternate version of formula
FORMULA <- as.formula(YVAR ~ EMAX - EFFECT / (1 + (C50/XVAR)^GAMMA))
FIT <-
2005 Dec 26
4
lme X lmer results
Hi,
this is not a new doubt, but is a doubt that I cant find a good response.
Look this output:
> m.lme <- lme(Yvar~Xvar,random=~1|Plot1/Plot2/Plot3)
> anova(m.lme)
numDF denDF F-value p-value
(Intercept) 1 860 210.2457 <.0001
Xvar 1 2 1.2352 0.3821
> summary(m.lme)
Linear mixed-effects model fit by REML
Data: NULL
AIC BIC
2011 Aug 30
1
R crash
Dear users,
By running the script below, R crashes systematically at the last
command, namely dev.off(), on Windows 7, but not on Windows XP.
I therefore don't provide a reproducible example and do not really
extract the relevant parts of the script because it has most likely
nothing to do with the script itself. I can do it though if you think it
might be relevant.
R crashes on Windows
2011 Feb 02
1
pass nrow(x) to dots in function(x){plot(x,...)}
Dear Rers,
I have a function to barplot() a matrix, eg
myfun <- function(x, ...) { barplot(x , ... )}
(The real function is more complicated, it does things to the matrix first.)
So I can do:
m1 <- matrix(1:20,4)
myfun(m1)
myfun(m1, main="My title")
I'd like to be able to add the number of rows of the matrix passed to
the function to the "..." argument, eg
2012 Jun 25
3
Loop for multiple plots in figure
Hello, I have longitudinal data of the form below from N subjects; I am
trying to create figure with N small subplots on a single page, in which
each plot is from only one subject, and in each plot there is a separate
curve for each value of param1.
So in this case, there would be four plots on the page (one each for Bob,
Steve, Kevin and Dave), and each plot would have two separate curves (one
2012 Sep 20
1
Gummy Variable : Doubt
Hi,
I have a system in which I analyze 2 subjects and 1 variable, so I have
2 models as follow:
y ~ x_1[, 1] + x_2[, 1] + x_1[, 2] + x_2[, 2]
Where
x_1[, i] = cos(2 * pi * t / T_i)
x_2[, i] = sin(2 * pi * t / T_i)
i = 1, 2
Data have two columns: t and y.
As you can see, I have a multiple components model, with rithm and
without trends, and I have a fundamental
2008 Oct 05
1
barchart for aggregated (sum) data in lattice?
Hi list,
I have data in a dataframe t1, with a column for different amounts
spent, a column what it was spent on, and a column with dates, from
which I create a new column with months.
Example:
amount <- rep(c(10,20,30),3)
what <- rep(c("food","books","cycling"),3)
when <- c(rep("2008-09-05",5),rep("2008-10-07",4))
t1 <-
2009 Oct 09
3
"Use R" -- term and logo copyright?
Dear list,
I would like to start some R workshops at King's College London, and
to do so, I would like to use the "Use R!" logo at
http://www.agrocampus-ouest.fr/math/useR-2009//useR%21%202008_fichiers/useR-middle.png
Since it seems to be difficult to get a shell account at KCL, I also went
ahead and registered use-r.org.uk and am starting to put together a
website at
2010 Aug 24
1
Index list by other list (w/ logical elements)?
I have two lists of the same shape, like this:
x <- list()
x[[1]] <- c("one","two")
x[[2]] <- c("three","four","five")
y <- list()
y[[1]] <- c(TRUE,FALSE)
y[[2]] <- c(FALSE,TRUE,TRUE)
I would like to index x "by" y, that is, the result in this case
should be:
z
[[1]]
[1] "one"
[[2]]
[1] "four"