search for: ldply

Displaying 20 results from an estimated 80 matches for "ldply".

Did you mean: ddply
2010 May 17
2
Problem with ldply
I've examining a number of linear regression models on a large dataset following the basic ideas presented here http://www.r-bloggers.com/r-calculating-all-possible-linear-regression-models-for-a-given-set-of-predictors/ Calculating all possible linear regressions . I run into a problem with ldply when I have a formula that includes no intercept. Here's a simple test to show what happens. # data and two linear model regressions xy <- data.frame(cbind(x=(0:10),y=2*x + 0.2*rnorm(11))) models <- as.list(c('y ~ x', 'y ~ -1 + x')) models <- lapply(models, function(x)...
2011 Jan 07
2
how to run linear regression models at once
hey, folks, I have two very simple questions. I am not quite sure if I can do this using R. so, I am analyzing a large data frame with thousands of variables. For example: Dependent variables: d1, d2, d3 (i.e., there are three dependent variables) Independent variables: s1, s2, s3, ......s1000 (i.e., there are 1000 independent variables) now I want to run simple linear regression analyses of
2011 Jun 27
2
Executing the same function on consecutive files
Hi all, I have the next problem: I have a matrix with size 8,000,000x18. My personal computer...blocks...so I have cut my original file into 100 different file. I have written a function that should be run on each of this file. So imagine I need to read data from q1 to q100 file data<-read.table("q1.txt",sep="") and each time I read 1 file execute my personal function
2012 Apr 29
1
r2 and p value dispaly in table
..., 0.72, 0.67, 0.73, 0.76, 0.65, 0.68, 0.78, 0.73, 0.71) test <- data.frame(individual, day, condition) ind.id <- unique(test$individual) ind.list <- lapply(1:length(ind.id), function(i){ subset(test, test$individual==ind.id[i])}) lms <- lapply(ind.list, lm, formula=condition~day) ldply(lms, function(x) x$coefficients) here I can display coefficients, here I need to write code for r2.squared I tried with following script summary(ldply(lms, function(x) )$r.squared, $p value) but it did not work. can any one help me? thanks Kristi [[alternative HTML version dele...
2010 Aug 09
2
coef(summary) and plyr
...n variables back into a dataframe. mydf <- data.frame(x1=rnorm(100), x2=rnorm(100), x3=rnorm(100)) mydf$fac<-factor(sample((0:2),replace=T,100)) mydf$y<- mydf$x1+0.01+mydf$x2*3-mydf$x3*19+rnorm(100) dlply(mydf,.(fac),function(df) lm(y~x1+x2+x3,data=df))->dl here I?d like to use ldply(dl,coef(summary)) or something similar but I cant figure it out... Best, M
2012 Apr 04
1
Subscript Error
...of JSON lists mapping lat/long route points between locations using CloudMade's API. post_url is the URL of the HTTP request for (n in json_dir) { i = i + 1 if (typeof(json_dir[[i]]) != "NULL") { if (i == 1) { dat_add <- ldply(json_dir[[i]], function(x) t(data.frame(x)), .progress = "text") names(dat_add) <- c("lat", "lon") json_path <- list(dat_add) } else { dat_add <- ldply(json_dir[[i]], function(x) t(dat...
2018 Apr 17
2
Time intervals in a datframe
...t column in each datframe contains a vector of "Interval" class after I have produced this column using "lubridate" package. I needed to convert my list of dataframes to be in a single dataframe for further analysis. I did this using the following syntax : SingleDataframe <- ldply (MylistofDFs,data.frame) The problem is that after this conversion, the the column with time intervals has been converted into numeric type with number of seconds during the time interval instead of the interval itself as follows : The column Before conversion looks like this: TimeInterval (clas...
2011 Jul 14
1
glm() scale parameters and predicted Values
...???????? m <- as.numeric(x$y) ????????????? x1 <- m <- as.numeric(x$x1) ????????????? x2 <- m <- as.numeric(x$x2) ????????????? summary(glm(m~1+x1+x2, family=Gamma),dispersion=NULL) ?????????????? }) #Save the results of the estimated parameters str(FGLM,no.list = TRUE) SFGLMC<- ldply(FGLM, function(x) x$coefficients) SFGLMD<- ldply(FGLM, function(x) x$dispersion) GLM <- cbind(SFGLMC,SFGLMD)
2011 Aug 25
2
how to read a group of files into one dataset?
for example : I have files with the name "ma01.dat","ma02.dat","ma03.dat","ma04.dat",I want to read the data in these files into one data.frame flnm<-paste("obs",101:114,"_err.dat",sep="") newdata<-read.table(flnm,skip=2) data<-(flnm,skip=2) but the data only contains data from the flnm[1] I also tried as below : for
2018 Apr 17
0
Time intervals in a datframe
...n each datframe contains a vector of "Interval" class after I have produced this column using "lubridate" package. I needed to convert my list of dataframes to be in a single dataframe for further analysis. I did this using the following syntax : > > SingleDataframe <- ldply (MylistofDFs,data.frame) > > The problem is that after this conversion, the the column with time intervals has been converted into numeric type with number of seconds during the time interval instead of the interval itself as follows : > > The column Before conversion looks like this:...
2011 May 23
6
Reading Data from mle into excel?
Hi there, I ran the following code: vols=read.csv(file="C:/Documents and Settings/Hugh/My Documents/PhD/Swaption vols.csv" , header=TRUE, sep=",") X<-ts(vols[,2]) #X dcOU<-function(x,t,x0,theta,log=FALSE){ Ex<-theta[1]/theta[2]+(x0-theta[1]/theta[2])*exp(-theta[2]*t) Vx<-theta[3]^2*(1-exp(-2*theta[2]*t))/(2*theta[2]) dnorm(x,mean=Ex,sd=sqrt(Vx),log=log) }
2011 Nov 26
2
simplify source code
Hi I would like to shorten mod1 <- nls(ColName2 ~ ColName1, data = table, ...) mod2 <- nls(ColName3 ~ ColName1, data = table, ...) mod3 <- nls(ColName4 ~ ColName1, data = table, ...) ... is there something like cols = c(ColName2,ColName3,ColName4,...) for i in ... mod[i-1] <- nls(ColName[i] ~ ColName1, data = table, ...) I am looking forward to help Christof
2010 Jul 29
2
Multiple binomial tests on a large table
I need to run binomial tests (binom.test) on a large set of data, stored in a table - 600 tests in total. The values of x are stored in a column, as are the values of n. The data for each test are on a separate row. For example: X N 11 19 9 26 13 21 13 27 18 30 It is a two-tailed test, and P in all cases is 0.5. My question is: Is there a quicker way of running these tests without having to
2012 Dec 05
4
Import multiple data frames and combine them using "cbind"
Hi group, I imported 16 data frames using the function "list.files" temp <- list.files(path="...........") myfiles = lapply(temp, read.table,sep = "") Now I have 16 data set imported in R window. I want to combine them by row and tried some thing like (Here I am considering only 20 columns) for(i in 1:16){ data<- cbind(myfiles[[i]][,1:20]) } but it
2011 Aug 29
2
splitting into multiple dataframes and then create a loop to work
Dear All Sorry for this simple question, I could not solve it by spending days. My data looks like this: # data set.seed(1234) clvar <- c( rep(1, 10), rep(2, 10), rep(3, 10), rep(4, 10)) # I have 100 level for this factor var; yvar <- rnorm(40, 10,6); var1 <- rnorm(40, 10,4); var2 <- rnorm(40, 10,4); var3 <- rnorm(40, 5, 2); var4 <- rnorm(40, 10, 3); var5 <- rnorm(40, 15,
2009 Mar 21
3
Retrieving Vertices Coordinates from SpatialPolygons
Dear List, I'm trying to use different R packages for my Teaching Assistantship classes. And I cam out to an (apparently) very simple problem. I would like to retrieve the vertices coordinate of a SpatialPolygon data. I know this is stored in the "coords" slot, but I can't get access to it! I tried to coerce the SpatialPolygon into a data.frame but it doesn't work.
2011 Jan 21
2
Looping with incremented object name and increment function
Folks, I am trying to get a loop to run which increments the object name as part of the loop. Here "fit1" "fit2" "fit3" and "fit4" are linear regression models that I have created. > for (ii in c(1:4)){ + SSE[ii]=rbind(anova(fit[ii])$"Sum Sq") + dfe[ii]=rbind(summary(fit[ii])$df) + } Error in anova(fit[ii]) : object 'fit' not found
2011 Aug 01
2
Errors, driving me nuts
Greetings all, I am getting this error that is driving me nuts... (not a long trip, haha) I have a set of files and in these files I want to calculate ttests on rows 'compareA' and 'compareB' (these will change over time there I want a variable here). Also these files are in many different directories so I want a way filter out the junk... Anyway I don't believe that this is
2011 Oct 14
3
Split a list
I have a list of dataframes i.e. each list element is a dataframe with three columns and differing number of rows. The third column takes on only two values. I wish to split the list into two sublists based on the value of the third column of the list element.  Second issue with lists as well. I would like to reduce each of the sublist based on the range of the second column, i.e. if the range of
2010 Sep 09
0
Fast / dependable way to "stack together" data frames from a list
...or (j in 1:m) resultDF4[(((j-1)*nr) + 1):(j*nr), ] <- mylist[[j]] ## This is a bit error prone for my taste. If the data frames have ## different numbers of rows, some major code surgery will be needed. ## ## Dennis Murphy pointed out the plyr package, by Hadley Wickham. ## Dennis said " ldply() in the plyr package. The following is the same ## idea as do.call(rbind, l), only faster." library("plyr") resultDF5 <- ldply(mylist, rbind) all.equal(resultDF, resultDF5) ## Plyr author Hadley Wickham followed up with "I think all you want here is rbind.fill:" r...