After performing a cluster analysis to my dataset (a dataframe named data.matrix), I added a new column, named cluster, at the end (col 27) containing the cluster name that each instance belongs to.
What I want now, is a representative instance from each cluster. I tried to find the instance having the smallest euclidean distance from t...
I'm using Emacs 23.1 with ESS 5.4 to edit an Sweave file. I'd like to turn off the default AUCTeX indentation behavior in the buffer (to avoid annoyances with code chunks contained in itemized lists), so at the top of the file I have % -*- LaTeX-indent-level: 0; LaTeX-item-indent: 0; -*-. When I open the buffer and run C-h v LaTeX-inde...
Is there a simple way to programmatically determine if an R script is being executed in Windows vs. Linux?
...
If I have a vector of type character in R, how can I concatenate the values into string? Here's how I would do it with paste():
sdata = c('a', 'b', 'c')
paste(sdata[1], sdata[2], sdata[3], sep='')
yielding "abc". But of course, that only works if I know the length of sdata ahead of time.
...
I have a plethora of both short and long pieces of R code that I would like to track as they evolve.
Does anyone have any recommendation or experience using version-control software with R?
...
I have an ultra short question about R
My aim is to assign a common title to a multi-panel plot generated using par, e.g.
par(mfrow=c(1,2))
plot(rnorm(1000))
plot(rnorm(1000))
So, something like "main" for the plot function, but extended to both plots. Is there a canonical way to do this?
Thanks for any answer :-)
...
I have a 16x16 matrix of grayscale values representing handwriting digits. Is there a plot in R that I can use to visualize it?
Matlab has pcolor, I am looking for something along those lines.
pcolor
...
I have filenames named <InputData>.<TestName>.csv and I'd like to make graphs for each test. The best way I can see to do this is to make one R table for each TestName. Each test produces the same columns of data, so I'd like to pull in all the data for each test into an R datatable with an extra column for the inputdata.
I'd like t...
I'm having a strange problem with the output window in RGui (under Win XP). I should see a plot like the one below...
... when I run this script:
library(ggplot2)
x <- rnorm(100,0,1)
y <- rnorm(100,0,1)
z <- data.frame(x,y)
g <- ggplot(z, aes(x,y)) + geom_point() + theme_gray()
Instead, in the plot window it shows a white backgrou...
I used the information from this post to create a histogram with logarithmic scale:
http://stackoverflow.com/questions/1245273/histogram-with-logarithmic-scale
However, the output from plot looks nothing like the output from hist. Does anyone know how to configure the output from plot to resemble the output from hist? Thanks for the hel...
I have a ggplot2 plot that looks like this:
from the following R code:
ggplot(newdata, aes(benefit, cost, colour = factor(opt), shape = factor(roster)))
+ facet_grid(. ~ location)
It's exactly what I need, except that the graph is too wide to be clearly read.
I'd like to be able to take the four rightmost locations and place the...
I would like to program a time series class. The idea is that I instantiate an object with an expression and some other time series objects, for instance
(two time series)
x <- ts(rnorm(10), frequency = 4, start = c(1959, 2))
y <- ts(rnorm(10), frequency = 4, start = c(1959, 2))
(a time series, defined to be the sum of x and y)
z <- ...
I have a data.frame, d1, that has 7 columns, the 5th through 7th column are supposed to be numeric:
str(d1[5])
'data.frame': 871 obs. of 1 variable:
$ Latest.Assets..Mns.: num 14008 1483 11524 1081 2742 ...
is.numeric(d1[5])
[1] FALSE
as.numeric(d1[5])
Error: (list) object cannot be coerced to type 'double'
How can this be? I...
This is a bit of a shot in the dark, but I have a script that does exactly what I expect it to do, yet, at the very end of the script I get an error like this:
Error in `[<-.data.frame`(`*tmp*`, "label", value = c(1L, 0L)) :
replacement has 2 rows, data has 0
In terms of an answer, I'm looking for general suggestions on how to tra...
I have a nearly-boxplot like jitter-plot:
dt <- rbind(se,cb,cb.se)
qplot(ds, size, data=dt, geom="jitter", colour=root, facets = test ~ .)
I'd love to put a summary label for each group in the middle of the plot - for example the size totals here:
aggregate(list(size=dt$size), list(dt$ds, dt$test), sum)
Group.1 Group.2 size...
I have a 2-D array in R which represents value data for a grid of rows and columns. It looks like this:
[,1] [,2] [,3] [,4]
[1,] 1 1 2 1
[2,] 1 5 6 3
[3,] 2 3 2 1
[4,] 1 1 1 1
I want to "smooth" these values. At this proof-of-concept point, I am fine with using any popular smoothi...
I wish to perform a social network analysis on a bunch of blogs, plotting who is linking to who (not just by their blogroll but also inside their posts). What software can perform such crawling/data-collecting/mapping ?
Thanks!
...
In python lists can be sliced like this x[4:-1] to get from the fourth to the last element.
In R something similar can be accomplished for vectors with x[4:length(x)] and for multidimensional arrays with something like x[,,,,4:dim(x)[5],,,]. Is this more elegant syntax for array slicing for a particular dimension from an element in the...
I have a data frame with about 40 columns, the second column, data[2] contains the name of the company that the rest of the row data describes. However, the names of the companies are different depending on the year (trailing 09 for 2009 data, nothing for 2010).
I would like to be able to subset the data such that I can pull in both ye...
I have data frame that looks like the following
models cores time
1 4 1 0.000365
2 4 2 0.000259
3 4 3 0.000239
4 4 4 0.000220
5 8 1 0.000259
6 8 2 0.000249
7 8 3 0.000251
8 8 4 0.000258
... etc
I would like to convert it into a table/matrix wit...