Displaying 20 results from an estimated 20000 matches similar to: "R: string connections"
2005 Mar 04
11
R: simulation
hi all
a simple question
i want to run simulations in r. i however want the experiments to be
repeated at a later time with exactly the same numbers by other users.
can i set the random number seed for rnorm in some way?
e.g. is there some arguement that goes with rnorm?
please supply an example
regards
Allan
2005 Sep 15
2
R: deleting rows
hi all
hopefully some one can help.
assume that i imported the following data into R (say the data frame is
called a)
x1 x2 x3
1 NA 3
1 2 NA
1 2 3
3 NA 6
4 5 9
7 5 6
7 8 9
NA 7 9
How can i construct a new data frame that only contains those rows that
does not contain the NA's? is these a quick way?
ie
x1 x2 x3
1 2 3
4 5 9
7 5 6
7 8 9
in this example we can simple use
2005 Apr 11
4
R: function code
HI
sorry to be a nuisance to all!!!
how can i see the code of a particular function?
e.g. nnet just as an example
2005 Feb 24
4
r: functions
hi all
i have a function that uses two inputs, say xdata and ydata. An example
is the following,
simple1<-function(xdata,ydata)
{
ofit<-lm(ydata~xdata)
list(ofit)
}
say i use arbitray number for xdata and ydata such that
D =
x1 x2 y
1 1 10
2 6 6
3 10 7
x<-D[,1:2]
and
y<-D[,3]
if one uses these inputs and rund the program we get the following:
>simple(xdata=x,ydata=y)
2005 Jul 29
5
R: graphics devices
a simple question
how does one produce plots on two different graphics devices?
/
allan
2004 Feb 10
6
R: lags
hi all
how does one simulate a random walk process?
i.e
y(0)=0
y(t)=y(t-1)+ e(t)
where e(t) is normal(0,1) say.
Regards
allan
2004 Feb 03
4
R: lags and plots
Hi all
I want to calculate certain lags of a time series and plot them
simultaneously on a graph. can anyone help?
2004 Feb 24
5
r: plots
hi all
i have another probably simple question.
I have three variables say x, y and z. x and y are quite large and z is
relative small.
how can one plot the three variables on the same graph with two separate
axis?
(one for x and y and the other for z)
e.g.
x<-c(101,110,150,167,120)
y<-c(120,135,175,95,200)
z<-c(0.001, 0.15, 0.6, 0.8, 1)
regards
Allan
2004 Jul 19
5
converting character strings to eval
Hi there fellow R-users,
I'm stuck on this seemingly trivial problem.
All I want to coerce a character string into a command.
For example:
x<-rnorm(20)
y<-rnorm(20)
str<-"lm(y~x)"
I want to evaluate the "str" command.
I have tried
eval(as.expression(str))
But it doesn't seem to work. I am aware of the call command, but for
reasons I won't go
2006 Jun 06
2
How to create list of objects?
Hi
I am doing several mle and want to store them in a list (or whatever is
the right construct) to be able to analyse them later.
at the moment I am doing:
f <- list()
f$IP <- mle(...)
f$NE <- mle(...)
but when I say:
> summary(f)
I get:
Length Class Mode
IP 0 mle list
NE 0 mle list
I don't get the output I would have, i.e. the one from
>
2004 Aug 26
5
GLMM
I am trying to use the LME package to run a multilevel logistic model
using the following code:
------------------------------------------------------------------------
-------------------------------------------
Model1 = GLMM(WEAP ~ TSRAT2 , random = ~1 | GROUP , family = binomial,
na.action = na.omit )
------------------------------------------------------------------------
2004 Jan 05
4
r: lm question
Hi all
this is a silly question since i should know the answer.
lm(y~x) perfroms linear regression with the intercept included.
How do i estimate the equation without the intercept?
cheers
2010 Feb 11
1
Fwd: Recall function: "evaluation nested too deeply: infinite recursion / options(expressions=)?"
hello all
i searched the archives and couldn't get a solution to the following question.
i have the following function:
F=function(z,v)
{
if (v==-.5) return(1) else return(2*v/z + 1/Recall(z,v-1))
}
and while testing whether it works (ie F(z,v) is approx = besselK(z,1+v)/besselK(z,V). the recursion formula allows one to calculate besselK(z,1+v)/besselK(z,V) for large values of z )
2008 Jul 24
3
incrementing for loop by 2
Dear List-serv members:
How can I structure a for loop so that it will increment the counter by two using R? I am just looking for a simple example that shows where the incrementing part should go. Thanks!
Jennifer
--
Jennifer Hayes Clark
Assistant Professor
Department of Political Science
University of Houston
Houston, TX 77204-3011
[[alternative HTML version deleted]]
2004 Jun 25
3
String manipulation
Hi,
let's see, if someone can help my with this one:
I have the string as follows:
> str<-("one","two","three")
Now I want to concatenate the items to one string, seperateted by space or
something else,
>str
>"one, two, three"
If possible without a loop.
My actual goal ist to create string like
>str.names
>"female = names1, male
2004 Sep 28
4
An index of all possible combinations of variables in a data fram e
Hello list
Does anybody know of any way to create an index of all the possible
combinations of variables (factors) in a data frame? ie for 3 factors A, B &
C we have
A
B
C
AB
AC
BC
ABC
which equates to columns 1, 2, 3, 1:2, (1,3), 2:3 and 1:3.
I realise that a function like model.matrix does this, but how to get the
seqence of the index?
Any help would be greatly appreciated.
2006 Nov 17
2
do.call("+", ...)
Hi
How do I make do.call() take "+" as a function for a list of more
than two elements?
Toy problem follows:
f <- function(i){matrix((1:6)^i,2,3)}
# Thus f() returns a matrix of size 2x3; I want to add a whole bunch
of such matrices,
# as in f(1) + f(2) + f(3) + f(4)
# But:
> do.call("+",sapply(1:4,f,simplify=FALSE))
Error in do.call("+",
2005 Aug 11
3
sub set selection
hi all
is there a package that undertakes subset selection but BASED ON AIC or
any other information criteria.
i've seen the "subselect" and the "leaps" package but i have not played
around with them yet.
thanx
2008 Jan 22
1
R: determinants and inverses
hello all
sorry for the following "none" R related question.
does anyone know of a reference to calculate the following identity:
|I + ABC|
where I is an identity matrix and A, B,C may not have to be square matrices?
you help will be greatly appreciated.
H. V. Henderson; S. R. Searle
SIAM Review, Vol. 23, No. 1. (Jan., 1981), pp. 53-60.
provides a result to
2006 Feb 22
3
elements that appear only once
Hi.
I have a factor and I want to extract just those elements that appear
exactly once.
How to do this?
Toy example follows.
> a <- as.factor(c(rep("oak",5) ,rep("ash",1),rep("elm",1),rep
("beech",4)))
> a
[1] oak oak oak oak oak ash elm beech beech beech beech
Levels: ash beech elm oak
> table(a)
a
ash beech elm oak