search for: mydataframe

Displaying 20 results from an estimated 87 matches for "mydataframe".

2011 Apr 07
3
Correlation Matrix
Listers, I have a question regarding correlation matrices. It is fairly straight forward to build a correlation matrix of an entire data frame. I simply use the command cor(MyDataFrame). However, what I would like to do is construct a smaller correlation matrix using just three of the variable out of my data set. When I run this: cor(MyDataFrame$variable1, MyDataFrame$variable2,MyDataFrame$variable3) I get an error. Is there a way to do this through a built in function or is th...
2009 Dec 08
1
problem with split eating giga-bytes of memory
...actual 52MB dataframe should be easily handled by my 12GB of RAM, but it is not. instead, when I try to split selectSubAct.df on one of its factors with 1473 levels, my memory is slowly gobbled up (plus 3 GB of swap) until I cancel the operation. Any ideas on what might be happening? Thanks, Mark myDataFrame <- data.frame(matrix(LETTERS, ncol = 7, nrow = 399000)) mySplitVar <- factor(as.character(1:1400)) myDataFrame <- cbind(myDataFrame, mySplitVar) object.size(myDataFrame) ## 12860880 bytes # ~ 13MB myDataFrame.split <- split(myDataFrame, myDataFrame$mySplitVar) object.size(myDataFrame.sp...
2007 Oct 24
3
Partial aggregate on sorted data
Hi All, I'm looking for ways to compute aggregate statistics (with the aggregate function) but with an option for sorting and selecting a subset of the data frame. For example, I have would like to turn this : aggregate(myDataframe$TargetValue,list(SomeFactor = myDataframe$SomeFactor),mean) into something like aggregate(myDataframe$TargetValue,list(SomeFactor = myDataframe$SomeFactor),mean, sort=DESCENDING, subset=0.33) where sort would sort TargetValue per factor level and subset would be (for example) a value between 0 a...
2010 Mar 11
2
Can't convert list to matrix properly
...list("A", "B","C","D") > myList [[1]] [1] "A" [[2]] [1] "B" [[3]] [1] "C" [[4]] [1] "D" I want to turn this list into a matrix of 1 row and 4 columns with those four components (A, B, C, D) so here is what I do: myDataFrame <- data.frame(myList) and here is how myDataFrame looks like: > myDataFrame X.A. X.B. X.C. X.D. 1 A B C D Until that point everything is ok because if I want to retrieve one element I make > myDataFrame[[1]] [1] A Levels: A But when I try to convert into matrix by doing t...
2010 Apr 26
1
help with code
I am new to R and have tried for a good while to figure out how to code this in R. The dataset below: FTIStandKey State County FTITract CoverType Ver_CT V_Origin V_SpGrp NAH6005-001 Texas Jasper NAH6005 PPLB-2000-U PPLB-2000-U P P NAH6005-002 Texas Jasper NAH6005 NHHX-1950-O NHHX-1950-I N H NAH6253-001 Texas Tyler NAH6253 PPLB-2001-U PPLB-2001-U P P
2010 Apr 29
2
understanding behavior of "merge"
...a vector of "ID"'s from my dataframe with replacement. Then I merge this back with my dataframe. I'm re-sampling subjects in the dataset rather than rows of the data. I thought I could use the left/right join features of the merge to select the records I want from the dataframe (mydataframe), like this. boot.sample <- merge( id.boot.draw,mydataframe, by=c("ID") , all.x=TRUE ) when I do that, the correct records are selected from "mydataframe" but the values for all the variables, other than the matching variable are now "NA". My other option is t...
2005 Apr 04
2
mysql retrive question
hello R-Users, I have this simple but not for me question: I do: > res<-dbSendQuery(con, "SELECT * FROM tabellaProva") > myDataFrame<-fetch(res) > myDataMatrix<-as.matrix(myDataFrame[,-1]) > namerows(myDataMatrix)<-as.character(myDataFrame[,1]) and I have: io tu io "0" "1" tu "1" "0" my problem is that the content of the matrix is interpreted by R as strings,...
2012 Jul 19
2
problem with using apply for dataframe
Dear people, I am including an example of a dataframe: mydataframe<-data.frame(X=c(1:4),total_bill=c(16.99,10.34,21.01,23.68),tip=c(1.01,1.66,3.50,3.31),sex=c("Male","Male","Male","Female")) When I use the sapply function getting the information about the factors works: sapply(mydataframe,function(x)is.factor(x))...
2012 Jul 04
2
Difference between two-way ANOVA and (two-way) ANCOVA
Hi! as my subject says I am struggling with the different of a two-way ANOVA and a (two-way) ANCOVA. I found the following examples from this webpage: http://www.statmethods.net/stats/anova.html # One Way Anova (Completely Randomized Design) fit <- aov(y ~ A, data=mydataframe) # Randomized Block Design (B is the blocking factor) fit <- aov(y ~ A + B, data=mydataframe) # Two Way Factorial Design fit <- aov(y ~ A + B + A:B, data=mydataframe) fit <- aov(y ~ A*B, data=mydataframe) # same thing # Analysis of Covariance fit <- aov(y ~ A + x, data=mydataframe...
2004 Nov 20
2
subset on data frame
I have a data frame. And I'd like to subset according to rownames. subset(mydataframe, rownames(mydataframe) == myrow, select = mycols) it turned out that "myrow" cannot be a vector. But I have multiple rows to pick. Is there a way to get around this problem?? Thank you for your help!! Lei Jiang Department of Chemsitry University of Washington Box 351700 Seattle, WA 9...
2010 May 15
1
Dataframe to word, using R2wd
Hi All, I'm trying to use R2wd to send a dataframe to Word. The dataframe isn't huge - 300 rows, 12 variables, although it has some long strings in it. Using: wdTable(format(myDataFrame)) or wdTable(myDataFrame) Produces a very complex table, which Word struggles to process and layout. (I can't work out what the table is - it seems to be nested tables. Converting to text gives one long column.) Using wdBody(MyDataFrame) or wdNormal(MyDataFrame) Is there another way to...
2007 Apr 22
1
dput/dget when a data frame has 2 rows (PR#9627)
This doesn't seem right; I'm using R version 2.4.1 (2006-12-18) on Mac OS and Win XP and find the same issue: > mydataframe <- data.frame(ppi=c(.5,.5),mmu=c(5,10)) > dput(mydataframe,"mydataframe.txt") > dget("mydataframe.txt") Error in attributes(.Data) <- c(attributes(.Data), attrib) : row names must be 'character' or 'integer', not 'double' > mydataframe3...
2010 Apr 26
1
Sweave: centering with echo=TRUE
In a .Rnw file I want to insert the R command pairs(mydataframe) and achieve the following effects 1. the command itseld is echoed into the tex document generated by Sweave <<fig=TRUE,echo=TRUE>>= 2. The graphics generated appears in the tex document, with the graphics centred. 3. The R command > pairs(mydataframe) is not centered. Sweave-manua...
2005 Jun 15
1
anova.lme error
...ova to do a LR test from inside a function, I get an error. The same call works outside of a function. It appears to not find the right environment when called from inside a function. I have provided the code below. Thanks, Nisha Mulakken ############################ myFunction <- function(myDataFrame) { # Less restricted fit1 <- gls(y ~ dose, weights=varIdent(form=~1|dose), data=myDataFrame) # more restricted fit2 <- gls(y ~ dose, data=myDataFrame) anova.results <- anova(fit1, fit2) anova.results } df <- data.frame( y=c(12,3,...
2011 May 26
0
Reference Classes: getter and setter functions/methods and possible shortcuts
...;) for Reference Class objects? Or is it desired to not use this stuff, but define methods like 'obj$getSubset(row=1:3, col=1)' and 'obj$setSubset(value=x)' instead? I have some example code that might help in clarifying what I'm exactly after: setRefClass( Class="MyDataFrame", fields=list( PRIMARYDATA="data.frame" ), methods=list( "subsetGet"=function( idx.row, idx.col, drop=if(missing(idx.row)) TRUE else length(PRIMARYDATA) == 1, ... ){ P...
2007 May 12
0
How to Derive an S4 Class from a data.frame?
...o R-Help: I would really appreciate some help on this. I have spent a good deal of time searching for an answer for what I would think to be a common practice: Subclasses an S4 class from a data.frame. But have found very little. Here is some sample code that I've been trying: setClass("MyDataFrame", representation("data.frame", mysize = "numeric")) new("MyDataFrame", data.frame(col1 = c(1,2,3), col2 = c("four", "five", "six")), mysize = 12) When I run this in R 2.3.1(Wi...
2011 May 27
1
Reference Classes/S4 Classes: can method dispatch check superclasses BEFORE resorting to method for "ANY"?
Dear list, is it possible that method dispatch checks for superclasses/virtual classes before checking "ANY"? I'd like to build a generic initialization method for all my Reference Class (say "MyDataFrame") objects by having them inherit from class, say "MyRefClassVirtual" (which would have to be a virtual S4 class; there are no virtual Reference Classes, are there?) The problem is that 'getRefClass("MyDataFrame")$new' calls (I think) the method that was written...
2007 Jan 11
2
Wishlist: Sweave: allow line breaks after forward slashes (PR#9443)
...leaves the current line rather empty. This problem can be solved if Sweave is allowed to introduce line breaks after forward slashes. (I guess that this problem can also be solved if parse() adds a blank after a forward slash.) Example: The following expression cannot be wrapped by Sweave: mean(myDataframe$myFirstVariable)/mean(myDataframe$mySecondVariable) Thanks for the great software packages (R, Sweave, ...), Arne
2011 Dec 22
1
ff object in lapply function
Hello. I'm using as.ffdf(mydataframe) to create ffdf objects inside an lapply loop and returning that. I then use crbind to combine the lapply results into allData. So...simplified flow looks like this. res <- lapply(1:nchunks, function(n) { blah blah with nth chunk mydataframe <- da...
2018 Mar 12
0
Equivalent of gtools::mixedsort in R base
1- mixedorder does not work in a "do.call(mixedorder, mydataframe)" call like the order function does This is tangential, but do.call(order, mydataframe) is not safe to use in a general purpose function either - you need to remove the names from the second argument: > d <- data.frame(method=c("New","New","Old","Old...