Displaying 20 results from an estimated 150 matches similar to: "From list to variable name"
2009 Feb 21
1
Extracting xy from raster based on raster value
I have a raster (which I called glc), which I read
into R as a raster with "raster.create.from.file" from the raster package (R-forge). Values in glc range between 1 and 27 (whole numbers only). I'd like to extract all cells with a value of 1 to create
a new raster with only the cells that have a value of 1, or to extract
the xy values of all raster cells with a value of 1. Could you
2007 Dec 05
1
Working with "ts" objects
I am relatively new to R and object oriented programming. I have relied on
SAS for most of my data analysis. I teach an introductory undergraduate
forecasting course using the Diebold text and I am considering using R in
addition to SAS and Eviews in the course. I work primarily with univariate
or multivariate time series data. I am having a great deal of difficulty
understanding and working with
2011 Nov 24
2
proper work-flow with 'formula' objects and lm()
Dear all
I have a work-flow issue with lm(). When I use
> lm(y1~x1, anscombe)
Call:
lm(formula = y1 ~ x1, data = anscombe)
Coefficients:
(Intercept) x1
3.0001 0.5001
I get as expected the formula, "y1 ~ x1", in the print()ed results or
summary(). However, if I pass through a formula object
> (form <- formula(y1~x1))
y1 ~ x1
> lm(form, anscombe)
Call:
2020 Oct 15
0
package(moments) issue
moments::anscombe.test(x) does give errors when x has too few values or if
all the values in x are the same
> moments::anscombe.test(c(1,2,6))
Error in if (pval > 1) pval <- 2 - pval :
missing value where TRUE/FALSE needed
> moments::anscombe.test(c(2,2,2,2,2,2,2,2))
Error in if (pval > 1) pval <- 2 - pval :
missing value where TRUE/FALSE needed
You can use tryCatch() to
2020 Oct 15
2
package(moments) issue
Hi all,
While running the anscombe.test in R, I'm getting an error of *Error in if
(pval > 1) pval <- 2 - pval : missing value where TRUE/FALSE needed* for a
few time series columns whereas for most of the series the function is
working fine. I have checked for those specific columns for missing values.
However, there is no NA/NAN value in the dataset.
I have also run kurtosis for
2020 Oct 15
2
package(moments) issue
Hi Bill,
Thanks for prompt reply and letting me know a way around it.
I have more than 1200 observations and not all the values are the same.
However, my data points are quite similar, for example,
0.079275, 0.078867, 0.070716 in millions and etc. I have run the data
without converting it to millions and I still get the same error
message. As I have kurtosis value, it should be fine for the
2006 Aug 16
3
separate row averages for different parts of an array
I have an array with 44800 columns and 24 rows I would like to compute the
row average for the array 100 columns at a time, so I would like to end up
with an array of 24 rows x 448 columns. I have tried using apply(dataset, 1,
function(x) mean(x[])), but I am not sure how to get it to take the average
100 columns at a time. Any ideas would be welcomed.
thanks,
Spencer
[[alternative HTML
2010 Jun 10
2
points marking
Hi,
How to mark points on x axis of a graph keeping x axis as constant and
changing y from y1 to y2 respectively. I want to highlight the area from y1
to y2.
Any suggestions
Thank you
Jeet
[[alternative HTML version deleted]]
2007 Mar 13
2
turn regression coefficients into matrix or...
I don't have much experience with r. What I am trying to do is to turn
regression coefficients (after I run a lm or glm model) into some matrix
such that I can do some post-estimation calculation, for example predicted
probabilities in glm model, etc.. Or, is there any function in r that I can
use to do something along that line? thanks.
Jun Xu, Ph.D.
Department of Sociology
Ball State
2006 Sep 25
1
Rows of a data frame to matrix
useRs,
I have a data frame where four of the columns of the data frame represent the values of a two-by-two
matrix. I'd like to, row-by-row, go through the data frame and use the four columns, in matrix form, to
perform calculations necessary to create new values for variables in the data frame. My first idea was to
use apply:
apply(as.array(data.frame[,1:4]), 1, matrix, nrow=2)
Though
2011 Oct 25
1
alternative option in skewness and kurtosis tests?
I have a question about the D'Agostino skewness test and the Anscombe-Glynn
kurtosis test.
agostino.test(x, alternative = c("two.sided", "less", "greater"))
anscombe.test(x, alternative = c("two.sided", "less", "greater"))
The option "alternative" in those two functions seems to be the null
hypothesis. In the output, the
2007 Aug 26
3
subset using noncontiguous variables by name (not index)
Hi All,
I'm using the subset function to select a list of variables, some of
which are contiguous in the data frame, and others of which are not. It
works fine when I use the form:
subset(mydata,select=c(x1,x3:x5,x7) )
In reality, my list is far more complex. So I would like to store it in
a variable to substitute in for c(x1,x3:x5,x7) but cannot get it to
work. That use of the c function
2020 Oct 15
0
package(moments) issue
Another bad case is
> moments::anscombe.test(rep(c(1,1.1),length=35))
Error in if (pval > 1) pval <- 2 - pval :
missing value where TRUE/FALSE needed
I haven't checked the formulas carefully, but I suspect the problem is from
taking the cube root of a negative number in
z <- (1 - 2/(9 * a) - ((1 - 2/a)/(1 + xx * sqrt(2/(a -
4))))^(1/3))/sqrt(2/(9 * a))
In R, the
2006 Aug 29
2
lattice/xyplot: plotting 4 variables in two panels - can this be done?
Hi,
I would like to create a plot of y1,y2,y3,y4 against x for several subjects such that y1 and y2 are plotted against x in one panel and y3 and y4 against x in another panel. Thus if there are 3 subjects I should end up with 6 panels. Is there a simple way of doing so (i.e. without calling xyplot() several times, and then padding the results together)??
Regards
S?ren
2006 Jul 11
2
R newbie: logical subsets
Hello! I'm a newcomer to R hoping to replace some convoluted database
code with an R script. Unfortunately, I haven't been able to figure out
how to implement the following logic.
Essentially, we have a database of transactions that are coded with a
geographic locale and a type. These are being loaded into a data.frame
with named variables city, type, and price. E.g., trans$city
2012 Jun 28
4
Printing a variable in a loop
Dear R Users:
I'm a STATA user converting to R, and I'd like to be to do the following.
#Assign var_1 and var_2 a value
10->var1
20->var2
#Now I'd like to print the values of var_1 and var_2 by looping through
var_1 and var_2 in such a manner:
while(y<3){
print(var_y)
y+1->y
}
In STATA, the "y" appended to " var_" is called the local variable and
2011 Aug 15
1
update() ignores object
Hi all,
I'm extracting the name of the term in a regression model that
dropterm specifies as the least significant one, and I'm assigning
this name to an object. However, when I use update(), it ignores this
object. Is there a way I can make it not ignore it? A reproducible
example is below:
> lm(x1~1+y1*y2+y3+y4,data=anscombe)->my.lm
>
2011 Dec 02
2
Sweave problem on Mac OS when using umlauts and summary()
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111202/d63d9021/attachment.pl>
2007 Jan 29
6
Loop with string variable AND customizable "summary" output
Dear All,
I am using R for my research and I have two questions about it:
1) is it possible to create a loop using a string, instead of a numeric vector? I have in mind a specific problem:
Suppose you have 2 countries: UK, and USA, one dependent (y) and one independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, xUSA) and you want to run automatically the following regressions:
2011 Jul 12
2
apply (or similar preferred) for multiple columns
Dear all,
I would like to use the apply or a similar function belonging to this
family, but applying for each column (or row) but let say for each q
columns. For example I would like to apply a function FUN for the first q
columns of matrix X then for q+1:2*q and so on. If I do apply (X, 2, FUN) it
applies for each column and not for every q columns. Is that possible with
any similar function?