I'm new to R.
I have a a Data.frame with a column called "Symbol".
Symbol
1 "IDEA"
2 "PFC"
3 "RPL"
4 "SOBHA"
I need to store its values as a vector(x = c("IDEA","PFC","RPL","SOBHA")). Which is the most concise way of doing this?
Thanks in Advance
...
I am trying to use cat() as functions inside apply(). I can almost make R do what I want, but I'm getting some very confusing (to me) NULLS at the end of the return. Here is a silly example, to highlight what I'm getting.
val1 <- 1:10
val2 <- 25:34
values <- data.frame(val1, val2)
apply(values, 1, function(x) cat(x[1], x[2], fill=TRUE))...
I am trying to recreate the following plot with R. Minitab describes this as a normal probability plot.
The probplot gets you most of the way there. Unfortunately, I cannot figure out how to add the confidence interval bands around this plot.
Similarly, ggplot's stat_qq() seems to present similar information with a transformed x axis...
Hi again all,
I have another newbie question;
lets say i have a set of numbers
graph_val <- c(4,2,3,4,1,1,9)
and i need to create a frequency table of them against this scale
1 2 3 4 5 9
"Very Poor" "Poor" "Average" "Good" "Very Good" "Don't Know" ...
When I import country data using RODBC I often use ISO2 codes. The unfortunate part is Namibia with ISO2 "NA" always gets set to missing. There are various ways around this of course, but I wonder if anyone has found a way to just import correctly. I've tried
df <- sqlFetch(ch,"data_from_database", na.strings="")
df <- sqlFetch(ch,"data...
As the title says: How can I plot a legend outside the plotting area when using base graphics?
I thought about fiddling around with layout and produce an empty plot to only contain the legend, but I would be interested in a way using just the base graph facilities and e.g., par(mar = ) to get some space on the right of the plot for the ...
Does anyone know whether it is possible to read the data stored in MS SQL server from R interface? If it is I would be also thankful if anyone could show the way to do it.
Thank you!
...
I am trying to write an interactive R script. For example:
try.R:
print("Entr some numbers. >",quote=F)
a = scan(what=double(0))
print a
q()
Now, if I run it on the command line as
$ R --no-save < try.R
It tries to get the stdin from try.R, giving the following error:
> print("Entr some numbers. >",quote=F)
[1] Entr some numbers....
Using ggplot2 under R (and the code below uses rpy2, I don't actually know straight R, sorry).
I'm trying to add an aspect_ratio to my plot (so it'll fit nicely on a slide). The below example is pretty minimal. Aspect_ratio does the right thing EXCEPT the title and x-axis label are placed way above and below the plot, respectively, with...
I'm writing an R package where the R code talks to a Java application. The Java application outputs a CSV formatted string and I want the R code to be able to directly read the string and convert it into a data.frame.
...
Question: I am testing functions in a package that I am developing and would like to know if you can suggest some general guidelines for how to do this. The functions include a large range of statistical modeling, transformations, subsetting, and plotting. Is there a 'standard' or some sufficient test?
An Example: the test that prompted...
I have data which looks like this (this is test data for illustration):
test <- matrix(c(1, 1, 1, 2, 2, 2 , 529, 528, 528, 495, 525, 510,557, 535, 313,502,474, 487 ), nr=6, dimnames=list(c(1,2,3,4,5,6),c("subject", "rt1", "rt2")))
And I need to turn it into this:
test2<-matrix(c(1,1,1,2,2,2,529,528,528,495,525,510,"slow","slow","fa...
I saw this in a recent economist and I was wondering if anyone has code that would help replicate it using ggplot. Economist Chart
Thanks!
...
I want to implement parallel coordinates for my muldimensional result. Does anyone have a good link to its implementation in matlab or R? Furthermore, are there any suggestions regarding the best tool to use for producing the parallel coordinates?
...
Hi everyone,
This
x <- list(12, 13)
names(y <- x) <- c("a", "b")
gives the error:
Error in names(y <- x) <- c("a", "b") : object 'y' not found
Can anyone explain why?
According to R's rules of evaluation y <- x should be evaluated inside the parent frame of names<-. So y should be created in global environment.
Thanks.
[upda...
Hello
I have a dataframe which resembles this- for example, 2 columns and multiple rows:
A 2
A 7
B 1
B 3
B 6
C 2
I want to do some operations on the items in column two within each unique value of column 1.
I have
unique.values <- sort(unique(mydata[,1]))
This part works for getting each unique va...
Hi all,
I have a matrix A which is:
A <- matrix(c(1:15), byrow=T, nrow=5)
A
[,1] [,2] [,3]
[1,] 1 2 3
[2,] 4 5 6
[3,] 7 8 9
[4,] 10 11 12
[5,] 13 14 15
Now I want to create a matrix B, which is 8x8 dimensions (or 10x10, or 15x15, etc), which would look like this:
[,1] [,2] [,3] [,4] [,...
Hi,
Reading the data the following way
data<-read.csv("userStats.csv", sep=",", header=F)
I tried to select an element at the specific position.
The example of the data (first five rows) is the following (V2 is the date and V3 is the day of week):
V1 V2
1 00002781A2ADA816CDB0D138146BD63323CCDAB2 201...
I have a dataset that includes a list of species, their counts, and the day count from when the survey began. Since many days were not sampled, day is not continuous. So for example, there could be birds counted on day 5,6,9,10,15,34,39 and so on. I set the earliest date to be day 0.
Example data:
species counts day
Blue tit ...
Greetings, I am trying to create a bar chart of the data posted below (referred to in my code as topTwoTable), disaggregated by group type. I've scanned through multiple online forums, as well as Hadley's website, and stuck when it comes to manually altering the fill color of the bars on the basis of treatment type.
...