Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I'm trying to do a simple calculation with my mean function. When I input mean(1, 10, 100), R returns 1, which is obviously not the correct average. It always returns the first entry of my vector. What went wrong?
You should use mean(c(1,10,100))
See http://www.rdocumentation.org/packages/base/functions/c
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 months ago.
Improve this question
I working with a csv that has 234 rows. I thought the length() function was supposed to return the number of rows in my csv, but it returns a much larger number. It gives me 1046860. Does the length function not do what I think it does? What is going on?
I just wanted to double check the length and haven't run any other code yet other than setting up my working directory and attaching a file (Cat6 <- read.csv("Category6.csv")).
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am doing an exercise to create a function. One of the questions is:
"We can estimate the cumulative risk of an certain event using the
exponential formula
1-exp(-1/10000*t) where t is the time to the event. Create a function ans(t), which returns the risk at time t.
and I am using this command:
function(t){ans(t)<-1-exp(-1/10000*t)return(ans(t))}
but it is giving wrong answer. Can someone help me to understand this please?
The proper format to define a function is this:
ans<-function(t){
answer<-1-exp(-1/10000*t)
return(answer)
}
ans(1)
#[1] 9.9995e-05
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am not sure why I cannot do write the following code.
as.Date(20110505, %Y%m%d)
I receive the error given in the title. Can anyone help me out?
It should be string with the format also in quotes
as.Date(as.character(20110505), "%Y%m%d")
#[1] "2011-05-05"
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am returning to some old code where I had used the following syntax:
y[df$myvar %between% c(1,100)]
but get the error
could not find function "%between%"
This code used to work, and I have updated R in the mean time. any thoughts?
As Pascal pointed out, you should load the package data.table first:
library(data.table)
Then you'll be able to use it.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am getting error on following lines of code...plz help.
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
string order1= string.Format ("exec a_add_user '{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}'",TextBox_first_name.Text ,TextBox_last_name.Text ,TextBox_user_name.Text ,TextBox_password.Text ,DropDownList_telephone_code.SelectedValue +TextBox_telephone_no.Text ,DropDownList_mobile_code.SelectedValue +TextBox_mobile_no.Text ,RadioButtonList_gender.SelectedValue ,DropDownList_country.SelectedValue ,DropDownList_city.SelectedValue ,TextBox_address.Text);
You're specifying 11 format items but have 10 strings you're trying to append.