similar to: Is there a place to put executable R scripts in new packages?

Displaying 20 results from an estimated 1000 matches similar to: "Is there a place to put executable R scripts in new packages?"

2012 Dec 04
3
How to find matching columns in a matrix of lists?
Dear R users, I have a matrix composed of lists: m <- matrix( list(), nrow=1, ncol=3 ) m[[ 1, 1 ]] <- list("A", "B") m[[ 1, 2 ]] <- list("A", "C") m[[ 1, 3 ]] <- list("A", "B") and want to get the sub-matrix where cells contain "B". But m[ , "B" %in% m[ 1, ], drop=F ] as well as m[ , "B"
2012 Dec 11
2
debug on lapply
Dear R experts, recently I tried to debug a R function with an internal lapply call. When debugging I seem not to be able to use the "n" command to debug the inner function called by lapply. How could I achieve this? *For example:* test <- function( ) { lapply( 1:3, function( x ) x + 1 ) } debug( test ) *Start debug:* > test() debugging in: test() debug bei #1:{
2013 Apr 02
3
How to do platform independent system calls?
Dear R experts, I hope everyone has had a happy easter break. Recently my work included writing R function that need to call external tools. I did this using R's system function for example: system( paste( 'tool', '-input', path_to_input, '-output', path_to_output, '-other_switch', some_val ) ) I have two question about this: 1) Is there a way to implement
2012 Dec 13
1
possible bug in function 'mclapply' of package parallel
Dear parallel users and developers, I might have encountered a bug in the function 'mclapply' of package 'parallel'. I construct a matrix using the same input data and code with a single difference: Once I use mclapply and the other time lapply. Shockingly the result is NOT the same. To evaluate please unpack the attached archive and execute Rscript mclapply_test.R I put the
2012 Nov 21
1
lists as matrix cells ?
Dear R experts, since more or less half a year I am using R. In many of my computations I construct huge matrices. Often I do so using 'cbind' on named lists: do.call( 'cbind', list( "Column_A"=list("Row_one"=1.0, "Row_two"=2.0, "Row_three"=3.0), "Column_B"=list("Row_one"=4.0, "Row_two"=5.0,
2012 Dec 17
2
Why does matrix selection behave differently when using which?
Dear R community, I have a medium sized matrix stored in variable "t" and a simple function " countRows" (see below) to count the number of rows in which a selected column "C" matches a given value. If I count all rows matching all pairwise distinct values in the column "C" and sum these counts up, I get the number or rows of "t". If I delete the
2013 May 24
0
Rcpp with OpenMP - Need example Makevars
Dear R experts, recently I started developing a Rcpp package "OpenMPTest". Within that package I want to use OpenMP, as in the following code example: // header file #include <omp.h> using namespace Rcpp ; RcppExport SEXP testOpenMP( SEXP nThreads ) ; // cpp file SEXP testOpenMP( SEXP nThreads ) { BEGIN_RCPP NumericVector numberThreads = NumericVector( nThreads );
2019 Nov 17
2
Inappropriate class(o)[!inherits(o,"AsIs")] in get_all_vars
SVN?revision?77401?changes ????????x[isM]?<-?lapply(x[isM],?function(o)?`class<-`(o,?class(o)[class(o)?!=?"AsIs"])) to ????????x[isM]?<-?lapply(x[isM],?function(o)?`class<-`(o,?class(o)[!inherits(o,"AsIs")])) in?function?'get_all_vars'?in?src/library/stats/R/models.R?in?R?devel. The?change?is?inappropriate.
2019 Nov 18
2
Inappropriate class(o)[!inherits(o,"AsIs")] in get_all_vars
>>>>> Martin Maechler >>>>> on Mon, 18 Nov 2019 12:15:38 +0100 writes: >>>>> suharto anggono--- via R-devel >>>>> on Sun, 17 Nov 2019 10:34:31 +0000 writes: >> SVN revision 77401 changes >> x[isM] <- lapply(x[isM], function(o) `class<-`(o, class(o)[class(o) != "AsIs"])) >> to
2020 Mar 29
2
is.vector could handle AsIs class better
Dear R-devel, AsIs class seems to be well handled by `typeof` and `mode` function. Those two functions are being referred when explaining `is.vector` behaviour in manual. Yet `is.vector` does not seem to be handling AsIs class the same way. is.vector(1L) #[1] TRUE is.vector(I(1L)) #[1] FALSE Is there any reason behind this behaviour? Could we have it supported so AsIs class is ignored when
2002 May 29
1
warning message for setAs when using class AsIs
This seemed too advanced for r-help and is related to the recent discussion of character vectors in dataframes. Following Brian Ripley's most excellent advice, we are moving to a world in which character vectors in dataframes are always of class AsIs. The cool way of doing this seemed to be the following: > cat(c("x", "y", "z"), file = "test.txt",
2020 Oct 23
2
Change to I() in R 4.1
Hi there, Is that change in R-devel intentional? library(Matrix) m <- as(matrix(c(0, 1)), "sparseMatrix") isS4(m) # [1] TRUE x <- I(m) # Warning message: # In `class<-`(x, unique.default(c("AsIs", oldClass(x)))) : # Setting class(x) to multiple strings ("AsIs", "dgCMatrix", ...); result will no longer be an S4 object
2006 Mar 15
5
Surv object in data.frame
Dear All, a Surv object I put in a data frame behaves somehow unexpected (see example). If I do a Cox regression on the original Surv object it works. If I put it in a data.frame and do the regression on the data frame it does not work. Seemingly it has to do with the class attribute, because if I change the class attribute to let "Surv" appeare first, again it works. Is this known?
2020 Mar 30
1
is.vector could handle AsIs class better
Thank you Gabriel, Agree, although I think that could be relaxed in this single case and AsIs class could be ignored. Best, Jan On Sun, Mar 29, 2020 at 7:09 PM Gabriel Becker <gabembecker at gmail.com> wrote: > > Jan, > > I believe it's because it has "a non-NULL attribute other than names" as per the documentation. In this case its class of "AsIs". >
2005 Mar 17
1
Binding one column of characters into a dataframe factors other numeric columns
Hi all, I searched through the archives, but couldn't find a fix... Basically, I've got a bunch of numeric vectors and one character vector that I want to bind into a data frame. When I include the character vector as a column in the data frame, all the numeric columns get factored in the data frame, which makes it tough to call those columns for calculations later on. I've tried
2020 Oct 30
2
Change to I() in R 4.1
Hi Martin, On 10/26/20 04:52, Martin Maechler wrote: >> >> Hi there, >> Is that change in R-devel intentional? >> >> library(Matrix) >> m <- as(matrix(c(0, 1)), "sparseMatrix") >> >> isS4(m) >> # [1] TRUE >> >> x <- I(m) >> # Warning message: >> # In `class<-`(x,
2010 Mar 12
2
Data frame question
Hi, I have the following question about creating data frames. I want to create a data frame with 2 components: a vector and a matrix. Let me use a simple example: y <- rnorm(10) x <- matrix(rnorm(150), nrow=10) Now if I do dd <- data.frame(x=x, y=y) I get a data frame with 16 colums, but if, according to the documentation, I do dd <- data.frame(x=I(x), y=y) then str(dd)
2016 Dec 20
3
Unexpected I(NULL) output
Hi all, I believe there is an issue with passing NULL to the function I(). class(NULL) # "NULL" (as expected) print(NULL) # NULL (as expected) is.null(NULL) # TRUE (as expected) According to the documentation I() should return a copy of its input with class "AsIs" preprended: class(I(NULL)) # "AsIs" (as expected) print(I(NULL)) # list() (not expected!
2010 Jan 16
1
order() fails on a chr object of class "AsIs" with "\265" in it
Here's an example (session info at the end). > tmpv <- c('\265g/L','Bq/L') > order(tmpv) [1] 2 1 > tmpv <- I(tmpv) > order(tmpv) Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed > foov <- gsub('\265','',tmpv) > order(foov) [1] 2 1 > str(tmpv) Class 'AsIs' chr [1:2] "\265g/L"
2020 Oct 30
1
[External] Re: Change to I() in R 4.1
On Fri, 30 Oct 2020, Pages, Herve wrote: > > On 10/29/20 23:08, Pages, Herve wrote: > ... >> >> I can think of 2 ways to move forward: >> >> 1. Keep I()'s current implementation but suppress the warning. We'll >> make the necessary adjustments to DataFrame() to repair columns supplied >> as I(<S4>) objects. Note that we would still be in