Displaying 20 results from an estimated 10000 matches similar to: "dimnames"
2008 Feb 13
2
apply on large arrays
I have a big contingency table, approximately of size 60*2*500*500,
and I need to count the number of cells containing a count of 1 for each
of the factors values defining the first dimension.
Here is my attempt:
tab1<-with(pisa1,table(CNT,GENDER,ISCOF,ISCOM))
tab2<-apply(tab1,1:4,function(x)ifelse(sum(x)==1,1,0))
tab3<-apply(tab2,1,sum)
Computing tab2 is very slow.
Is there a faster
2005 Dec 21
3
NextMethod causes R 2.2.0 to crash (PR#8416)
I found writing the following default method the for the generic
function "julian" causes R to crash.
julian.default <- function(x, ...) {
x <- as.Date(x)
NextMethod("julian", x, ...)
}
Here is a test example
> m <- as.Date("1972-09-27") + 0:10
> m
[1] "1972-09-27" "1972-09-28" "1972-09-29"
1999 Sep 22
1
model.matrix() (PR#285)
I was alarmed to discover that model.matrix.default() can permute columns
with respect to the formula. This seems to happen with user-defined
components of the formula. Thus
X <- matrix(1:4, 1, 4, dimnames = list(NULL, LETTERS[1:4]))
Q <- function(x) x^2 # because model.matrix() does not like, eg, A:A
model.matrix(~ -1 + A + A:B + Q(C), data.frame(X))
has columns ordered A, Q(C), and
2008 Feb 01
6
Accessing the elements of a list
Hi R,
I wanted to know how do we access the elements of a list. In particular,
v=list(c(1,2,3,4,5),c(1,2,33,4,5),c(1,2,333,4,5),c(1,2,3333,4,5))
I want to access all the thirds items of the elements of the list. i.e.,
I want to access the elements, 3,33,333,3333. This can be done through
sapply as:
sapply(v,function(x) x[3])
But I need to access this without using
2005 Apr 30
3
as.numeric method for objects of class "difftime"
I have just become painfully aware that objects of class "difftime",
generated by the difference of two POSIXct objects, carry a "units"
attribute, which flashes by when the object is printed, for example.
The pain was occasioned when I tried to turn these objects into numberic
objects for use elsewhere as a covariate.
as.numeric(difftime object)
simply turns off the units
2006 Dec 22
5
substitute creates an object which prints incorrectly (PR#9427)
The function "substitute" seems to fail to make a genuine
substitution, although the printed verision seems fine. Here is an
example.
> m <- substitute(Y <- function(x) FUN(x+1),
+ list(Y = as.name("y"), FUN = as.name("sin")))
> m
y <- function(x) sin(x + 1)
> eval(m)
> y
function(x) FUN(x+1)
However the story doesn't end there. The
2007 Jul 03
1
termplot - changes in defaults
While termplot is under discussion, here's another proposal. I'd like to
change the default for partial.resid to TRUE, and for smooth to
panel.smooth. I'd be surprised if those changes were to break existing
code.
John Maindonald email: john.maindonald at anu.edu.au
phone : +61 2 (6125)3473 fax : +61 2(6125)5549
Centre for Mathematics & Its Applications, Room
1999 Mar 17
1
hist(list)?
It seems that the following should work:
> x<-read.table('1A.tab',header=T,skip=1);
> mode(x[1])
[1] "list"
> x[1]
p01
R1-00 0.0295
R1-01 0.0283
R1-02 0.0145
R1-03 0.0235
R1-04 0.0339
R1-05 0.0239
R1-06 0.0414
R1-07 0.0259
> hist(x[1])
Error: hist: x must be numeric
> as.numeric(x[1])
Error: (list) object cannot be coerced to vector type 14
>
2001 Nov 01
1
cor.test for a correlation matrix
Is there a simple way to run cor.test on for a matrix of correlations?
Of course, cor on a data frame produces a correlation matrix, but cor.test will only take two variables at a time. Is there a way to get behavior similar to that of cor with cor.test?
I suppose the programming alternative would be to run two for loops with the number of items and cor test embedded accessing the columns of
2000 May 25
1
diag() (PR#555)
Full_Name: David Duffy
Version: 1.0.1
OS: Linux
Submission from: (NULL) (152.98.96.21)
Documentation for diag() states that "If x is a vector (or a
1-d array) then diag(x) returns a diagonal matrix whose diagonal
is x."
> m<-matrix(1:4,ncol=1)
> diag(m)
[1] 1
diag(as.vector(m)) gives the advertised performance.
Fix: Change documentation.
2000 Sep 20
1
SV: sample from contingency table
I have had the same problem and I wrote this function
rmulti <- function(n, size, p)
{
NrDim <- length(p)
if(NrDim<2) stop("The simulated variabel has to be at least
2-dimensional")
res <- matrix(data=NA, nrow=n, ncol=NrDim)
p <- p/sum(p)
TempSize <- size
for(i in 1:NrDim)
{
TempP <- p[i]/sum(p[i:NrDim])
TempBin <- rbinom(n=n, size=TempSize,
2000 Mar 07
1
A simple question??
Dear all,
I'm currently use R v0.99 on Windows 98 Second Edition. I have a question on some simple calculations. I wonder that I've done something wrong with the calculation.
Here is the imput commands:
> a <- 25.01
> b <- 56.08
> a.trunc <- trunc(a)
> b.trunc <- trunc(b)
> a.tail <- a - a.trunc
> b.tail <- b - b.trunc
> a.trunc
[1] 25
>
2001 Oct 30
2
moving dimnames when reassigning
Hi, all.
I've got a question that arose when I was switching some row and columns in
a matrix. I was expecting the row and column names to follow their rows and
columns, and they didn't. I think I see some logic to the behavior, but I'm
not sure whether it's intentional or not, so I thought I'd ask the list
whether this is a feature or a bug.
Here's an example (R-1.3.1,
2007 Nov 15
3
generate combination set
I have a set data={A,B,C,D,E,F,G}
I want to choose 2 letter from 8 letters, i.e. generate the combination set
for choose 2 letters from 8 letters.
I want to get the liking:
combination set={AB,AC,AD,....}
Does anyone konw how to do in R.
thanks,
Aimin
2000 Jan 12
3
functions for flat file import/export + utilities
Dear R-Developers,
please find attached a set of drafted functions for flat file import and
export, partially extending existing functions, partially completely written
as new code.
I thought you might be interested in those functions and the accompanying
utilities for padding and trimming.
Main features are
- supports several formats, i.e. fixed width and CSV (with one exception)
- supports
2000 Feb 03
1
Re: your mail
> On Wed, 2 Feb 2000, Adriane Leal wrote:
>
> > I'd like to perform a box-cox transformation to a data set and also plot
> > lambda versus L(lambda) using R. Does anybody knows how can I do such a
> > thing?
gnlr3 in my gnlm library does both linear and nonlinear models with
Box-Cox transformation. However, it is somewhat nonstandard as it
renormalizes to obtain a
2000 Jan 04
1
correlation matricies: getting p-values?
I have to admit that I'm at a bit of a loss here; any pointers would be
greatly appreciated.
I've been making correlation matricies from some of my datasets, and
have been instructed to get the probability values for each of these
correlations.
I've checked the online help for info on both the cor and cov functions,
but I was unable to find any relevant info on finding how to obtain
2000 Jun 22
1
help
Dear All,
Further to answers to sorting, can someone tell me how can I sort a list
that contains duplicates (name) but keeping the duplicates together when
sorting the values.
e.g., a data frame with name (in duplicates), Mvalues(may be different for
the duplicates)
name M
1234 8
1234 8.3
4321 9
4321 8.1
If I sort by M, it will be 1234, 4321, 1234, 4321 but I want to keep the
duplicates together,
2008 Mar 04
6
vector manipulations
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?...
Nom : non disponible
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20080304/9de37092/attachment.pl
1999 Sep 29
2
avoiding loops, gaining generality
Hi, all.
Given an array, I'd like to add elements whose location vectors are
permutations of one another. For example, in a 3-dimensional array, I'd
add the elements in positions (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2)
and (3,2,1); those in positions (1,2,4), (1,4,2), (2,1,4), (2,4,1),
(4,1,2), and (4,2,1); and so on. Elements with repeated positions
-- (1,1,2) or (1,4,4), for