r

[R] how to avoid loops

HI All, I'm new to R. I have two panel data files, with columns "id", "date" and "ret" file A has a lot more data than file B, but i'm primarily working with file B data. Combination of "id" and "date" is unqiue indentifier. Is there an elegent way of looking up for each (id, date) in B, I need to get the past 10 days ret from file...

Plotting Data from XML that has Timestamps on the X-axis.

I got help parsing the following XML file on this site: <?xml version = "1.0"?> <Company > <shareprice> <timeStamp> 12:00:00.01</timeStamp> <Price> 25.02</Price> </shareprice> <shareprice> <timeStamp> 12:00:00.02</timeStamp> <Price> 15</Price> </shareprice> <shareprice> <timeStamp> 12:00:00.0...

Adding lines and labels in lattice barchart [R]

Hi, I have two questions concerning customizing a barchart in lattice. I tried to add labels to the barchart respectively edit the scale, but my code doesn't work. What I'm doing wrong? There should be some values including "%". The second question is how lines can be drawn between the top and the bottom of the plotting area behind the ...

Remove rows from a single-column data frame

When I try to remove the last row from a single column data frame, I get a vector back instead of a data frame: > df = data.frame(a=1:10) > df a 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 > df[-(length(df[,1])),] [1] 1 2 3 4 5 6 7 8 9 The behavior I'm looking for is what happens when I use this command on a two-c...

How to edit rules for drawing control chart in R using qcc package?

As captioned, I need to find out which combination of the rules can give the highest sensitivity and lowest specificity using my dataset, so I am trying to figure which several out of 8 Shewhart rules, which are default in the qcc package, should be applied. I know there is a function for storing the rules, but I don't understand what I...

Is there any HTTP library in R?

I need to make HTTP POST commands using R. Are there any R http libraries that can do this? ...

How to compute descriptive statistics on a set of differently sized vectors

In a problem, I have a set of vectors. Each vector has sensor readings but are of different lengths. I'd like to compute the same descriptive statistics on each of these vectors. My question is, how should I store them in R. Using c() concatenates the vectors. Using list() seems to cause functions like mean() to misbehave. Is a data fram...

Non Linear Integer Programming

I would like to know if there is a package in R handling non linear integer optimization. "Basically", I would like to solve the following problem: max f(x) s.t x in (0,10) and x is integer. I know that some branching algorithms are able to handle the linear version of this problem, but here my function f() might be more complicated. ...

read data from internet

I have a remote folder on a webserver containing data. I access the data using: myData <-read.table("http://.../myData.csv", sep=',', header=T) Is there a way to password protect the remote folder and enter the authorisation in the above command? Thx. ...

How to make mosaic plot with pictures as bars with R?

Hi, I'd like to plot mosaic bar or spinogram like here: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=117, but I'd like to have vertically streched 3-letter string legend inside of each bar. Any ideas how to implement this easily? ...

Do any of the R GUI assist with power calculations / analysis?

I met with several people who are familiar with SPSS and would be reluctant to wade into R but might be encouraged to do so from the comfort of a GUI. Do any of the GUIs provide support for power calculations? I searched around for about 15 minutes and could not find anything to tell me that they could. Do you happen to know? ...

Using the qplot command the line does not show

This is a follow on from my last question relating to plotting timestamps in R. I am using the same XML file. The question has been answered and is working except for the following command: qplot(timeStamp,Price,data=test.df,geom=c("point","line"),color="Measured", shape="Measured",linetype="Measured", scale_y_continuous(limits = c(10,2...

Gram-Schmidt orthogonalization

Given a matrix A (not neccessarily square) with independent columns, I was able to apply Gram-Schmidt iteration and produce an orthonormal basis for its columnspace (in the form of an orthogonal matrix Q) using Matlab's function qr A=[1,1;1,0;1,2] [Q,R] = qr(A) and then >> Q(:,1:size(A,2)) ans = -0.577350269189626 -0.000000000000...

how to unmask a function in R

When I loaded package debug to debug a script with zoo objects, I got trouble: function index from zoo got masked by debug package. How can I unmask index? In general, how to deal with these name colliding problems? We just do not use debug package with `zoo'? ...

Using RMysql's dbGetQuery in R, how do i coerce string data type on the result set?

RMysql's dbGetQuery converts BigInt to numeric types. This alters some of the values. How can I read the BigInt fields as strings instead of numeric? ...

Date labels overlap when putting multiple ggplot plots on single page

I am trying to put multiple ggplot2 time series plots on a page using the gridExtra package's arrange() function. Unfortunately, I am finding that the x-axis labels get pushed together; it appears that the plot is putting the same number of x-axis labels as a full-page chart, even though my charts only take up 1/4 of a page. Is there a b...

Avoiding Loop with R using Apply (?)

I'm trying to run apply a function to each row of a dataset. The function looks up matching rows in a second dataset and computes a similarity score for the product details passed to it. The function works if I just call it with test numbers but I can't figure out how to run it on all rows of my dataset. I've tried using apply but can't...

How do concat a vector of character in R?

I tried using the paste command but it returns the same vector? x = c("a","b","c") y = paste(x) y [1] "a" "b" "c" length(y) [1] 3 I want a single character of "abc" ...

Python Rpy R data processing optimization

I am writing a data processing program in Python and R, bridged with Rpy2. Input data being binary, I use Python to read data out and pass them to R, then collect results to output. Data are organized into pieces, each being around 100 Bytes (1Byte per value * 100 values). They just work now, but the speed is very low. Here are some o...

Time Stamps, Qplot and strptime in R.

This is a follow up question as hadley pointed out unless I fix the problem with the time stamps the graphs I produce would be incorrect. With this in mind I am working towards fixing the issues I am having with the code. So far I have from my earlier questions that have been answered stopped using the attach() function in favour of usin...