• Register
0 votes
1.4k views

Problem :

I am looking for the function with the parameters such as data name as (mydata), factor as (myfactor) and variable names such as (myvar) to dynamically generate the histograms as I have to use them in lattice.

I tried to do as mentioned above but error appears as follows : invalid 'envir' argument of type 'character'. I think the program doesn't know where to look for this myf` string. How should I fix this issue?

6 5 3
7,540 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

I guess there is no object called Sepal.Length. That’s why R is creating the error even before your my_function is getting called. There should be only one column name and it must be quoted to pass it to your function. Here the data object can not be created as your URL might fail to deliver the required data. So you should be using the built-in copy of your iris data object.

You must build the formula from the myvar and myfactor. The formulas are the expressions and so must get parsed without the evaluation of their tokens. So you need to build the formula inside the function that must look like: ~Sepal.Length|Species and after that pass it to your histogram call. Consult ?as.formula.

9 7 4
38,600 points
0 votes

Solution:

Employ load directly

load("C:\\pathToRDA\\swiss.RDA")
#Assuming the dataset inside swiss.RDA is called swiss
simple.fit = lm(formula = VoteYes ~ age, data=swiss) 

dataset = load("C:\\pathToRDA\\swiss.RDA") will make a varible in the Values section named dataset in your Global env with a string vlaue "swiss".

 Example Given:

mtest = mtcats
save(mtest, file = "mt.rda")
mtc = load("~/mt.RDA") #Will create variable called mtc = "mtest" in Values in Global env.  
load("~/mt.RDA") #loads the mtest dataset

 

10 6 4
31,120 points

Related questions

0 votes
1 answer 16 views
16 views
Problem: How should I fix this issue: Error in eval(predvars, data, env) : invalid 'envir' argument of type 'character'.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
0 answers 7 views
7 views
Problem: How should I fix this issue: Error in eval(predvars, data, env) : invalid 'envir' argument of type 'character'.
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 690 views
1 vote
1 answer 6 views
6 views
Problem: Why this invalid character value for cost specification error occuring? Invalid character value for cast specification ssis.
asked Mar 25 PkGuy 13.1k points
0 votes
1 answer 2 views
2 views
Problem: Can someone help me with the error message i am getting invalid subscript type closure?
asked Apr 4 Sana8989 8.5k points
1 vote
1 answer 312 views
312 views
Problem: I have very fundamental knowledge of logistic regression. I am trying to write code on logistic regression. I have done a lot of research on this issue but because of my limited knowledge I am still unable to fix the below error. Error ... (data) stock.direction <- data$Direction training_model=glm(stock.direction~data$lag2,data=data,family=binomial) Please help me in fixing above error.
asked May 26, 2020 Martin K 6.6k points
0 votes
1 answer 2 views
2 views
Problem: I am trying to access items in an array of structs and print the structs fields But I get loads of errors as suchinvalid type argument of '->' What am I doing wrong with this pointer?
asked Apr 4 Sana8989 8.5k points
1 vote
1 answer 1.7K views
1.7K views
Problem : I am beginner to Scatter Plot. I have recently joined new project and they gave task to plot the simple best fit line to a scatterplot. If I try to execute my below code with my data I always face the following error message: plot(log(datatest$MEAN_intact_for),log( ... plot my graph it works as expected but the problem comes up if I try to add a abline command to have a best fit line.
asked Apr 14, 2020 morrisBson 3.2k points
0 votes
1 answer 5 views
5 views
Problem: I'm trying to run the following code in R, but I'm getting an error: R attempt to apply non-function I'm not sure what part of the formula is incorrect. Any help would be greatly appreciated.
asked Mar 30 ummesalma 22.9k points
0 votes
1 answer 4 views
4 views
Problem: Please can somebody help me with the error I am getting return type specification for invalid?
asked Mar 25 Sana8989 8.5k points