similar to: for loop, error in model frame.default ... variable lengths differ

Displaying 20 results from an estimated 20000 matches similar to: "for loop, error in model frame.default ... variable lengths differ"

2012 Apr 16
2
Problems with subset, droplevels and lm: variable lengths differ
[Env: R 2.14.2 / Win Xp] In the script below, I want to select some variables from rrcov::OsloTransect, delete cases with any missing data, and subset the data frame Oslo to remove cases for two levels of the factor litho that occur with low frequency. The checks I run on my new data frame Oslo look OK, but I when I try to fit a multivariate linear model with lm(), I am getting an error:
2012 Jan 31
1
about colnames
Hi, when I run the below code,there is an error occured. could you please tell me how to treat it? > pdf('covariate.pdf') > par(mfrow=c(1,1)) > pairs(data2[,c("ID","TYPE","AGE","GNDR","HT")], + panel=function(x,y) { points(x,y); lines(lowess(x,y))}) Error in `[.data.frame`(data2, , c("ID", "TYPE",
2012 Feb 14
2
save objects of own function to workspace
Dear R-helpers, I created an own function which looks like this s_elternmz <- function(Var="balt") { Dg_a<-mz[,c("asbhh","apkz",Var)] colnames(Dg_a)[colnames(Dg_a)=="apkz"]<-"bpkzm" colnames(Dg_a)[colnames(Dg_a)==Var]<-paste(Var,"_m",sep="")
2012 Dec 25
5
aggregate / collapse big data frame efficiently
Hi, I need to aggregate rows of a data.frame by computing the mean for rows with the same factor-level on one factor-variable; here is the sample code: x <- data.frame(rep(letters,2), rnorm(52), rnorm(52), rnorm(52)) aggregate(x, list(x[,1]), mean) Now my problem is, that the actual data-set is much bigger (120 rows and approximately 100.000 columns) ? and it takes very very long
2011 Aug 29
2
Problem in writing a R data frame to Excel format using RODBC package
Hi Experts, I was trying to write a data frame which has a header row, from R to Excel disk file using RODBC ( RODBC_1.3-1) package. I met with an issue:- If in sqlSave(), I set a parameter "colnames=FALSE" then I get first row as header in excel file. If 'colnames=TRUE' then it gives me first 2 rows as header in excel file. Actually, according to my
2013 Aug 26
3
Naming columns
Hi , I just imported a large data set from notepad. I want to label the columns in R. I used 'import Dataset' to bring in my data set Now, I would like to label V1,V2,V3 etc?? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Naming-columns-tp4674595.html Sent from the R help mailing list archive at Nabble.com.
2012 Oct 14
6
transforming a .csv file column names as per a particular column rows using R code
Hello all, I have a .csv file like below. Tool,Step_Number,Data1,Data2... etc up to 100 columns. A,1,0,1 A,2,3,1 A,3,2,1 . . B,1,3,2 B,2,1,2 B,3,3,2 . . ...... so on upto 50 rows where the column "*Tool*" has distinct steps in second column "*Step_Number*",but both have same entries in Step_Number column. I want the output like below.
2012 Jul 07
4
replacement has length zero
I have been working on the following code but keep getting an err message. My current thinking is that the problem is on the indexing but do not know how to fix it. Any help please? ungulate <- read.csv("Ungulate.csv",row.names=1) ungulate <- as.matrix(ungulate);colnames(ungulate)<-NULL;rownames(ungulate)<-NULL habitat <- read.csv("Ungulate_vegetation.csv")
2012 Oct 08
3
Removing header from a matrix
I have three column vectors (X1, X2, X3).          X1  X2  X3        20   25  40        100 90  80 I want to put them as one matrix of dimention 2 by 3,  but remove headers(X1,X2,X3) from the matrix. I wrote as follows U<-cbind (X1,X2,X3) the headers are there. I need help please. Thanks Dereje [[alternative HTML version deleted]]
2017 Aug 19
4
My very first loop!! I failed. May I have some start-up aid?
Dear all, I have a data similar to this: myframe<- data.frame (ID=c("Ernie", "Ernie","Ernie","Ernie"), Timestamp=c("24.09.2012 08:00", "24.09.2012 09:00", "24.09.2012 10:00", "25.09.2012 10:00"), Longitude=c("8.481","8.482","8.483","8.481"),
2012 Dec 06
1
Fuction Error
I'm calling a list of symbols and then using a function to build a data frame from that symbol list. It works great until I introduce this index symbol from yahoo '^GSPC'. When and index symbol is introduced I get and error which is below. > Data <- symbolFrame(symbols) Error in get(S) : object '^GSPC' not found Since R does not like the ^ in front of a name it
2018 Mar 05
2
Help with apply and new column?
Thanks. I think nabble is good for programming questions. Bear with me if I'm incorrect. Data: Genomics SNP information Goal: I need to add Chromosome and SNP position to the data frame I'm using through apply. I'd like to add new column from text processed through apply function. For example: 10:60523:T:G (Column 2) CHR: 10 Position: 60523 Dataset: chr rs ps n_miss allele1
2012 Oct 26
4
Merge matrices with different column names
A general question that I have been pursuing for some time but have set aside. When finishing some analysis, I can have multiple matrices that have specific column names. Ideally, I would like to combine these separate matrices for a final output as a csv file. A generic example: Matrix 1 var1A var1B var1C x x x x x
2012 Jul 22
1
Lattice/"panel.bwplot" and Gviz: Boxplot question
Hi, I was using Gviz package to create a boxplot. I understand that Gviz uses "panel.bwplot" to create the boxplot. Is there any way that I can remove the dashed line surrounding each pair of boxplots? Here is some sample code: ############# library(Gviz) thisdata <- matrix(sample(1:100,60),nrow=10,ncol=6) positions <- sample(1:100,6) limit1 <- min(positions)-1 limit2
2008 Apr 27
1
Adding rownames with different lengths to a table
Hello! I would like to add names to a table. The table presents median values, numbers of values (n) and percentage(%) for a given agegroup. Thus I would like to add a label above these three variables for each category. But if I try to use colnames I get a message telling me that the number of labels must be equal to the number of columns in the table. I hope someone could understand what I mean!
2013 Apr 20
2
Editing data sheet issue with write.table append
I'm running R 2.15.2 on Max OS X 10.6.8 If I write a simple file Data1<-1 DF<-data.frame(Data1) colnames(DF)<-"Col1" and write to a csv file write.table(DF,file="Data.csv",sep=",",row.names=FALSE,col.names=TRUE) I can then append to it no problem Data2<-2 Data3<-4 DF2<-data.frame(Data2) DF3<-data.frame(Data3)
2017 Aug 19
0
My very first loop!! I failed. May I have some start-up aid?
Thank you for providing the example code... for the request of running it multiple times it would have helped if you could have confirmed that the example ran through without errors... there were a lot of mistakes in it. Look into using the reprex package to check your example next time. I don't do this kind of analysis... I really don't know what to expect from the functions. The
2012 Oct 15
2
Chopping a two column data frame by rows into a three dimensional array.
If I have a two column data frame like: > dat <- cbind("x"=c(1:100),"y"=c(100:1)) How can I create an array that splits every ten rows of that data frame into a third dimension of an array so that: > newarray[,,1] ,,1 x y 1 100 2 99 3 98 ... ... 10 91 ,,2 x y 11 90 12 89 ... ... ... Thanks. [[alternative HTML version deleted]]
2018 Mar 05
0
Help with apply and new column?
Comments interspersed, and some code at the end. On Mon, 5 Mar 2018, Sariya, Sanjeev wrote: > Thanks. I think nabble is good for programming questions. Bear with me > if I'm incorrect. You may have found R-help archives at Nabble, but R-help has nothing to do with Nabble. > > Data: Genomics SNP information I know almost nothing about using R for genomics. > Goal: I need
2012 Jul 25
2
reshape -> reshape 2: function cast changed?
Hi, I used to use reshape and moved to reshape2 (R 2.15.1). Now I tried some of my older scripts and was surprised that my cast function wasn't working like before. What I did/want to do: 1) Melt a dataframe based on a vector specifying column names as measure.vars. Thats working so far: dfm <- melt(df, measure.vars=n, variable_name = "species", na.rm = FALSE) 2) Recast the