Let's say I have a data.frame, like so:
x <- c(1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10)
df <- data.frame("Label 1"=x,"Label 2"=rnorm(100))
head(df,3)
returns:
Label.1 Label.2
1 1 1.9825458
2 2 -0.4515584
3 3 0.6397516
How do I get R to stop automagically replacing the space with a period in the ...
Let's say I have a data.frame like:
a <- c(1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10,1:10)
df <- data.frame(a,rnorm(100))
And I want to be able to write a csv file for each value of x. Is it possible to do this with ddply?
I can already do this with a for loop in a few lines... but I'm curious if it's possible to do it with ddpl...
How can I use command line arguments with a R script using Tinn-R.
I can give arguments with a R script like this:
R.exe --args 2010 test.R
And after that read them in the script with commandArgs.
But how can I provide them when using Tinn-R? I cannot find anything in the Tinn-R help
...
I'm struggling with the different R executables. What exactly is the difference between R.exe (with or without CMD BATCH), Rcmd.exe, Rscript.exe and Rterm.exe when running command line in a batch file?
And what, for example, is the difference between
"C:\Program Files\R\R-2.10.1\bin\R.exe" --no-environ --no-save < "c:\temp\R\test.R" > ...
Is there a way to allow a method of an S4 object to directly adjust the values inside the slots of that object without copying the entire object into memory and having to re-write it to the parent environment at the end of the method? Right now I have an object that has slots where it keeps track of its own state. I call a method that ...
Hi, I want to use R in Python, as provided by the module Rpy2. I notice that R has very convenient [] operations by which you can extract the specific columns or lines, how could I achieve such a function by python scripts? My idea is to create a R vector and add those wanted elements into this vecotr so that the final vector is the same...
I am confused by the use of the ellipsis (...) in some functions, i.e. how to pass an object containing the arguments as a single argument.
In Python it is called "unpacking argument lists", e.g.
>>> range(3, 6) # normal call with separate arguments
[3, 4, 5]
>>> args = [3, 6]
>>> range(*args) # call with argumen...
I have some 100k values. When I plot them as a line in R (using plot(type="l") the numbers next to the x-axis ticks are printed in scientific format (e.g. 0e+00,2e+04,...,1e+05). Instead, I would like them to be:
A) 0,20kb,...,100kb
B) the same but now the first coordinate should be 1 (i.e. starting to count from 1 instead of 0).
BTW ...
Hi, I got the following R code and I need to convert it to python and run it in python environment, basically I have done this with rpy2 module, but it looks kind of dull with python doing the same things, so could someone find a better way to rewrite the following R code to an equivalent python script with the rpy2 module?
mymad <- fun...
Simple question, but cannot find the answer.
Instead of:
Df<-sqlQuery(ch,"SELECT * FROM tblTest WHERE Id=25")
I want a more dynamic piece of code. Something like:
Id<-25
Df<-sqlQuery(ch,c("SELECT * FROM tblTest WHERE Id=",Id))
But this is not correct. I'm still struggling with R...
...
This is related to an ongoing issue that I'm having, where certain packages don't exist when I try install.packages in R 2.10 (which is what's available from Ubuntu 10.04 apt-get). This includes highlight and Rcpp. Does anyone know how to install R 2.11 on Ubuntu 10.04?
...
I have a huge datafile (~4GB) that I am passing through R (to do some string clean up) on its way into an MySQL database. Each row/line is independent from the other. Is there any speed advantage to be had by using parallel operations to finish this process? That is, could one thread start with by skipping no lines and scan every seco...
When I convert a factor to a numeric, the values change to rank values.
R> m$obs
[1] 0 0 1 1 1 1 3 3 3 3 3 3 3 9 9 9 9 9 9 9 9 9 11 11 12 13 13 13 13 13
13 13 14
Levels: 0 1 3 9 11 12 13 14
R> as.numeric(m$obs)
[1] 1 1 2 2 2 2 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 6 7 7 7 7 7 7 7 8
I have to resort to paste() ...
Hello,
I have a data frame holding information on options like this
> chData
myIdx strike_price date exdate cp_flag strike_price return
1 8355342 605000 1996-04-02 1996-05-18 P 605000 0.002340
2 8355433 605000 1996-04-02 1996-05-18 C 605000 0.002340
3 8356541 605000 1996-04-09 19...
I'd like to create a geom_path() that has arrows pointing towards the next location in the path.
I can get the path to plot, without issue, for example:
df <- (x=1:12, y=20:31, z=1:12)
p <- ggplot(df, aes(x=x, y=y))
p + geom_point() + geom_path()
Now what I'd like to be able to do is plot that point arrows from one element in the p...
I am trying to scan a dataset using a loop in R, to see if the data points in the subset of data fulfill some rules, an example is pasted here:
loop.ward <- 1
loop.control.chart <- 1
while (loop.ward <= length(unique(control.chart[,"ward"])))
{
loop.weekly.count <- 3
while (loop.weekly.count <= nrow(control.chart[control.chart[,"w...
I try reading a JSON file from R using rjson but keep getting errors. I validated the JSON file using various online validators. Here is the content of the JSON file:
{
"scenarios": [
{
"files": {
"type1": "/home/blah/Desktop/temp/scen_0.type1",
"type2": "/home/blah/Desktop/temp/scen_0.type2"
...
Usually when I plot some R line plot and set ylim=c(0,some_value), there is small space between the x axis and y=0.
I would like the y axis to show exactly at y=0 so points (x,0) will be plotted on the y axis (and not above).
...
I am trying to add arrows marking specific x coordinates below the x axis in an R plot. My x axis is at y=0 and when I try to use negative y-coordinates in arrows, so the arrows will be perpendicular to x axis, I get only the very edges of the arrow plotted (although is some space, e,g where the x-axis label and tickmarks are plotted).
...
Is there a reason why R won't allow me to have a number as the column name of my dataframe?
also noticed that if i do data.frame(XX) it adds an X to all the column headers that have numbers at the front.
...