similar to: read.table performance

Displaying 20 results from an estimated 5000 matches similar to: "read.table performance"

2010 Jul 09
3
apply is slower than for loop?
I thought the "apply" functions are faster than for loops, but my most recent test shows that apply actually takes a significantly longer than a for loop. Am I missing something? It doesn't matter much if I do column wise calculations rather than row wise ## Example of how apply is SLOWER than for loop: #rm(list=ls()) ## DEFINE VARIABLES mu=0.05 ; sigma=0.20 ; dt=.25 ; T=50 ;
2011 Aug 29
3
replacing elements of a zoo object
Why doesn't this work? x = zoo(1:5, as.Date('2001-01-01')+1:5) x[as.Date('2001-01-05')] x[as.Date('2001-01-05')] = 0 x I think this is especially bad because it doesn't cause an error. It lets you do something to x, but then you can't see x again to see what it did. [[alternative HTML version deleted]]
2010 Apr 19
2
How to pass a list of parameters into a function
Does anyone know how to pass a list of parameters into a function? for example: somefun=function(x1,x2,x3,x4,x5,x6,x7,x8,x9){ ans=x1+x2+x3+x4+x5+x6+x7+x8+x9 return(ans) } somefun(1,2,3,4,5,6,7,8,9) # I would like this to work: temp=c(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9) somefun(x1=1,x2=2,temp) # OR I would like this to work: temp=list(x3=3,x4=4,x5=5,x6=6,x7=7,x8=8,x9=9)
2011 Dec 07
1
RSPython installation
Does anyone know if Is there a way to manually install RSPython? I get this error when I try to run the script from my DOS prompt. V:\>R CMD INSTALL -c C:/Users/gene.leynes/Downloads/RSPython_0.7-1.tar.gz * installing to library 'C:/Users/gene.leynes/Documents/R/win-library/2.13' * installing *source* package 'RSPython' ... **********************************************
2011 Feb 23
4
The L Word
I've been wondering what L means in the R computing context, and was wondering if someone could point me to a reference where I could read about it, or tell me what it's called so that I can search for it myself. (L by itself is a little too general for a search term). I encounter it in strange places, most recently in the "save" documentation. save(..., list = character(0L),
2011 Sep 06
2
Possible to access a USB volume by name in windows
On the Mac it's pretty easy to get to a USB drive by name. For example the following command works if you have a USB drive named "MYUSB" setwd('/Volumes/MYUSB') Is there a way to do the same thing in Windows (without knowing the drive letter)? Thanks! [[alternative HTML version deleted]]
2011 Sep 26
4
Testing for arguments in a function
I don't understand how this function can subset by i when i is missing.... ## My function: myfun = function(vec, i){ ret = vec[i] ret } ## My data: i = 10 vec = 1:100 ## Expected input and behavior: myfun(vec, i) ## Missing an argument, but error is not caught! ## How is subsetting even possible here??? myfun(vec) Is there a way to check for missing function arguments, *and*
2011 Dec 07
2
curve fitted ... how to retreive data
Dear R users, I have now managed to fit the curve using the thin plate spline as follows: library(mgcv) b <- gam(y~s(x1,x2,k=100),data =dat) vis.gam(b) What I want now is to get the fitted data for y and copy it so that I use it for further analysis. Many thanks in advance mintewab
2007 Aug 23
2
read big text file into R
Dear Rs: Hi, I am trying to read a big text file (nrows=243440, ncols=144). It seems the computational time of all the read methods (scan,readtable,read.delim) is not linear to the number of rows I want to read in: things became really slow once I tried to read in 100000 lines compare to 10000 lines). If I am reading the profiling result right, I guess scan wouldn't help either. My
2015 May 04
2
Problem with adding slots to S4 object
Dear all, I'm trying to create a virtual S4 class with some subclasses. I noticed that adding slots to this class increases the memory use and slows the functions down. Note that I'm adding very small slots (integer or character both of length 1). I've made a reproducible example at https://github.com/ThierryO/testvirtualclass. The R CMD check --as-cran fails on the tests. Some of
2009 Jul 22
3
How to replace NAs in a vector of factors?
# Just when I thought I had the basic stuff mastered.... # This has been quite perplexing, thanks for any help ## Here's the example: db1=data.frame( olditems=c('soup','','','','nuts'), prices=c(4.45, 3.25, 4.42, 2.25, 3.98)) db2=data.frame( newitems=c('stew','crackers','tofu','goatsmilk','peanuts'))
2012 Jul 31
1
Ubuntu installation
I just followed the instructions on CRAN<http://cran.r-project.org/bin/linux/ubuntu/README> to install R on an Ubuntu instance. sudo apt-get install r-base Why does it install an old version of R? Can I install version 15.1? I changed my sources.list to be a current cran mirror. I believe that I have entered the URL correctly because at first I had it wrong (there was a trailing
2007 Oct 22
2
Help interpreting output of Rprof
Hello there, I am not quite sure how to interpret the output of Rprof (in the following the output I was staring at). I was poking around the web a little bit for documentation but without much success. I guess if I want to figure out what takes so long in my code the 2nd table $by.total and the total.pct column (pct = percent) is the most helpful. What does it mean that [ or [.data.frame is
2023 Oct 14
2
Create new data frame with conditional sums
Well, here's one way to do it: (dat is your example data frame) Cutoff <- seq(0, .15, .01) Pop <- with(dat, sapply(Cutoff, \(p)sum(Totpop[Pct >= p]))) I think there must be a more efficient way to do it with cumsum(), though. Cheers, Bert On Sat, Oct 14, 2023 at 12:53?AM Jason Stout, M.D. <jason.stout at duke.edu> wrote: > > This seems like it should be simple but I
2011 Jan 13
1
PBSmodelling: Change the "edit" option of a widget
Is it possible to toggle the "edit" option of a widget? I would like to make it so that when a user clicks on a boolean (like "use constraints") it will lock or unlock the field in which they would enter the constraints. I can imagine redrawing the whole GUI using a function attached to the boolean, but that's clunky and slow. I tried changing the .PBSmod variable... but
2012 Aug 03
2
Recursive function calls
My apologies, I know that this is not a new problem, but I'm not sure how to find the answer I want to recursively loop over an object and trim trailing white space. When I use this function on a list of data.frame I get output like this: [1] "c(\" many spaces \", \" many spaces \")" "c(\" many spaces \", \" many spaces
2011 Jan 12
2
Require
I think that the "quietly" argument in "require" isn't working > require('JumboShrimp', quietly=TRUE) Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called 'JumboShrimp' > By the way, the behavior is the same with options(warn=0) or options(warn=1) I'm using R 2.12
2023 Oct 15
2
Create new data frame with conditional sums
Under the hood, sapply() is also a loop (at the interpreted level). As is lapply(), etc. -- Bert On Sun, Oct 15, 2023 at 2:34?AM Jason Stout, M.D. <jason.stout at duke.edu> wrote: > > That's very helpful and instructive, thank you! > > Jason Stout, MD, MHS > Box 102359-DUMC > Durham, NC 27710 > FAX 919-681-7494 > ________________________________ > From: John
2011 Feb 04
4
aggregate function - na.action
Can someone please tell me what is up with na.action in aggregate? My (somewhat) reproducible example: (I say somewhat because some lines wouldn't run in a separate session, more below) set.seed(100) dat=data.frame( x1=sample(c(NA,'m','f'), 100, replace=TRUE), x2=sample(c(NA, 1:10), 100, replace=TRUE), x3=sample(c(NA,letters[1:5]), 100, replace=TRUE),
2009 Oct 19
2
how to get rid of 2 for-loops and optimize runtime
Short: get rid of the loops I use and optimize runtime Dear all, I want to calculate for each row the amount of the month ago. I use a matrix with 2100 rows and 22 colums (which is still a very small matrix. nrows of other matrixes can easily be more then 100000) Table before Year month quarter yearmonth Service ... Amount 2009 9 Q3 092009 A ...