similar to: One step way to create data frame with variable "variable names"?

Displaying 20 results from an estimated 600 matches similar to: "One step way to create data frame with variable "variable names"?"

2010 Apr 02
2
How to save a model in DB and retrieve It
I'm wondering how to save an object (models like lm, loess, etc) in a DB to retrieve and use it afterwards, an example: wind_ms <- abs(rnorm(24*30)*4+8) air_kgm3 <- rnorm(24*30, 0.1)*0.1 + 1.1 wind_dg <- rnorm(24*30) * 360/7 ms <- c(0:25) kw_mm92 <- c(0,0,0,20,94,205,391,645,979,1375,1795,2000,2040) kw_mm92 <- c(kw_mm92, rep(2050, length(ms)-length(kw_mm92))) modelspline
2019 Jul 08
2
Salvar los plots a alta resolución la vez de incluirlos en documento
Buenas! Supongo que será fácil, pero se me está haciendo difícil. Tengo un documento Rmarkdown en RStudio en el que escribí lo que me pidieron, que me lo piden en formato MS Word. Markdown lo saca decentemente, pero me temo que no tan decente del todo las imágenes. Quiero que, además de salir las imágenes incrustadas en los respectivos chunks, también salve automáticamente la imágen en archivos a
2006 Apr 24
2
Ror has problems with memory usage??
I saw this on a forum for MODx (a CMS which seem very good, built on standards, with clean XHTML/CSS, using PHP). "RoR is a killer application, but is either a crusher when it comes to memory usage or SQL usage. Even simple seeming things can kill a server if it''s not dedicated to the application. In addition, RoR is much more complex really than MODx if you''re not
2012 Feb 25
1
Unexpected behavior in factor level ordering
Hello, Everybody: This may not be a "bug", but for me it is an unexpected outcome. A factor variable's levels do not retain their ordering after the levels function is used. I supply an example in which a factor with values "BC" "AD" (in that order) is unintentionally re-alphabetized by the levels function. To me, this is very bad behavior. Would you agree? #
2012 May 14
2
Error in names(x) <- value: 'names' attribute must be the same length as the vector
Dear R-helpers, I am stuck on an error in R: When I run my code (below), I get this error back: Error in names(x) <- value : 'names' attribute must be the same length as the vector Then when I use traceback(), R gives me back this in return: `colnames<-`(`*tmp*`, value = c(""Item", "Color" ,"Number", "Size")) I'm not exactly
2003 Apr 07
4
subsetting a dataframe
How does one remove a column from a data frame when the name of the column to remove is stored in a variable? For Example: colname <- "LOT" newdf <- subset(olddf,select = - colname) The above statement will give an error, but thats what I'm trying to accomplish. If I had used: newdf <- subset(olddf,select = - LOT) then it would have worked, but as I said the column
2012 Apr 20
1
predictOMatic for regression. Please try and advise me
I'm pasting below a working R file featuring a function I'd like to polish up. I'm teaching regression this semester and every time I come to something that is very difficult to explain in class, I try to simplify it by writing an R function (eventually into my package "rockchalk"). Students have a difficult time with predict and newdata objects, so right now I'm
2004 Jul 16
3
still problems with predict!
Hi all, I still have problems with the predict function by setting up the values on which I want to predict ie: original df: p1 (193 obs) variates y x1 x2 rm(list=ls()) x1<-rnorm(193) x2<-runif(193,-5,5) y<-rnorm(193)+x1+x2 p1<-as.data.frame(cbind(y,x1,x2)) p1 y x1 x2 1 -0.6056448 -0.1113607 -0.5859728 2 -4.2841793 -1.0432688 -3.3116807 ...... 192
2003 Sep 05
2
eliminating a large subset of data from a frame
I have a data frame with 155,000 rows. One of the columns represents the user id (of which about 10,000 are unique). I am able to isolate 1000 of these user ids (stored in a list) that I want to eliminate from the data set, but I don't know of an efficient way to do this. Certainly this would be slow: newdf<-df for(i in listofbadusers) { newdf<-subset(tmp,uid!=i) } is there a better
2011 Aug 22
1
Selecting cases from matrices stored in lists
Hi, I have two lists (c and h - see below) containing matrices with similar cases but different values. I want to split these matrices into multiple matrices based on the values in h. So, I did the following: years<-c(1997:1999) for (t in 1:length(years)) { year=as.character(years[t]) h[[year]]<-sapply(colnames(h[[year]]), function(var)
2018 Apr 27
5
predict.glm returns different results for the same model
Hi all, Very surprising (to me!) and mystifying result from predict.glm(): the predictions vary depending on whether or not I use ns() or splines::ns(). Reprex follows: library(splines) set.seed(12345) dat <- data.frame(claim = rbinom(1000, 1, 0.5)) mns <- c(3.4, 3.6) sds <- c(0.24, 0.35) dat$wind <- exp(rnorm(nrow(dat), mean = mns[dat$claim + 1], sd = sds[dat$claim + 1])) dat <-
2012 Jul 14
3
Can't understand syntax
OK, I need help!! I've been searching, but I don't understand the logic of some this dataframe addressing syntax. What is this type of code called? test [["v3"]] [is.na(test[["v2"]])] <-10 #choose column v3 where column v2 is == 4 and replace with 10 and where is it documented? The code below works for what I want to do (find the non-missing value in a row),
2007 Dec 02
1
odfWeave error
hello all, I trying to use the package 'odfWeave' and I get the follow error: ### error message ############################################################# ... Removing content.xml Post-processing the contents Error in .Call("RS_XML_Parse", file, handlers, as.logical(addContext), : Error in the XML event driven parser for content_1.xml: error parsing attribute name
2017 Jul 16
0
Arranging column data to create plots
On Sat, 15 Jul 2017, Michael Reed via R-help wrote: > Dear All, > > I need some help arranging data that was imported. It would be helpful if you were to use dput to give us the sample data since you say you have already imported it. > The imported data frame looks something like this (the actual file is > huge, so this is example data) > > DF: > IDKey X1 Y1 X2 Y2
2009 Jan 22
1
Problem with cex=0.1 when making jpegs
I am using the following script to make .jpg files. jpeg('plotx.jpg') ddat <-read.table("file",header=T) attach(ddat) tdat<-read.table("file1") plot(xx1,yy1,type='p',pch=1,col="blue",cex=0.2,xlim=c(0,3.5),ylim=c(-75,75)) points(tdat,col="green",pch=1,cex=0.2) dev.off() The problem is that I want the points to be very small;
2011 Sep 21
1
Problem with predict and lines in plotting binomial glm
Problems with predict and lines in plotting binomial glm Dear R-helpers I have found quite a lot of tips on how to work with glm through this mailing list, but still have a problem that I can't solve. I have got a data set of which the x-variable is count data and the y-variable is proportional data, and I want to know what the relationship between the variables are. The data was
2017 Jul 16
3
Arranging column data to create plots
Dear All, I need some help arranging data that was imported. The imported data frame looks something like this (the actual file is huge, so this is example data) DF: IDKey X1 Y1 X2 Y2 X3 Y3 X4 Y4 Name1 21 15 25 10 Name2 15 18 35 24 27 45 Name3 17 21 30 22 15 40 32 55 I would like to create a new data frame with the following NewDF: IDKey X Y Name1 21 15 Name1
2003 May 30
2
Need help installing qtoolbox
I have windows version of R v1.6.2 I have downloaded the qtoolbox.zip from http://www.cmis.csiro.au/S-PLUS/qtoolbox/ My R command line is > install.packages("C:/Program Files/R/qtoolbox.zip", .libPaths()[1], CRAN = NULL) and I get the following error message: updating HTML package descriptions Warning message: error -1 in extracting from zip file > Is there another way to
2005 Dec 07
4
Maintaining factors when copying from one data frame to another
Greetings all: OK, this is bugging the @#@%* out of me. I know the answer is simple and straightforward but for the life of me I cannot find it in the documentation, in the archives, or in my notes (because I know I've encountered this in the past). My problem is: I have a data frame with columns A, B, C, D, and E. A, B, and E are factors and C and D are numeric. I need a new data frame with
2013 Feb 01
3
Transforming 4x3 data frame into 2 column df in R
I have the following data frame: > foo w x y z n 1.51550092 1.4337572 1.2791624 1.1771230 q 0.09977303 0.8173761 1.6123402 0.1510737 r 1.17083866 1.2469347 0.8712135 0.8488029 What I want to do is to change it into : > newdf 1 n w 1.51550092 2 q w 0.09977303 3 r w 1.17083866 4 n x 1.43375725 5 q x 0.81737606 6 r x