I would like to generate a random sequence composed of 3000 points, which follows the normal distribution. The mean is c and the standard deviation is d. But I would like these 3000 points lies in the range of [a,b].
Can you tell me how to do it in R?
If I would like to plot this sequence, if Y-axis uses the generated 3000 points, then...
I have a dataframe and would like to calculate the correlation (with Spearman, data is categorical and ranked) but only for a subset of columns. I tried with all, but R's cor() function only accepts numerical data (x must be numeric, says the error message), even if Spearman is used.
One brute approach is to delete the non-numerical col...
Following the directions provided in this related question, I was able to send html formated mail messages. Now the question is this: How should I modify the following code, in order to attach one or more files (of any type) to this message?
library(sendmailR)
from <- "<[email protected]>"
to <- c("<[email protected]...
Hi All,
I am using the following code for the Share Price Application I have been developing (with plenty of help from people here that is greatly appreciated!). One of the things it should do is allow the user to pick a company to analyse from stored XML Files, I have been using the following code to do this:
df <- xmlToDataFrame(file...
Sometimes it would be useful to name variables like no programmer should name his or her variables. Of course there's some good reason for conventions and limitations on stoopid variable names, but still I'd be nice. Particularly in a language like R that is used frequently to create graphs and some labels with the graphs. Thus, some lab...
Consider this output from browser() that is located inside calcDistance:
Called from: calcDistance(object = rst, xy = xy[[i]][j, ], effect.distance = effect.distance)
Browse[1]> ls.str()
effect.distance : num 236
object : Formal class 'RasterLayer' [package "raster"] with 12 slots
xy : Named num [1:2] -101.8 35.5
Browse[1]>
debuggin...
I have to solve the following convolution related numerical integration problem in R or perhaps computer algebra system like Maxima.
Integral[({k(y)-l(y)}^2)dy]
where
k(.) is the pdf of a standard normal distribution
l(y)=integral[k(z)*k(z+y)dz] (standard convolution)
z and y are scalars
The domain of y is -inf to +inf.
The integral in ...
Using R, I just want to read the contents of a file into a variable like:
query <- read_file_contents('biglongquery.sql')
As to avoid putting, well, big long queries in the R script itself. I do not want to read in data like CSV (e.g. read.tables), etc- just the raw text.
...
Hi everyone,
Can anyone tell me what does Rterm.exe and Rcmd.exe do.
Thanks,
...
I have successfully completed a multiple imputation on the missing data of my questionnaire research using the MICE package in R and performed a linear regression on the pooled imputed variables. I can't seem to work out how to extract single pooled variables and plot in a graph. Any ideas?
e.g.
>imp <- mice(questionnaire)
>fit <- wit...
I'm new to R and ggplot2 - any advice appreciated!
For each year I am trying to plot the ratios of incomes between different skill groups in ggplot. I.e. I want to have the ratio of incomes Level_4/Level_3, Level_4/Level_2 and Level_4/Level_1 in the same plot.
Data frame column headings are Skills (Levels 1 to 4), Year and MeanIncome
...
I am in my way of finishing the graphs for a paper and decided (after a discussion on stats.stackoverflow), in order to transmit as much information as possible, to create the following graph that present both in the foreground the means and in the background the raw data:
However, one problem remains and that is overplotting. For exam...
I'd like to create a function that automatically generates uni and multivariate regression analyses, but I'm not able to figure out how I can specify *variables in vectors...*This seems very easy, but skimming the documentation I havent figured it out so far...
Easy example
a<-rnorm(100)
b<-rnorm(100)
k<-c("a","b")
d<-c(a,b)
summary(k[...
I am building a gui which lets me select a subset of a data.frame by clicking on the various factor names.
After having received user input, how do i pass it to the subset function?
e.g.: I have a dataframe df with factors MORNING and EVENING in column timeofday and RECEIVE and SEND in column optype. From the GUI I know that the user w...
I would like to force specific variables into glm regressions without fully specifying each one. My real data set has ~200 variables. I haven't been able to find samples of this in my online searching thus far.
For example (with just 3 variables):
n=200
set.seed(39)
samp = data.frame(W1 = runif(n, min = 0, max = 1), W2=runif(n, min ...
I use par(new=T) before each of my plots to add my plot to the same graph.
However, when I do that it superimposes the two plots and the axis values get overwritten over each other and look messed up.
How do I properly add plot to the same graph that also normalizes axis intervals based on the two plots?
...
Dear Stackers,
I have to merge to data frames in R. The two data frames share a common id variable, the name of the subject. However, the names in one data frame are partly capitalized, while in the other they are in lower cases. Furthermore the names appear in reverse order. Here is a sample from the data frames:
DataFrame1$Name:
"Van...
I know nothing about R, when I read a R code, in the very first line, there appears
rm(list=ls())
What does it mean? Thanks
...
Dear R-experts,
The following R code generates a snippet from data frame I am working with at the moment:
rep1 <- c("20/02/01","23/03/02")
rep2 <- c(NA, "03/05/02")
rep3 <- c("16/04/01",NA)
rep4 <- c(NA,"12/02/03")
data <- data.frame(rep1 = rep1, rep2 = rep2, rep3 = rep3, rep4 = rep4)
The data frame generated by the code looks like t...
I read a R code on loess regression, here is part of it:
f.lo<- loess(bgs ~ f[,1], span=bw, degree=1)
bsln <- f.lo$fitted
What are their functions: bgs~f[,1] , the ~ and the $ in the next line? thanks
...