similar to: Simple loop code

Displaying 20 results from an estimated 10000 matches similar to: "Simple loop code"

2010 Feb 26
2
Loop overwrite and data output problems
Hello R users, I have been using R for a while now for basic stats but I'm now trying to get my head around looping scripts and in some places I am failing! I have a data set with c. 1200 data points on 98 individual animals with data on each row representing a daily measure and I am asking the question "what variables affect the animal's behaviour?" the dataset includes
2010 Jun 13
1
Boxplot intervals combining names
Hi R users, This seems like a simple problem but I have searched nabble for the answer and can't seem to find it. All I want to do is produce a boxplot where I have two boxes for one Individual but on the xaxis I only have one tick mark centred between the boxes so I can add the Individuals' name. I have 30 IDs and have shown the code I use below for a couple of IDs, I figure the data
2010 Jun 01
2
storing output data from a loop that has varying row numbers
Hi All, I am trying to run a loop that will have varying numbers of rows with each output. Previously I have had the same number of rows so I would use (and I appreciate that this will no doubt achieve some gasps as being thoroughly inefficient!): xdfrow<-(0) xdfrow1<-(1:32) xdfrow2<-(33:64) xdfrow3<-(65:96) xdfrow4<-(97:128) xdfrow5<-(129:160) xdfrow6<-(161:192)
2012 Mar 07
1
confidence intervals in dotplots in a for loop
# I have some population estimates and confidence intervals for various size classes # of animals captured with two gear types. I'd like to plot the estimates along with # the 90 and 95% CI's by size class for each gear type. # The data can be read in as: estimates <- c(67.42,30.49,32.95,23.53,10.26,6.03,23.53,0.93,50.72,24.2,25.84,18.54,
2012 Apr 14
3
Choose between duplicated rows
Dear r experts, Sorry for this basic question, but I can't seem to find a solution? I have this data frame: df <- data.frame(id = c("id1", "id1", "id1", "id2", "id2", "id2"), A = c(11905, 11907, 11907, 11829, 11829, 11829), v1 = c(NA, 3, NA,1,2,NA), v2 = c(NA,2,NA, 2, NA,NA), v3 = c(NA,1,NA,1,NA,NA), v4 = c("N",
2008 Apr 02
1
Quickest way to access data.frame?
Hi, I have tried search around this forum for the best way to access a data.frame.. i got the feeling that "no partial match" is the way to make it fast.... so I convert everything to factor.. but I'm still not 100% sure if the following code will do it... is this the fastest way to do something foreach (ID, ID2) pair? Thanks! data <- data.frame(ID = floor(runif(n = 40000, min=0,
2013 Apr 12
1
Removing rows that are duplicates but column values are in reversed order
Hi, From your example data, dat1<- read.table(text=" id1?? id2?? value a????? b?????? 10 c????? d??????? 11 b???? a???????? 10 c????? e???????? 12 ",sep="",header=TRUE,stringsAsFactors=FALSE) #it is easier to get the output you wanted dat1[!duplicated(dat1$value),] #? id1 id2 value #1?? a?? b??? 10 #2?? c?? d??? 11 #4?? c?? e??? 12 But, if you have cases like the one
2008 Jul 09
2
Parsing
Dear R users, I have a big text file formatted like this: x x_string y y_string id1 id1_string id2 id2_string z z_string w w_string stuff stuff stuff stuff stuff stuff stuff stuff stuff // x x_string1 y y_string1 z z_string1 w w_string1 stuff stuff stuff stuff stuff stuff stuff stuff stuff // x x_string2 y y_string2 id1
2005 Aug 10
1
Why only a "" string for heading for row.names with write.csv with a matrix?
Consider: > x <- matrix(1:6, 2,3) > rownames(x) <- c("ID1", "ID2") > colnames(x) <- c("Attr1", "Attr2", "Attr3") > x Attr1 Attr2 Attr3 ID1 1 3 5 ID2 2 4 6 > write.csv(x,file="x.csv") "","Attr1","Attr2","Attr3" "ID1",1,3,5
2007 Apr 20
2
Fastest way to repeatedly subset a data frame?
Hi - I have a data frame with a large number of observations (62,000 rows, but only 2 columns - a character ID and a result list). Sample: > my.df <- data.frame(id=c("ID1", "ID2", "ID3"), result=1:3) > my.df id result 1 ID1 1 2 ID2 2 3 ID3 3 I have a list of ID vectors. This list will have anywhere from 100 to 1000 members, and
2011 Apr 25
2
Problem with ddply in the plyr-package: surprising output of a date-column
Hi Together, I have a problem with the plyr package - more precisely with the ddply function - and would be very grateful for any help. I hope the example here is precise enough for someone to identify the problem. Basically, in this step I want to identify observations that are identical in terms of certain identifiers (ID1, ID2, ID3) and just want to save those observations (in this step,
2012 Feb 22
1
Lattice and horizontally stacked density plots
Hello, I am try to make a density plot where plots are stacked like the one found here: http://dsarkar.fhcrc.org/lattice/book/images/Figure_14_03_stdBW.png I am facing problems, however. Using the code example below, I'd like to generate a separate panel for each val of id2. Within each panel, I'd like to have individual histograms each on separate lines based on the value of id1. ?Note
2006 Feb 09
1
List Conversion
Hello, I have a list (mode and class are list) in R that is many elements long and of the form: >length(list) [1] 5778 >list[1:4] $ID1 [1] "num1" $ID2 [1] "num2" "num3" $ID3 [1] "num4" $ID4 [1] NA I'd like to convert the $ID2 value to be in one element rather than in two.?? It shows up as c(\"num2\", \"num3\") if I try to use
2009 Dec 10
1
problem with data processing in R
Hi, I'm stuck with parsing data into R for heatmap representation. The data looks like: 1 id1 x1 x2 x3 .... x20 2 id1 x1 x2 x3 .... x20 3 id1 x1 x2 x3 .... x20 4 id1 x1 x2 x3 .... x20 ......... 348 id2 x1 x2 x3 .... x20 349 id2 x1 x2 x3 .... x20 350 id2 x1 x2 x3 .... x20 351 id2 x1 x2 x3 .... x20 ......... The data is sorted for the IDs (id1,id2 .....id40) and I like to
2010 Sep 07
1
average columns of data frame corresponding to replicates
Hi Group, I have a data frame below. Within this data frame there are samples (columns) that are measured more than once. Samples are indicated by "idx". So "id1" is present in columns 1, 3, and 5. Not every id is repeated. I would like to create a new data frame so that the repeated ids are averaged. For example, in the new data frame, columns 1, 3, and 5 of the original
2011 Apr 20
1
How to check if a value of a variable is in a list
Hi all, I am working with some social network analysis in R and ran into a problem I just cannot solve. Each observation in my data consists of a respondent, some characteristics and up to five friends. The problem is that all of these five friends might no show up later as a respondent (observation). Therefore I might not have characteristics on all the friends listed in the data and I want to
2005 Jun 10
1
Problems with corARMA
Dear all I am tryiing to fit the following lme with an ARMA correlation structure: test <- lme(fixed=fev1f~year, random=~1|id2, data=pheno2, correlation=corARMA(value=0.2, form=~year|id2), na.action=na.omit) But I get the following error message: Error in getGroupsFormula.default(correlation, asList = TRUE) : "Form" argument must be a formula I have used this same form
2006 Jan 14
3
In place editing and external control
Dear all, First I''d like to thank authors for so nice Scriptaculous and Prototype libraries, which helped me already a lot! I have question regarding externalControl parameter in InPlaceEditor. If I understand correctly, I can use that to have one image as a trigger to enter edit mode? I tried with below code but without success: <span id="id1">My text</span>
2008 Sep 25
2
How to order some of my columns (not rows) alphabetically
Hello, I have a dataframe with 9 columns, and I would like to sort (order) the right-most eight of them alphabetiaclly, i.e.: ID1 ID2 F G A B C E D would become ID1 ID2 A B C D E F G Right now, I'm using this code: attach(data) data<-data.frame(ID1,ID2,data[,sort(colnames(data)[3:9])]) detach(data) but that's not very elegant. Ideally I could specify which columns to sort and
2009 Feb 09
1
gee with auto-regressive correlation structure (AR-M)
Dear all, I need to fit a gee model with an auto-regressive correlation structure and I faced some problems. I attach a simple example: ####################################################### library(gee) library(geepack) # I SIMULATE DATA FROM POISSON DISTRIBUTION, 10 OBS FOR EACH OF 50 GROUPS set.seed(1) y <- rpois(500,50) x <- rnorm(500) id <- rep(1:50,each=10) # EXAMPLES FOR