Displaying 20 results from an estimated 34 matches for "mdat".
Did you mean:
dat
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 variables, but it only has one
The update() function in conjunction with...
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", "row2","row3","row4","row5","row6","row7"),
c("C.1", "C.2", "C.3")))
mdat<-...
2012 Mar 29
1
Retrieving matrix column and row names by index value
Hi all,
So let's say I have a matrix, mdat and I only know the index number. How do
I retrieve the column and row names?
For example,
> mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol=3, byrow=TRUE,
dimnames = list(c("row1", "row2"),
c("C.1", "C.2&quo...
2005 Jan 06
5
How to avoid rounding of matrix elements?
...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?
>mdat<-matrix(c(0.0187972950,0.4446208550,1.0000000000,0.0003204380,0.0105002420,1.1087556380,0.0742164230,0.0362898240),
nrow = 2, ncol=4)
> mdat
[,1] [,2] [,3] [,4]
[1,] 0.01879729 1.000000000 0.01050024 0.07421642
[2,] 0.44462085 0.000320438 1.10875564 0.03628982...
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 (rows) and species occurrences (0/1
values, colu...
2012 May 10
0
Coloring subsets of points of a strip chart by quantiles
...ot;E1", "E2", and "E3" columns plotted on a
single plot (containing the three strip charts). I am overlaying the strip
chart over a transparent background box plot.
##OK, here's some data (This is probably an inelegant way to do this, but
I'm obviously new to R):
mdat <-
matrix(c(round(runif(14,min=50,max=100)),round(runif(14,min=50,max=100)),round(runif(14,min=50,max=100))),
nrow = 14, ncol=3, byrow=F,dimnames = list(c(seq(1,14,by=1)),c("E1", "E2",
"E3"))) ; mdat <- as.data.frame(mdat)
mdat
E1 E2 E3
1 72 96 95
2 56 8...
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"),
+ c("C.1", &qu...
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 : Factor w/ 6 levels "2003","2004",..: 5 1 5 6 6 2 2 3 2 5 ...
$ variable: Factor w/ 1 level "mpg": 1 1 1 1 1 1 1 1 1...
2011 Jul 25
1
two sample histogram
dear all,
i am anewcomer. i have a set of paired data, the values are great different from each other. i want to show them in histogram.
first, how to draw each bar for corresponding paired data side by side;
second, how to set the scale of y axis? one is up to 100-fold to the other. ifdoubleslash is used to omit some coordinates, the histogram will looks better.
is there anyone that can help
2012 Jun 06
2
ggplot2: legend for geom_rug() ..?
...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)) + geom_point(aes(colour = X2)) +
geom_rug(subset = .(position < 14),aes(y=NULL),color="orange") +
geom_rug(subset = .(position > 14),aes(y=NULL),color="black")
This gives the plot corre...
2012 Nov 15
0
problem in fitting model in NLS function
Bad scaling will waste a lot of everyone's time.
I put the data in a data frame mdat, then
library(nlmrt)
mdat<-read.csv("muzzamil.csv", header=T)
fmn <- nlxb(y~a * (x^b), data=mdat, start=c(a=1,b=1), trace=T)
fm <- nls(y~a * (x^b), data=mdat, start=c(a=1,b=1), trace=T)
fmn2 <- nlxb(y~a2 * ((x-1979)^b2), data=mdat, start=c(a2=1,b2=1), trace=T)
fm2 <- nls(y...
2008 Nov 22
2
ggplot2 - facet_grid and facet_wrap
...), C =
c(6.9118223461127,
6.92991088926983, 16.1293054123787, 10.2251608535304)), .Names = c("D",
"G", "E", "I", "B", "F", "A", "J", "H", "C"), row.names = c(NA,
4L), class = "data.frame")
mdat <- melt(dat, id = "D")
qplot(D, value, data = mdat, fill = D, geom = "bar") + facet_grid(~
variable)
qplot(D, value, data = mdat, fill = D, geom = "bar") + facet_wrap(~
variable)
The first plot is good, but I think there is a problem in the second plot :
the barp...
2007 Jun 12
1
Subset and logical operator error
...ecific on the way to implement
this type of exclusion subset?
Can you please point to me my syntax mistake or indicate a method to get
this type of data.frame subset ?
Thank you in advance
ID value
1 1 1.2
2 2 1.2
3 3 1.2
4 4 1.2
5 5 A
6 6 A
7 7 A
8 8 A
subset(mdat,value!"A")
Error: syntax error, unexpected '!', expecting ',' in "subset(mdat,value!"
Sebastien
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
===>
row col dat
1 row1 col1 1
2 ...
2011 Jun 24
0
reshape: cast(x, a ~ b ~ .) vs. cast(x, a ~ b) difference
...lem with understanding what the function cast() from the package reshape is doing. In the example below I have a 2x2x2 array which I first melt and then cast to get the averages over the field 'strain' for every combination of the fields 'treatement' and 'gene':
------
> mdat <- melt(array(rnorm(8), dim=c(2,2,2),
dimnames=list(strain=c("s1", "s2"),
treatment=c("t1", "t2"),
gene=c("g1", "g2"))))
> mdat
strain treatment gene va...
2012 Nov 07
5
Calling R object from R function
Hi,
Can you please help me with this please?
What I am trying to do is call a vector from R function and used in the new
function
So I create 4 functions with these arguments
M11 <- function(TrainData,TestData,mdat,nsam) {
ls <- list()
I have few statments one of them is
vectx <- c(,1,2,3,4,5,6,6)
vectz <- c(12,34,5,6,78,9,90)
and then................
ls(vectx=vtecx,vectz=vectz)
return(ls)
}
Then I great an new function has the following arguments
get.m <- function(dat,asim,ModelFun,M){
Sim <...
2009 Jun 03
1
Lattice(barchart) related query
...39; Sweave (generating
EPS/PDF)?
2) As you will notice, there are negative values in the data. Is it
possible to have a different color for the bars depicting negative
values?
Reproducible code pasted below:
------------------------------------------------------------------------------------------
mdat <- matrix(c
(-2.65,-3.7,-0.8,-1.4,-2.39,-1.12,-4.78,-4.9,-0.76,-1.56,
1.77,1.41,1.92,1.78,0.05,0.96,0.29,1.4,0.53,1.49,
1.4,0.35,1.65,2.14,1.88,2.75,1.86,0.32,2.96,2.28), nrow = 3, ncol=10,
byrow=TRUE, dimnames = list(c("A", "B","C"),c
("S-1","S-2&quo...
2009 Jul 16
3
DataFrame help
Alright, so I am trying to write my own function to calculate column sums in
a matrix. I want the result as a single list with the values.
So far I have:
csum<-function(m)
{
a = data.frame(m)
s = lapply(a,sum)
return(s)
}
What is the easiest way to have it return in a format such as [1] 6 15 24 ?
Thanks.
--
View this message in context:
2010 Sep 21
3
change y axis "distance"
Hi
I got a barplot that has values between 0-150 and the y-axis shows the steps
0 50 100 and 150 but I would like to change it to 0 10 20 30... ...130 140
150
Dont really know the word in english so sry about it beeing abit confusing
:)
Thx for your help
Joel
--
View this message in context: http://r.789695.n4.nabble.com/change-y-axis-distance-tp2548363p2548363.html
Sent from the R help
2009 Sep 09
2
ggplot2: mixing colour and linetype in geom_line
Hi all,
I try to represent a multiple curve graphic where the x-axis is the
temperature and the different y-axes are the different X (X22,X43,X44...)
some X corresponds to the same molecule (22 and 44 are for CO2 for instance)
so I use the same colour for them.
I wanna mix the linetype with the colour to be able to visually see the
difference between X43 and X45
The best I have done up to now