Displaying 20 results from an estimated 500 matches similar to: "Retrieving matrix column and row names by index value"
2010 May 04
2
R for web browser
Hi Everyone,
Does anyone know of any projects for running an interactive R session within
a web browser?
I'm looking for something similar to the one on the Ruby website
(http://tryruby.org), except for R.
Thanks for your responses in advance!
Lanna
-----
Lanna Jin
lannajin at gmail.com
510-898-8525
--
View this message in context:
2010 Mar 10
2
function to create multiple matrices
Hi All,
If given a dataframe (long form) with Year, Species, and Location,
How would I write a function that would create a unique matrix of Species &
Location for each Year?
What I've tried doing is the following:
data #dataframe
dataT<-table(data$Species,data$Location,data$Year) #creates tables of
Species vs Location for each Year
But I'm encountering issues individually
2010 May 11
1
create a data.frame for aov
Hi R-experts,
I try to find a way to transfer a matrix to a data.frame that is used as input of aov.
can you give me advice for that?
>mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol=3, byrow=TRUE, dimnames = list(c("row1", "row2"), c("Col1", "Col2", "Col3")))
>mdat
Col1 Col2 Col3
row1 1 2 3
row2 11 12 13
===>
2011 Nov 07
2
adjusting levelplot color scale to data
Hi guys,
I have a matrix with values varying from approximately -0.7 to 0.33 that I
want to create a heatmap/levelplot with.
When I execute the levelplot function for my matrix, I end up getting colors
that are adjusted to the max and min rather than around 0. In other words,
ideally I would like to have a color ramp that goes from red (negative
number), to white (0), to blue (positive);
2009 Nov 06
1
using xyplot to plot frequencies
Hi all,
First off, thank you for the overwhelming response last time. I'm still
trying to figure out the syntax of R to plot some distributions of some
frequencies. I've managed to plot histograms from the data, but I would
like to clean it up using xyplot from library(lattice). Unfortunately
I cannot find a solution to my problem.
Given a dataframe "all2", with numerical
2010 Mar 16
1
nested looping functions and dataframes
Hey All,
So, I am confused how exactly to use nesting loop functions in R to spit out
data frames. I've managed to create a working function for my data set that
generates a data frame for a given set of Year i and Location j; but how
would I do it for all Years and Locations?
Here is my working function:
test<-function(i,j){
a<-x[which(x$Year==i & x$Location==j),]
2009 Nov 05
3
performing operations on a dataframe
Hey all,
I feel like the solution to this problem should be relatively simple, but
for some reason I can't find answers or come up with my own solution.
Given the dataframe:
(SpA and SpB not important, want to look at distribution of cooccurance for
each year)
Year SpA SpB Coocc
2000 0
2000 2
2000 1
2001 8
2001 2
2001 0
2001 0
2002 1
2002 2
How can I apply different functions to
2010 May 04
7
How to replace all <NA> values in a data.frame with another ( not 0) value
I need to replace <NA> occurrences in multiple columns in a data.frame
with "000/000"
how do I achieve this?
Thanks
Nevil Amos
2010 May 03
8
Delete rows with duplicate field...
as a r noob i am having another problem:
i have a big dataframe where each row corresponds to one entry and each
column is a field...
for instance, i have the column ID and time and many more...
Id like to get a dataframe where all IDs are just included once (some users
with that ID might have several entries but Id like to kepp only one)..
when i use unique I only get a list of the levels (or
2009 Mar 05
3
Dropping rows conditionally
Dear R-help team,
I am getting addicted to using R but keep on getting many challenges on the way especially on data management (data cleaning).
I have been wanting to drop all the rows if there values are `NA' or have specific values like 1 or 2 or 3.
mdat <- matrix(1:21, nrow = 7, ncol=3, byrow=TRUE,
dimnames = list(c("row1",
2010 Sep 18
2
feedback/question on function update()
Hi,
First let me say I am a big fan of R and appreciate all your time and
effort.
The update() function does not seem to work in a for loop. Consider the
following:
mdat <- matrix(c(1,2,3, 11,23,13, 12,4,8), nrow = 3, ncol=3, byrow=TRUE)
reg <- lm(mdat[7:9]~1)
for(i in 1:2) {
reg <- update(reg,.~.+mdat[((i-1)*3 + 1):(i*3)]) #update reg twice
}
reg # reg should have two independent
2009 Jan 26
1
reshape problem: id and variable names not being recognized
Hi everyone. Long time listener, first-time caller here.
I have a data set that's been melted with the excellent reshape package, but
I can't seem to cast it the way I need to.
Here's the melted data's structure:
> str(mdat)
'data.frame': 6978 obs. of 4 variables:
$ VehType : Factor w/ 2 levels "Car","Truck": 1 1 2 1 1 2 1 1 1 1 ...
$ Year :
2011 Nov 11
1
barplot names.arg
Hello there,
I have a question regarding bar plots. I am trying to plot the data from
the following matrix as a barplot -
# input data
mdat <- matrix(c(0.1,0.9,0.9,0.1,0.5,0.5,0.45,1-0.45,0.6,0.4,0.8,0.2), nrow
= 6, ncol=2, byrow=TRUE,
+ dimnames = list(c("Mon", "Mon", "Tues", "Tues", "Thurs",
"Friday"),
+
2011 May 18
1
matrix help (first occurrence of variable in column)
Dear R help,
Apologies for the less than informative subject line. I will do my
best to describe my problem.
Consider the following matrix:
mdat <- matrix(c(1,0,1,1,1,0), nrow = 2, ncol=3, byrow=TRUE,
dimnames = list(c("T1", "T2"),
c("sp.1", "sp.2", "sp.3")))
mdat
In my actual data I have time
2010 Nov 12
2
sobre matrices
HOla a todos
soy novato en R.
Lo que pasa es que tengo un conjunto de datos en una matriz y me gustaría
saber , si es que el R tiene un comando en especial (para no tener que hacer
el programa) para que dichos datos queden en una sola fila o columna.
gracias.
--
[[alternative HTML version deleted]]
2005 Jan 06
5
How to avoid rounding of matrix elements?
Hi all R-users,
If I have a matrix with numeric elements as follows, the values are
rounded when I try to refer to a specifici element using [], the value
is rounded.
The same thing happens if the matrix is read from a file, the values are
stored to the correct precision but then when I try to refer to a
specific element (such as using [], it is rounded.
How do I avoid this rounding?
2008 Nov 22
2
ggplot2 - facet_grid and facet_wrap
Hello R users (and Hadley)
I have another question about ggplot2 :-)
(version 0.8)
`dat` <-
structure(list(D = c("a", "b", "c", "d"), G = c(1.51520888871520,
1.88812208268440, -6.60521862, 0.55968739), E = c(1.38888592256404,
1.39366168665589, 1.22509259382058, 1.36617701059296), I =
c(6.92634958902857,
6.94416045215158, 13.2179488828556,
2012 Jun 06
2
ggplot2: legend for geom_rug() ..?
Hi,
I was trying to make another legend for the rug plot. Sample code:
library(ggplo2)
ids <- paste('id_',1:3,sep='')
before <- sample(9)
after <- sample(1:10,9)
dat <- as.matrix(cbind(before,after))
rownames(dat) <- rep(ids,3)
position <- c(rep(10,3),rep(13,3),rep(19,3))
mdat <- cbind(melt(dat),position)
ggplot(mdat, aes(position, value)) +
2010 Apr 30
3
short question about data frame manipulation
Dear group,
I am losing my mind with a simple question. Sorry if obvious, but I maybe
start to be confused after days and days of reading documentations.
Df :
df <-
structure(list(a = 1:3, b = 4:6, c = structure(c(1L, 1L, 1L), class =
"factor", .Label = "w")), .Names = c("a",
"b", "c"), row.names = c(NA, -3L), class =
2007 Jun 12
1
Subset and logical operator error
Hello,
It looks to me as if the ! logical operator cannot be called when
subsetting a data.frame. In the example below, the value column has two
factor levels (but my typical datasets have more), and what I am trying
to do is to exclude all lines for which the "value" is different from
"A". I have got a syntax error message everytime I try to use the
subset() function.