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 4 years ago.
Improve this question
I am using R Studio and creating some vectors and doing some calculations with them. However, when I execute the code, I get the unused argument error. How can I solve this issue?
f <- c(2,4,6)
v <- c(1,2,3,4,5)
cos(c(0, pi/4, pi/2, pi))
The variable might exist in your R workspace. What you could do is to start from a clean session or try typing rm("c") in your console and this will solve your problem. It cleans c from the workspace.
Related
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 2 years ago.
Improve this question
Is it possible to pass an entire (square) matrix as the argument of a function in R ?
I mean, what I want is that while running the programme, an user will create his / her desired matrix (Say A) in the R console, and if the name of the function is cdecom (Created by me) , the user will write cdecom(A) to get the required output. A possible demonstration of the input by an user is as follows :
A <- matrix( 1:25 , nrow=5 , byrow=TRUE)
cdecom(A)
Is this somehow possible ? Thanks in advance. (If my question is unclear, please see the 3rd comment)
Maybe you can use class(A)=="matrix" and stopifnot within your function cdecom like below
cdecom <- function(A) {
stopifnot(class(A)=="matrix")
...
}
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 2 years ago.
Improve this question
I am not able to integrate this function.
I am getting an error: argument "y" is missing, with no default. The answer to this problem is 1.
First of all, your expression is actually a function of y.
If you want to write the double integral, you can make it with integrate (but you need to simplify the integral a bit in advance)
f <- function(y) 6*integrate(function(x) x,0,1)$value*integrate(function(z) z**2,0,y)$value/y**2
Mathematically, you can derive that, the function f can be further simplified to
f <- function(y) y
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
I am having trouble operating Matrixs.
First, I want to make factor data to integer so i can operate.
Second, The First col, which shows date, should be factor. How can i change?
Try this:
d <- data.frame(1:10, letters[1:10])
data.matrix(d)
Also you can try this too :
m = matrix(scan("file.csv", what=numeric(), skip=1))
skip=1 to skip a header line.
Hope this will help you
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
I inherited legacy code from 2009 that includes the many of the following types of expressions -
variable %in% cs(do, ph, t, secchi)
I get the following error - Error: could not find function "cs" when I try to run anything like this, have not seen 'cs' before, and can't locate any info in help files, google, or on this site so far. I'm guessing it is a deprecated way of concatenating strings but would like to confirm before I update the legacy code.
There is a Cs function in Hmisc package. I think it is that.
See this
library(Hmisc)
Cs(a,cat,dog)
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