Displaying 20 results from an estimated 70000 matches similar to: "Pass String from R to C"
2011 Mar 24
2
Using C code in R
Hi,
I am new to R and I want to know how to use C code which contains two
functions one called inside another.I know that how to use C code in R if it
has only one function but dont know how to do it in above case. I want to
use the same in R .My C code is as follows.
//#include <R.h>
void sayHello();
void g();
void sayhello() {
Rprintf("Hello world %d\n",global);
}
void
2005 Jul 15
3
Passing character strings from C code to R
Hi,
I have a C code which produces array of integers and potentially a string,
and I have problems passing the string out. Here is the relevant part of the
code:
 1   PROTECT(Ret = allocVector(INTSXP, n));
 2   ret     = (int*) INTEGER(Ret);  /* get pointer to R's Ret */
 3   for(i=0; i<n; i++) ret[i] = data[i];
 4   Free(data);
 5   i=1;
 6   if (comment) { // comment was found
 7     n
2005 Jul 15
3
Passing character strings from C code to R
Hi,
I have a C code which produces array of integers and potentially a string,
and I have problems passing the string out. Here is the relevant part of the
code:
 1   PROTECT(Ret = allocVector(INTSXP, n));
 2   ret     = (int*) INTEGER(Ret);  /* get pointer to R's Ret */
 3   for(i=0; i<n; i++) ret[i] = data[i];
 4   Free(data);
 5   i=1;
 6   if (comment) { // comment was found
 7     n
2011 Mar 28
1
Points on Map
Hi,
I am new to R and I want to plot points on the Map of New York .  I also
want to divide map of New York into small grids(not fixed) .I want that
these point should be plotted from a file.How can I do it?Any help would be
greatly appreciated.
Thanks
Jaimin
	[[alternative HTML version deleted]]
2011 Apr 05
1
Grid on Map
I am new to R.I want to draw grid from a csv file which contains latitude
minimum ,latitude maximum ,longitude minimum ,longitude maximum.The grid
should be divided into exactly 4 quadrants. The map is of NY state of USA. I
want to know how can I do it.
Help would be appreciated.
Thanks
Jaimin
	[[alternative HTML version deleted]]
2017 Jun 30
1
Rprintf expected encoding
I'm trying to find information about how to use Rprintf with a UTF-8 
encoded string, and I'm not sure what the right cross-platform usage is. 
I found an earlier thread about this 
(http://r.789695.n4.nabble.com/How-to-print-UTF-8-encoded-strings-from-a-C-routine-to-R-s-output-td4724337.html) 
but it wasn't very helpful.
If I want to print a UTF-8 string, I can do one of the
2010 Apr 05
2
Rprintf not updating
Hello all,
I am using Rprintf in a C for loop (from .Call) to print a progress indicator showing the current percent complete. The loop I am doing is an time intensive call to another function.  I have noticed that Rprintf does not print to the R-window until the entire loop has been completed.  When it reaches the end of the loop it suddenly prints 0 percent to 100 percent in a split second. 
2011 Jun 18
1
Pass Vector from R to C
Hi ,
I have a function which passes a vector from R to C. However the size of the
vector is decided inside the c program. But as I have to pass the size while
calling the function from R lot of my space is getting wasted. Is there any
other alternative?
I call c function as :
2011 Jan 04
1
C code hanging and printing everything at the end
Hi,
I am currently writing an extension for R and have the need to include some C code. If I call the code with a large amount of data then it can take several minutes to complete.
The C code prints out after a certain iteration hence letting the user know it hasn't crashed.
When running in R this generally does not happen and all is printed out at the end once the program has completed
2005 Apr 02
2
Building new graphic device drivers with g++
Dear Group,
I'm trying to build a set of new graphic device drivers. I use the
devNull example a a beginning point:
$ R CMD SHLIB devNull.c
gcc -shared -L/usr/local/lib -o devNull.so devNull.o
(everything works OK)
$ R CMD SHLIB devNull.cpp
g++ -shared -L/usr/local/lib -o devNull.so devNull.o
(everything works OK)
The difficulties start when trying to compile manually. I compile the
2003 Feb 02
1
printing reals from C with digits -- once more
Thank for Brian D. Ripley for the answer to my previous question.  
My aim is to print single values from different real vectors with
different digits option.  This is quite a possible with Rprintf() but
that one supprots printing format as C does, not in R native way
(setting digits=7 or printing with "%12.7f" are two quite different
things).  So I would like to find something more
2009 Feb 08
2
Strange behavior of C compiled program
Hi the list,
I need to include some C code in R, but the behavior of the C code is 
strange : Here is my code :
--- 8< ---
    Rprintf("\n XXXX mTraj=%f 
mClus=%f",mTraj[i+nbId*c],mClustersCenter[j+nbClusters*c]);
    Rprintf("\nDistA=%d Tmp=%d",dist,tmp);
            tmp = mTraj[i+nbId* c] - mClustersCenter [j+nbClusters* c];
    Rprintf("\nDistB=%d
2010 Jan 23
1
matrix to a C function
Hi the list,
Is there a way to give a matrix to a C function, and then to use it as a 
matrix ?
I write a function to print a matrix, but I use it as a vector :
1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2.     int i=0,j=0;
3.     for(i=0 ;  i < *nbLigne ; i++){
4.     for(j=0 ; j < *nbCol ; j++){
5.         Rprintf(" %f",mTraj[i * *nbCol + j]);
6.     }
7.    
2011 Aug 11
1
.C and .Call: convolve example not working
Dear R users,
I want to call C code via the .C or .Call interface. This works fine
with integer values but using doubles the array received in C will be
set to zeros.
I have tried the convolve examples (Writing R extensions, chapter 5.2)
and still the resulting array consists of zeros.
My code (shortened for my purposes. Original did not work either):
2005 Jul 15
0
[R] Passing character strings from C code to R
Thanks,
That fixed the problem.
Jarek 
-----Original Message-----
From: ripley at stats.ox.ac.uk [mailto:ripley at stats.ox.ac.uk] 
Sent: Friday, July 15, 2005 11:11 AM
To: Tuszynski, Jaroslaw W.
Cc: r-devel at stat.math.ethz.ch
Subject: Re: [R] Passing character strings from C code to R
Reading the posting guide would have shown you that R-help was quite
inappropriate, so I have moved this to
2012 Mar 14
1
Dealing with printf() &c. in third-party library code
Dear all,
I recognise the reason for strongly discouraging use of printf() and
similar C functions in R packages, but I wonder what people do in
practice about third-party code which may be littered with such calls.
I maintain a package (RNiftyReg) which provides an R interface to a
third-party library which contains hundreds of calls to printf(...),
fprintf(stderr,...) and similar. It seems to
2009 Jun 18
2
Argument as.integer(NA) to a function C
Hi the list,
I am writing a R function that call a C function. The C function needs 
integers but I do not manage to give a NA integer as argument :
--- C code ---
void essai(int *t){
    Rprintf("\nT0=%i T1=%i T2=%i T3=%i",t[0],t[1],t[2],t[3]);
}
--- R ---
boub <- c(1,2,3,4)
.C("pour",as.integer(boub),NAOK=TRUE)
# T0=1 T1=2 T2=3 T3=4[[1]]
# [1] 1 2 3 4
boub <-
2008 Sep 26
1
Bug? in some package installations when a Print is added in memory.c
Hi All,
    The first time i noticed this problem is when i enabled some debug
prints in memory.c
DEBUG_GC
DEBUG_ADJUST_HEAP
DEBUG_RELEASE_MEM etc.. These have some prints for debugging .Base R package
installation completes well and good.
The problem comes when some of the Recommended package installation happens.
The following Packages fail "KernSmooth,lattice,rpart,cluster,survival
2012 Jun 21
2
debug R objects at C level
Dear R-devel,
I am now at a debugging phase, and would like to inspect the
(individual) values in an arbitrary R vector. It should be simple, but
after hours of reading I am simply unable to find the right
information.
A possible C code is:
?????????????????
# include <R.h>
# include <Rinternals.h>
# include <R_ext/Rdynload.h>
SEXP foo(SEXP x) // where x is a vector passed by
2014 Dec 20
2
Unexplained difference between results of dppsv and dpotri LAPACK routines
Dear R contributors,
Considering the following sample C code, that illustrates two possible
uses of a Cholesky decomp for inverting a matrix, equally valid at
least in theory:
SEXP test() {
int d = 2;
int info = 0;
double mat[4] = {2.5, 0.4, 0.4, 1.7};
double id[4] = {1.0, 0.0, 0.0, 1.0};
double lmat[3];
F77_CALL(dpotrf)("L", &d, mat, &d, &info);
lmat[0] = mat[0];
lmat[1]