Displaying 20 results from an estimated 3000 matches similar to: "Plot Coloured Triangle"
2012 Oct 04
1
Ops.factor(point1, point2) : - not meaningful for factors
Hi, can anyone help me in this problem :(. I am a total beginner in R
software. It took me 2 days just to look into this problem. Due to this
problem. I cant do looping. i want to find the distance between x and DSi
> DSi
i Si
1 1 (5, 20)
2 2 (20, 2)
3 3 (25, 32)
4 4 (8, 39)
5 5 (10, 17)
6 6 (35, 20)
7 7 (38, 10)
> str (DSi)
'data.frame': 7 obs. of 2 variables:
$ i
2008 Nov 10
2
how to convert indvidual pairwise distances to matrix
Hello,
I am trying to convert list of pairwise distances to a distance matrix for
spatial analysis (kriging). For instance, I have something like this for
each pair pf points, and I want to convert it to a matrix:
point1 point2 distance
1 1 0
1 2 4
2 2 0
2 1 4
Please let me know if there is a
2011 Apr 11
3
Geographic distance between lat-long points in R?
Dear R,
I have a bunch of geographic locations specified by lat-long coordinates. What's an easy way to calculate geographic distance between any two points? OR, perhaps there is a function for calculating a distance matrix for K sites?
Sincerely,
Scott Chamberlain
[[alternative HTML version deleted]]
2008 Dec 05
6
levels update
Hello,
I hope this question is not too stupid. I would like to know how to update
levels after subsetting data from a data.frame.
df <- data.frame(factor(c("a","a","c","b","b")), c(4,5,6,7,8), c(9,1,2,3,4))
names(df) <- c("X1","X2","X3")
my.sub <- subset(df, X1 == "a" | X1 == "b")
2009 Jan 21
3
merging several dataframes from a list
Hi there,
I have a list of dataframes (generated by reading multiple files) and all
dataframes are comparable in dimension and column names. They also have a
common column, which, I'd like to use for merging. To give a simple example of
what I have:
df1 <- data.frame(c(LETTERS[1:5]), c(2,6,3,1,9))
names(df1) <- c("pos", "data")
df3 <- df2 <- df1
df2$data
2013 Feb 26
2
merging or joining 2 dataframes: merge, rbind.fill, etc.?
#I want to "merge" or "join" 2 dataframes (df1 & df2) into a 3rd
(mydf). I want the 3rd dataframe to contain 1 row for each row in df1
& df2, and all the columns in both df1 & df2. The solution should
"work" even if the 2 dataframes are identical, and even if the 2
dataframes do not have the same column names. The rbind.fill function
seems to work. For
2018 Feb 25
4
reshaping column items into rows per unique ID
Hi All
I have a datafram which looks like this :
CustomerID DietType
1 a
1 c
1 b
2 f
2 a
3 j
4 c
4 c
4 f
And I would like to reshape this so I can
2009 Aug 27
3
Merge data frames but with a twist.
Dear all,
Question: How to merge two data frames such that new column are added
in a particular way?
I'm not actually sure how to best articulate my question to be honest,
so i hope showing you what I want to achieve will communicate my
question better.
Lets say I have two data frames:
> DF1 <- data.frame(cbind(Show=c('Firefly', 'Red Dwarf'), Measure=1:2,
2009 Sep 28
2
Levelplot without margins
Hello,
I'm not very experienced with lattice and I was wondering whether I get
get some hints from you how to create a pure heatmap (using levelplot),
without any axis, title, legend, margin at all... I just want to see the
coloured squares, nothing else.
Any suggestions?
Antje
2012 May 03
5
Identifying the particular X or Y in a sorted list
Dear All,
I have a data sets as shown below A (Patient ID ), B and C are the
Concentration of drug in blood on day 1 and day 4, D is the difference in
conc. To do this in R I have written a code as follows, identified the
number of patients who have more concentration on day 4 . Here I want to
identify specifically the patient ID (is he patient 1 or 2 or 5 and 7),
whose concentration is more.
How
2018 Feb 25
0
reshaping column items into rows per unique ID
I believe you need to spend time with an R tutorial or two: a data frame
(presumably the "table" data structure you describe) can *not* contain
"blanks" -- all columns must be the same length, which means NA's are
filled in as needed.
Also, 8e^5 * 7e^4 = 5.6e^10, which almost certainly will not fit into any
local version of R (maybe it would in some server version --
2009 Feb 27
1
levelplot help needed
Hi there,
I'm looking for someone who can give me some hints how to make a nice
levelplot. As an example, I have the following code:
# create some example data
# --------------------------------------
xl <- 4
yl <- 10
my.data <- sapply(1:xl, FUN = function(x) { rnorm( yl, mean = x) })
x_label <- rep(c("X Label 1", "X Label 2", "X Label 3", "X
2004 Jul 30
3
Counting question
Hi All,
Here is something that sounds simple, but I'm having trouble getting it. I
have a data frame with two columns, the first is date and the second is
employee ID. I'd like to plot date on the horizontal axis, employee ID on
the vertical axis, and the number of times the employee appears for the
given date as a color. I've kluged something where I make a table
(table(date, id))
2006 Jan 09
3
two y-axis in xy-plot
Hi there,
I am wondering if it is possible to do an xyplot with two y-axes. I'd like to print two parameters in a time series but they both have different scales.
Which parameter in xyplot can I add to achieve this result?
Thanks a lot for any help.
Antje
[[alternative HTML version deleted]]
2008 Dec 16
6
Find all numbers in a certain interval
Hi all,
I'd like to know, if I can solve this with a shorter command:
a <- rnorm(100)
which(a > -0.5 & a < 0.5)
# would give me all indices of numbers greater than -0.5 and smaller than +0.5
I have something similar with a dataframe and it produces sometimes quite long
commands...
I'd like to have something like:
which(within.interval(a, -0.5, 0.5))
Is there anything I
2011 Feb 11
2
fitdistr question
Hello,
I tried to fit a poisson distribution but looking at the function
fitdistr() it does not optimize lambda but simply estimates the mean
of the data and returns it as lambda. I'm a bit confused because I was
expecting an optimization of this parameter to gain a good fit...
If I would use mle() of stats4 package or mle2() of bbmle package, I
would have to write the function by myself
2006 Nov 01
4
extract values from a vector
Hello,
I'm looking for a solution for the following problem:
I have two vectors
V1 <- c("apple","honey","milk","bread","butter")
V2 <- c("bread","milk")
now, I would like to know for each element in V1 if it's equal to one of
the elements in V2
I could do:
which(V1 == V2[1] | V1 == V2[2])
but what if I
2009 Jan 20
5
from matrix to data.frame
Hello,
I have a question how to reshape a given matrix to a data frame.
# ----------------------------------
> a <- matrix(1:25, nrow=5)
> a
[,1] [,2] [,3] [,4] [,5]
[1,] 1 6 11 16 21
[2,] 2 7 12 17 22
[3,] 3 8 13 18 23
[4,] 4 9 14 19 24
[5,] 5 10 15 20 25
> colnames(a) <- LETTERS[1:5]
> rownames(a) <-
2011 Mar 15
1
Changing colour of continuous time-series in ggplot2
Hi,
This seems like there should be a simple answer, but having spent most of
the day trying to find it, I'm becoming less convinced and as such am asking
it here.
Here's a sub-set of my data (a data.frame in R):
myDF
time value trial
1 2011-03-01 01:00:00 64092 FALSE
2 2011-03-01 02:00:00 47863 FALSE
3 2011-03-01 03:00:00 43685
2009 May 05
3
Heatmap without levelplot
Hi there,
as I'm not sure to understand the coloring levelplot uses, I'm looking for
another easy way to create a heatmap like this:
library(lattice)
mat <- matrix(seq(1,5, length.out = 12), nrow = 3)
mat[1,2] <- 3.5
my.at <- seq(0.5,5.5, length.out = 6)
my.col.regions <- rainbow(5)
graph <- levelplot(t(mat[nrow(mat):1, ] ), at = my.at, col.regions =
my.col.regions)