[R] problem in R

Sarah Goslee sarah.goslee at gmail.com
Fri Feb 20 16:38:24 CET 2015


First, please reply to the list, not just me.

On Fri, Feb 20, 2015 at 10:22 AM, thanoon younis
<thanoon.younis80 at gmail.com> wrote:
> thank you very much for your help
>
> actually, my data set like this
>
> #Data Set
> testJAGSdata =  list(N1=200, N2=200, P=18,
>
>    R=structure(
>               .Data=c(8.0, 1.0,1.0, 8.0),
>               .Dim=c(2,2)),
>
> thd <- matrix(testJAGSdata$thd, ncol=6, byrow=TRUE)
>> head(thd)
>      [,1]   [,2]   [,3]   [,4]  [,5] [,6]
> [1,] -200 -2.517 -1.245 -0.444 0.848  200
> [2,] -200 -1.447 -0.420  0.119  1.245 200
> [3,] -200 -1.671 -0.869 -0.194  0.679 200
> [4,] -200 -1.642 -0.869 -0.293  0.332 200
> [5,] -200 -1.671 -0.827  0.052  0.756 200
> [6,] -200 -1.769 -1.098 -0.469  0.255 200
> [7,] -200 -1.490 -0.670 -0.082  0.880 200
> [8,] -200 -1.933 -0.880 -0.317  1.008 200
> [9,] -200  -1.587 -0.624  0.000  1.008 200
> [10,] -200 -1.983 -1.348 -0.348  1.045 200
> [11,] -200 -1.983 -1.229 -0.247  0.869 200
> [12,] -200 -2.262 -1.426  0.037  1.330 200
> [13,] -200 -2.371 -1.295 -0.224  0.651 200
> [14,] -200 -2.039 -1.112 -0.149  1.169 200
> [15,] -200 -2.262 -1.198 -0.309  1.198 200
> [16,] -200 -2.176 -1.537 -0.717  0.597 200
> [17,] -200 -1.447 -0.786  0.119  1.008 200
> [18,] -200 -2.039 -1.769 -0.661  0.642 200
>
>
>> #Data Set
>> testJAGSdata =  list(N1=200, N2=200, P=18,
> +
> +    R=structure(
> +               .Data=c(8.0, 1.0,1.0, 8.0),
> +               .Dim=c(2,2)),
> +
> + thd <- matrix(testJAGSdata$thd, ncol=6, byrow=TRUE)
> + > head(the)

Did you do what I suggested and look at your commands?

R is expecting the rest of whatever your first command is supposed to
do, and it isn't complete. That's what the + prompt is trying to tell
you.

The first command ends with a , and doesn't have enough parentheses -
something is missing there.
After that, you continue trying to paste in R output to the console.

It looks to  me like you are working by copying and pasting from notes
that you don't understand. Maybe going back and rereading an
introduction to R would help you.


> +      [,1]   [,2]   [,3]   [,4]  [,5] [,6]
> + [1,] -200 -2.517 -1.245 -0.444 0.848  200
> Error: unexpected numeric constant in:
> "     [,1]   [,2]   [,3]   [,4]  [,5] [,6]
> [1,] -200 -2.517 -1.245 -0.444 0.848"
>> [2,] -200 -1.447 -0.420  0.119  1.245 200
> Error: unexpected '[' in "["
>> [3,] -200 -1.671 -0.869 -0.194  0.679 200
> Error: unexpected '[' in "["
>> [4,] -200 -1.642 -0.869 -0.293  0.332 200
> Error: unexpected '[' in "["
>> [5,] -200 -1.671 -0.827  0.052  0.756 200
> Error: unexpected '[' in "["
>> [6,] -200 -1.769 -1.098 -0.469  0.255 200
> Error: unexpected '[' in "["
>> [7,] -200 -1.490 -0.670 -0.082  0.880 200
> Error: unexpected '[' in "["
>> [8,] -200 -1.933 -0.880 -0.317  1.008 200
> Error: unexpected '[' in "["
>> [9,] -200  -1.587 -0.624  0.000  1.008 200
> Error: unexpected '[' in "["
>> [10,] -200 -1.983 -1.348 -0.348  1.045 200
> Error: unexpected '[' in "["
>> [11,] -200 -1.983 -1.229 -0.247  0.869 200
> Error: unexpected '[' in "["
>> [12,] -200 -2.262 -1.426  0.037  1.330 200
> Error: unexpected '[' in "["
>> [13,] -200 -2.371 -1.295 -0.224  0.651 200
> Error: unexpected '[' in "["
>> [14,] -200 -2.039 -1.112 -0.149  1.169 200
> Error: unexpected '[' in "["
>> [15,] -200 -2.262 -1.198 -0.309  1.198 200
> Error: unexpected '[' in "["
>> [16,] -200 -2.176 -1.537 -0.717  0.597 200
> Error: unexpected '[' in "["
>> [17,] -200 -1.447 -0.786  0.119  1.008 200
> Error: unexpected '[' in "["
>> [18,] -200 -2.039 -1.769 -0.661  0.642 200
> Error: unexpected '[' in "["
>
>
> Many thanks in advance
>
> On 20 February 2015 at 18:04, Sarah Goslee <sarah.goslee at gmail.com> wrote:
>>
>> Hi,
>>
>> On Fri, Feb 20, 2015 at 9:48 AM, thanoon younis
>> <thanoon.younis80 at gmail.com> wrote:
>> > Dear all members
>> >
>> > I have the following matrix in R
>> >
>> >> thd <- matrix(testJAGSdata$thd, ncol=6, byrow=TRUE)
>> >> head(thd)
>> >      [,1]   [,2]   [,3]   [,4]  [,5] [,6]
>> > [1,] -200 -2.517 -1.245 -0.444 0.848  200
>> > [2,] -200 -1.447 -0.420  0.119  1.245 200
>> > [3,] -200 -1.671 -0.869 -0.194  0.679 200
>> > [4,] -200 -1.642 -0.869 -0.293  0.332 200
>> > [5,] -200 -1.671 -0.827  0.052  0.756 200
>> > [6,] -200 -1.769 -1.098 -0.469  0.255 200
>> > [7,] -200 -1.490 -0.670 -0.082  0.880 200
>> > [8,] -200 -1.933 -0.880 -0.317  1.008 200
>> > [9,] -200  -1.587 -0.624  0.000  1.008 200
>> > [10,] -200 -1.983 -1.348 -0.348  1.045 200
>> > [11,] -200 -1.983 -1.229 -0.247  0.869 200
>> > [12,] -200 -2.262 -1.426  0.037  1.330 200
>> > [13,] -200 -2.371 -1.295 -0.224  0.651 200
>> > [14,] -200 -2.039 -1.112 -0.149  1.169 200
>> > [15,] -200 -2.262 -1.198 -0.309  1.198 200
>> > [16,] -200 -2.176 -1.537 -0.717  0.597 200
>> > [17,] -200 -1.447 -0.786  0.119  1.008 200
>> > [18,] -200 -2.039 -1.769 -0.661  0.642 200
>>
>> This is not reproducible, so the below are guesses.
>>
>> > and when i implemented this matrix i found this error
>>
>> I have no idea what "implemented this matrix" might mean.
>>
>> >
>> > + > head(the)
>>
>> First problem: the + means R expects continuation of a previous line,
>> because the command is incomplete. So whatever you did BEFORE this
>> line is wrong.
>>
>> > +      [,1]   [,2]   [,3]   [,4]  [,5] [,6]
>> > + [1,] -200 -2.517 -1.245 -0.444 0.848  200
>> > Error: unexpected numeric constant in:
>> > "     [,1]   [,2]   [,3]   [,4]  [,5] [,6]
>> > [1,] -200 -2.517 -1.245 -0.444 0.848"
>>
>> These and subsequent errors are what you'd get if you pasted the above
>> R output back into the R console. Why would you do that?
>>
>> So: check your previous commands.
>> If you can't find your mistake, respond to the list with a clear
>> reproducible example.
>>
>> >> [2,] -200 -1.447 -0.420  0.119  1.245 200
>> > Error: unexpected '[' in "["
>> >> [3,] -200 -1.671 -0.869 -0.194  0.679 200
>> > Error: unexpected '[' in "["
>> >> [4,] -200 -1.642 -0.869 -0.293  0.332 200
>> > Error: unexpected '[' in "["
>> >> [5,] -200 -1.671 -0.827  0.052  0.756 200
>> > Error: unexpected '[' in "["
>> >> [6,] -200 -1.769 -1.098 -0.469  0.255 200
>> > Error: unexpected '[' in "["
>> >> [7,] -200 -1.490 -0.670 -0.082  0.880 200
>> > Error: unexpected '[' in "["
>> >> [8,] -200 -1.933 -0.880 -0.317  1.008 200
>> > Error: unexpected '[' in "["
>> >> [9,] -200  -1.587 -0.624  0.000  1.008 200
>> > Error: unexpected '[' in "["
>> >> [10,] -200 -1.983 -1.348 -0.348  1.045 200
>> > Error: unexpected '[' in "["
>> >> [11,] -200 -1.983 -1.229 -0.247  0.869 200
>> > Error: unexpected '[' in "["
>> >> [12,] -200 -2.262 -1.426  0.037  1.330 200
>> > Error: unexpected '[' in "["
>> >> [13,] -200 -2.371 -1.295 -0.224  0.651 200
>> > Error: unexpected '[' in "["
>> >> [14,] -200 -2.039 -1.112 -0.149  1.169 200
>> > Error: unexpected '[' in "["
>> >> [15,] -200 -2.262 -1.198 -0.309  1.198 200
>> > Error: unexpected '[' in "["
>> >> [16,] -200 -2.176 -1.537 -0.717  0.597 200
>> > Error: unexpected '[' in "["
>> >> [17,] -200 -1.447 -0.786  0.119  1.008 200
>> > Error: unexpected '[' in "["
>> >> [18,] -200 -2.039 -1.769 -0.661  0.642 200
>> > Error: unexpected '[' in "["
>> >
>> >
>> > Any help would be very appreciated
>> >
-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list