Displaying 20 results from an estimated 3000 matches similar to: "Call to rgamma using .C causes R to hang"
2006 Feb 21
4
simple C function segfaults
Hello,
I use the simplest of examples that somebody can think
of in order to generate a matrix of random numbers
from within C, calling appropriate R functions. The
concrete example is below:
--- file pico.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <R.h>
#include <Rmath.h>
#define COLM( i, j, m ) ( m*j + i)
void pico ( double *y, int n,
2010 Apr 01
2
pdf files in loops
I need to make a bunch of PDF files of histograms. I tried
gatelist = unique(mdf$ArrivalGate)
for( gate in gatelist) {
outfile = paste("../", airport, "/", airport, "taxiHistogram", gate,
".pdf", sep="")
pdf(file = outfile, width = 10, height=8, par(lwd=1))
title=paste("Taxi time for Arrival Gate", gate, "by
2005 Nov 30
1
RNG stuck via Fortran call
Having not much success with my previous question I try to reformulate it:
I'm simulating a Markow chain in Fortran interfaced with R.
Each loop of my Fortran calls various functions of the R RNG through
the wrapper given below.
In a run of 100 iterations of the Markov kernel,
after 20 iterations, the RNG seems like frozen.
For example, the first call to the RNG in my loop is:
2010 Sep 07
4
minor diagonal in R
Dear all,
seems that easy question but cannot find the function for that.
How to get the elements of the minor diagonal of the matrix?
Thanks a lot.
[[alternative HTML version deleted]]
2010 Oct 15
1
creating 'all' sum contrasts
OK, my last question didn't get any replies so I am going to try and ask a different way.
When I generate contrasts with contr.sum() for a 3 level categorical variable I get the 2 orthogonal contrasts:
> contr.sum( c(1,2,3) )
[,1] [,2]
1 1 0
2 0 1
3 -1 -1
This provides the contrasts <1-3> and <2-3> as expected. But I also want it to create <1-2> (i.e.
2010 Oct 29
2
R version 2-12.0 - running as 32 or as 64 bit?
Question: I installed R verison 2-12.0 on my Windows 7 (64 bit) PC.
When I was installing it, it did not ask me anything about 32 vs. 64 bit.
So, if I run R now - is it running as a 32-bit or a 64-bit?
thank you!
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
2009 Nov 15
2
Relase positive with log and zero of negative with 0
This is a very simple question but I couldn't form a site search quesry that would return a reasonable result set.
Say I have a vector:
x <- c(0,2,3,4,5,-1,-2)
I want to replace all of the values in 'x' with the log of x. Naturally this runs into problems since some of the values are negative or zero. So how can I replace all of the positive elements of x with the log(x) and the
2009 Nov 11
1
Unexpected behaviour for as.date()
Hi everyone,
I am trying to use the function as.date() from the "dates" package in R
2.10.0 to convert a character date to a Julian date, as follows:
> as.date("02-MAY-01", order="mdy") # convert May 2, 2001 to a Julian date
[1] 2May1
However, when trying to convert a character date from the year 2000 to a
Julian date, I get an <NA> instead of the
desired
2011 Jan 19
1
expand.grid
Hello list.
I feel like an idiot.
There exists a method called expand.grid which, from the documentation,
appears to do just what I want, but then it doesn''t, and I can''t get it to
behave.
Given a dataframe
dfr<-data.frame(c1=c("a", "b", NA, "a", "a"), c2=c("d", NA, "d", "e", "e"),
2005 Jun 28
1
GetRNGstate() crashes in Windows
Hi,
Has anyone managed to successfully call GetRNGstate() / PutRNGstate()
without crashing in a Windows environment (spec. XP)? I've compiled
successfully using both the latest Cygwin, latest Mingw, and the version
of Mingw suggested in "Building R for Windows" website, but when the
executable runs, it crashes; the functions themselves can run when I omit
2011 Aug 03
1
expand.gird with constraints?
Hi, R users,
Here is an example.
k <- c(1,2,3,4,5)
i <- c(0,1,3,2,1)
if k=1, then j=0 from i
if k=2, then j=0, 1 from i
if k=3, then j=0, 1, 2, 3 from i
if k=4, then j=0, 1, 2 from i
if k=5, then j=0, 1 from i
so i'd like to create a list like below.
> list
k j
1 1 0
2 2 0
3 2 1
4 3 0
5 3 1
6 3 2
7 3 3
8 4 0
9 4 1
10 4 2
11 5 0
12 5 1
I tried expand.grid, but I
2010 Sep 25
2
OT: What distribution is this?
Hi
This is OT, but I need it for my simulation in R.
I have a special case for sampling with replacement: instead of sampling
once and replacing it immediately, I sample n times, and then replace all n
items.
So:
N entities
x samples with replacement
each sample consists of n sub-samples WITHOUT replacement, which are all
replaced before the next sample is drawn
My question is: which
2011 Jan 22
4
two apparent anomalies
(1)
> a = c("a","b")
> mode(a)
[1] "character"
> b = c(1,2)
> mode(b)
[1] "numeric"
> c = data.frame(a,b)
> mode(c$a)
[1] "numeric"
(2)
> a = c("a","a","b","b","c")
> levels(as.factor(a))
[1] "a" "b" "c"
> levels(as.factor(a[1:3]))
[1]
2010 Nov 16
4
DBLEPR?
Ravi Varadhan and I have been looking at UCMINF to try to identify why it gives occasional
(but not reproducible) errors, seemingly on Windows only. There is some suspicion that its
use of DBLEPR for finessing the Fortran WRITE() statements may be to blame. While I can
find DBLEPR in Venables and Ripley, it doesn't get much mention after about 2000 in the
archives, though it is in the R FAQ
2010 Nov 16
4
DBLEPR?
Ravi Varadhan and I have been looking at UCMINF to try to identify why it gives occasional
(but not reproducible) errors, seemingly on Windows only. There is some suspicion that its
use of DBLEPR for finessing the Fortran WRITE() statements may be to blame. While I can
find DBLEPR in Venables and Ripley, it doesn't get much mention after about 2000 in the
archives, though it is in the R FAQ
2010 May 28
3
Gelman 2006 half-Cauchy distribution
Hi,
I am trying to recreate the right graph on page 524 of Gelman's 2006
paper "Prior distributions for variance parameters in hierarchical
models" in Bayesian Analysis, 3, 515-533. I am only interested, however,
in recreating the portion of the graph for the overlain prior density
for the half-Cauchy with scale 25 and not the posterior distribution.
However, when I try:
2010 Oct 25
2
R-Fortran question (multiple subroutines)
Dear R-helpers,
apologies if this is somewhere in a manual, I have not been able to
find anything relevant. I run Windows Vista.
I have some Fortran code in a subroutine, and have no problem calling
this from R with .Fortran, compiling the code either with 'R CMD
SHLIB' or independently with gfortran.
But is it possible to have more than one subroutine in my source file,
one depending
2014 Jan 11
1
Fortran BLAS giving bad results
Hello r-devel,
When compiling Fortran code containing BLAS functions and calling it using
dyn.load, I am getting incorrect results. A small example with which I can
reproduce the problem is below.
I am running on OSX Mavericks (upgraded R, Xcode, etc per instructions on
this list), but I do not think it is related since the check on my
"blupsurv" package on r-forge seems to be showing
2010 Oct 26
5
cube root of a negative number
Hi,
This might be me missing something painfully obvious but why does the cube root of the following produce an NaN?
> (-4)^(1/3)
[1] NaN
>
As we can see:
> (-1.587401)^3
[1] -4
Thanks!
Greg
2004 Mar 03
1
generating normal numbers: GetRNGstate, PutRNGstate
Hi
I'd like to generate thousands of normal numbers from my C function using
the C API functions provided R. I have two options:
1. double norm_rand(); (page 61 of R extension 1.8.1)
2. double rnorm(double mu, double sigma); (page 58 of R extension 1.8.1)
If my understanding of R-exts is correct, then I only need to call
GetRNGstate once, and then call 1000 norm_rand, and then call