similar to: Select part of character row name in a data frame

Displaying 20 results from an estimated 1000 matches similar to: "Select part of character row name in a data frame"

2017 Oct 19
0
Select part of character row name in a data frame
Quoting Francesca PANCOTTO <f.pancotto at unimore.it>: > Dear R contributors, > > I have a problem in selecting in an efficient way, rows of a data > frame according to a condition, > which is a part of a row name of the table. > > The data frame is made of 64 rows and 2 columns, but the row names > are very long but I need to select them according to a small
2017 Oct 19
0
Select part of character row name in a data frame
(Re-)read the discussion of indexing (both `[` and `[[`) and be sure to get clear on the difference between matrices and data frames in the Introduction to R document that comes with R. There are many ways to create numeric vectors, character vectors, and logical vectors that can then be used as indexes, including the straightforward way: df[ c( "Unique to strat ", "Unique
2017 Oct 19
2
Select part of character row name in a data frame
Thanks a lot, so simple so efficient! I will study more the grep command I did not know. Thanks! Francesca Pancotto > Il giorno 19 ott 2017, alle ore 12:12, Enrico Schumann <es at enricoschumann.net> ha scritto: > > df[grep("strat", row.names(df)), ] [[alternative HTML version deleted]]
2012 May 25
2
Collecting results of a test with array
Dear contributors I have tried this experiment: x<-c() for (i in 1:12){ x[i]<-list(cbind(x1[i],x2[i])) #this is a list of 12 couples of time series I am using to perform a test } # that compares them 2 by 2 # ################# #trace statistic test<-data.frame() cval<-array( , dim=c(2,3,12)) for (i in 2:12){ for (k in 1:2){ for (j in 1:3){ result[k,j,i]<-
2012 May 18
3
How to fix indeces in a loop
Dear Contributors, I have an easy question for you which is puzzling me instead. I am running loops similar to the following: for (i in c(100,1000,10000)){ print((mean(i))) #var<-var(rnorm(i,0,1)) } This is what I obtain: [1] 100 [1] 1000 [1] 10000 In this case I ask the software to print out the result, but I would like to store it in an object. I have tried a second loop, because if I
2011 Jul 27
3
Reorganize(stack data) a dataframe inducing names
Dear Contributors, thanks for collaboration. I am trying to reorganize data frame, that looks like this: n1.Index Date PX_LAST n2.Index Date.1 PX_LAST.1 n3.Index Date.2 PX_LAST.2 1 NA 04/02/07 1.34 NA 04/02/07 1.36 NA 04/02/07 1.33 2 NA 04/09/07 1.34 NA 04/09/07
2013 Jan 27
2
Loops
Dear Contributors, I am asking help on the way how to solve a problem related to loops for that I always get confused with. I would like to perform the following procedure in a compact way. Consider that p is a matrix composed of 100 rows and three columns. I need to calculate the sum over some rows of each column separately, as follows: fa1<-(colSums(p[1:25,])) fa2<-(colSums(p[26:50,]))
2011 Nov 12
1
Simulation over data repeatedly for four loops
Dear Contributors, I am trying to perform a simulation over sample data, but I need to reproduce the same simulation over 4 groups of data. My ability with for loop is null, in particular related to dimensions as I always get, no matter what I try, "number of items to replace is not a multiple of replacement length" This is what I intend to do: replicate this operation for four
2015 Jun 15
2
Different behavior of model.matrix between R 3.2 and R3.1.1
Terry - your example didn't demonstrate the problem because the variable that interacted with strata (zed) was not a factor variable. But I had stated the problem incorrectly. It's not that there are too many strata terms; there are too many non-strata terms when the variable interacting with the stratification factor is a factor variable. Here is a simple example, where I have
2015 Jun 15
2
Different behavior of model.matrix between R 3.2 and R3.1.1
Terry - your example didn't demonstrate the problem because the variable that interacted with strata (zed) was not a factor variable. But I had stated the problem incorrectly. It's not that there are too many strata terms; there are too many non-strata terms when the variable interacting with the stratification factor is a factor variable. Here is a simple example, where I have
2011 Sep 28
1
Wilcox test and data collection
Dear Contributors I have a problem with the collection of data from the results of a test. I need to perform a comparative test over groups of data , recall the value of the pvalue and create a table. My problem is in the way to replicate the analysis over and over again over subsets of data according to a condition. I have this database, called y: gg t1 t2 d 40 1 1
2015 Jun 16
1
Different behavior of model.matrix between R 3.2 and R3.1.1
Terry Therneau has been very helpful on r-help but we can't figure out what change in R in the past months made extra columns appear in model.matrix when the terms object is subsetted to remove stratification factors in a Cox model. Terry has changed his logic in the survival package to avoid this issue but he requires generating a larger design matrix then dropping columns. A simple
2011 Nov 11
8
Help
Dear Contributors I would like to perform this operation using a loop, instead of repeating the same operation many times. The numbers from 1 to 4 related to different groups that are in the database and for which I have the same data. x<-c(1,3,7) datiP1 <- datiP[datiP$city ==1,x]; datiP2 <- datiP[datiP$city ==2,x]; datiP3 <- datiP[datiP$city ==3,x] datiP4 <-
2009 Feb 08
0
Initial values of the parameters of a garch-Model
Dear all, I'm using R 2.8.1 under Windows Vista on a dual core 2,4 GhZ with 4 GB of RAM. I'm trying to reproduce a result out of "Analysis of Financial Time Series" by Ruey Tsay. In R I'm using the fGarch library. After fitting a ar(3)-garch(1,1)-model > model<-garchFit(~arma(3,0)+garch(1,1), analyse) I'm saving the results via > result<-model
2010 Apr 29
2
Rotating Titles
Hi All, I am looking for help in rotating species titles produced using the strat.plot( ) function in the rioja package. This function produces a stratigraphic plot of paleoenvironmental data. Currently the titles of each species are plotted vertically while they are typically plotted at a 45 degree angle in other programs. Does anyone have any idea of how to rotates these titles? Below is an
2011 Mar 10
2
using lapply
I have a function with the follow signare: apply.strategy(instr, strat) where instr and strat are both objects of classes instrument and strategy respectively. I want to apply this function to a list that holds objects of the class instrument. Currently I am doing this by explicit looping: for(i in length(instr.list) ) { apply.strategy(instr.list[[i]], my.strat) } Is it possible to
2009 Oct 01
5
How to use Subpopulation data?
Dear Helpers   I have a sample frame and i have sampled from it using three methods and now i want to calculate the statistics but i only get the population parameters.   H <- matrix(rnorm(100, mean=50000, sd=5000)) sampleframe=data.frame(type=c(rep("H",100)),value=c(H)) sampleframe   str=strata(sampleframe,c("type"),size=c(20,), method="srswor")
2012 Apr 10
6
trust relationship between this workstation and the primary domain failed
Samba shares work for windows 7 and Server 2008, but XP and Server 2000 recieve the following error when trying to map samba shares: "The trust relationship between this workstation and the primary domain failed." tail -f /var/log/messages Apr 10 07:38:03 samba01 smbd[23581]:?? connect_to_domain_password_server: unable to open the domain client session to machine ad1.strat.com. Error
2013 Nov 13
2
determinacion del tamaño de la muestra
Yo no conozco ningún paquete para hacer esto aunque probablemente exista. De todas maneras las cuentas de este tipo de calculos no suelen ser complicadas. Personalmente le recomendaría pasarse por una biblioteca y adquirir el siguiente libro donde explica con todo lujo de detalles, en castellano y simpliciddad como hacer estos calculos
2007 May 04
3
Error in if (!length(fname) || !any(fname == zname)) { :
Dear R users, I tried to fit a cox proportional hazard model to get estimation of stratified survival probability. my R code is as follows: cph(Surv(time.sur, status.sur)~ strat(colon[,13])+colon[,18] +colon[,20]+colon[,9], surv=TRUE) Error in if (!length(fname) || !any(fname == zname)) { : missing value where TRUE/FALSE needed Here colon[,13] is the one that I want to stratify and the