search for: dd1

Displaying 20 results from an estimated 57 matches for "dd1".

Did you mean: d1
2008 Nov 13
0
sem and "simple variables"
...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 from time 1 to time 2 and dc2 is the change in c from time 2 to time 3. i want to predict dc1 and dd1 from both c1 and d1. similarly i want to predict dc2 and dd2 from c2 and d2. to do this i calculate c2 as a "simple v...
2014 Jul 21
2
Inserción de condicionales en pequeño código
...-01","2014-02-01","2012-10-20","2013-10-15","2012-08-25"))) myfun <- function(data, edad_u=65, Apertura=as.Date("2010-01-01")) { ### 1 ) Si "finicio" es ANTERIOR O IGUAL a la fecha de Apertura ### dd1 <- data[data$finicio <= Apertura,] # Variable temporal: Edad en la fecha de apertura dd1$edad_Apertura <- unclass(round(difftime(Apertura, dd1$fnacim, units="auto")/365.25,1)) # De estos individuos, identifico a aquellos CUYA EDAD EN FECHA DE APERTURA ES # I...
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 Frid...
2012 Aug 06
1
more efficient way to parallel
...## initialization, not of interest Sigmahalf <- matrix(sample(1:10000,size = 10000,replace =T ), 100) Sigma <- t(Sigmahalf)%*%Sigmahalf x <- mvrnorm(n=1000, rep(0, 10), Sigma) xlist <- list() for (j in 1:1000) { xlist[[j]] <- list(X = matrix( x [j, ],5)) } ## end of initialization dd1 <- sapply(xlist,function(s) {min(abs((eigen(s$X))$values))}) ## sumdd1=sum(dd1) for (j in 1:1000) { xlist[[j]]$dd1 <- dd1[j]/sumdd1 } ## Assume dd2 and dd1 can not be combined in one sapply() dd2 <- sapply(xlist, function(s){min(abs((eigen(s$X))$values))+s$dd1}) result.seq[i] <- sum(...
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. http://r.789695.n4.nabble.com/file/n3476831/barplot_d...
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 matrix> ddm = as.matrix(dd1)> ddm    1   2   3   4   5   61 0.0 0.1 0.2 0.3 0.4...
2011 Mar 03
2
Plotting Mean in plotting degree distribution
Hi, I am plotting degree distribution of a graph using the function, library(igraph) dd1 = degree.distribution(G) plot(dd1, xlab = "degree", ylab="frequency") I would like to plot the mean of the distribution as a vertical line in the attached plot. Please let me know how to do this. Thanks, Kumar http://r.789695.n4.nabble.com/file/n3334375/cdata3_dd.png cdata3_d...
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 matrix> ddm = as.matrix(dd1)> ddm    1   2   3   4   5   61 0.0 0.1 0.2 0.3 0.4...
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 something to do with that. In fact > dd1 [1]...
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 mess...
2008 Apr 14
3
Doing the right amount of copy for large data frames.
...<- callNextMethod( ) .Object@store <- new.env(hash = TRUE) assign('data', as.list(.Object@data), .Object@store) .Object@nrow <- nrow(.Object@data) .Object@ncol <- ncol(.Object@data) .Object@data <- data.frame( ) .Object }) ### Usage: nn <- 10 ## dd1 below could possibly be created by read.table or scan and data.frame dd1 <- data.frame(xx = rnorm(nn), yy = rnorm(nn)) dd2 <- new('DataFrame', data = dd1) rm(dd1) ## Now work with dd2 Thanks a lot, Gopi Goswami. PhD, Statistics, 2005 http://gopi-goswami.net/index.html [[alternativ...
2007 Jun 28
3
Function call within a function.
...ro or FAQ. Any help would be much appreciated. EXAMPLE ------------------------------------------------------------------------------- # create data.frame cata <- c( 1,1,6,1,1,4) catb <- c( 1,2,3,4,5,6) id <- c('a', 'b', 'b', 'a', 'a', 'b') dd1 <- data.frame(id, cata,catb) # function to create list from data.frame lstfun <- function(file, alpha , beta ) { cda <- subset(file, file[,1] == alpha) cdb <- subset (file, file[,1]== beta) list1 <- list(cda,cdb) } # funtion to operate on list ukn <- function(file, alph...
2007 Apr 19
1
Character coerced to factor and I cannot get it back
...vec <- letters[1:10] ) #Get data frame from list dd <- mylist[[1]] attach(dd) # Convert numeric id to character id id <- as.character(dd[,3]) ; id # get site designators (first one or two characters of id st <- substring(id, 1,nchar(id)-4 ) ; st typeof (st) ; class(st) dd1 <- cbind(dd, st) names(dd1) <- c("aa","bb","cc","st") dd1 typeof(dd1$st); class(dd1$st) dd2 <- cbind(dd, as.character(st)) names(dd2) <- c("aa","bb","cc","st") dd2 typeof(d...
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", "ALP"), yy = c("mat harry", "jim bob" , "j...
2006 Aug 24
1
Using a 'for' loop : there should be a better way in R
...uter loop hh <- levels(df1$years) # levels for inter loop mp <- c(1, 5, 10) # inflation factor tt <- data.frame(matrix(NA, length(nn), 2)) names(tt) <- c("s1","s2") rownames(tt) <- nn for (i in 1:length(nn)){ scat <- data.frame(matrix(NA, length(hh),2)) dd1 <- subset(df1, id==nn[i]) for (j in 1:length(hh)){ dd2 <- subset(dd1, dd1$years==hh[j]) s1 <- sum(dd2$cat1,dd2$cat2, na.rm=T) s2 <- sum(dd2$cat3,dd2$cat4,na.rm=T) scat[j,] <- c(s1,s2) *mp[j] # multiply by the inflation factor } crush <- apply(scat, 2, sum) tt[i,] <- crush }...
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
...+ 1 ~ 1, + lambda = seq(-5, 5, length.out = 101), + plotit = FALSE) + b$x[which.max(b$y)] + } > mrow <- 500 > mcol <- 2 > set.seed(12345) > dd <- matrix(rgamma(mrow*mcol, shape = 2, scale = 5), nrow = mrow, ncol = + mcol) > dd1 <- dd[, 1] # 1st column of dd > res <- boxcox(lm(dd1 + 1 ~ 1), lambda = seq(-5, 5, length.out = 101), plotit + = FALSE) > res$x[which.max(res$y)] [1] 0.2 > apply(dd, 2, BoxCoxLambda, simplify = TRUE) [1] 0.2 0.2 ------ snip ------ One could also use the powerTrans...
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
...oxcox in order that it can be applied to each column easily. >> Except that I'm getting an error when calling the function. If I just >> extract a column of the matrix and run the code not in the function, it >> works. If I call the function either with an extracted column (ie dd1 in >> the reprex below) or in a call to apply I get an error (see the reprex >> below). >> >> I'm sure I'm doing something silly, but I can't see what it is. Any help >> appreciated. >> >> library(MASS) >> >> # Find optimised Lambda...
2023 Jul 08
1
Getting an error calling MASS::boxcox in a function
...ncludes the call to MASS::boxcox in order that it can be applied to each column easily. Except that I'm getting an error when calling the function. If I just extract a column of the matrix and run the code not in the function, it works. If I call the function either with an extracted column (ie dd1 in the reprex below) or in a call to apply I get an error (see the reprex below). I'm sure I'm doing something silly, but I can't see what it is. Any help appreciated. library(MASS) # Find optimised Lambda for Boc-Cox transformation BoxCoxLambda <- function(z){ b <- boxcox(...
2011 Aug 23
0
Matrix:::qr.qy and signature(qr = "sparseQR", y = "dgCMatrix")
...s that it understands this signature. Following is a minimal example (in my application dd2 is too large for my memory): library(Matrix) data(KNex); mm <- KNex$mm mmQR <- qr(mm) dim(mmQR) # 1850 712 class(mmQR) # [1] "sparseQR";attr(,"package");"Matrix" dd1 <- sparseMatrix(1:ncol(mm),1:ncol(mm), x = 1, dims = c(nrow(mm),ncol(mm))) class(dd1) # dgCMatrix;attr(,"package");Matrix dd2 <- diag(1,ncol = ncol(mm) , nrow = nrow(mm)) class(dd2) #matrix showMethods("qr.qy") #Function: qr.qy (package base) #qr="ANY", y=&qu...
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...