Displaying 20 results from an estimated 30000 matches similar to: "matrix Manipulation..."
2011 Oct 02
2
Sum of Probabilities in a matrix...
Hi all,
I have 2 columns in a mtrix, one of which is a column of probabilities and
the other is simply a vector of integers. I want to sum all the
probabilities with the same integer value and put it in a new column.
For example,
If my matrix is:
0.98 2
0.2 1
0.01 2
0.5 1
0.6 6
Then I should get:
0.98 2 0.99
0.2 1 0.70
0.01 2 0.99
0.5 1 0.70
0.6 6
2012 Jul 05
3
Histogram
I have a column of 1000 datapoints from the normal distribution with mean 2
and variance 4. How can I get a histogram of these observations with 20
bins with each bin having 50 observations?
--
Thanks,
Jim.
[[alternative HTML version deleted]]
2011 Dec 16
1
kmeans and plot labels
Hi,
Thanks Sarah. Unfortunately I did not get a step further.
My question, perhaps a bit clearer, is how to display the case control status (or any other arbitrary point label) after clustering in a plot:
With a bit of pseudo code, where dataset is a data.frame, parameters are those column names where we find numerical values (no NAs) and nclasses is the desired number of classes.
fit <-
2011 Sep 14
1
draw points in R
Hello list
I have this file
0 121289479 25
0 212599129 1
0 285254098 21
0 444889848 45
0 469197123 30
0 640007403 82
0 718215617 8
0 758534043 56
0 799706577 4
0 814441385 93
0 843545059 37
0.2 121289479 6
0.2 285254098 3
0.2 444889848 6
0.2 469197123 13
0.2 640007403 24
0.2 718215617 3
0.2 758534043 2
0.2 799706577 2
0.2
2011 Sep 22
2
Proportions of a vector
>
> Hi all,
> I have a vector xm say: xm = c(1,2,3,4,5,5,5,6,6)
>
> I want to return a vector with the corresponding probabilities based on the
> amount of times the numbers occurred. For example, I should get the
> following vector for xm:
> prob.xm = c(1/9, 1/9, 1/9, 1/9, 3/9, 3/9, 3/9, 2/9, 2/9)
>
Using prop.table gives:
Usage (with table)
> prob.xm <-
2011 Jun 04
3
cbind 3 or more matrices
How can I cbind three or more matrices like A,B and C. This does not work:
cbind(A,B,C)
--
Thanks,
Jim.
[[alternative HTML version deleted]]
2012 May 15
9
help
1. Emma is performing an experiment that requires individual handling of some animals. The sizes of the animals are lognormally distributed: The natural logarithms of their sizes has a normal distribution with mean 3 and standard deviation 0.4. The time (in minutes) it takes to handle each animal is given by
10 + s · 1.5 + eε for animals with s ≤ 20 20 + s · 0.8 + eε for animals with s > 20
2012 Apr 26
2
ErrError in f(x, ...) : object 'g.' not found
Hi , R is a new language for me so sorry in advance if this error is to basic
for posting. I have tried the R manual and search online for quite a few, if
anyone could help i would be very thankful.
Here is my code.
kappa = 1.1
theta = 0.1
sigma = 0.4
rho = -0.6
v0 = 0.2
r = 0.05
T = 0.5
s0 = 1
K = 0.5
type = 1
Hestoncall = function(kappa,theta,sigma,rho,v0,r,T,s0,K,type)
{
u = 0.5
b
2009 Mar 18
3
numeric equality
Dear all,
I am totally confused by the following R output, but don't have a clue
for it.
> a <- 1 - 0.2
> a == 0.8
[1] TRUE
> a <- 1 - 0.8
> a == 0.2
[1] FALSE
> a <- 1 - 0.5
> a == 0.5
[1] TRUE
> a <- 1 - 0.6
> a == 0.4
[1] TRUE
> a <- 1 - 0.9
> a == 0.1
[1] FALSE
My R version is Windows XP R version 2.8.1 (2008-12-22).
2012 Dec 05
3
data manipulation between vector and matrix
Dear list,
I was curious how to subtract a vector from matrix?
Say, I have
mat <- matrix(1:40, nrow=20, ncol=2)
x <-c(1,2)
I want,
x-mat[1,] and x-mat[2,], and so on... Basically, subtract column elements
of x against column elements in mat.
But x-mat won't do it.
Thanks,
Mike
[[alternative HTML version deleted]]
2011 Jul 18
1
cluster by unique value
Hi,
I need to make a cluster classification by the unique values of the data frame.
I explain the problem. I need to classify this table, and assign to
the same cluster each row that has the same combination of value:
> data1
layer_1 layer_2 layer_3
[1,] 0.2460000000 2 -0.1
[2,] 0.5460000000 3 -0.1
[3,] 0.2460000000 2 -0.1
[4,]
2012 Feb 10
3
problem subsetting data frame with variable instead of constant
Hello,
I've encountered a very weird issue with the method subset(), or maybe this
is something I don't know about said method that when you're subsetting
based on the columns of a data frame you can only use constants (0.1, 2.3,
2.2) instead of variables?
Here's a look at my data frame called 'ea.cad.pwr':
*>ea.ca.pwr[1:5,]
MAF OR POWER
1 0.02 0.01 0.9999
2 0.02
2012 Feb 10
4
function arrows.circular not working
I have started using the circular package but it is not recognizing the function arrows.circular. I attempted to use the example provided in the circular manual. Here is the example code using the circular package:
plot(rvonmises(10, circular(0), kappa=1))
arrows.circular(rvonmises(10, circular(0), kappa=1))
arrows.circular(rvonmises(10, circular(0), kappa=1), y=runif(10), col=2)
2012 Feb 24
2
data frame manipulation with condition
Dear list,
n00b question, but still can't find any easy answer.
Here is a df:
> df<-data.frame(cbind(x=c("AA","BB","CC","AA"),y=1:4))
> df
x y
1 AA 1
2 BB 2
3 CC 3
4 AA 4
I want to modify this df this way :
if df$x=="AA" then df$y=df$y*10
if df$x=="BB" then df$y=df$y*25
and so on with other conditions.
TY for any
2012 Mar 01
4
problem with sum function
Hi!
I'm running R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)
When i type in the command:
sum(c(-0.2, 0.8, 0.8, -3.2, 1.8))
R returns the value:
-5.551115e-17
Why doesn't R return zero in this case? There shouldn't be any rounding
error in a simple sum.
Thanks,
Mark
2012 Jul 06
3
estimating NA values against selected slots
Dear R Users,
Could you please help me on the following issue?
I have a real large yearly data set. For each year I have
365 flow values. Some of the flow values are not known and that’s why you will
see NA written in those slots. I wanted to know, is there a way that I can
estimate those values? I tried approx command but it seems least helpful for
the kind of issue I am up against.
2013 Mar 22
4
ggplot2 will not draw a rectangle. Error: ggplot2 doesn't know how to deal with data of class XXX"
What am I missing? When I run the code below I get the error message
"Error: ggplot2 doesn't know how to deal with data of class function"
Googling suggests a message of "Error: ggplot2 doesn't know how to deal with data of class XXX" is not uncommon but I don't see why I am getting a "function" error unless I am using some reserved word?
2012 Jul 10
2
estimation of NA by predict command
Dear arun and all R users,
I will first of all try to simply define my issue..
I have data in the following format
Year Discharge
dd/mm/yyyy x
.. …
… …
There are some NA values in the discharge which I would like to predict by using “predict command”. I cant figure out the way to write the coding for that. Could you please help me on that???
I have also ,written
2007 Oct 22
2
Help interpreting output of Rprof
Hello there,
I am not quite sure how to interpret the output of Rprof (in the following the output I was staring at). I was poking around the web a little bit for documentation but without much success. I guess if I want to figure out what takes so long in my code the 2nd table $by.total and the total.pct column (pct = percent) is the most helpful. What does it mean that [ or [.data.frame is
2018 Apr 04
2
Plot data in sequence
Hi r-users,
I would like to draw line plots. However, the plot starts from 11121 data
and plot data ENTRY last in the plot.
Here is the code and data.
datn <- read.table(header=TRUE, text='
LEVEL STATUS CGPA
DIPLOMA ENTRY 3.32
DIPLOMA 11121 2.91
DIPLOMA 11122 2.90
DIPLOMA 12131 2.89
DIPLOMA 12132 2.89
DIPLOMA 13141 2.93
DIPLOMA 13142 2.96
DIPLOMA 14151 2.76
DIPLOMA 14152 2.73
STPM