similar to: subsetting from a vector or matrix

Displaying 20 results from an estimated 9000 matches similar to: "subsetting from a vector or matrix"

2009 Aug 10
4
problem selecting rows meeting a criterion
When I try to select only those rows from the following data frame, called "data", in which X > Y X Y V3 2 2 1 8.062258 3 3 1 2.236068 4 4 1 6.324555 5 5 1 5.000000 6 1 2 8.062258 8 3 2 9.486833 9 4 2 2.236068 10 5 2 5.656854 11 1 3 2.236068 12 2 3 9.486833 14 4 3 8.062258 15 5 3 5.099020 16 1 4 6.324555 17 2 4 2.236068 18 3 4 8.062258 20 5 4 5.385165 21 1 5 5.000000
2010 May 06
2
splitting character strings and converting to numeric vectors
This seemingly should be quite simple but I can't solve it: I have a long character vector of geographic data (data frame column named "XY") whose elements vary in length (from 11 to 14 chars). Each element is structured as a set of digits, then an underscore, then more digits, e.g: > data.frame(head(as.character(XY))) head.as.character.XY.. 1 -448623_854854 2
2010 May 12
1
removing duplicate rows
I'm trying to identify and remove rows in a data frame that are duplicated only on particular columns within it (i.e. not on all columns). The "unique" function looks for uniqueness across all columns of a data frame. Identifying unique rows based only on specific columns of interest returns only those columns, not all of the columns in the original frame. I tried this, and then
2009 Feb 27
3
question about 3-d plot
Hi R Users, I have produced a simulated scatter plot of y versus x tightly clustered around the 45 degree line through the origin with the following code: x <- seq(1,100) y <- x+rnorm(100,0,10) plot(x,y,col="blue") abline(0,1) Is there some way to generate a 3-dimensional analogue of this? Can I get a similar simulated scatter plot of points in 3 dimensions where the points
2009 Mar 09
2
mean reverting model
dear useRs, i'm working with a mean reverting model of the following specification: y = mu + beta(x - mu) + errorterm, where mu is a constant currently I estimate just y = x (with lm()) to get beta and then calculate mu = estimated intercept / (1-beta). but I'd like to estimate mu and beta together in one regression-step and also get the test-statistics (including parameter
2009 Jul 23
5
error message: .Random.seed is not an integer vector but of type 'list'
I'm trying to run this simple random sample procedure and keep getting the error message shown. I don't understand this; I've designated x as a numeric vector, so what is going on here? Thanks. > x = as.vector(c(1:12));x [1] 1 2 3 4 5 6 7 8 9 10 11 12 > mode(x) [1] "numeric" > sample(x, 3) Error in sample(x, 3) : .Random.seed is not an integer vector
2010 Jul 06
3
Function for gruping similar variables?
Hi, I have a matrix of results of multiple 2x2 chi^2 tests, non- significant tests are marked as TRUE. Is there a function for grouping those variables in a similar way LSD.test from agricolae library does? I reviewed LSD.test's source but it's not helpful for me. This is my matrix: [,1] [,2] [,3] [,4] [,5] [,6] [,7] 1 TRUE FALSE TRUE TRUE TRUE FALSE TRUE 2 FALSE TRUE
2009 Oct 23
2
splitting a vector of strings...
Quick question -- if I have a vector of strings that I'd like to split into two new vectors based on a substring that is inside of each string, what is the most efficient way to do this? The substring that I want to split on is multiple characters, if that matters, and it is contained in every element of the character vector. --j -- Jonathan A. Greenberg, PhD Postdoctoral Scholar
2009 Jun 08
2
Tinn R
Dear R-users, I have installed the latest version of Tinn R (Version 2.2.0.2). With the older versions it was possible to run Tinn R next to R and then select code that one could send to R. Now it seems that one has to start the R gui in Tinn R and then it is possible to select en run code of R. But if I start R within Tinn R it does NOT start the R-Gui but only the R console. When I start R
2008 Dec 10
2
missing argument
Dear list, I have a question and I'm going to give an example of my problem f<- function(d1, d2, d3) { d<- d1*d2/d3 return(d) } v1<- 1 v2<- 2 If I try f(v1, v2, v3) Error in f(v1, v2, v3) : object "v3" not found I obviously got the above error message. I would like to add something to my function to allow me to get a certain value (say zero) if one of the arguments is
2009 Mar 18
2
How do I set the Windows temporary directory in R?
I'm trying to redirect where temporary files go under R to D:\temp\somerandomname from its default (C:\Documents and Settings\username\Temp\somerandomname) -- how do I go about doing this? --j -- Jonathan A. Greenberg, PhD Postdoctoral Scholar Center for Spatial Technologies and Remote Sensing (CSTARS) University of California, Davis One Shields Avenue The Barn, Room 250N Davis, CA 95616
2011 Sep 23
2
converting object elements to variable names and making subsequent assignments thereto
This has got to be incredibly simple but I nevertheless can't figure it out as I am apparently brain dead. I just want to convert the elements of a character vector to variable names, so as to then assign formulas to them, e.g: z = c("model1","model2"); I want to assign formulas, such as lm(y~x[,1]) and lm(y~x[,2]), to the variables "model1" and
2009 May 08
3
'Dynamic' 3D plot
Hi, I am looking for a R package to draw 3d plot. But not in a static way like scatterplot3d or stuff like that. I would like to make rotate the plot, to zoom/unzoom etc..., actually to render the graph 'dynamic'... (for the biologist and bioinformatician, a R package which permitts to reproduce what pdb viewer does). Does a Way exist to do something like that in R ? Thanks,
2010 Dec 26
2
object names from character strings
I realize this is probably pretty basic but I can't figure it out. I'm looping through an array, doing various calculations and producing a resulting data frame in each loop iteration. I need to give each data frame a different name. Although I can easily create a new character string for writing each frame to an output file, I cannot figure out how to convert such strings to
2010 Jul 07
3
quantiles on rows of a matrix
I'm trying to obtain the mean of the middle 95% of the values from each row of a matrix (that is, the highest and lowest 2.5% of values in each row are removed before calculating the mean). I am having all sorts of problems with this; for example the command: apply(matrix1,1,function(x) quantile(c(.05,.90),na.rm=T)) returns the exact same quantile values for each row, which is clearly
2009 Aug 04
2
R's database capabilities
I admit that I've not done a thorough search on this topic, but from the several instructional manuals and/or tutorials I've looked at, I don't see any mention of relational database capabilities in R? Have I missed something, and if so, can someone point me in the right direction to get started? Thanks! Jim Bouldin, PhD Research Ecologist Department of Plant Sciences, UC Davis
2011 Oct 24
3
extract the p value
OK, what is the trick to extracting the overall p value from an lm object? It shows up in the summary(lm(model)) output but I can't seem to extract it: > test2 = apply(aa, 1, function(x) summary(lm(x[,1] ~ 0 + x[,3] + x[,6]))) > test2[[1]] Call: lm(formula = x[, 1] ~ 0 + x[, 3] + x[, 6]) [omitted summary output] F-statistic: 40.94 on 2 and 7 DF, p-value: 0.0001371 It does not seem
2010 Mar 11
3
NAs and row/column calculations
I continue to have great frustrations with NA values--in particular making summary calculations on rows or cols of a matrix containing them. For example, why does: > a = matrix(1:30,nrow=5) > is.na(a[c(1:2),c(3:4)]);a [,1] [,2] [,3] [,4] [,5] [,6] [1,] 1 6 NA NA 21 26 [2,] 2 7 NA NA 22 27 [3,] 3 8 13 18 23 28 [4,] 4 9 14 19 24 29
2008 Dec 15
5
how to create duplicated ID in multi-records per subject dataset
Hi R helpers, If I have a dataset looks like: ID record 1 20 . 30 . 25 2 26 . 15 3 21 4..................... And I want it becomes ID record 1 20 1 30 1 25 2 26 2 15 3 21 4..................... That is, I have to duplicate IDs for those with multiple records. I am wondering it is possible to be
2009 Sep 10
1
Order a vector and move to new vector
I currently have a data frame with a Fund ID and NAV value. Is it possible to order the data frame and move to separate columns in a new data frame or matrix in R without using a for loop? I suppose I'd like to use a built in function to make it faster because I will have around 60,000 entries to sort and my current program takes too long to do this. I know how to use order, but is there a