similar to: Trim trailng space from data.frame factor variables

Displaying 20 results from an estimated 2000 matches similar to: "Trim trailng space from data.frame factor variables"

2007 Aug 08
1
tapply grand mean
Hi R-users, I have a data.frame like this (modificated from https://stat.ethz.ch/pipermail/r-help/2007-August/138124.html). y1 <- rnorm(20) + 6.8 y2 <- rnorm(20) + (1:20*1.7 + 1) y3 <- rnorm(20) + (1:20*6.7 + 3.7) y <- c(y1,y2,y3) x <- rep(1:5,12) f <- gl(3,20, labels=paste("lev", 1:3, sep="")) d <- data.frame(x=x,y=y, f=f) and this is how I can
2007 Aug 07
2
Interaction factor and numeric variable versus separate regressions
Dear list members, I have problems to interpret the coefficients from a lm model involving the interaction of a numeric and factor variable compared to separate lm models for each level of the factor variable. ## data: y1 <- rnorm(20) + 6.8 y2 <- rnorm(20) + (1:20*1.7 + 1) y3 <- rnorm(20) + (1:20*6.7 + 3.7) y <- c(y1,y2,y3) x <- rep(1:20,3) f <- gl(3,20,
2007 Aug 23
1
How to merge string to DF
#Hi R-users, #I have an example DF like this: y1 <- rnorm(10) + 6.8 y2 <- rnorm(10) + (1:10*1.7 + 1) y3 <- rnorm(10) + (1:10*6.7 + 3.7) y <- c(y1,y2,y3) x <- rep(1:3,10) f <- gl(2,15, labels=paste("lev", 1:2, sep="")) g <- seq(as.Date("2000/1/1"), by="day", length=30) DF <- data.frame(x=x,y=y, f=f, g=g) DF$wdays <- weekdays(DF$g)
2008 Jan 02
3
Find missing days
Hi, I have a data.frame like this: y <- rnorm(60) lev <- gl(3,20, labels=paste("lev", 1:3, sep="")) date1 <- as.Date(seq(ISOdate(2007,9,1), ISOdate(2007,11,5), by=60*60*24)) date1 <- date1[-c(3,4,15,34,38,40)] df <- data.frame(lev=lev, date1=date1, y=y) I would like to produce a new data.frame with missing days in df$date1 in each df$lev, like this: lev
2007 Dec 01
2
How to cbind DF:s with differing number of rows?
#Hi R-users, #Suppose that I have a data.frame like this: y1 <- rnorm(10) + 6.8 y2 <- rnorm(10) + (1:10*1.7 + 1) y3 <- rnorm(10) + (1:10*6.7 + 3.7) y <- c(y1,y2,y3) x <- rep(1:3,10) f <- gl(2,15, labels=paste("lev", 1:2, sep="")) g <- seq(as.Date("2000/1/1"), by="day", length=30) DF <- data.frame(x=x,y=y, f=f, g=g) DF$g[DF$x == 1]
2006 Feb 17
1
Transforming results of the summary function
Hi all, I have a question about transforming the data from summary function. Let's say I have a data frame like this: > x = data.frame(a = c(rep("lev1", 5), rep("lev2", 5)), b = c(rnorm(5)+2, rnorm(5))) > x a b 1 lev1 1.5964765 2 lev1 2.2945609 3 lev1 3.5285787 4 lev1 1.4439838 5 lev1 2.2948826 6 lev2 1.7063506 7 lev2 -0.4042742 8 lev2
2008 Oct 19
2
definition of "dffits"
R-users E-mail: r-help@r-project.org Hi! R-users. I am just wondering what the definition of "dffits" in R language is. Let me show you an simple example. function() { library(MASS) xx <- c(1,2,3,4,5) yy <- c(1,3,4,2,4) data1 <- data.frame(x=xx, y=yy) lm.out <- lm(y~., data=data1, x=T) lev1 <- lm.influence(lm.out)$hat sig1 <-
2007 Aug 07
1
Naming Lists
Hi Im pretty new to R and I have run in to a problem. How do I name all the levels in this list. Lev1 <- c("A1","A2") Lev2 <- c("B1","B2") Lev3 <- c("C1","C2") MyList <- lapply(Lev1,function(x){ lapply(Lev2,function(y){ lapply(Lev3,function(z){ paste(unlist(x),unlist(y),unlist(z)) })})}) I would like to name the different
2008 Dec 29
4
Merge or combine data frames with missing columns
Hi R-experts, suppose I have a list with containing data frame elements: [[1]] (Intercept) y1 y2 y3 y4 -6.64 0.761 0.383 0.775 0.163 [[2]] (Intercept) y2 y3 -3.858 0.854 0.834 Now I want to put them into ONE dataframe like this: (Intercept) y1
2004 Jan 05
1
lda() called with data=subset() command
Hi I have a data.frame with a grouping variable having the levels C, mild AD, mod AD, O and S since I want to compute a lda only for the two groups 'C' and 'mod AD' I call lda with data=subset(mydata.pca,GROUP == 'mod AD' | GROUP == 'C') my.lda <- lda(GROUP ~ Comp.1 + Comp.2 + Comp.3 + Comp.4+ Comp.5 + Comp.6 + Comp.7 + Comp.8 ,
2007 Dec 02
1
How to recode a factor level (within the list)?
#Dear R-users, #I have a data.frame like this: y1 <- rnorm(10) + 6.8 y2 <- rnorm(10) + (1:10*1.7 + 1) y3 <- rnorm(10) + (1:10*6.7 + 3.7) y <- c(y1,y2,y3) x <- rep(1:3,10) f <- gl(2,15, labels=paste("lev", 1:2, sep="")) g <- seq(as.Date("2000/1/1"), by="day", length=30) DF <- data.frame(x=x,y=y, f=f, g=g) DF$g[DF$x == 1] <- NA
2009 Dec 01
1
Multiple grouping on the X axis.
I am trying to plot data with multiple logical and physical groups using R. Below is a sample of the kind of data I am working with and the desired output. We have a jmp script that can do the same thing, but at ~$200 a year the licensing is counterproductive. Thanks for any help. Data input: Loaded from a CSV file. Physical_1 Logical_1 Logical_2 Data_1 Data_2 x Y Z2
2009 Jun 16
4
confusion on levels() function, and how to assign a wanted order to factor levels, intentionally?
Dear R-helpers, I want to make a series of boxplots on several numeric univariates with two group variables (species and population, population nested in species, and with population as the X-axis). In order to get a proper order of the individual populations in X-axis, I need to assign a wanted order to the factor (population). I used the levels() function to do this assignment, but it seemed
2012 Jan 22
1
Calling update on an lm-object inside a function
Dear all, I want to update an lm (or glm) object by changing the response variable and I want to do so inside a function. Doing the update outside of a function is straight forward: x <- 1:5 y <- c(1,2,3,3,6) mm <- lm(y~x) y2 <- c(1,3,3,4,6) mm2<- update(mm, y2 ~ .) But I want to make the update inside a function (where the new response variable is declared inside the
2013 Apr 22
0
Copula fitMdvc:
Hello, I am trying to do a fit a loglikelihood function with Multivariate distribution via copulas with fitMdvc. The problem is that it doesn't recognize that my beta is a vector of km parameter and when I try to run it it say that the length of my initial values is not the same as the parameter. Can somebody guide me where my mistake is. Thanks, Elisa. #################################
2005 Apr 04
1
custom loss function + nonlinear models
Hi all; I'm trying to fit a reparameterization of the assymptotic regression model as that shown in Ratkowsky (1990) page 96. Y~y1+(((y2-y1)*(1-((y2-y3)/(y3-y1))^(2*(X-x1)/(x2-x1))))/(1-((y2-y3)/(y3-y1))^2)) where y1,y2,y3 are expected-values for X=x1, X=x2, and X=average(x1,x2), respectively. I tried first with Statistica v7 by LS and Gauss-Newton algorithm without success (no
2011 Aug 15
1
update() ignores object
Hi all, I'm extracting the name of the term in a regression model that dropterm specifies as the least significant one, and I'm assigning this name to an object. However, when I use update(), it ignores this object. Is there a way I can make it not ignore it? A reproducible example is below: > lm(x1~1+y1*y2+y3+y4,data=anscombe)->my.lm >
2006 May 30
2
merging
Dear List, Given, y <- matrix(c(0,1,1,1,0,0,0,4,4), ncol = 3, byrow = TRUE) rownames(y) <- c("a","b","c") colnames(y) <- c("1","2","3") y y2 <- y[2:3, ] rownames(y2) <- c("x","z") y2 how can I stop merge(y, y2, all = TRUE, sort = FALSE) squishing the extra rows? Ideally I want the same as: rbind(y,
2005 Jan 21
2
Selecting a subplot of pairs
Hello, I'm trying to plot a set of 3 dependant variables (y) against 4 predictors (x) in a matrix-like plot, sharing x- an y-axis for all the plot on the same column/line : y1/x1 y1/x2 y1/x3 y1/x4 y2/x1 y2/x2 y2/x3 y2/x4 y3/x1 y3/x2 y3/x3 y3/x4 In fact, this plot is a rectangular selection of the result of pairs(), limited to the relations between x's and y's
2010 Oct 21
1
All other variables in upper scope arg for stepAIC
Hi - I am trying to substitute for "the_other_y" in the code below. I want y2 and y3 to be there when i is 1, y1 and y3 to be there when i is 2 and y1 and y2 to be there when i is 3. I'm sure it's to do with what format the data should be in and I've tried alldata[,-i], but it fits all the columns of alldata except i rather than each column one at a time. I've tried