similar to: how do I join two lists of the same type ?

Displaying 20 results from an estimated 40000 matches similar to: "how do I join two lists of the same type ?"

2009 Dec 31
1
joining two lists...
My "R" problem.. I want to join two lists but am so for not having any luck. Can anyone assist ? Variable: myData[1] "Data.Id" "Data.Length" "Data.Weight" "1" 12 12 "2" 45 23 Variable: myData[2] "Data.Id" "Data.Length" "Data.Weight" "3" 25 56 "4" 55
2012 Jul 17
1
problem with function
Dear list, I have a problem with defining a function (see below) to read my testfile (see testfile). My function only returns mydata I wish to work with attr(mydata, 'fc') as well (for labelling a plot). Principally it works if I do not insist on this function but it would be much easer if it is possible to return mydata AND attr(mydata, 'fc') by using a function. 1) testfile:
2007 Mar 16
1
Probably simple function problem
# I have a simple function problem. I thought that I could write a function to modify a couple of vectors but I am doing something wrong #I have a standard cost vector called "fuel" and some adjustments to the #costs called "adjusts". The changes are completely dependend on the length #of the dataframe newdata I then need to take the modifed vectors and use # them later. I
2007 Apr 09
3
do.call vs. lapply for lists
Hi All, I'm trying to understand the difference between do.call and lapply for applying a function to a list. Below is one of the variations of programs (by Marc Schwartz) discussed here recently to select the first and last n observations per group. I've looked in several books, the R FAQ and searched the archives, but I can't find enough to figure out why lapply doesn't do what
2011 Apr 18
2
Predicting with a principal component regression model: "non-conformable arguments" error
Hello all, I have generated a principal components regression model using the pcr() function from the PLS package (R version 2.12.0). I am getting a "non-conformable arguments" error when I try to use the predict() function on new data, but only when I try to read in the new data from a separate file. More specifically, when my data looks like this #########training data
2008 Jan 29
3
How to get two y-axises in a bar plot?
Hi, I have measured two response variables (y1, y2) at each treatment level (x = 0, 1.5 or 3). Now I would like to show the y1 and y2 against x in a bar plot. However, y1 and y2 differ in scale so I need two y-axises, one on the left side and one on the right side (and I dont want to standardize my responses). This is fairly easy if you want to show points,lines etc, but gets more complicated
2011 Nov 23
1
Losing custom attributes
Hi All, I was adding a new row of data to my data frame using rbind(). I was surprised to see that after adding new row, I lost my data frame level attibute as well as col level attribute. Please help me to insert a new row at frist or middle position so that my custom attribute is not lost. Here is what I did. age<-c(15,20,18) weight<-c(40,42,30) ### creating my data frame
2009 Apr 26
2
RWeka prediction
Dear All,I encountered a problem when I use RWeka for prediction. Specifically, I use the following: res=J48(X1~.,data=mydata); predict(res), #it worked fine but when I tried to use a different data set, i.e. predict(res,newdata=mynewdata); all the predictions I get is 0, which apparently is problematic. What is weird is, if I use the old data, but use the newdata option, i.e.
2008 Feb 20
3
reshaping data frame
Dear all, I'm having a few problems trying to reshape a data frame. I tried with reshape{stats} and melt{reshape} but I was missing something. Any help is very welcome. Please find details below: ################################# # data in its original shape: indiv <- rep(c("A","B"),c(10,10)) level.1 <- rpois(20, lambda=3) covar.1 <- rlnorm(20, 3, 1) level.2
2006 Mar 24
1
predict.glmmPQL Problem
Dear all, for a cross-validation I have to use predict.glmmPQL() , where the formula of the corresponding glmmPQL call is not given explicitly, but constructed using as.formula. However, this does not work as expected: x1<-rnorm(100); x2<-rbinom(100,3,0.5); y<-rpois(100,2) mydata<-data.frame(x1,x2,y) library(MASS) # works as expected model1<-glmmPQL(y~x1, ~1 | factor(x2),
2012 Jul 06
2
Graph showing fitted values obtained by binomial GLM
I have completed a binomial GLM in R (details attached (finalModel.docx)) and I am trying to create a graph of observed and fitted values using the following commands: > MyData<-data.frame(time=seq(from=0,to=1323,by=1)) > Pred<-predict(M2,newdata=MyData,type="response") > plot(x=turtle$time,y=turtle$success) > lines(MyData$time,Pred) However, I get the following
2007 Jul 17
2
poor rbind performance
Hi I rbind data frames in a loop in a cumulative way and the performance detriorates very quickly. My code looks like this: for( k in 1:N) { filename <- paste("/tmp/myData_",as.character(k),".txt",sep="") myDataTmp <- read.table(filename,header=TRUE,sep=",") if( k == 1) { myData <- myDataTmp } else{ myData
2007 Feb 13
1
Missing variable in new dataframe for prediction
Hi, I'm using a loop to evaluate several models by taking adjacent variables from my dataframe. When i try to get predictions for new values, i get an error message about a missing variable in my new dataframe. Below is an example adapted from ?gam in mgcv package library(mgcv) set.seed(0) n<-400 sig<-2 x0 <- runif(n, 0, 1) x1 <- runif(n, 0, 1) x2 <- runif(n, 0, 1) x3 <-
2010 Sep 07
1
average columns of data frame corresponding to replicates
Hi Group, I have a data frame below. Within this data frame there are samples (columns) that are measured more than once. Samples are indicated by "idx". So "id1" is present in columns 1, 3, and 5. Not every id is repeated. I would like to create a new data frame so that the repeated ids are averaged. For example, in the new data frame, columns 1, 3, and 5 of the original
2007 Sep 25
1
10- fold cross validation for naive bayes(e1071)
Hallo! I would need a code for 10-fold cross validation for the classifiers Naive Bayes and svm (e1071) package. Has there already been done something like that? I tried to do it myself by applying the tune function first: library(e1071) tune.control <- tune.control(random =F, nrepeat=1, repeat.aggregate=min.,sampling=c("cross"),sampling.aggregate=mean, cross=10, best.model=T,
2011 Nov 23
2
SPSS F-test on change in R square between hierarchical models
Hi, I am wondering if anyone knows how to perform an F-test on the change in R square between hierarchical models in R? SPSS provides this information and a researcher that I am working with is interested in getting this information. Alternatively, if someone knows how I can calculate the test statistic (SPSS calls it F-change?) and dfs that would be helpful as well. The output and the test I am
2018 May 22
2
Using tryCatch in a for loop
Data and code as promised: #Creating a test dataset Year<- c(2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014) Lake1<- c(2, 4, 5, 2, 1, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2) Lake2<- c(1, 3, -1, 4, -2, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2) Lake3<- c(1, 2, 5, -3, 1, 1, 2, 3, 4, 5, 6, 2, 3, 1, 2) Lake4<- c(1, 1, 1, 1, 1, 1, 1, 250, 240, 240, 240, 240, 240, 239,
2010 May 17
1
suggestions/improvements for recoding strategy
I am recoding some data. Many values that should be 1.5 are recorded as 1-2. Some example data and my solution is below. I am curious about better approaches or any other suggestions. Thanks! # example input data myData <- read.table(textConnection("id, v1, v2, v3 a,1,2,3 b,1-2,,3-4 c,,3,4"),header=TRUE,sep=",") closeAllConnections() # the first column is IDs so remove
2008 Aug 29
3
Density estimates in modelling framework
Hi all, Do any packages implement density estimation in a modelling framework? I want to be able to do something like: dmodel <- density(~ a + b, data = mydata) predict(dmodel, newdata) This isn't how sm or KernSmooth or base density estimation works. Are there other packages that do density estimation? Or is there some reason that this is a bad idea. Hadley -- http://had.co.nz/
2018 May 22
0
Using tryCatch in a for loop
No. If your ouput is a numeric "matrix", it cannot include alpha. Columns in a data frame can be of different classes, but each column must be single class. and finally, of course, see ?cat -- I think you are misusing it. If you simply want to return "somestuff", your function should be: function(w) {"somestuff"} not function(w) {cat("somestuff")} As