Displaying 20 results from an estimated 7000 matches similar to: "Basic function output/scope question"
2009 Jun 23
4
SAS Macro Variable in R
Hi I'm new to R and would like to implement a SAS-like macro variable
in R.
What I'd like to do is take the simple R code below and change the
"=TEF" to different letters to refer to different companies' data for
download.
# DOWNLOADS FILES FROM YAHOO INTERNET
2010 Apr 12
2
SAS like Macro variable substituion?
I'd like to use a string to refer to an R object with the end
objective of going through a loop and saving various files of the same
name with different contents using a numbered suffix.
# This will be the loop counter and file suffix.
master.i <- 1
# This is the generic file name.
unislopes <- c(1,2,3)
# This assigns the data to the correct file name "unislopes1".
2009 Oct 28
3
Lost all script
Hi all,
I just had a rather unpleasant experience. After considerable work I
finally got a script working and set it to run. It had some memory
allocation problems when I came back so I used Windows to stop it.
During that process it told me that the script had been changed and
asked if I wanted to save it. Not being positive that I'd saved the
very last changes I said yes. Now when I
2008 Nov 10
6
Variable passed to function not used in function in select=... in subset
Hello!
I have the problem that in my function the passed variable is not used, but the variable name of the dataframe itself?- difficult to explain, but an easy example:
TestFunc<-function(df, group) {
??? print(names(subset(df, select=group)))
}
df1<-data.frame(group="G1", visit="V1", value=0.9)
TestFunc(df1, c("group", "visit"))
Result:
[1]
2009 Oct 15
1
Removing Embedded Null characters from text/html
Hi,
I'm trying to download some data from the web and am running into
problems with 'embedded null' characters. These seem to indicate to R
that it should stop processing the page so I'd like to remove them.
I've been looking around and can't seem to identify exactly what the
character is and consequently how to remove it.
# THE CODE WORKS ON THIS PAGE
library(RCurl)
2013 Jan 26
2
[LLVMdev] Code compiling in gcc but not llvm
Hi,
This is my first post, sorry if not in the right format.
I am stuck at a place where I have a code fragment that runs in normal gcc
but fails when I give -fplugin=dragonegg.so
extern int *testfunc();
extern __typeof (testfunc) testfunc __asm__ ("" "__GI_testfunc")
__attribute__ ((visibility ("hidden")));
extern __typeof(testfunc) __testfunc;
extern __typeof
2009 Oct 14
2
puzzle using gsub (and encodings maybe)
Hello,
Below is some output that shows my issue.
I have a variable x that I read from a file (more on this below)
> x
[1] "NEW YORK NEW ENGLAND"
> gsub(" -", "-", x) # this does not work!
[1] "NEW YORK NEW ENGLAND"
> Encoding(x) # is x in a special encoding? no
[1] "unknown"
> y = "NEW YORK -NEW
2012 Sep 21
2
Parallel Programming
I am trying to do parallel programming and I tried this
library(doSNOW)
library(foreach)
testfunc<-function(x){
x<-x+1
x
}
noc<-2
cl <- makeCluster(do.call(rbind,rep(list("localhost"),noc)), type = "SOCK")
registerDoSNOW(cl)
clusterExport(cl=cl,c("testfunc.r"))
testl<-foreach(pp=1:2) %dopar% {
testfunc(pp)
}
And this works but if I try to
2019 Jun 18
3
Fast way to call an R function from C++?
Hi,
I'm looking for a most efficient way to call an R function from C++ in a
package. I know there are two functions (`R_forceAndCall` and `Rf_eval`)
that can do the "call" part, but both are slow compared to calling the same
function in R. I also try to use Rcpp and it is the worse one. Here is my
test code:
C++ code:
```
// [[Rcpp::export]]
SEXP C_test1(SEXP f, SEXP x) {
SEXP
2009 Aug 30
4
[LLVMdev] Perfect forwarding?
BLAST! LLVM mailing list headers are still royally screwed up...
My message is below...
On Sun, Aug 30, 2009 at 2:20 PM, Talin<viridia at gmail.com> wrote:
> Hey all, it's been a while since I have posted on this list, but I've
> been continuing my work with LLVM and getting lots done :)
>
> One question I wanted to ask is whether anyone had any advice on how to
>
2004 Mar 10
1
Question concerning library function "nlme" and lexical scoping
I am running into problems calling the library function nlme from within
another function. Basically,the following function (with v a list
containing data and initialization values)
> testfunc
function(dat=v) {
test<-nlsList(result~a+(b-a)/(1+(conc/(c+z*cdiff))^d)
|rep,start=dat$init,data=dat$mixeddat)
return(nlme(test,random=b~1))
}
produces the error message
Error in eval(expr, envir,
2009 Aug 05
0
[LLVMdev] Stack Management in LLVM
First off, thanks for the help so far.
>From what I have been able to tell, emitPrologue kicks in after the arguments
for the function have been copied. For example, consider the function
int testfunc( int foo, int bar );
Emitting assembly code from the llvm-gcc frontend in a small test program
gives the following for the call to testfunc
movl $1338, (%esp)
movl $1339, 4(%esp)
call
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: methods
[1] TRUE
> testFunc
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: methods
[1] TRUE
> testFunc
2008 Nov 04
1
Help needed using 3rd party C library/functions from within R (Nvidia CUDA)
Hello,
I'm trying to combine the parallel computing power available through NVIDIA
CUDA (www.nvidia.com/cuda) from within R. CUDA is an extension to the C
language, so I thought it would be possible to do this.
If I have a C file with an empty function which includes a needed CUDA
library (cutil.h) and compile this to an .so file using a NVIDIA compiler
(nvcc), called 'myFunc.so' I
2017 Apr 05
2
Deopt operand bundle behavior
Hi!
We have started to use deopt operand bundle to make our native stacktrace deoptimizable and garbage collectable. We stumbled upon an issue and we don't know if it is really an issue on our side or really a problem within LLVM.
For example, for this input:
declare { i8*, i8* } @getCode()
define void @testFunc() {
entry:
%0 = call { i8*, i8* } @getCode()
%1 = extractvalue { i8*, i8* }
2009 Nov 23
2
categorisation of continuous variables in R
Dear all,
I'm looking for a function comparable to switch, to categorize a
continuous variable in a few levels. Off course that can be done with
a series of ifelse statements, but that looks rather clumsy. I looked
at switch, but couldn't figure out how to use it for this. I guess
that's not possible, as it only works with characters or integers, not
with intervals.
Basically,
2011 Jan 18
2
[LLVMdev] compiling a call to function in compiler
Hi,
I'm trying to follow the advice from this message:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2008-October/017574.html,
to create a call instruction from a function pointer. But I'm
getting...
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"),
function cast, file /usr/local/include/llvm/Support/Casting.h, line 202.
2019 Jun 18
2
Fast way to call an R function from C++?
For reference, your benchmark using UNWIND_PROTECT:
> system.time(test(testFunc, evn$x))
user system elapsed
0.331 0.000 0.331
> system.time(test(C_test1, testFunc, evn$x))
user system elapsed
2.029 0.000 2.036
> system.time(test(C_test2, expr, evn))
user system elapsed
2.307 0.000 2.313
> system.time(test(C_test3, testFunc, evn$x))
user system
2010 Mar 18
1
Using a function to consolidate variables
Dear List,
I'm getting the error: object of type 'closure' is not subsettable
And am not sure how to get around the problem. I've included two
short code sets below. One that shows what I want to do and works,
but without using the function much, and another that tries to use the
function but causes the error.
# THIS WORKS AND SHOWS WHAT I'D LIKE TO DO
a <- c(1,2,3)
b