Displaying 20 results from an estimated 20000 matches similar to: "Copying a subset of a matrix"
2007 Mar 06
3
Passing command line parameters to a script
Hi,
Does any one know if it is possible to create an R script that can use
command line parameters. I can execute an R script from the command line,
but I cannot figure out how to pass parameters to the script. The only
resources I have found seem somewhat involved or incomplete.
Any help is appreciated.
Akintayo
[[alternative HTML version deleted]]
2009 Sep 03
2
Easy way to get top 2 items from vector
Hi,
I use the max function often to find the top value from a matrix or
column of a data.frame.
Now I'm looking to find the top 2 (or three) values from my data.
I know that I could sort the list and then access the first two items,
but that seems like the "long way". Is there some way to access "max_2"
or similar?
Thanks!
--
Noah
2010 Nov 29
4
subset
?Hi:
I always use subset the same way but now is returning 0 rows.
What's wrong with the way I am subsetting?
library(ggplot2)
structure(list(first = c(38.2086, 43.1768, 43.146, 41.8044, 42.4232,
46.3646, 38.0813, 40.0745, 40.4889, 38.6246, 40.2826, 41.6056,
34.5353, 40.0768), second = c(43.3295, 42.4326, 38.8994, 37.0894,
42.3218, 46.1726, 39.1206, 41.2072, 42.4874, 40.2657, 38.7766,
2006 May 16
3
subset
Hello everyone,
I have a large dataset (x) with some rows that have duplicate variables
that I would like to remove. I find which rows are the duplicates with
X1<-which(duplicated(x)). That gives me the rows with duplicated
variables. Now, how can I remove just those rose from the original data
frame. I think I can create a new data frame without the duplicates
using subset. I have tried:
2008 May 14
4
Newbie question about vector matrix multiplication
Hello All,
I have a covariance matrix, generated by read.table, and cov:
co<-cov(read.table("c:/r.x"))
X Y Z
X 0.0012517684 0.0002765438 0.0007887114
Y 0.0002765438 0.0002570286 0.0002117336
Z 0.0007887114 0.0002117336 0.0009168750
And a weight vector generated by
w<- read.table("c:/r.weights")
X Y
2006 Nov 01
3
matrix manipulation with a for loop
Hi,
Having a matrix F.zoo (6575,189) with NA's in some columns I'm trying to
extract from each column the percent of days within an specific range,
so I've wrote this procedure:
length(subset(F.zoo[,86],(F.zoo[,86]>=5) & (F.zoo[,86]<=
9)))/(length(F.zoo[,86])-length(subset(F.zoo[,86],is.na(F.zoo[,86]))))*100
But to do this for each column (189) is pretty hard, so I want
2010 Jun 22
1
subset dataset using factor levels instead of factor names
Hi All,
I have a factor variable with 52 levels -with long, annoying names. I want to keep only rows with some variables. I can do this using this code:
test1 <- subset(nih2009,ic_name %in% c('NATIONAL EYE INSTITUTE','Veterans Affairs'))
dim(test1)
[1] 2396 38
But this doesn't work:
t1 <- subset(nih2009, ic_name %in% c(27,51))
dim(t1)
[1] 0 38
I know
2010 Oct 05
2
Subset POSIXlt Field
Hello All
I, for the life of me, can't figure out to subset my dataframe by my Date
field. The field has been formatted as POSIXlt.
str(wild)
......
$ Date : POSIXlt, format: "2010-05-28" "2010-05-28" "2010-05-28" ...
This doesn't work:
test <-subset(wild,ID=="2830" & Date=="2010-08-17")
which returns:
<0 rows> (or
2009 Dec 08
3
re-ordering x-lables using barchart()
Hi R Users,
I'm trying to re-order the "site names" ("Waseca", "Morris", ...). I'm using
following code:
libarry(lattice)
barchart(yield ~ variety | site, data = barley,
groups = year, layout = c(6,1), aspect=.7,
ylab = "Barley Yield (bushels/acre)",
scales = list(x = list(abbreviate = TRUE, rot=45,
2011 Feb 17
2
sort by column and row names
Hello, All,
How can one sort on column and row names. For example:
How can this
X1 X3 X2
X1 1 0 0
X3 0 1 0
X2 0 0 1
become this?
X1 X2 X3
X1 1 0 0
X2 0 1 0
X3 0 0 1
Thank you for your time!
Jim
[[alternative HTML version deleted]]
2010 Oct 01
3
Suppressing printing in the function
Hello!
I wrote a function that returns a data frame. Nowhere in the function
do I say print(my.data.frame), but when I run the function - the data
frame is printed on the console.
Is there any way to suppress it?
Thank you!
--
Dimitri Liakhovitski
Ninah Consulting
www.ninah.com
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
2009 Mar 11
4
R-help: grep in for loop using index - doesn't work
Hi everyone
I am trying to use grep in a for loop to compare a string value. It works
if I use
the actual index value but when I use the for loop index, it doesn't work.
Any suggestions plz.
Here is the code:
data <- read.table(file="Sigmoid.csv", head=FALSE, sep=",");
c1 <- data$V1
c2 <- data$V2
c3 <- data$V3
c1data <- data.frame(c1);
c2data <-
2010 Aug 19
1
Converting sparse matrix to data.frame in Matrix package
I am able to create a coordinate list sparse matrix this way:
r = c(1,2,2,3,3)
c = c(4,1,2,3,5)
v = c(1,2,1,3,1)
a = sparseMatrix(i=r,j=c,x=v)
However, this results in an object that looks like this:
a
3 x 5 sparse Matrix of class "dgCMatrix"
[1,] . . . 1 .
[2,] 2 1 . . .
[3,] . . 3 . 1
How do I convert this object into a data.frame that would look like this:
2010 Jul 28
2
read.delim()
I am reading in a very large file with names in it and R is truncating the number of rows it reads in. The separator in this file is a pipe '|' and so I use
dat <- read.delim('pathToMyFile', header= TRUE, sep='|')
It turns out that it is reading up to row 61145 and stopping and I think I see why, but am not sure of the best solution to this problem. I see the name of
2009 Aug 07
3
Simple Question: adding points to a boxplot
I apologize in advance for the simplicity of this question. I use R 2-3 times a year, and I seem to forget more in the intervening months than I learn during my days of panicked reading.... I HAVE tried looking at the help resources; I'm just not very good at understanding them.
I have a dataframe with 18 observations of 5 different things, and a second dataframe with and estimate for those
2010 Jun 10
1
importing multidimensional matrix from MATLAB
Hi,
Suppose I have a matrix of size 256x14x32 in MATLAB. I want to import
that into R. I used readMat and then do.call. But the variable is
stored as an array as its done in R. However, I want to define a
variable W=array(0,c(256,14,32)) in R and read the multidimensional
matlab variable into W. I am not able to do this in R. Please, could
you help ?
Thanks
Gopi
[[alternative HTML version
2010 May 06
1
How to rank matrix data by deciles?
Hi R users,
I have a matrix of data similar to:
> y=matrix(rnorm(55),ncol=5)
I would like to know to which decile each number belongs compared to the
numbers in its column.
Say y[1,1] is the third decile among y[1:11,1] and y[2,1] is in the second
decile
I would like get a matrix that would return their ranks in decile, i.e.,
y[1,1] -> 3
y[2,1] -> 2
Your help is much appreciated!
2010 Nov 22
1
how to round only one column of a matrix ?
round() function affects all values of a matrix, I want only to round column
that is called 'y'.
--
View this message in context: http://r.789695.n4.nabble.com/how-to-round-only-one-column-of-a-matrix-tp3054363p3054363.html
Sent from the R help mailing list archive at Nabble.com.
2010 Dec 01
1
read a matrix to find a value
Dear all of you,
I would like if someone can help me to know how I can read a matrix looking for positions in the matrix that are not null.
I have a matrix with most of the "cells" or "positions" null, I am trying to know the invasion power of a plant (number 1 in the matrix when t==1).
I would like to continue the model writing some condition when the value of the matrix in