search for: subdata

Displaying 20 results from an estimated 24 matches for "subdata".

2012 Sep 24
0
stop on rows where !is.na(mydata$ti_all)
...ot;plyr is loaded correctly") } else { print("trying to install plyr") install.packages('plyr') if(require(plyr)){ print("plyr installed and loaded") } else { stop("could not install plyr") } } newrows <- ddply(mydata, .(id), function(subdata) { subdata_ty = subdata[!is.na(subdata$ty_all), ] if (NROW(subdata) == 1) { r = subdata[1, ] c("v_001_arm_1", NA, NA, NA, NA, NA, lookup$c_name[lookup$t_name == r$t_name], NA) } else if (NROW(subdata_ty) > 0) { numbers = sappl...
2009 Sep 14
3
Eliminate cases in a subset of a dataframe
Hi folks, I created a subset of a dataframe (i.e., selected only men): subdata <- subset(data,data$gender==1) After a residual diagnostic of a regression analysis, I detected three outliers: linmod <- lm(y ~ x, data=subdata) plot(linmod) Say, the cases 11,22, and 33 were outliers. Here comes the problem: When I want to exclude these three cases in a further regressi...
2007 Aug 01
1
Problem to remove loops in a routine
...p on DVID # j=1 ijdata<-subset(idata,idata$DVID==j) for (k in 1:nPer) { #loop on Period # k=1 ijkdata<-subset(ijdata,ijdata$OCC==k) for (l in 1:nGRP) { #loop on Group # l=1 subdata<-subset(ijkdata,ijkdata$GRP==l) nModel<-nlevels(factor(subdata$MODEL)) #number of models to be plotted in this loop mylegend<-c("Raw data",levels(factor(subdata$MODEL))) subID<-nlevels(factor(subdata$ID)) #number of...
2003 Mar 25
2
Help with data.frame subsets
Hello all, I'm trying to get a subset of a data frame by taking all rows where the 2nd column is >= Min and <= Max. I can do that by a 2 step process similar to the following: subData <- dataFrame[dataFrame[,2] >= Min,] subData2 <- subData[subData[,2] <= Max,] Then I try to graph the results where col 2 is the X var and col 3 is the Y var. Therefore I do the following: X <- subData2[,2] Y <- subData2[,3] HOWEVER, sometimes subData2 is only left with 1 row re...
2011 Aug 17
3
How to apply a function to subsets of a data frame *and* obtain a data frame again?
...st sort df ## according to Group, then paste the values computed by edf to the sorted df; ## seems a bit tedious). ## A solution I have is the following (but I would like to know if there is a ## simpler one): (edf.. <- do.call("rbind", lapply(unique(df$Group), function(strg){ subdata <- subset(df, Group==strg) # sub-data subdata <- cbind(subdata, edf=edf(subdata$Value)) })) ) Cheers, Marius
2007 Oct 01
3
mean of subset of rows
...IDs is repeated a different number of times. I would like to get the mean size for each ID as another data.frame. I have tried the following: >ID= as.character(unique(data[,1])) # I use unique() because "data" will be larger in future >nIDs = length(ID) >for(i in 1:nIDs){ + subdata = subset(data,V1==ID[i]) + average = as.data.frame(cbind(1:i,ID[i],mean(subdata[,2])) + } Unfortunately, my output only gets the last level of ID four times: >average V1 V2 V3 1 1 D 179.777777777778 2 2 D 179.777777777778 3 3 D 179.777777777778 4 4 D 179.777777777778...
2011 Oct 31
1
googleVis motionchart - slow with Date class
...umn as a Date class variable, the plot as presented in the browser becomes considerably slower and very prone to crashing the browser. To illustrate this issue I have modified the WorldBank demo. ### objects from demo("WorldBank", package = "googleVis") M <- gvisMotionChart(subData, idvar="country.name", timevar="year", options=list(width=700, height=600)) plot(M) This works fine and I can smoothly move back and forth between the scatter plots and the line plots. ## here I express the date as a Date class object - arbibrarily assigning each year to Jun...
2002 Sep 30
0
using step function in functions
...[1]-i),] for (j in 1:dimz[2]) { names(cDat)[j]<-paste(names(cDat)[j],"xL", i, sep="",collapse=NULL) } if (i==1) indDat<-cDat else indDat<-cbind(indDat,cDat) } # build regression models for (i in 1:dimz[2]) { subData<-cbind(depDat[[i]],indDat) names(subData)[1]<-names(rData)[i] # make model where first variable in frame is the dependent variable regOut00<-eval(substitute(lm( dV ~ . , data=subData), list(dV = as.name(names(subData)[1])) )) regOut...
2008 Jun 19
2
Advanced Filtering problem
http://www.nabble.com/file/p18018170/subdata.csv subdata.csv I've attached 100 rows of a data frame I am working with. I have one factor, id, with 27 levels. There are two columns of reference data, x and y (UTM coordinates), one column "date" in POSIXct format, and one column "diff" in times format (chron package...
2009 Feb 11
2
How to apply table() on subdata and stack outputs
Dear R helpers: I am a R novice and have a question about using table() to extract frequences over many sub-datasets. A small example input dataframe and wanted output dataframe are provided below. The real data is very large so a for loop is what I try to avoid. Can someone englithen me how to use sapply or the like to achieve it? Many thanks in advance! -Sean #example input dataframe id
2007 Jun 21
2
Overlaying lattice graphs (continued)
...oo many tested models. The fun part is that the values of p, m, n and t might vary from one dataset to the other, so everything has to be coded dynamically. For the plotting part I was thinking about having a loop in my code containing something like that: for (i in 1:nlevels(mydata$Model)) { subdata<-subset(mydata,mydata$Model=level(mydata$Model)[i]) xyplot(subset(Observed + Predicted ~ Time | Individuals, data = subdata) #plus additionnal formatting code } Unfortunately, this code simply creates a new Trellis plot instead of adding the model one by one on the panels. Any idea or...
2011 Oct 10
1
calculate multiple means of one vector
Dear R-Users, I have the following two vectors: data <- rnorm(40, 0, 2) positions <- c(3, 4, 5, 8, 9, 10, 20, 21, 22, 30, 31, 32) now I would like to calculate the mean of every chunk of data-points (of the data-vector) as defined by the positions-vector. So I would like to get a vector with the mean of element 3 to 5 of the data-vector, 8 to 10, 20 to 22 and so
2008 Mar 03
2
handling big data set in R
...function "split": datamatrix<-read.csv("datas.csv", header=F, sep=",") dim(datamatrix) # [1] 2980523 3 names(datamatrix)<-c("X","Y","Z") attach(datamatrix) subX<-split(X, X) subY<-split(Y,X) subZ<-split(Z,X) n<-length(subdata) ### number of groups s1<-s2<-rep(NA, n) ### vector to store the regression slope for (i in 1:n){ a<-table(Y[[i]]) table.x<-as.numeric(names(a)) table.y<-as.numeric(a) fit1<-lm(table.y~table.x) ##### find the slope of the histogram of y s1[i]<-fit$coefficie...
2008 Feb 21
1
Save a group of matrix
Hello, I'm creating a loop to work with vegan, to get a species abundance curve. Here I send the script I've created and also an excel file to prove what it can do. Well, I have a database with 20 years, and each year we have sampled 19 stratum, and in each estratum we have carry out some sumpling. Then, with the script that I've sent I've got to calculate the species abundance
2017 Jan 10
7
[Bug 99354] New: [G71] "Assertion `bkref' failed" reproducible with glmark2
..."glmark2: pushbuf.c:238: pushbuf_krel: Assertion `bkref' failed." quite easily. I'm not sure if this is a duplicate of other bugs. The fastest way to reproduce seems to be: ./glmark2 -b buffer:columns=200:interleave=false:update-dispersion=0.99:update-fraction=0.5:update-method=subdata:buffer-usage=static --run-forever Changing some parameters from that command line still trigger the assertion, but usually it takes a bit more time. The command above triggers for me after 2.5 seconds (usually less than that), while for example the following command ./glmark2 -b buffer:columns=20...
2007 Aug 30
2
customizing the color and point shape for each line drawn using lattice's xyplot
Description of what I am trying to do: I am using the xyplot code below to plot the variable ?MeanBxg? against the variable ?PercentVarExplained? for all 9 possible combinations of variables ?bdg? and ?bdx?. Within each of these 9 scenarios I am plotting a separate line for each of up to 9 different methods that I used to estimate the variable MeanBxg. These methods are identified by the numeric
2012 Nov 10
4
help on date dataset
...Mexique 26 13 27/04/2009 Canada 6 14 27/04/2009 Spain 1 15 28/04/2009 Canada 6 I want to create something like that: ? When entering two dates date1,date2 in the fuction extraction. The result must be: a new subdata with one line per date , per PAYS,per nb_pays.ILI (by summing all the number in variable nb_pays.ILI per date,per country) and the date must be between date1 and date2. I sart to do somethings like that extraction=function(date1,date2) {date<-derdata[["DATE"]] date sort(dat...
2020 Oct 23
1
Extracting data and saving in excel
Hi all, I have a dataframe call "data", and have lots of rows. One of them is data$`birth` my data has been imported from an excel file in RSTUDIO I want to obtain in a function all rows (with the names) where data$`birth` is bigger than 1979/01/01 and extract in a excel file as an output (a sub-excel of the original). Can you guide with the functions I need to use? I have been many
2009 Oct 11
1
How do you test if a number is in a list of numbers?
Hi, I want to subset a data frame if one of the variables matches any in a list. I could of course do something like this: subset(dataset, var == 1 | var == 2 | var ==3) but that's tedious. I tried varlist = c(1,2,3,4) subset(dataset, any(var == varlist)) but it doesn't work because 'any' doesn't go row-by-row and hence always returns TRUE. Is there any simple way to do this?
2009 Nov 14
1
re move row if the column "date_abandoned" has a date in it
I want to go through a column in data called date_abandoned....data["date_abandoned"]....and remove all the rows that have numbers greater than 1,010,000. The dates are in the format 20091114 so i'm just going to treat them as numbers for clean up purposes. I know that i use subset but not sure how to proceed from there. -- View this message in context: