/biostat/
http://www.student.kuleuven.be/~m0390867/dimitris.htm
- Original Message -
From: Werner Wernersen [EMAIL PROTECTED]
To: Gabor Grothendieck [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Wednesday, April 05, 2006 3:55 PM
Subject: Re: [R] List to Array
Oh yes, I
By works on the rows or first dimension. See ?by, ?apply, ?aperm
?tapply
On 4/5/06, Werner Wernersen [EMAIL PROTECTED] wrote:
Hi,
having solved one problem with your kindest help I
directly ran into the next one:
I now have a 4-dimensional array and I want to
aggregate subsets (sum up
I assume you want a list containing length(x) data frames, one per
list component. If that's it try this:
test - function(x = 1:4, s = 1:2, rangit = 0:11)
lapply(x, function(x) data.frame(rangit, y = x+s[1]+rangit, p=x+s[2]+rangit))
test() # test run
On 4/6/06, Guenther, Cameron [EMAIL
Try this:
do.call([-, c(list(b), idx, list(a)))
On 4/6/06, Paul Roebuck [EMAIL PROTECTED] wrote:
I have the following:
a - matrix(1:10, nrow = 2, byrow = TRUE)
b - array(as.integer(0), c(7, 5))
idx - list()
length(idx) - 2
dim(idx) - c(1, 2)
idx[[1]] - as.integer(1:2)
idx[[2]] -
Just follow this example from example(reshape):
reshape(wide, idvar=Subject, varying=list(names(wide)[2:12]),
v.names=conc, direction=long)
like this:
long - reshape(dd, direction = long, varying =
list(names(dd)[5:7]), idvar = v,
v.names = x, times = paste(value, 1:3,
Here are two ways:
with(iris, Sepal.Length + Sepal.Width)
attach(iris)
Species
On 4/6/06, Brian Quinif [EMAIL PROTECTED] wrote:
I have a question about how to reference variables in a dataframe.
Normally, after I have read in some Stata data using the following command
all -
See the first two hits for:
RSiteSearch(IRR)
On 4/6/06, Liaw, Andy [EMAIL PROTECTED] wrote:
Those functions in Excel are for computing things like interest payment for
fixed interest rate loan, etc. RSiteSearch() doesn't turn up anything
useful, so I'd guess no one has written them. Good
See ?paste and try:
paste(sub.dataset[i], tex, sep = .)
On 4/7/06, Brian Quinif [EMAIL PROTECTED] wrote:
I would like to use a for loop to run estimations on 12 different
subsets of a dataset.
I have the basics of my script figured out, but I am having problems
getting the loop to name some
in it:
x - paste(101, tex, sep = .)
x
[1] 101.tex
cat(x)
101.tex nchar(x)
[1] 7
Note that there are 7 characters in x.
Thanks,
BQ
2006/4/7, Gabor Grothendieck [EMAIL PROTECTED]:
See ?paste and try:
paste(sub.dataset[i], tex, sep = .)
On 4/7/06, Brian Quinif [EMAIL PROTECTED
Another possibility is to create a data.frame. I've just put
one statistic, sum, in it but you could put in as many as
you like:
g - expand.grid(i = 1:2, j = 1:2, k = 1:3)
f - function(x) with(x, c(i = i, j = j, k = k, sum = i+j+k))
do.call(rbind, lapply(split(g, rownames(g)), f))
i j k
Try this:
library(fMultivar)
set.seed(1)
x - rnorm(25)
rollFun(x, 15, FUN = function(x) adf.test(x)$p.value)
[1] 0.1207730 0.3995849 0.3261577 0.4733004 0.5776586 0.6400228 0.6758550
[8] 0.6897812 0.3792858 0.6587171 0.5675147
rollFun(x, 15, FUN = function(x) adf.test(x)$statistic)
[1]
Did you try installing it first? From R,
install.packages(e1071, dep = TRUE)
On 4/8/06, Chelsea Ellis [EMAIL PROTECTED] wrote:
Hi,
I'm trying to use the svm function in R, but I can't find the e1071 package.
When I type library(e1071), I get the error message that the package
doesn't
P VALUE:
0.5612
Description:
Sat Apr 08 19:11:40 2006
I checked with the help pages of the adfTest and fMultivar, but can simply
not figure out why I am receiving these error messages above.
How could I fix this?
Many thanks!
Sincerely,
Bernd Dittmann
Gabor Grothendieck
I guess I am coming a bit late to this but here is a one-line zoo solution.
The lapply creates a zoo object from each foo component with the constant
value 1 and the contents as the times of that object.Merging the objects
together using cbind gives columns of 1s and NAs and removing the NAs
Don't know about a function but it can be done in one plot statement
like this:
plot(seq(x) - match(x, x) ~ x, list(x = sort(mydata)),
xlim=c(25,45), ylab =, yaxt=n, pch=19, frame.plot=FALSE)
On 4/9/06, Jinsong Zhao [EMAIL PROTECTED] wrote:
Hi,
I am wondering whether there is a
Try this:
t(t(a)+b)
On 4/9/06, Tim Smith [EMAIL PROTECTED] wrote:
Hi All,
This is probably a very simple question. I was trying to add a row to the
rows in a matrix. For example:
a - matrix(1:6,2,3)
b - a[1,]
print(a)
[,1] [,2] [,3]
[1,]135
[2,]246
If c is c(c1, c2, c3) and x is c(x1, x2, x3) then
c+x is (c1+x1, c2+x2, c3+x3)
so sum(c+x) is c1+x1+c2+x2+c3+x3 = sum(c) + sum(x)
What you were expecting is given by:
rowSums(outer(1:4, c(-1,0,1), +)) # gives c(3, 6, 9, 12)
Review the Introduction to R manual and also look at ?outer and
Or, of course, if you are willing to reduce it then its just
sum(c) + length(c) * x
On 4/9/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
If c is c(c1, c2, c3) and x is c(x1, x2, x3) then
c+x is (c1+x1, c2+x2, c3+x3)
so sum(c+x) is c1+x1+c2+x2+c3+x3 = sum(c) + sum(x)
What you were
Try this where g is f summed over j and k for given scalars
theta and rho and gv is g vectorized over theta. I have not
checked this carefully so be sure you do:
f - function(theta = 0, rho = 0, j = 0, k = 0)
dnorm(theta+2*pi*j,0,1)*pnorm(2*pi*(k+1)-rho*(theta+2*pi*j))
g - function(theta
Sorry, I replied to the wrong email. Here it is again:
Try this where g is f summed over j and k for given scalars
theta and rho and gv is g vectorized over theta. I have not
checked this carefully so be sure you do:
f - function(theta = 0, rho = 0, j = 0, k = 0)
RSiteSearch(skewness)
On 4/10/06, Jian Zhang [EMAIL PROTECTED] wrote:
I think it is simply, but I cannot find the method to figure out skewness.
Thanks!
[[alternative HTML version deleted]]
__
R-help@stat.math.ethz.ch mailing list
If you are using XP then create a shortcut to Rgui.bat, which
can be found in:
http://cran.r-project.org/contrib/extra/batchfiles/
0.2-7 is the most recent. When you install R it saves in the registry
the R version and Rgui.bat looks that up and runs that version thereby
giving you the last
Its undoubtedly a timezone or daylight savings time issue. Use this
instead:
seq(from=as.Date('2005-12-4'), to=as.Date('2006-4-9'), by='weeks')
[1] 2005-12-04 2005-12-11 2005-12-18 2005-12-25 2006-01-01
[6] 2006-01-08 2006-01-15 2006-01-22 2006-01-29 2006-02-05
[11] 2006-02-12 2006-02-19
Try this.
dd - Sys.time() # test data
lt - as.POSIXlt(dd)
ISOdate(1900+lt$year, 1, 1, 0, tz = )
ISOdate(1901+lt$year, 1, 1, 0, tz = )
seq(now, length = 2, by = paste(-, lt$wday, day, sep =))[2]
seq(now, length = 2, by = paste(7-lt$wday, day))[2]
with(lt, ISOdate(1901+year, mon, mday, 0, tz
On 4/10/06, Farrel Buchinsky [EMAIL PROTECTED] wrote:
1) I know how to post to the list. You simply send an e-mail to
[EMAIL PROTECTED] But how do you read the items and respond to them?
I usually read the items at
http://tolstoy.newcastle.edu.au/R/help/06/04/index.html#end and then have to
On 4/10/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Try this.
dd - Sys.time() # test data
lt - as.POSIXlt(dd)
ISOdate(1900+lt$year, 1, 1, 0, tz = )
ISOdate(1901+lt$year, 1, 1, 0, tz = )
seq(now, length = 2, by = paste(-, lt$wday, day, sep =))[2]
seq(now, length = 2, by = paste(7
Try:
sprintf((%.2f), pi)
[1] (3.14)
On 4/11/06, Brian Quinif [EMAIL PROTECTED] wrote:
Perhaps someone will have a solution to my more general problem, but
here is the specific one:
I used the round() function to round some estimates to 3 decimal
places. I then sent put the rounded
Or use letters. = letters and similarly for the other arguments of the
form x = x.
On 4/11/06, Prof Brian Ripley [EMAIL PROTECTED] wrote:
'letters' is an argument to your function, with default 'letters', that it
itself. (Default arguments are evaluated in the evaluation frame of the
Here are some different approaches:
x - 1
y - 2
paste(p, x, y, .dat, sep = ) # p12.dat
sprintf(p%s%s.dat, x, y)
file.path(a, b.dat) # a/b.dat
library(gsubfn)
gsubfn(,,p$x$y.dat) # p12.dat
On 4/11/06, Damaris Zurell [EMAIL PROTECTED] wrote:
Hello,
I have about 2000 data files which I
Try:
junk - capture.output(print(abc))
On 4/11/06, Sumanta Basak [EMAIL PROTECTED] wrote:
Hi All,
I'm running garch models for different combinations, like (1,1),(1,2) etc.
in a for loop. But, when i'm running it, R is showing a text *
ESTIMATION WITH ANALYTICAL GRADIENT * . How can
Are you trying to turn each of the components of foo into a matrix?
If that's it then:
lapply(foo, function(x) matrix(unlist(x), nrow = length(x)))
On 4/11/06, Muhammad Subianto [EMAIL PROTECTED] wrote:
Dear all,
I have a result my experiment like this below (here my toy example):
foo1 -
I forgot the byrow = TRUE. Try this instead:
lapply(foo, function(x) matrix(unlist(x), nrow = length(x), byrow = TRUE))
On 4/11/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
Are you trying to turn each of the components of foo into a matrix?
If that's it then:
lapply(foo, function(x
One other thought. If they are all of the same dimension you could
alternately consider putting them into a 3d array:
library(abind)
abind(lapply(foo, function(x) do.call(rbind, x)), along = 3)
which may or may not have some advantage to you.
On 4/11/06, Muhammad Subianto [EMAIL PROTECTED]
Use local or codetools package as in:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/69694.html
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/69695.html
On 4/12/06, James Kirkby [EMAIL PROTECTED] wrote:
Hi,
I was wondering if there is a way to stop R looking outside the scope of
a
You might want to look at the dyn package. It allows
time series in model formulae, e.g. this aligns UKgas
and diff(UKgas) properly:
dyn$lm(UKgas ~ diff(UKgas))
dyn$ transforms the above to
dyn(lm(dyn(UKgas ~ diff(UKgas
and the inner dyn adds class dyn to the formula's class vector
I think its good enough to just define an array method, i.e. you
don't need the matrix method or the matrixOrArray class, and the
vector method can call foo(matrix(A,1), ...) so:
setGeneric(foo,
function(A, ...) {
cat(generic, match.call()[[1]], \n)
For the lines you posted this read them in successfully:
read.table(clipboard, sep = |)
To extract the RD lines you will need two passes:
L - readLines(clipboard)
L - grep(^RD, L, value = TRUE)
read.table(textConnection(L), sep = |)
or you can use read.table(pipe(...), sep = |)
where ... is a
This is surprising. I would have thought that the parent/child relationships
determine the order that dispatched methods are invoked, not the order
that the setMethod commands are issued in.
On 4/12/06, Paul Roebuck [EMAIL PROTECTED] wrote:
On Wed, 12 Apr 2006, Gabor Grothendieck wrote:
On 4
The minimum you need is to have a single file, DESCRIPTION, plus
R and man directories/folders which contain your .R and .Rd
files respectively. A package need not use C and I suspect most
don't.
On 4/12/06, James Anderson [EMAIL PROTECTED] wrote:
Hi,
Just a silly question about R source
Maechler [EMAIL PROTECTED] wrote:
Gabor == Gabor Grothendieck [EMAIL PROTECTED]
on Wed, 12 Apr 2006 18:24:46 -0400 writes:
Gabor This is surprising. I would have thought that the
Gabor parent/child relationships determine the order that
Gabor dispatched methods are invoked
What you are referring to iris is called iris3 in R so just replace
iris with iris3. iris3 is a 3d array in R whereas iris is a data frame.
On 4/13/06, Sasha Pustota [EMAIL PROTECTED] wrote:
It's in the Venables Ripley MASS (ed 3) book in the section on
principal components.
The context is
If you think of n and the function as components of an object
then you could use the proto package to define an object, p,
that contains those two components. If we assume no
children of p are required (from your description I assume
that that is the case) then its just:
library(proto)
p -
On 4/13/06, Sasha Pustota [EMAIL PROTECTED] wrote:
I hope this time I'm using the iris dataset correctly:
ir - rbind(iris3[,,1], iris3[,,2], iris3[,,3])
lir - data.frame(log(ir))
names(lir) - c(a,b,c,d)
I'm trying to understand the meaning of expressions like ~ a+b+c+d,
used with princomp,
Try this:
tt2 - tt
tt2[,1] - as.character(tt2[,1])
tt2[,2] - as.character(tt2[,2])
f - function(x) with(tt2, mean(righta_a[x == itd_1 | x == itd_45]))
sapply(unique(unlist(tt2[,1:2])), f)
On 4/13/06, Doran, Harold [EMAIL PROTECTED] wrote:
I have a data frame where I need to subset certain
See:
https://www.stat.math.ethz.ch/pipermail/r-help/2006-March/089888.html
and succeeding messages in thread.
On 4/13/06, gynmeerut [EMAIL PROTECTED] wrote:
Dear R users,
I am using a loop that does matrix multiplication in a manner
(A%*%B)%*%(A)
Here A is a row of data frame D of
Look at:
str(obj)
class(obj)
dput(obj)
On 4/13/06, Thomas L Jones [EMAIL PROTECTED] wrote:
Okay, I am dealing with an object. Without going into too much detail,
a gam (Generalized Additive Model) is involved. Assume that the name
of the object is obj without the quotes. I tell it:
print
Look at ?ave
ave(vec, Fac)
ave(vec, Fac, FUN = mean) # same
ave(vec, Fac, FUN = sd)
On 4/14/06, Murray Jorgensen [EMAIL PROTECTED] wrote:
I found myself wanting to average a vector [vec] within each level of a
factor [Fac], returning a vector of the same length as vec. After a
while I
In section 5.5 of the language manual it says:
It is important to realize that the choice of the next method depends on the
current values of .Generic and .Class and not on the object. So changing
the object in a call to NextMethod affects the arguments received by
the next method but does not
On 4/14/06, Prof Brian Ripley [EMAIL PROTECTED] wrote:
On Fri, 14 Apr 2006, ronggui wrote:
My question is when the object argument of NexthMethod be used?
Looking at the C code, I don't think it is. But look at do_nextmethod in
src/main/objects.c yourself.
Note that in your examples it
2 1.589235 1.098612 0.3364722 -1.6094379
3 1.547563 1.163151 0.2623643 -1.6094379
4 1.526056 1.131402 0.4054651 -1.6094379
5 1.609438 1.280934 0.3364722 -1.6094379
6 1.686399 1.360977 0.5306283 -0.9162907
On 4/14/06, Sasha Pustota [EMAIL PROTECTED] wrote:
Gabor Grothendieck [EMAIL PROTECTED
aggregate(DF[,-1], DF[, 1, drop = FALSE], mean)
On 4/15/06, Srinivas Iyyer [EMAIL PROTECTED] wrote:
dear group,
i have a sample matrix
name v1 v2 v3 v4
cat 1011 12 15
dog 3 12 10 14
cat 9 12 12 15
cat 5 12 10 11
dog 12113 123 31
Try this:
# test data
y - 0:1000 # values
dd - Sys.Date() + y # Dates
# create zoo object, aggregate it by year using last value and plot it
z - zoo(y, dd)
yr - function(x) as.POSIXlt(x)$year + 1900
# or, yr - function(x) as.numeric(format(x, %Y))
z.yr - aggregate(z, yr, tail, 1)
plot(z.yr,
Try:
y - 1:length(sam4) # test data
dd - as.Date(sam4, %m/%d/%y)
plot(dd, y)
# also try this
library(zoo)
z - zoo(y, dd)
plot(z)
Also read, from earlier today:
https://www.stat.math.ethz.ch/pipermail/r-help/2006-April/092471.html
On 4/17/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Dear
Try:
axis.Date(1, sam5, sam5, format = %b-%y)
On 4/17/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Dear R-help,
My apologies, my previous script ran successfully before I posted as I had
already created mkf
as an object in my active workspace. I have had some success, however I am
unable
Read the R News 4/1 help desk article which specifically discusses this.
On 4/17/06, jim holtman [EMAIL PROTECTED] wrote:
I am using POSIXct objects to store my date/time information. If I am
plotting less that 2 days worth of data, I get the correct tick marks on the
x-axis which is showing
This was just posted this week:
https://www.stat.math.ethz.ch/pipermail/r-help/2006-April/092457.html
and I think there are some relevant macros on the vim web page
I use vim but do not use anything special with it. It gives syntax
highlighting out of the box.
On 4/18/06, Michael Graber [EMAIL
This was just discussed recently. See the following thread:
http://tolstoy.newcastle.edu.au/R/help/06/04/24923.html
On 4/18/06, XinMeng [EMAIL PROTECTED] wrote:
Hello sir:
group1:1,2,3,4
group2:1,3,4,5
group3:2,4,8,9
.. ...
group1000:9,3,8,2
I wanna get the intersection set and union
One can use the fact that converting a zoo object to a
ts object fills in the holes with NAs.
First create some test data, x, and create the table, tab.
Then create a zoo object and convert that to a ts object.
Now barplot the ts values using the times as names.
set.seed(1)
x - rpois(20, 4) #
Maybe you could discuss in words what you want but perhaps
you are looking for diff:
bp - c(0, 250, 800, 1200)
diff(bp)
[1] 250 550 400
On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote:
Isn't there a builtin method for doing this and, if so,
what is it called?
breakdown -
Since everyone else wimped out with a tedious you-do-not-want-to-do-that,
here is a solution that uses R to control Excel and create a 3d chart.
You will
need the RDCOMclient package that you can find via google.
library(RDCOMClient)
xl - COMCreate(Excel.Application) # starts up Excel
On 4/19/06, Frank E Harrell Jr [EMAIL PROTECTED] wrote:
Rolf Turner wrote:
Gabor Grothendieck wrote:
Since everyone else wimped out with a tedious you-do-not-want-to-do-that,
here is a solution that uses R to control Excel and create a 3d chart.
.
.
.
People really
See:
http://finzi.psych.upenn.edu/R/doc/manual/R-data.html#Reading-Excel-spreadsheets
Also the RDCOMClient package (find it via google) and rcom (on CRAN)
can control Excel from R and can be used.
On 4/19/06, Michael [EMAIL PROTECTED] wrote:
Currently I have to convert all my xls into csv
There are a number of approaches:
1. This will identify the line numbers of the short lines
and then you can fix them up by hand.
k - count.fields(myfile)
which(k max(k))
2. If you can assume that 4 spaces, say, represents a missing
value then:
L - readLines(myfile)
L - gsub(, . , L)
On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote:
On Wed, 19 Apr 2006, Gabor Grothendieck wrote:
On 4/19/06, Paul Roebuck [EMAIL PROTECTED] wrote:
Isn't there a builtin method for doing this and, if so,
what is it called?
breakdown - function(whole) {
breaks
Try this:
set.seed(1)
f - function(x) { dd - dfr[dfr$x == x,]; dd[sample(nrow(dd),1),] }
do.call(rbind, lapply(levels(dfr$x), f ))
On 4/20/06, Kelly Hildner [EMAIL PROTECTED] wrote:
I don't use R much, and I have been unable to figure out how to get the
subset of my data frame that I would
Try using breaks[breaks = x] in place of breaks. Your solution
always returns three components if breaks has two whereas this one
does not but you could extend the output it if that is an essential part.
On 4/20/06, Paul Roebuck [EMAIL PROTECTED] wrote:
On Thu, 20 Apr 2006, Gabor Grothendieck
Read them in as zoo objects (you can replace textConnection(Lines1)
with the filename) and then merge them using all = FALSE to retain
only common time points. Note that in my English locale I had
to modify your Apl to Apr.
Lines1 - Date x y
Jan-1,2005120 230
Try paste:
paste(Axis, f)
On 4/20/06, Eric Ferreira [EMAIL PROTECTED] wrote:
Dear R-colleagues,
Is it possible to mix TEXT and VALUE of objects in y (or x) label of a plot?
For instance:
f-2
plot(..., ylab='Axis f', ...)
where f means the VALUE of f.
Thany you in advance,
Eric.
Try:
c(sapply(1:2, function(i) [EMAIL PROTECTED]@my.slot))
On 4/20/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
Hello,
I don't manage to see if you have already focussed on this point in some
previous messages so I post my question:
I have a little problem with the S4 style of
a single file and in the situation that there is junk
on the first few lines of the spreadsheet you could use the skip= argument
to read.csv to skip over that. I don't think the RODBC approach can
handle that.
On 4/20/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:
See:
http://finzi.psych.upenn.edu
Using the built in data.frame iris sum each of the first 4 columns for
each value of the 5th column.
rowsum(iris[,-5], iris[,5])
On 4/20/06, Sachin J [EMAIL PROTECTED] wrote:
Hi,
How can I accomplish this in R. Example:
R1 R2
3 101
4 102
3 102
18102
11101
For your first question the simplest way to handle it is to
sample the indices rather than the data. For example,
x - seq(10,200,10) # data
ix - sample(length(x),10,rep=T) # 10 samples from 1:length(x)
s - x[ix] # samples
Now ix has the indices of s.
Taemyong Choi tmchoi at
f-as.factor(c(1,1,2,2,3,3,3))
model.matrix(~f-1)
Patrik Waldmann Patrik.Waldmann at genfys.slu.se writes:
:
: Hello again,
:
: I was too quick before. What I was looking for was a function that
: constructs the design (or incidence) matrix (X in a linear model) from a
: factor. Uwe Ligges
Check out aggregate.table in package gregmisc .
Jeff D. Hamann jeff.hamann at forestinformatics.com writes:
:
: I've got a newbie question and I got a little lost in the table helps.
: I've got a data.frame I would like to summarize as a (and pardon for the
: lack of correct vernacular) data
lm(y~.,data=x)
ivo welch iaw4 at welch.som.yale.edu writes:
:
: hi: I have a y vector and an x data frame. is it possible to use the
: standard linear regression (lm, summary.lm) without having to construct
: a formula, i.e., all x variables should be used.
:
: x - data.frame(
You can do that with ls and the pattern= argument. For example,
ls(pattern = my)
finds all objects with my anywhere in the name. See ?ls
Andrew White andrew_white at hmsa.com writes:
:
: In S-plus I have depended upon a simple extended ls() function developed by
John wallace called lsx()
Perhaps you really prefer something with a continuous first derivative?
In that case, all the continuous cumulative distribution functions have
a sigmoidal shape and might be suitable. You could fit pnorm, plogis or tanh
with suitable scaling and location parameters using nls. An example
of
Don't know about xtable but here is an alternative:
require(Hmisc)
data(iris)
iris4 - iris[1:4,] # first 4 rows of iris as test
latex(iris4,file=) # with row names
attr(iris4,row.names) - NULL
latex(iris4,file=) # without row names
Jeff D. Hamann jeff.hamann at forestinformatics.com writes:
:
t. - table(a,b)
xtable(format(t.))
From: Ian Wilson [EMAIL PROTECTED]
:
: Any more elegant solutions to this?
:
: a - sample(c(a,d,c),100,replace=T)
: b - sample(c(d,e,f,100,replace=T)
: t - table(a,b)
: xtable(t)
: Error in xtable(t) : no applicable method for xtable
:
: The problem
David Orme d.orme at imperial.ac.uk writes:
:
:
: outer() generally works by expanding out the lists like
:
: Y - rep(y,length(x))
: X - rep(x,each=length(y)) # or maybe it's vice versa, never mind...
: FUN(X,Y,extras)
:
: and then adds dims and dimnames. If FUN vectorizes, this is the
:
Webb Sprague wwsprague at ucdavis.edu writes:
: Is there any documentation on running R like one would run a shell or
: Perl script, with out/input directed appropriately, environment variable
: access, and command switch processing?
:
: I looked some, and even remembered to check the FAQ, but
As another respondent already mentioned, Lattice is probably the way to
go on this one but if you do want to use tapply try this:
names(Pot) - SGruppo
dummy - tapply(Pot,SGruppo,function(x)hist(x,main=names(x)[1],xlab=NULL))
Vittorio v.demartino2 at virgilio.it writes:
:
: I'm learning how
I want to draw and edit networks. Currently I will do something like this --
my actual networks are larger and more complex:
1. Plot network
# use polygon with nodes as example network
N - 20
t. - 2*pi*seq(N+1)/N
plot(cos(t.), sin(t.), type=b, pch=19, cex=5, col=blue, axes=F, ann=F)
2. copy
See plotCI in package gregmisc.
Sebastian Schubert Sebastian-Schubert at gmx.de writes:
:
: Hi,
:
: I'm now to R and hope (actually, I'm quite sure) you can help me. I made
: an experiment and measured two values. As I know the errors of these
: values I want to use them with the linear
Execute these two commands:
ans - fun(x,f)
attributes(ans)
and you get this:
$dim
[1] 20
$dimnames
$dimnames[[1]]
[1] a a b c a d a b d d a b d c c c b c b
[20] d
so ans does not have names, it has dimnames. If you try dimnames(ans) - NULL
then its dimnames do get nulled
If you want pairwise correlations for the cols of matrix x and N
is some parameter to your routine that does not vary throughout
the calculation then:
apply(x,2,function(a)apply(x,2,function(b)Transmer.cor(a,b,N)))
Replace both occurrences of 2 with 1 if you want rows.
Ruedi Epple ruedi.epple
If its just arg 1 then you can use S3 generics for this. Here it is
but we have extended it to data frames too which isn't so easy
if you can only specify one type:
sum.across - function(x) UseMethod(sum.across)
sum.across.matrix - function(x) { stopifnot(is.numeric(x)); c(rowMeans(x)) }
The shortest expression I can think of is:
as.numeric(interaction(mat[,1],mat[,2],drop=T))
Completing the thought of those who suggested dist or
unique:
N - nrow(mat)
dd - as.matrix(dist(rbind(mat,unique(mat[-seq(N),seq(N)]
apply(dd,2,function(x)match(0,x))
Scott Waichler scott.waichler
Note that if f is a factor with Date labels, e.g.
f - factor(c(2000-02-02,2000-02-03))
then as.Date has a factor method whose effect is such that (as of R 1.9.1):
as.Date(f)
*is* the same as as.Date(as.character(f)) . (Presumably this makes
it easier to use as.Date with read.table.)
I don't know if this workaround suffers the same problem or not
since I have not tried it but you could try using the xfig device
for your graphics and then using xfig2dev to convert that file
to .cgm format (which is also vector based) and then in Word use:
Insert | Picture
or if a
predict(lm(AV~as.factor(GROUP)))
Felix Eschenburg Atropin75 at t-online.de writes:
:
: Hello list !
:
: I have a huge data.frame with several variables observed on about 3000
: persons. For every person (row) there is variable called GROUP which indices
: the group the person belongs to.
as.data.frame(matrixname)$validname
chris1 chris1 at psyctc.org writes:
:
: I'm using 1.9.0 on Windoze 2k and I created a numeric matrix and used
: colnames() to give it some column names, but if I try to select a
: column using matrixname$validname I get a null return but if I use
:
Waichler, Scott R Scott.Waichler at pnl.gov writes:
Thanks to all of you who responded to my help request.
Here is the very efficient upshot of your advice:
mat2 - apply(mat, 1, paste, collapse=:)
vec - match(mat2, unique(mat2))
vec
[1] 1 2 1 1 2 3
P.S. I found that Andy Liaw's
Jason Watts jcwatts999 at yahoo.com writes:
I'm looking for a function that returns the time at which a permanently
stored version of a dataset (object)
was last modified, just like dataset.date in S-Plus. Any suggestions?
I think others have already answered this (i.e. R does not store
?seek
Vadim Ogranovich vograno at evafunds.com writes:
:
: Hi,
:
: I am looking for an efficient way of skipping big chunks of lines on a
: connection (not necessarily at the beginning of the file). One way is to
: use read lines, e.g. readLines(1e6), but a) this incurs the overhead of
:
Data frames are supposed to have unique rownames but it
seems xtable does not know that so just set them all
to anyways on a copy of ata that you throw away later:
ata2 - ata
rownames(ata2) - rep(,nrow(ata2))
xtable(ata2)
rm(ata2)
Jeff D. Hamann jeff.hamann at forestinformatics.com writes:
:
(interaction(as.data.frame(mat), drop=T))]
:
: With 10 columns in the matrix, f0 and f1 ran fine in under 10 seconds, but
: f2g started thrashing, and ran out of memory after a while. If you look at
: how interaction() is written you'll quickly see why...
:
: Andy
:
: From: Gabor Grothendieck
Saving of the low level graphics that R displays can be
1. turned on with dev.control(displaylist=enable) and
2. turned off with dev.control(displaylist=inhibit).
recordPlot() can be used to save the display list in a variable.
For example:
# turn on display list, perform plot, turn off
Others have already addressed the bug.
Your other question seems to be how to get some simplification.
Note that Greg Warnes responded in:
http://article.gmane.org/gmane.comp.lang.r.general/18033
regarding the use of running in gregmisc.
Another thing you could do
if you want to retain the
.
:
: Daehyok Shin (Peter)
:
: -Original Message-
: From: r-help-bounces at stat.math.ethz.ch
: [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Gabor
Grothendieck
: Sent: Saturday, May 15, 2004 PM 11:59
: To: r-help at stat.math.ethz.ch
: Subject: Re: [R] How to restore and edit
1501 - 1600 of 3333 matches
Mail list logo