How to add variables without "$" [closed] - r

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
I want to run a binary logistic regression in R but I see this error:
Error in if (!length(fname) || !any(fname == zname)) { :
missing value where TRUE/FALSE needed
It happens because I use variables with $. For example data$HEIGHT.
I use read.table() for importing .txt file.
How can I use HEIGHT instead of data$HEIGHT?

Related

How to print a character vector 'pretty' in R Markdown? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is there a function such as kable to output character vectors in a way that doesn't look as ugly as the default console type?
See eg p from the pander package or the generic pander method:
> pander::pander(sample(letters, 5))
_p_, _r_, _v_, _f_ and _t_
If you want to override the default formatting, see panderOptions or specify directly in the p function.

Specific code from SAS to R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I am trying to write this (SAS) comand in R. x is a variable with this specific format: j61915035t
x1 = trim(upcase(substr(x,1,1)));
I really appreciate what you are doing in this site!
You want to remove leading/trailing blanks from a character string that is the uppercase first letter of the string x. So this should do it.
library(stringr)
x1 = str_trim(str_to_upper(str_sub(x,1,1)))

r auto arima excluding (0,0,0) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
For the auto.arima function in forecast package of R, is there a way to let the function omit a model of arima(0,0,0), as I simply assume there must be some correlation within the dataset.
You could try looking at the help for the function
auto.arima(). Check the arguments start.p, start.q,
d,max.d

Variable path in a loop [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I would like to get this loop to work. I am trying to save different dataframes with different names at once. I don't know how to get the path part of the code to vary with i:
for (i in specific) {
write.dta(get(paste0("degreeS", i)), "D:/Educacion/PeerEffects/",paste0( "degreeS", i,".dta"))
}
I needed to use the command file.path(). This solved the problem
for (i in specific) {
write.dta(get(paste0("degreeS", i)), file.path("D://Educacion//PeerEffects//", paste0("degreeS", i,".dta")))
}

R : Do not understanding the objective of a code [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Given the following setup:
area.factor <- cut(state.x77[,"Area"],
breaks=quantile(state.x77[,"Area"],c(0,.25,.75,1)),
labels=c("small","medium","large"),
include.lowest=TRUE)
state <- data.frame(pop=state.x77[,"Population"],
inc=state.x77[,"Income"],
area=area.factor,
region=state.region)
pop.area.region <- with(state,ftable(pop,area,region))
The following two lines of code are show the same result:
head(ftable(prop.table(pop.area.region,margin=2)))
head(prop.table(pop.area.region,margin=2))
I don't understand what effect adding ftable has, if any, in:
head(ftable(prop.table(pop.area.region,margin=2)))
Adding ftable witll try to coerce the pop.area.region to a ftable class. Here
No need to add ftable since pop.area.region is already an ftable.
identical(ftable(prop.table(pop.area.region,margin=2)),
prop.table(pop.area.region,margin=2))
TRUE

Resources