similar to: avoid losing data.frame attributes on cbind()

Displaying 20 results from an estimated 7000 matches similar to: "avoid losing data.frame attributes on cbind()"

2012 Jul 10
3
fill 0-row data.frame with 1 line of NAs
Dear all Is there a simpler method to achieve the following: When I obtain an empty data.frame after subsetting, I need for it to contain one line of NAs. Here's a dummy example: > (.xb <- iris[ iris$Species=='zz', ]) [1] Sepal.Length Sepal.Width Petal.Length Petal.Width Species <0 rows> (or 0-length row.names) > dim(.xb) [1] 0 5 > (.xa <-
2012 Jun 11
1
saving sublist lda object with save.image()
Greetings R experts, I'm having some difficulty recovering lda objects that I've saved within sublists using the save.image() function. I am running a script that exports a variety of different information as a list, included within that list is an lda object. I then take that list and create a list of that with all the different replications I've run. Unfortunately I've been
2010 Jun 09
4
question about "mean"
Hi there: I have a question about generating mean value of a data.frame. Take iris data for example, if I have a data.frame looking like the following: --------------------- Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2
2010 Feb 03
1
Calculating subsets "on the fly" with ddply
Hi, [I sent this to the plyr mailing list (late) last night, but it seems to be lost in the moderation queue, so here's a shot to the broadeR community] Apologies in advance for being more verbose than necessary, but I'm not even sure how to ask this question in the context of plyr, so ... here goes. As meaningless as this might be to do with the `iris` data, the spirit of it is what
2005 Sep 26
3
How to get the rowindices without using which?
Hi, I was wondering if it is possible to get the rowindices without using the function "which" because I don't have a restriction criteria. Here's an example of what I mean: # take 10 randomly selected instances iris[sample(1:nrow(iris), 10),] # output Sepal.Length Sepal.Width Petal.Length Petal.Width Species 76 6.6 3.0 4.4 1.4
2009 Sep 09
1
change character to factor in data frame
Dear all I have a simple problem which I thought is easy to solve but what I tried did not work. I want to change character variables to factor in data frame. It goes easily from factor to character, but I am stuck in how to do backwards conversion. Here is an example irisf<-iris irisf[,2]<-factor(irisf[,2]) # create second factor str(irisf) 'data.frame': 150 obs. of 5
2012 Aug 01
3
Neuralnet Error
I require some help in debugging this codeĀ  library(neuralnet) ir<-read.table(file="iris_data.txt",header=TRUE,row.names=NULL) ir1 <- data.frame(ir[1:100,2:6]) ir2 <- data.frame(ifelse(ir1$Species=="setosa",1,ifelse(ir1$Species=="versicolor",0,""))) colnames(ir2)<-("Output") ir3 <- data.frame(rbind(ir1[1:4],ir2))
2017 Oct 28
2
Cannot Compute Box's M (Three Days Trying...)
Hey Duncan, Hard to debug? That's an understatement. Eyes bleeding.... In any case, I tried all your suggestions. To get "integer" for the final column, I had to change the code to get integers instead of strings. double[] d1 = ((REXPVector) ((RList) tableRead).get(0)).asDoubles(); double[] d2 = ((REXPVector) ((RList) tableRead).get(1)).asDoubles(); double[] d3 = ((REXPVector)
2017 Oct 29
2
Cannot Compute Box's M (Three Days Trying...)
Thanks Duncan. I can't tell you how helpful all your terrific replies have been. I think the biggest surprise is that nobody appears to be using Java and R together like I"m trying to do. I suppose it should be a surprise since there are no books on the subject and almost no technical documentation other than a few sites here and there. ----- I originally had the "int" as the
2011 Aug 16
3
Newbie question - struggling with boxplots
Hopefully I will not be flamed for this on the list, but I am starting out with R and having some trouble with combining plots. I am playing with the famous iris dataset (checking out example dataset in R while reading through Introduction to datamining) What I would like to do is create three graphs (combined boxplots) besides each other for each of the three species (Setosa, Versicolour and
2009 Jul 03
2
Two questions about the cloud function in the lattice package
Hi, I have two questions regarding the cloud function in the lattice package: 1) Is there a way to not print the surrounding frame (i.e. the square surrounding the entire plot)? 2) Is there a way to italicize the text displayed with the key argument? Some sample code: data(iris) cloud(Sepal.Length~Petal.Length*Petal.Width,data=iris, groups=Species,screen=list(z=20,x=-70),
2008 Sep 02
2
cluster a distance(analogue)-object using agnes(cluster)
I try to perform a clustering using an existing dissimilarity matrix that I calculated using distance (analogue) I tried two different things. One of them worked and one not and I don`t understand why. Here the code: not working example library(cluster) library(analogue) iris2<-as.data.frame(iris) str(iris2) 'data.frame': 150 obs. of 5 variables: $ Sepal.Length: num 5.1 4.9 4.7
2011 Aug 02
1
'data.frame' method for base::rep()
Dear R developers Would you consider adding a 'data.frame' method for the base::rep function? The need to replicate a df row-wise can easily arise while programming, and rep() is unable to handle such a case. See below. > x <- iris[1, ] > x Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa > rep(x, 2)
2010 Sep 06
3
likelyhood maximization problem with polr
Dear community, I am currently trying to fit an ordinal logistic regression model with the polr function. I often get the same error message : "attempt to find suitable starting values failed", for example with : require(MASS) data(iris) polr(Species~Sepal.Length+Sepal.Width+Petal.Length+Petal.Width,iris) (I know the response variable Species should be nominal but I do as levels
2012 Dec 10
3
splitting dataset based on variable and re-combining
I have a dataset and I wish to use two different models to predict. Both models are SVM. The reason for two different models is based on the sex of the observation. I wish to be able to make predictions and have the results be in the same order as my original dataset. To illustrate I will use iris: # Take Iris and create a dataframe of just two Species, setosa and versicolor, shuffle them
2009 Oct 17
1
Easy way to `iris[,-"Petal.Length"]' subsetting?
Dear all What is the easy way to drop a variable by using its name (and not its number)? Example: > data(iris) > head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 1.3 0.2 setosa 4 4.6 3.1
2017 Oct 28
2
Cannot Compute Box's M (Three Days Trying...)
Thanks Duncan. Awesome ideas! I think we're getting closer! I tried what you suggested and got a possibly better error... . . . rConnection.assign("boxMVariable", myDf); String resultBV = "str(boxMVariable)"; // your suggestion. RESULTING ERROR: Error in format.default(nam.ob, width = max(ncn), justify = "left") : invalid 'width' argument (No idea
2005 Sep 16
6
How do I get the row indices?
Hi, I was wondering if it's possible to get the row numbers from a filtering. Here's an example: # give me the rows with sepal.length == 6.2 iris[(iris[,1]==6.2),] # output Sepal.Length Sepal.Width Petal.Length Petal.Width Species 69 6.2 2.2 4.5 1.5 versicolor 98 6.2 2.9 4.3 1.3 versicolor 127 6.2
2004 Aug 21
2
more on apply on data frame
Hi R People: Several of you pointed out that using "tapply" on a data frame will work on the iris data frame. I'm still having a problem. The iris data frame has 150 rows, 5 variables. The first 4 are numeric, while the last is a factor, which has the Species names. I can use tapply for 1 variable at a time: >tapply(iris[,1],iris[,5],mean) setosa versicolor virginica
2010 Jul 29
1
where did the column names go to?
I've just tried to merge 2 data sets thinking they would only keep the common columns, but noticed the column count was not adding up. I've then replicated a simple example and got the same thing happening. q1. why doesn't 'b' have a column name? q2. when I merge, why does the new column 'y' have all values as 5.1? Thanks in advance, Mr. confused > a <-