search for: rowid

Displaying 20 results from an estimated 23 matches for "rowid".

2011 Apr 27
6
Assignments inside lapply
...nside a lapply statement. For example I would like to covert a double nested for loop for (i in c(1:dimx)){ for (j in c(1:dimy)){ Powermap[i,j] <- Pr(c(i,j),c(PRX,PRY),f) } } to something like that: ij<-expand.grid(i=seq(1:dimx),j=(1:dimy)) unlist(lapply(1:nrow(ij),function(rowId) { return (Powermap[i,j]<-Pr(c(ij$i[rowId],ij$j[rowId]),c(PRX,PRY),f)) })) as you can see lapply does not return nothing as the assignment is done inside the function. Would that work correctly? What are the cases such a statement will misfunction? I would like to thank you in advace for yo...
2020 Sep 24
1
How to use `[` without evaluating the arguments.
....intern='environment'), contains='long.table') #' LongTable constructor method #' #' @param rowData [`data.table`, `data.frame`, `matrix`] A table like object #' coercible to a `data.table` containing the a unique `rowID` column which #' is used to key assays, as well as additional row metadata to subset on. #' @param rowIDs [`character`, `integer`] A vector specifying #' the names or integer indexes of the row data identifier columns. These #' columns will be pasted together to make up the ro...
2010 Mar 12
1
Length as fun.aggregate in cast function of reshape package: unexpected error
...s (to me) to be identical to that generated by melt. # no melt operation is therefore carried out on the data, which looks exactly like the # 'testdata' dataframe described below. # testdata contains four numeric biochemistry results (Na,K,Ur,Cr) from a single test, # identified by having rowid=1. # the objective is to compute summaries of this table by a variety of # explanatory variables; in this case, there is only one, 'rowid'. # I had thought that reshape would be an easy and consistent way of doing this, # and so it is, for means, max, min and other standard statistics, #...
2010 Feb 08
1
R ggplot2 legend text left justify
In ggplot2 how do you justify the legend text ? In the example below the opts(legend.text = theme_text(size = 9,hjust=0)) changes the size of the text OK but it remains right justified. > mydata=data.frame(RowID=c("A","B","C"),Name=c("long long long long long name","short name ","medium medium name"),Speed=c(100,140,120)) > mydata RowID Name Speed 1 A long long long long long name 100 2 B...
2012 Mar 07
1
SELECT CASE in RODBC
...ansfer.Date AS date, AnimalTransferType.Code AS codeevent, AnimalTransferType.Description AS event FROM Animal FULL JOIN AnimalTransfer ON Animal.AnimalNumber = AnimalTransfer.AnimalNumber FULL JOIN AnimalTransferType ON AnimalTransfer.AnimalTransferTypeId = AnimaltransferType.RowId FULL JOIN AnimalStatus ON Animal.AnimalStatusId = AnimalStatus.RowId UNION ALL SELECT TOP(100)PERCENT Animal.Herdnumber AS herd, Animal.ChrNumber AS chrNr, Animal.AnimalNumber AS animalid, Animal.DateOfBirth AS datebirth, AnimalStatus.Code AS codestatus, AnimalStatus.Descriptio...
2012 Aug 17
2
How can we compare corresponding values of x and y (first value of x exacly matches with the first value of y)?
df <- data.frame ( "RowId" = 4:7, "x"=c("1_1", "2_2", "3_3", "3_3"), "y"=c("1_1", "3_3", "2_2", "3_3") ) How can we compare corresponding values of x and y (first value of x exacly matc...
2013 Apr 26
1
Stratified Random Sampling Proportional to Size
..._CD_LL and EMPL_TYPE and store it in a dataframe CURRPOP<-sqlQuery(ch,"SELECT APPT_TYP_CD_LL, EMPL_TYPE,ASOFDATE,EMPLID,NAME,DEPTID,JOBCODE,JOBTITLE,SAL_ADMIN_PLAN,RET_TYP_CD_LL FROM PS_EMPLOYEES_LL WHERE EMPL_STATUS NOT IN('R','T') ORDER BY APPT_TYP_CD_LL, EMPL_TYPE") #ROWID is a dummy ID I added and repositioned after the strat columns for later use CURRPOP$ROWID<-seq(nrow(CURRPOP)) CURRPOP<-CURRPOP[,c(1:2,11,3:10)] # My strata. Stratp is how many I want to sampled from each strata. NOTE THERE ARE SOME 0's which just means I won't sample from that grou...
2011 Dec 18
1
Identifying records with the correct number of repeated measures
...9;, 'P4', 'P5', 'P6', 'P7', 'P8', 'P9') for individuals sampled 9 times. In my sample data below the new vector (e.g. WW_Names) would include only 'WW_08I_01' and 'WW_08I_03'. Two other quick questions: 1) how can I re-number my 'ROWID', as when I subset my complete dataset to a smaller dataset the old ROWID's are no longer meaningful, and 2) when I subset my dataset my 'factor' variables contain all the levels from the complete dataset, how can I reset these factor variables to condense my 'dump' file as...
2006 Jan 16
8
AJAX + Table.
Hello all. I am trying ot load table rows using AJAX based on a search. The following code results in: 1. Firefox renders correctly (Multiple rows inserted into page). 2. Opera renders the entire returned string in one <td> by the looks of it (Bunched up under first header, the <> tags arne''t visible) 3. IE6 does nothing....great ;) This is driving me nuts so any help
2006 Mar 01
3
Optimization problem: selecting independent rows to maximize the mean
Dear R community, I have a dataframe with 500,000 rows and 102 columns. The rows represent spatial polygons, some of which overlap others (i.e., not all rows are independent of each other). Given a particular row, the first column contains a unique "RowID". The second column contains the "Variable" of interest. The remaining 100 columns ("Overlap1" ... "Overlap100") each contain a row ID that overlaps this row (but if this row overlaps fewer than 100 other rows then the remainder of the columns "OL1...OL100&qu...
2012 Jan 01
4
matrix position to list of coordinates
How can I extract a list of the positions in the matrix? > A=matrix(1:8, nrow=2,ncol=4) > A [,1] [,2] [,3] [,4] [1,] 1 3 5 7 [2,] 2 4 6 8 Something like this pos.A 1 1 1 2 1 3 1 4 2 1 2 2 2 3 2 4
2005 Oct 11
4
Any way to add to data frame saved as .rData file?
Hi all, I've got a script that generates a few moderate-size data frames, and then puts them together into one big data frame at the end in order to write that data frame to disk, so that it may be re-opened later on... I'm trying to trim down memory requirements in this script, so I was wondering if there was any way to append to a data frame already saved on disk (just like
2012 Feb 21
1
sqlite create new unique id
Hi everyone, I am trying to insert a row in sqlite table with my own unique id. I want to create unique id using sqlite internal function last_insert_rowid() which returns the next max rowid of the table which is always unique. I tested this using sqlite and it works fine but when i run the same query using RSQlite from r prompt, my query doesn't create new unique id. last_insert_rowid() always returns 0 value from RSQLite always returns 0. How...
2007 Dec 01
2
How to cbind DF:s with differing number of rows?
...#After this, I would like to cbind these data.frames (in g) into a single data.frame (which to export to MS Excel) #do.call(cbind, g) does not seem to work because of the different number of rows in each data.frame. #The resulting data.frame shoul look like this (only two variables printed here): Rowid;x;Freq.x;y;Freq.y; # etc... 1;1;9;1.69151845313816;1; 2;2;9;5.03748767699799;1; 3;3;8;5.37387749444247;1; 4;Empty;Empty;6.83926626214299;1; 5;Empty;Empty;6.97484558968873;1; 6;Empty;Empty;7.11023821708323;1; 7;Empty;Empty;7.1348316549091;1; 8;Empty;Empty;7.16727166992407;1; 9;Empty;Empty;7.35983428...
2010 Nov 19
2
Question on overdispersion
I have a few questions relating to overdispersion in a sex ratio data set that I am working with (note that I already have an analysis with GLMMs for fixed effects, this is just to estimate dispersion). The response variable is binomial because nestlings can only be male or female. I have samples of 1-5 nestlings from each nest (individuals within a nest are not independent, so the response
2007 Nov 08
3
skip non-sequential lines using scan?
Hi all, Is there a way to skip non-sequential lines using the "skip" argument in the scan function? E.g., I have a matrix with 100 rows and 1e7 columns. I open a connection and want to read only lines 5, 7, 9, etc [i.e., seq(5,99,2)] It might seem that the syntax to do this would be something like this (if only the "skip" allowed vectors in the same way colClasses does in
2010 Feb 17
3
Extending data frame with longer columns
Hi, I am a beginner in R and have only read a few chapters in the R book, I was not able to find a solution for this simple problem. I have an empty data frame: a=data.frame(name="test") which I would like to extend in a for-loop (with data extracted from a database). Ideally I would like to extend the data frame like this: a["new_1"] = 1:10 a["new_1"] = 1:12
2012 Jan 27
3
Subsetting for the ten highest values by group in a dataframe
Hello, I am looking for a way to subset a data frame by choosing the top ten maximum values from that dataframe. As well this occurs within some factor levels. ## I've used plyr here but I'm not married to this approach require(plyr) ## I've created a data.frame with two groups and then a id variable (y) df <- data.frame(x=rnorm(400, mean=20), y=1:400,
2010 Dec 07
4
Creating binary variable depending on strings of two dataframes
Hi, consider the following two dataframes: x1=c("232","3454","3455","342","13") x2=c("1","1","1","0","0") data1=data.frame(x1,x2) y1=c("232","232","3454","3454","3455","342","13","13","13","13")
2006 Aug 14
4
Updating a table with Ajax
I''ve been banging my head against the wall trying to update a table (add/delete rows) using Ajax. It seems simple enough but just doesn''t work for me. I can get it to work using DIVs instead of a table, but doing the layout with DIVs is much more cumbersome and I know it works for others with a table (though I haven''t been able to find an exact example code anywhere).