• Register
0 votes
1.1k 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 270 views
1 vote
1 answer 156 views
156 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
1 vote
1 answer 1K views
1K 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 700 views
700 views
Problem : I want to use the neural net for predictions. I am trying to create some X as follows : x <- cbind(seq(1, 50, 1), seq(51, 100, 1)) I am trying to create some Y as follows : y <- x[,1]*x[,2] Give them the names as follows colnames(x) ... =0.01) error in terms.formula(formula) : '.' in formula and no 'data' argument Does anybody have any idea regarding the error I am facing? Any solution?
asked Dec 11, 2019 alecxe 7.5k points
1 vote
1 answer 1.7K views
1.7K views
Problem : I am facing following error : formula(formula, data = data) : invalid model formula in ExtractVars I am using the below code: install.packages("rpart") library("rpart") # you must change the below from windows to work on your linux box: mydata <- read.csv(file="c ... file to commas. I guess it is unable to read the data correctly. I am very new to the R and also a very new programmer.
asked Dec 14, 2019 alecxe 7.5k points
0 votes
1 answer 211 views
211 views
Problem : I want to use the TraMineR's (version 1.8.4) seqdef-funciton to define the sequence object, however I always face the following error message which is completely senseless to me: Error in row.names<-.data.frame(*tmp*, value = value) : invalid 'row. ... tried running it after re-labeling the states without "-", but it does not affect the error. Does someone knows what causes this error?
asked Dec 6, 2019 alecxe 7.5k points
0 votes
1 answer 1.3K views
1.3K views
Problem : I think my dataframe is correct and my code is also okay. But I am facing following error: Error in .Call.graphics(C_palette2, .Call(C_palette2, NULL)) : invalid graphics state What is wrong with my below data? date trt var val 1/12/2019 cc sw5 0.2684138 1/12/2019 ... ] Also I want to make the scatterplot as follows: ggplot(data = df,aes(x = date,y = val)) + geom_point(aes(group = trt))
asked Dec 6, 2019 alecxe 7.5k points
0 votes
2 answers 837 views
837 views
Problem : I am trying to do some practice on the broom package in R. I ran the below code : kclusts <- data.frame(k=1:9) %>% group_by(k) %>% do(fit=kmeans(data.frame, .$k)) But I have received the below error: Error in as.vector(x, mode) : ... type 'any' I wanted to know whether I am missing something in my above string. Does anyone have the solution on this issue which I am facing currently?
asked Dec 21, 2019 alecxe 7.5k points
0 votes
1 answer 44 views
0 votes
1 answer 639 views