Hi all,
I am having a problem when converting irregular time series to regular time series. Below a simplified example can be found:
require(zoo)
t <- as.character(c(1981,1984,1985))
d <- c(1,3,6)
dt <- data.frame(d,t)
t <- as.Date(t,"%Y")
z <- zoo(d,t)
plot(z)
ts.d <- as.ts(as.zooreg(z,freq=1)) # create a regular ts object
ts.d # regu...
Hello,
I've searched far and wide, read a previous question in stackoverflow but cant seem to solve the problem of installing rpy2 on my Mac with OS X 10.5.8.
I have Xcode 3.1.4 installed and R 2.1.11.
when I run:
sudo python setup.py build install
I get this:
running build
running build_py
running build_ext
building 'rpy2.rinterfac...
Is there a kind of package in R for this? Is the "AMORE" package a possible surrogate for Matlab's Neural Network Toolbox? Thanks.
...
I am using RPostgreSQL to connect to a local database. The setup works just fine on my Linux machine. R 2.11.1, Postgres 8.4.
I was playing with the 'foreach' with the multicore (doMC) parallel backend to wrap some repetitive queries (numbering a few thousand) and appending the results into a data structure. Curiously enough, it works i...
In R, how can I determine whether a function call results in a warning?
That is, after calling the function I would like to know whether that instance of the call yielded a warning.
...
I would like to replace values in a vector (x) with values from another vector (y). Catch 22: The methods needs to be dynamic to accommodate different number of "levels" in vector x. For instance, consider vector x
x <- sample(c(1, 2, 3, 4, 5), 100, replace = TRUE)
> x
[1] 2 4 1 1 3 1 1 1 1 1 2 2 5 5 4 5 5 3 4 1 2 2 3 3 3 5 1 3 4 5 5 ...
I have a 104 attribute dataset called data. I want to reduce the number of attributes to 20 using prcomp function in R.
I did this:
pr = prcomp(data)
But pr only contains an instance of the prcomp class. How do I reduce the number of attributes in the original dataset to 20?
...
I'm trying to install a package into R, something I swore on my blood never to do, yet here I am.
The command supposedly goes: install.packages('NCStats',,'http://www.rforge.net/') while I am enjoying the healthy dose of:
Warning: dependencies 'nortest', 'plotrix', 'sciplot', 'car', 'gplots', 'gdata', 'Hmisc', 'TeachingDemos' are not a...
I have a vector of values which include NAs. The values need to be processed by an external program that can't handle NAs, so they are stripped out, its written to a file, processed, then read back in, resulting in a vector of the length of the number of non-NAs. Example, suppose the input is 7 3 4 NA 5 4 6 NA 1 NA, then the output would...
I'm working with vim on my linux machine and need code folding to work for R. I have the Vim-R-plusing2 installed to enable passing code from vim into an R session, but the folding does not work when foldmethod=syntax. How do I get folding for R working?
...
This is my first attempt to throw data back and forth between a local MySQL database and R. That said, I have a table created in the database and want to insert data into it. Currently, it is a blank table (created with MySQL Query Browser) and has a PK set.
I am using the RODBC package (RMySQL gives me errors) and prefer to stick w...
I'm programming in R. I've got a vector containing, let's say, 1000 values. Now let's say I want to partition these 1000 values randomly into two new sets, one containing 400 values and the other containing 600. How could I do this? I've thought about doing something like this...
firstset <- sample(mydata, size=400)
...but this doesn'...
I have two data.frames each with three columns: chrom, start & stop, let's call them rangesA and rangesB. For each row of rangesA, I'm looking to find which (if any) row in rangesB fully contains the rangesA row - by which I mean rangesAChrom == rangesBChrom, rangesAStart >= rangesBStart and rangesAStop <= rangesBStop.
Right now I'm d...
I'm using the geom_tile to draw an imagemap and want to clear out the zero level for clarity.
#dummy data
set.seed(1)
tdata <- data.frame(cat1=rep(letters[1:3],4),cat2=sort(rep(LETTERS[1:4],3)),val=rpois(12,1.5))
tdata$val<-tdata$val/max(tdata$val)
I have found 2 ways to do this but both have their drawbacks:
1)
qplot(cat1,cat2,data...
Hi
I have a data.frame with 10 rows and 3 columns
a b c
1 1 201 1
2 2 202 1
3 3 203 1
4 4 204 1
5 5 205 4
6 6 206 5
7 7 207 4
8 8 208 4
9 9 209 8
10 10 210 5
I want to delete all rows where the same value in the column "c" repeated less than 3 times.
In this example I want to remove rows 6, 9 and 10. (my real d...
I wish to access my Google Webmaster's tools' API via R.
I see from here:
http://code.google.com/apis/webmastertools/docs/2.0/reference.html
That it requires fetching a feed behind https and parsing it.
Any suggestions on how to do it?
...
How can an R script determine what platform it's running on? I'm using R 2.10.1, sometimes on Windows, sometimes on Linux. I would prefer a built-in function over filesystem taxonomy. I've already searched the index of the base package for anything with "os" or "platform" in the description — no dice there, alas.
...
I have a dataframe with millions of rows and three columns labeled Keywords, Impressions, Clicks. I'd like to add a column with values depending on the evaluation of this function:
isType <- function(Impressions, Clicks)
{
if (Impressions >= 1 & Clicks >= 1){return("HasClicks")} else if (Impressions >=1 & Clicks == 0){return("NoClicks"...
Hi there,
I'm trying to automate some of the systems at work here specifically to do with report generation based on survey data.
Lets say i have 3 comments for 1 question.
current_comments <- c("too slow", "not fast enough", "bad speed")
Basically what i want to do is merge the comments into one string separated by a "-" too look ...
I have some data which represents a sizes of particles. I want to plot the frequency of each binned-size of particles as a histogram, but scale the frequency but the size of the particle (so it represents total mass at that size.)
I can plot a histogram fine, but I am unsure how to scale the Y-axis by the X-value of each bin.
e.g. if I...