similar to: Doing the right amount of copy for large data frames.

Displaying 20 results from an estimated 3000 matches similar to: "Doing the right amount of copy for large data frames."

2006 Aug 24
1
Using a 'for' loop : there should be a better way in R
I need to apply a yearly inflation factor to some wages and supply some simple sums by work category. I have gone at it with a brute force "for" loop approach which seems okay as it is a small dataset. It looks a bit inelegant and given all the warnings in the Intro to R, etc, about using loops I wondered if anyone could suggest something a bit simpler or more efficent? Example:
2009 Feb 25
1
S4 helper functions: regular or generic?
Hi there, I want to write helper functions for a base class, which will be used by its subclasses in the S4 world. This function ___will___ update certain slots of its argument object. Please help me decide which one of the following is a better approach with respect to coding style, memory usage and speed: o Write a regular function. o Declare a generic and implement it just for the base
2014 Jul 21
2
Inserción de condicionales en pequeño código
Buenas tardes, He construido la función “myfun” al objeto de considerar aquellas persones que a partir de una determinada fecha de Apertura tienen como mínimo 65 años. Se tiene su fecha de nacimiento, su fecha de inicio en la institución y su fecha de salida de la misma. Doy vueltas al script y no acabo se saber cómo poder aplicar de un modo eficiente las instrucciones “if” ó bien “ifelse”, y me
2012 Aug 06
1
more efficient way to parallel
Dear All, Suppose I have a program as below: Outside is a loop for simulation (with random generated data), inside there are several sapply()'s (10~100) over the data and something else, but these sapply's have to be sequential. And each sapply do not involve very intensive calculation (a few seconds only). So the outside loop takes minutes to finish one iteration. I guess the better way
2003 Dec 04
4
bug in as.POSIXct ?
I think that there is a bug in the as.POSIXct function on Windows. Here is what I get on Win2000, Pentium III machine in R 1.8.1. > dd1 <- ISOdatetime(2003, 10, 26, 0, 59, 59) > dd2 <- ISOdatetime(2003, 10, 26, 1, 0, 0) > dd2 - dd1 Time difference of 1.000278 hours Now, the 26th of October was the day that change to the standard time occurred, so I suspect that this has
2008 Mar 24
1
Great difference for piecewise linear function between R and SAS
Dear Rusers, I am now using R and SAS to fit the piecewise linear functions, and what surprised me is that they have a great differrent result. See below. #R code--Knots for distance are 16.13 and 24, respectively, and Knots for y are -0.4357 and -0.3202 m.glm<-glm(mark~x+poly(elevation,2)+bs(distance,degree=1,knots=c(16.13,24)) +bs(y,degree=1,knots=c(-0.4357,-0.3202
2010 Aug 16
1
data frame handling
Dear all, I have an xts object , t.xts with 4 columns: "v1" "DD1" "v2" "DD2" and created a data frame : t <- as.data.frame(t.xts) I would like to extract data and create a new data frame for when the values in column DD1 falls between 0 and 30 and extract the corresponding v1 value. How can I do this? Thanks. -- View this message in context:
2018 Oct 05
2
Seg fault stats::runmed
Dear all, I just found this issue: dd1 = c(rep(NaN,82), rep(-1, 144), rep(1, 74)) xx = runmed(dd1, 21) -> R crashes reproducibly in R 3.4.3, R3.4.4 (Ubuntu 14.04/Ubuntu 16.04) With GDB: Program received signal SIGSEGV, Segmentation fault. swap (l=53, r=86, window=window at entry=0xc59308, outlist=outlist at entry=0x12ea2e8, nrlist=nrlist at entry=0x114fdd8, print_level=print_level at
2012 Jul 07
11
Splitting a character vector.
I am lousy at simple regex and I have not found a solution to a simple problem. I have a vector with some character values that I want to split. Sample data dd1 <- c( "XXY (mat harry)","XXY (jim bob)", "CAMP (joe blow)", "ALP (max jack)") Desired result dd2 <- data.frame( xx = c("XXY", "XXY", "CAMP",
2009 Jun 02
2
What do you think about my function?
Hello, I want to know what do you think about my function. I know that it isn't briliant :/ but what do you think? What I should do that my function will be better? (now is very slow and not ideal, sometimes I also get a mistake!) ########## My function ############################################# dzieci<-transform(dzieci, zywnosc=0) zywnoscCalosc<- function( jedzenie, sklep, n1, n2,
2009 May 20
2
How to load data from Statistics Canada
We would like to load data from Statistics Canada (http://www.statcan.gc.ca/) using R, for example, Employment and unemployment rates. It seems to me that the tables are displayed in HTML. I was wondering if you know how to load these tables. Thanks, -james
2007 Apr 19
1
Character coerced to factor and I cannot get it back
Something probably obivous but I don't see it. I needed to find the first 1 or two digits of some 5 and 6 digit numbers since they identified research sites while the rest of the number was the plot id. I converted the numbers to characters, got the first 1 or 2 characters as appropriate and went to add the new vector to the data.frame. For some reason R is insisting on turning the
2009 May 31
1
Error:non-numeric argument in my function
Hello! I have a function: zywnoscCalosc<- function( jedzenie, n1, n2, n3, n4, d1, d2, d3, d4 ) { ndf <- data.frame(nn1=n1,nn2=n2,nn3=n3,nn4=n4) ddf <- data.frame(dd1=d1,dd2=d2,dd3=d3,dd4=d4) for (i in 1:length(n1)){ wekt_n = ndf[i,] wekt_n_ok = wekt_n[!is.na(wekt_n)] dl_n = length(wekt_n_ok) wynik = (1*wekt_n_ok)/(1*dl_n) } } and I get an error like this: Error in 1 * wekt_n_ok :
2006 Mar 11
2
weird! QDA does not depend on priors?
Hi all, If I run LDA on the same data (2-class classification) with default(no priors specified in the lda function) vs. "prior=c(0.5, 0.5)", the results are different. The (0.5, 0.5) priors give better 1-classify-to-1 rate, and the proportional priors(default, no priors specified in the lda function) give better 0-classify-to-0 rate, for both training and testing data sets. However,
2008 Nov 13
0
sem and "simple variables"
salutations! i am doing some longitudinal modeling with sem and thought calculating some "simple variables" would make my model more readable. this is the smallest subset of my model that illustrates the resulting problem. i have 2 observed exogenous variables (c1, d2) and 4 observed endogenous variables (dc1, dd1, dc2, dd2). c1 is the observed state at time 1, dc1 is the change in c
2013 Jan 18
1
Object created within a function disappears after the function is run
Dear R-helpers, I have run the code below which I expected to make an object called dd1, but that object does not exist. So, in summary, my problem is that my function is meant to make an object (dd1), and it does indeed make that object (I know that the last line of the function prints it out) but then, after the function has run, the object has disappeared. It's late on a Friday so I may
2011 Apr 26
1
Barplot for degree distribution
In barplot for degree distribution x-axis is not seen. See the example below > g = barabasi.game(500, 0.4) > dd1 = degree.distribution(g) > plot(dd1, xlab="degree", ylab = "frequency") whereas barplot doesnot have any x-axis > barplot(dd1, xlab = "degree", ylab = "frequency") Please see the figures attached.
2011 Nov 15
5
Convert back to lower triangular matrix
Given a vector;> ab = seq(0.5,1, by=0.1)> ab[1] 0.5 0.6 0.7 0.8 0.9 1.0 The euclidean distance between the vector elements is given by the lower triangular matrix > dd1 = dist(ab,"euclidean")> dd1    1   2   3   4   52 0.1                3 0.2 0.1            4 0.3 0.2 0.1        5 0.4 0.3 0.2 0.1    6 0.5 0.4 0.3 0.2 0.1 Convert the lower triangular matrix to a full
2011 Nov 15
1
Convert full matrix back to lower triangular matrix
Given a vector;> ab = seq(0.5,1, by=0.1)> ab[1] 0.5 0.6 0.7 0.8 0.9 1.0 The euclidean distance between the vector elements is given by the lower triangular matrix > dd1 = dist(ab,"euclidean")> dd1    1   2   3   4   52 0.1                3 0.2 0.1            4 0.3 0.2 0.1        5 0.4 0.3 0.2 0.1    6 0.5 0.4 0.3 0.2 0.1 Convert the lower triangular matrix to a full
2011 Dec 09
1
'callNextMethod' in a '[<-' function does not work ?
Hi the list, I try to use callNextMethod in a setteur ([<-) but it does not work. Any raison ? Any other option ? --- 8< ------------------ ### Class B0 ### setClass("B0" , representation(b0 = "numeric")) setReplaceMethod("[","B0",function(x,i,j,value){x at b0 <- -value}) a <- new("B0") a at b0 <- 3 a a["b0"] <- 3 a