Displaying 20 results from an estimated 10000 matches similar to: "POSIX primer"
2009 Nov 08
1
Summary methods
I've defined the following for objects of a class called jml
summary.jml <- function(object, ...){
tab <- cbind(Estimate = coef(object),
StdError = object$se,
Infit = object$Infit,
Outfit = object$Outfit)
res <- list(call = object$call, coefficients = tab,
N = nrow(object$Data), iter = object$Iterations)
class(res) <- "summary.jml"
res
}
2010 Dec 02
4
Integral of PDF
The integral of any probability density from -Inf to Inf should equal 1, correct? I don't understand last result below.
> integrate(function(x) dnorm(x, 0,1), -Inf, Inf)
1 with absolute error < 9.4e-05
> integrate(function(x) dnorm(x, 100,10), -Inf, Inf)
1 with absolute error < 0.00012
> integrate(function(x) dnorm(x, 500,50), -Inf, Inf)
8.410947e-11 with absolute error <
2009 Oct 21
1
formula and model.frame
Suppose I have the following function
myFun <- function(formula, data){
f <- formula(formula)
dat <- model.frame(f, data)
dat
}
Applying it with this sample data yields a new dataframe:
qqq <- data.frame(grade = c(3, NA, 3,4,5,5,4,3), score = rnorm(8), idVar = c(1:8))
dat <- myFun(score ~ grade, qqq)
However, what I would like is for the resulting dataframe (dat) to include
2009 Aug 07
1
Gauss-Laguerre using statmod
I believe this may be more related to analysis than it is to R, per se.
Suppose I have the following function that I wish to integrate:
ff <- function(x) pnorm((x - m)/sigma) * dnorm(x, observed, sigma)
Then, given the parameters:
mu <- 300
sigma <- 50
m <- 250
target <- 200
sigma_i <- 50
I can use the function integrate as:
> integrate(ff, lower= -Inf, upper=target)
2010 Mar 23
1
Bold greek letters using plotmath
I'm trying to annotate some graphics using plotmath and finding out that the
code I'm using isn't bolding the greek letters - it bolds the rest (once I
adjusted the numerics to characters), it's just failing on the greek
characters.
Any suggestions welcomed.
Jim Price.
Cardiome Pharma Corp.
Test code:
plot(1:5, type = 'n')
# The not bold version
text(2, 2:4, cex =
2009 Jun 01
2
Sweave:Figures from plot (LME output) not getting generated (pdf or eps)
Hi,
I seem to be facing a strange problem when I use Sweave for creating a
LaTeX document of the R lme() output --- The EPS and PDF figure files
get created, but are empty. I have attached a reproducible example
below (taken from the R lme() help example).
------------------------------------------------------------------------------------
\documentclass[a4paper,10pt]{article}
2009 May 21
1
vcd package --- change layout of plot
Hello,
I'm trying to use the vcd package to analyze survey data. Expert judges
ranked possible features for product packaging. Seven features were
listed, and 19 judges split between 2 cities ranked them.
The following code (1) works, but the side-by-side plots for Cities PX,
SF are shrunk too much. Stacking PX on top of SF would make for a
better plot. (I could switch the order of
2008 Jul 17
2
nested calls, variable scope
Below is an example of a problem I encounter repeatedly when I write functions. A call works at the command line, but it does not work inside a function, even when I have made sure that all required variables are available within the function. The only way I know to solve it is to make the required variable global, which of course is dangerous. What is the elegant or appropriate way to solve
2009 Nov 11
1
Clarification on generic functions and methods
I have constructed the following functions and need a little clarification:
### function to fit the model parameters
jml.fit <- function(dat, con = 1e-3, bias=FALSE, ...){
do stuff ...
}
### default function which calls jml.fit
jml.default <- function(dat, con = 1e-3, bias=FALSE, ...){
result <- jml.fit(dat, con = 1e-3, bias)
result$call <- match.call()
class(result) <-
2009 Dec 22
1
as.Date function yields inconsistent results (PR#14166)
Full_Name: Mario Luoni
Version: 2.10.0
OS: Windows XP HE SP3
Submission from: (NULL) (217.194.59.134)
This piece of code:
zzz1 <- as.POSIXct("1999-03-18", tz="CET")
zzz2 <- as.POSIXlt("1999-03-18", tz="CET")
zzz1 == zzz2
as.Date(zzz1)
as.Date(zzz2)
yields TRUE for "zzz1==zzz2", but the two dates returned by as.Date are
different:
>
2012 Aug 14
2
Communative Matrix Multiplcation
Friends
I'm not seeing why the following occurs:
> T1 <- (A1 - A2) %*% D
> T2 <- (A1 %*% D) - (A2 %*% D)
> identical(T1, T2)
[1] FALSE
Harold
> dput(A1)
new("dsCMatrix"
, i = c(0L, 1L, 2L, 3L, 0L, 1L, 4L, 2L, 3L, 5L)
, p = c(0L, 1L, 2L, 3L, 4L, 7L, 10L)
, Dim = c(6L, 6L)
, Dimnames = list(NULL, NULL)
, x = c(5, 5, 5, 5, 5, 5, 10, 5, 5, 10)
2009 Nov 10
0
qplot error
When I invoke qplot, I get the following error:
Error in rename.default(x, .base_to_ggplot) : object '.data' not found
I would appreciate any advice.
sessionInfo:
R version 2.10.0 (2009-10-26)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
2009 Apr 29
1
RweaveHTML (R2HTML) Help
I have found Sweave() to be great for producing PDF documents. I have
been experimenting with RweaveHTML (from the R2HTML) package and have
had moderate success. My main issue has been that I simply want the R
output to be shown verbatim in the HTML document but RweaveHTML tends to
convert most output to a table, for example. So, is there a way to
force the RweaveHTML driver to simply provide
2012 Jun 27
0
Matrix multiplication using Matrix package
I have the following matrix operation
A %*% B %*% A
Where these matrices have the following dimensions and class attributes.
> dim(A)
[1] 5764 5764
> class(A)
[1] "dgCMatrix"
attr(,"package")
[1] "Matrix"
> dim(B)
[1] 5764 5764
> class(B)
[1] "dgCMatrix"
attr(,"package")
[1] "Matrix"
Now, when I do just the first part
2009 Oct 14
1
using mapply to avoid loops
Hello, I would like to use mapply to avoid using a loop but for some reason, I can't seem to get it to work. I've included copies of my code below. The first set of code uses a loop (and it works fine), and the second set of code attempts to use mapply but I get a "subscript out of bounds" error. Any guidance would be greatly appreciated. Xj, Yj, and Wj are also lists, and s2,
2009 Nov 29
1
optim or nlminb for minimization, which to believe?
I have constructed the function mml2 (below) based on the likelihood function described in the minimal latex I have pasted below for anyone who wants to look at it. This function finds parameter estimates for a basic Rasch (IRT) model. Using the function without the gradient, using either nlminb or optim returns the correct parameter estimates and, in the case of optim, the correct standard
2009 Nov 04
3
inconsistent behavior for logical vectors when using apply (" TRUE")
Hello,
> X <- data.frame(letters=letters[1:3], flag=c(TRUE, FALSE, TRUE))
> X
letters flag
1 a TRUE
2 b FALSE
3 c TRUE
> apply(X, 1, as.list)
[[1]]
[[1]]$letters
[1] "a"
[[1]]$flag
[1] " TRUE"
[[2]]
[[2]]$letters
[1] "b"
[[2]]$flag
[1] "FALSE"
[[3]]
[[3]]$letters
[1] "c"
[[3]]$flag
[1] " TRUE"
2011 Feb 09
3
Problem with xlsx package
I am trying to read an xlsx spreadsheet (1506 rows, 501columns) all
populated but getting the following error:
Please advise as to how to get around this issue.
> res <- read.xlsx("c:\\BSE_v2.xlsx",1)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.lang.OutOfMemoryError: Java heap space
Here is the session info:
2008 Jul 01
1
[.data.frame speedup
Below is a version of [.data.frame that is faster
for subscripting rows of large data frames; it avoids calling
duplicated(rows)
if there is no need to check for duplicate row names, when:
i is logical
attr(x, "dup.row.names") is not NULL (S+ compatibility)
i is numeric and negative
i is strictly increasing
"[.data.frame" <-
function (x, i, j,
2007 Sep 19
2
By() with method = spearman
I have a data set where I want the correlations between 2 variables
conditional on a students grade level.
This code works just fine.
by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor,
use='complete', method='pearson')
However, this generates an error
by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor,
use='complete',