similar to: match values from data.frame and vector

Displaying 20 results from an estimated 10000 matches similar to: "match values from data.frame and vector"

2012 Nov 17
3
transform input argument (matrix) of function
Dear list!   I would like to write a function to transform matrix, which is input argument of a written function. It is easy with new matrix (see below), but my idea is to transform input argument (matrix) of function without any additional matrixes. Here is an example: fun1 <- function(xy) { xy <- cbind(xy[,1], xy[,2], xy[,1] + xy[,2]) return(xy) }   df1 <- matrix(c(1,2,3,1,2,3), ncol =
2012 Nov 07
1
row index for max values of row groups
Dear list members! I am looking for ''nice solution'' for (maybe) simple problem. I need a code (small program) to calculate row index for max value (example below: df1$values) by groups (example below: df1$groups). df1 <- data.frame( groups = c(1,1,1,1,1,2,2,2,3,3,3,3), values = c(1,1,1,2,1,1,2,3,2,1,4,3) ) df1 expected results > 4 8 11 # row index of max values by group
2012 Dec 15
3
kruskalmc, significant differences while median values are the same
Dear list! I work with multiple Kruskal-Wallis test (kruskalmc, package pgirmess), which evaluates differences in medians among groups (5 groups). A result of a test is significant differences among some groups, while median values are the same for 4 groups (using tapply). Why? p.s.: number of samples in groups vary from 50 to 4900. Thanks to all, OV .
2012 Jun 26
5
chisq.test
Dear list! I would like to calculate "chisq.test" on simple data set with 70 observations, but the output is ''Warning message:'' Warning message: In chisq.test(tabele) : Chi-squared approximation may be incorrect Here is an example:         tabele <- matrix(c(11, 3, 3, 18, 3, 6, 5, 21), ncol = 4, byrow = TRUE)         dimnames(tabela) <- list(        
2012 Apr 07
1
rgeos - gBuffer, width by z-value
Dear list! I have problem with buffer size (width) in package rgeos. I would like to expand given geometry (points) to specified width based on the z value from attribute table. Here is example: point <- data.frame(x=c(10,20), y=c(10, 10), z = c(2,7)) point_shp <- SpatialPointsDataFrame(point[,1:2],point) plot(point_shp, xlim = c(0,30), ylim = c(0,20)) plot(gBuffer(point_shp, width = 5,
2012 Nov 20
2
correct function formation in R
Dear list! ? I have question of?'correct function formation'. Which function (fun1 or fun2; see below) is written more correctly? Using ''structure'' as output or creating empty ''data.frame'' and then transform it as output? (fun1 and fun1 is just for illustration). ? Thanks a lot, OV ? code: input <- data.frame(x1 = rnorm(20), x2 = rnorm(20), x3 =
2011 Oct 22
1
setMethod "[" - extract by names within Slot
Hi R-helper! I have problem with setMethods for "[". Here is example : setClass("myClass", representation(ID.r = "numeric", ID.c = "character", DAT = "matrix")) to.myClass <- function(ID.r, ID.c, DAT) {     out <- new("myClass", ID.r = ID.r, ID.c = ID.c, DAT = DAT)     return(out)       }       setMethod("[",
2011 Oct 01
1
class definition
Hi everybody! I have a matrix of class "myClass", for example: myMat <- matrix(rnorm(30), nrow = 6) attr(myMat, "class") <- "myClass" class(myMat) When I extract part of ''myMat'', the corresponding class ''myClass'' unfortunately disappear: myMat.p <- myMat[,1:2] class(myMat.p) Please for any advice / suggestions, how
2012 Oct 30
1
mapply instead for loop
Hi all!   My question in about using mapply instead for loop. Below is a example with for loop: Is it posible to give same results with mapply function?   Thanks for help!   OV   x <- 1:10 y <- 1:10 xyz <- data.frame(expand.grid(x,y)[1], expand.grid(x,y)[2], z = rnorm(100)) names(xyz) <- c("x", "y", "z") head(xyz) size <- 2 output <- NULL   ### for
2012 Feb 28
1
colour by z value, persp in raster package
Hi all!   My question is how to colour pixels by z value in persp plot in raster package. Here is an example:     x <- seq(-1.95, 1.95, length = 30) y <- seq(-1.95, 1.95, length = 35) z <- outer(x, y, function(a,b) a*b^2) r1 <- raster(nrows=35, ncols=30, xmn=0, xmx=30, ymn = 0, ymx = 35) r1[] <- c(z) persp(r1)   There already exist some function to produce persp plot for anothe
2004 Jun 29
1
nls fitting problems (singularity)
Hallo! I have a problem with fitting data with nls. The first example with y1 (data frame df1) shows an error, the second works fine. Is there a possibility to get a fit (e.g. JMP can fit also data I can not manage to fit with R). Sometimes I also got an error singularity with starting parameters. # x-values x<-c(-1,5,8,11,13,15,16,17,18,19,21,22) # y1-values (first data set)
2010 Nov 19
3
Still confused with lapply
Hello, I would like to replace a for loop with lapply in order to speed up the treatment of my data (I've read lapply can help to do it). At the end of the message, you will find a simple example (function is more complex and data frames is more than 1 million of rows) of what I would like to do, that is applying the same calculation to all the rows of the data frame (knowing that I cannot
2012 May 20
4
write.xls
Hello, All: The "writeFindFn2xls" function in the "sos" package tries to write an Excel file with 3 sheets ('PackageSum2', 'findFn', 'call'). Unfortunately, it is often unable to do this because of configuration problems that are not easy to fix. I've found 3 contributed packages that provide facilities to write Excel files with
2004 Sep 09
2
Skipping panels in Lattice
Dear all, I wish to generate a lattice boxplot which skips an empty cell in a design. I have trawled r-help, scruitinized xyplot(lattice) help page, and merrily reproduced examples of using skip from a couple of previous r-help queries and the example given in Pinheiro & Bates. But I must be missing something... Here's an example (running R 1.9.1 on Win2k): # generate some data df1
2011 Jun 28
1
Using Match in a lookup table
Hi All, I'm having a few problems using match and a lookup table, previous Googling show numerous solutions to matching a lookup table to a dataset, My situation is slightly different as i have multiple lookup tables, (that i cannot merge - for integrity reasons) that i wish to match against my data, and each of these files is large, so lots of for / if conditions are not ideal. (withstanding
2011 Aug 22
1
Selecting cases from matrices stored in lists
Hi, I have two lists (c and h - see below) containing matrices with similar cases but different values. I want to split these matrices into multiple matrices based on the values in h. So, I did the following: years<-c(1997:1999) for (t in 1:length(years)) { year=as.character(years[t]) h[[year]]<-sapply(colnames(h[[year]]), function(var)
2018 Feb 27
3
Aggregate over multiple and unequal column length data frames
Thank you Pikal and Bert. My apology for posting parts of my previous email in HTML. Bert's suggestion will work but i am wondering if there is an alternative especially in the case where the data frames are big; that is the difference in lengths among them is large. Below is a list of sample date frames and desired result. EK
2007 Sep 27
2
create data frame(s) from a list with different numbers of rows
# Hello, # I have a list with 6 categories and with different numbers of rows. # I would like to change each of them into a unique data frame in order to match # values with other data frames and perform some calculations. # Or I could make each category or list element have the same number of rows and create one large data.frame. # below is a creation of a sample list # I apologize for the
2009 Mar 22
5
If statement generates two outputs
Hi, How do I tell an if statement to generate two seperate outputs. E.g If X>5 I want to create df1 and df2: if (X>5) {df1<-c(4,5,6,7,8) AND df2<-c(9,10,11,12,13)} Thanks, James -- View this message in context: http://www.nabble.com/If-statement-generates-two-outputs-tp22650844p22650844.html Sent from the R help mailing list archive at Nabble.com.
2018 Feb 21
3
Aggregate over multiple and unequal column length data frames
Hi All-- I have generated several 2 column data frames with variable length. The data frames have the same column names and variable types. I was trying to aggregate over the 2nd column for all the date frames, but could not figure out how. I thought i could make them all of equal length then combine them in 1 data frame where i can use aggregate, the formula version Or to put them in a list and