unexpected '}' in R Programming [closed] - r

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 trying to use following piece code in R Studio and I'm expecting a result that calculates b for 1:3 times.
for(b in 1:3){+cat(b,"+",b,"=",b+b, "\n")+}
However I keep getting an error:
Error: unexpected '}' in: "cat(b,"+",b,"=",b+b, "\n")+}"
Can anyone help please?

It expects something to add, but there is nothing to the right hand side of +.

Related

How to debug unexpected symbol in R [closed]

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 2 years ago.
Improve this question
I know that is really simple. I'm trying to calculate:
-2ˆ2 -(2.6)ˆ2 * (1/2)
Error: unexpected input in "-2�"
When I replace the ˆ with ^ it works on my system.

Error: unexpected ',' in "df = read.csv(("/home/rstudio/IMDB_data.csv" ," [closed]

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
df = read.csv(("/home/rstudio/IMDB_data.csv" ,header=T ,fileEncoding='latin1', sep=",")[-2,])
I wrote the above R code to remove the second line in a file, however it is not working.
This process was already shown in a previous example here, But it's giving me error message unexpected : ','
This should work.
df = read.csv("/home/rstudio/IMDB_data.csv" ,header=T ,fileEncoding='latin1', sep=",")[-2,]

Error: unexpected SPECIAL in "as.Date(20110505, %Y%" [closed]

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"

R programmin help, trying to create a decision tree(now fixed typo) [closed]

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 6 years ago.
Improve this question
This is the R command I used to create a decision tree,
k <- C5.0(data1[1:16000,-32],as.factor(data2{1:16000,32])
but this output I get for error:
Error: unexpected '{' in "k <- C5.0(data1[1:16000,-32],as.factor(data2{"
Did I forget a bracket? I couldn't figure out why
Try
k <- C5.0(data1[1:16000,-32],as.factor(data2[1:16000,32]))
You used { instead of [ at the end and you also forgot to include another ) to wrap up your C5.0 function.

Error: unexpected '[' in r [closed]

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 have an error
> for (i in 1:(cutoff_size-1)){work$group[i]=rep(c(0,1),c([i]-1,cutoff_size-[i]-1))}
Error: unexpected '[' in:"for (i in 1:(cutoff_size-1)){work$group[i]=rep(c(0,1),c(["
'cutoff_size' is numeric.
How can I solve this problem?
for (i in 1:(cutoff_size-1)){work$group[i]=rep(c(0,1),c(i-1,cutoff_size-i-1))}
this is probably what you're looking for.
[] are used to refer to position in array/data table/list.
If you're using it in a mathematical operation, you do not need the [] around the i.

Resources