[R] New mask.ok option for libraries

2021-01-07 Thread Magnus Torfason
I had sent the following to r-devel a while ago, but perhaps r-help is more appropriate. I guess my question is what to do with this, would people generally file an issue, or is there a way to hear if this is something that makes sense to add – whether more info would be helpful and so on? = I

Re: [R] Trying to tile wireframe plots (using lattice package)

2010-06-25 Thread Magnus Torfason
Thanks, that was the pointer I needed. I'd tried the split parameter but didn't realize that it doesn't work well within wireframe() itself, rather, I had to call print.trellis() directly using the trellis object that wireframe() returns if one assigns it to something. After that, it was prett

[R] Trying to tile wireframe plots (using lattice package)

2010-06-25 Thread Magnus Torfason
Hi all, I'm trying to print a number of wireframe plots (generated using the lattice package), and I want them to appear in a two-by two matrix along with some other (standard) plots. In other words I am trying to create a subplot or tiled plot that works for wireframes. I've tried the metho

Re: [R] Deleting duplicate rows in a matrix at random

2010-06-03 Thread Magnus Torfason
> I need to remove all but one of each [row in a matrix], which > must be chosen at random. This request (included in full at the bottom), has been unanswered for a while, but I had the same problem and ended up writing a function to solve it. I call it "duplicated.random()" and it does exactly

[R] Memory warning (Reached total allocation of ...) - but no error

2010-05-05 Thread Magnus Torfason
Hi all, I'm getting the following warnings inside a loop: Warning messages: 1: In calc.measures(g, 1, i) : Reached total allocation of 1535Mb: see help(memory.size) 2: In calc.measures(g, 1, i) : Reached total allocation of 1535Mb: see help(memory.size) Usually, when I see these warnings, t

Re: [R] Advantages of using SQLite for data import in comparison to csv files

2010-01-14 Thread Magnus Torfason
RSQLite is actually much more than a "driver for data import". It basically allows any manipulation of SQLite databases, including reading, writing, or updating and munging data within the database. Regarding the original question of data import: I use csv and sqlite files interchangeably to

Re: [R] Ask about large data set

2010-01-13 Thread Magnus Torfason
On 1/12/2010 8:29 PM, Yi Du wrote: Hi, Is that okay to let R to read data set more than 1 rows and use it to do some kernel density estimation? Thanks. Yi Why don't you just try it and see? Nothing bad will happen - the absolute worst case scenario is that R will hang. But I can tell y

Re: [R] <= returns wrong result? Why

2010-01-13 Thread Magnus Torfason
Yupp, FAQ 7.31 is definitely your friend here. You might also want to take a look at these two very recent threads on this help list: "Strange behaviour of as.integer()" http://tolstoy.newcastle.edu.au/R/e9/help/10/01/index.html#547 "Newbie question on precision" http://tolstoy.newcastle.edu.

Re: [R] Solving graph theory problems with R ? (minimum vertex cover)

2010-01-12 Thread Magnus Torfason
On 1/12/2010 12:12 AM, Johannes Hüsing wrote: Tal Galili schrieb: My specific problem is called: Minimum vertex cover for a hypergraph I know nothing about the problem at hand, but on the Wikipedia page it says that the problem can be formulated as an integer linear program. There is an R pack

Re: [R] Conditional Sampling

2010-01-12 Thread Magnus Torfason
Would the following work, or is there a reason why it would not? risk.set <- 1:100 first.10 <- sample(risk.set, 10) remainder <- setdiff(risk.set, first.10) for ( i in 1:1000 ) { next.5 <- sample(remainder, 5) do.something.with(next.5) } Best, Magnus On 1/12/2010 9:00 AM, ehcpiet

Re: [R] Strange behaviour of as.integer()

2010-01-11 Thread Magnus Torfason
On 1/11/2010 10:37 AM, Martin Maechler wrote: Magnus Torfason Of course there is still the problem that: > 1+1 == sqrt(2)*sqrt(2) [1] FALSE and gmp will not solve this . I don't know if there is an R-package for arbitrary-precision reals floating around, but probably not. Yes,

Re: [R] Newbie question on precision

2010-01-08 Thread Magnus Torfason
On 1/8/2010 1:29 PM, Magnus Torfason wrote: Paul Evans wrote: How can I get R to change the default precision value? For example: x=0.9 1-x [1] 0 Is there a way that I can get a non-zero value using some parameter, or some package? many thanks. The 'gmp' pack

Re: [R] Newbie question on precision

2010-01-08 Thread Magnus Torfason
Paul Evans wrote: How can I get R to change the default precision value? For example: x=0.9 1-x [1] 0 Is there a way that I can get a non-zero value using some parameter, or some package? many thanks. The 'gmp' package allows calculation with arbitrary precision rationals (

Re: [R] Strange behaviour of as.integer()

2010-01-07 Thread Magnus Torfason
There have been some really great responses to this question. I would like to make a minor contribution by throwing the 'gmp' package into the mix. On 1/7/2010 8:12 AM, Duncan Murdoch wrote: On 07/01/2010 7:31 AM, Ulrich Keller wrote: as.integer(.57 * 100) [1] 56 Yes, as the man page state

Re: [R] Naming functions for the purpose of profiling

2010-01-07 Thread Magnus Torfason
(parse(text=paste( desired.func.name," = d$func; ",desired.func.name,"()", sep=""))) Rprof(NULL) ## And thanks to Jim Holtman who contacted me off-line and gave me some helpful advice on profiling in general. Best, Magnus On 1/5/2010 2:58 PM, Magnus Tor

[R] Naming functions for the purpose of profiling

2010-01-05 Thread Magnus Torfason
Hi all, I have some long-running code that I'm trying to profile. I am seeing a lot of time spent inside the function. Of course, this can in fact be any of several functions, but I am unable to see how I could use the information from Rprof.out to discern which function is taking the most t

[R] Problems when using lag() in plm package

2009-12-29 Thread Magnus Torfason
Hi, I've been trying out the plm package, which seems like a great boon to those who want to analyze panel data in R. I haven't started to use the estimation functions themselves - for now I am just interested in having a robust way to deal with lags in unbalanced panel data, since it is such

[R] The RSQLite version of dbGetQuery drops colums

2009-12-18 Thread Magnus Torfason
Hi all, I just noticed (the hard way of course) that when a query returns 0 rows, the columns in the resulting data.frame get dropped as well. See the following example code (where conn is an active connection to an SQLite db): > dbGetQuery(conn, "select 1 as hey, 2 as ho where 1") hey ho

Re: [R] Matrixes as data

2009-10-16 Thread Magnus Torfason
> Hola! > > I am working on a problem where data points are (square) matrices. Is > there a way to make a "vector" of matrices, such that it can be stored > in a data.frame? I agree with previous posters that in most cases, you would want to store matrices in a list. However, if you already have

Re: [R] Creating a list of empty lists

2009-10-14 Thread Magnus Torfason
On 10/13/2009 10:06 AM, Henrique Dallazuanna wrote: Try this: replicate(3, list()) Thanks! I now have three ways to achieve my goal: 1: rep(list(list()), 3) 2: replicate(3, list()) 3: Due to the way R recycles arguments, I found that it is enough to have construct a list(list()), and then

Re: [R] Creating a list of empty lists

2009-10-13 Thread Magnus Torfason
Live and learn ... Thank you! On 10/13/2009 9:57 AM, Romain Francois wrote: On 10/13/2009 03:48 PM, Magnus Torfason wrote: l = list(list()) for ( i in sequence(length-1) ) { l = list(unlist(l,recursive=FALSE), list()) } About this : > rep( list(list()), 3 )

[R] Creating a list of empty lists

2009-10-13 Thread Magnus Torfason
Well here is one more brain-teaser related to assigning stuff into a list of list. What if I need to create a new list of empty lists? I have actually got a solution to this problem: l = list(list()) for ( i in sequence(length-1) ) { l = list(unlist(l,recursive=FALSE), list(

Re: [R] lapply / mapply and assignments

2009-10-13 Thread Magnus Torfason
Thank you so much, relist and SIMPLIFY both work. See more comments below ... On 10/12/2009 5:35 PM, Charles C. Berry wrote: On Mon, 12 Oct 2009, Magnus Torfason wrote: I want to achieve the following: l <- list( list(a=1,b=2), list(a=3,b=4)) l[[]]["a"] <- 5:6 &g

[R] lapply / mapply and assignments

2009-10-12 Thread Magnus Torfason
I have a list of isometric structures, and I want to change the same part of each structure in the list, assigning one element of a vector to each of these parts. In other words, I want to achieve the following: > l <- list( list(a=1,b=2), list(a=3,b=4)) > unlist(lapply(l, "[[", "a")) [1] 1 3

Re: [R] Basic question: Reading in multiple choice question responses to a single column in data frame

2009-08-20 Thread Magnus Torfason
On 8/19/2009 11:06 PM, Damion Dooley wrote: Slight addendum. Working from your code, I found 1 line of code does the conversion: myColumn = unlist(strsplit(as.character(myData[[myQuestion]]),",")); But the dataframe you set up may prove more useful. I'm glad my suggestion was useful.

Re: [R] Basic question: Reading in multiple choice question responses to a single column in data frame

2009-08-19 Thread Magnus Torfason
Are you looking for something like this? > d = data.frame(a=1:5,b=c("1","2,3","2","3,4","1")) > d a b 1 1 1 2 2 2,3 3 3 2 4 4 3,4 5 5 1 > multis = strsplit(d$b,",") > counts = sapply(strsplit(d$b,","),length ) > d2 = data.frame( a=rep(d$a,counts), b=unlist(multis) ) > d2 a b 1 1

[R] Using ODBC/RODBC with DBI

2008-06-30 Thread Magnus Torfason
Hi all, I would like the following code to work, but it doesn't: library(DBI) library(RODBC) m <- dbDriver("RODBC") # Example for dbConnect(DBI), causes error m <- dbDriver("ODBC") # Example for DBIDriver-class(DBI), causes error The errors are: Error in do.call(as.character(drvName), list(...))