Re: [R] JSON to Dataframe

2016-10-18 Thread Bob Rudis
If those are in "ndjson" files or are indeed single records, `ndjson`
functions will be a few orders of magnitude faster and will produce
perfectly "flat" data frames. It's not intended to be a replacement
for `jsonlite` (a.k.a. the quintessential JSON pkg for R) but it's
tailor made for making quick work of (potentially deeply nested)
ndjson records/files.

On Tue, Oct 18, 2016 at 7:49 AM, K. Elo  wrote:
> Hi!
>
> 18.10.2016, 14:38, Abhinaba Roy wrote:
>>
>> Hi R helpers,
>>
>> I have json inputs from an app which I want to convert to dataframes.
>> Below
>> are the two inputs. Can someone help me in converting these to dataframes
>>
> [...]
>
> IMHO, the best way is to use the package 'jsonlite', see:
>
> * https://cran.r-project.org/web/packages/jsonlite/index.html
>
> A good documentation comes with the package, but the links listed on the
> CRAN site provide useful information, too.
>
> HTH,
> Kimmo
>
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] JSON to Dataframe

2016-10-18 Thread K. Elo

Hi!

18.10.2016, 14:38, Abhinaba Roy wrote:

Hi R helpers,

I have json inputs from an app which I want to convert to dataframes. Below
are the two inputs. Can someone help me in converting these to dataframes


[...]

IMHO, the best way is to use the package 'jsonlite', see:

* https://cran.r-project.org/web/packages/jsonlite/index.html

A good documentation comes with the package, but the links listed on the 
CRAN site provide useful information, too.


HTH,
Kimmo

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Merge data by coordinates

2016-10-18 Thread Michal Kubista
Dear Milu,
If your objective is to match the places from one table to the nearest
place in the second table, you can generally use knn algorithm for 1
nearest neighbourhood.
But please, check what David suggests first.

Best regards,
Michal

2016-10-16 19:24 GMT+02:00 David Winsemius :

>
> > On Oct 16, 2016, at 6:32 AM, Miluji Sb  wrote:
> >
> > Dear all,
> >
> > I have two dataframe 1 by latitude and longitude but they always do not
> > match. Is it possible to merge them (e.g. nearest distance)?
> >
> > # Dataframe 1
> > structure(list(lat = c(54L, 55L, 51L, 54L, 53L, 50L, 47L, 51L,
> > 49L, 54L), lon = c(14L, 8L, 15L, 7L, 6L, 5L, 13L, 5L, 13L, 11L
> > ), PPP2000_40 = c(4606, 6575, 6593, 7431, 9393, 10773, 11716,
> > 12226, 13544, 14526)), .Names = c("lat", "lon", "PPP2000_40"), row.names
> =
> > c(6764L,
> > 8796L, 8901L, 9611L, 11649L, 12819L, 13763L, 14389L, 15641L,
> > 16571L), class = "data.frame")
> >
> > # Dataframe 2
> > structure(list(lat = c(47, 47, 47, 47, 47, 47, 48, 48, 48, 48
> > ), lon = c(7, 8, 9, 10, 11, 12, 7, 8, 9, 10), GDP = c(19.09982,
> > 13.31977, 14.95925, 6.8575635, 23.334565, 6.485748, 24.01197,
> > 14.30393075, 21.33759675, 9.71803675)), .Names = c("lat", "lon",
> > "GDP"), row.names = c(NA, 10L), class = "data.frame")
>
> I think you should first do this:
>
> plot(d1$lat,d1$lon)
> points(d2$lat,d2$lon, col="red")
>
> And then respond to my suggestion that this is not a well-posed computing
> problem. Explain why the red dots should have a 1-1 relationship with the
> black dots.
>
>
> --
> David.
>
> >
> > Thank you so much!
> >
> > Sincerely,
> >
> > Milu
> >
> >   [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius
> Alameda, CA, USA
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] JSON to Dataframe

2016-10-18 Thread Abhinaba Roy
Hi R helpers,

I have json inputs from an app which I want to convert to dataframes. Below
are the two inputs. Can someone help me in converting these to dataframes

*Input1*

{"booking":{"id":"54092","createdOn":"2016-10-06T06:29:00.000+","bookingDateTime":"2016-10-08T06:45:00.000+","checkInDateTime":null,"checkOutDateTime":null,"tableNumbers":null,"pax":3,"type":"calling","status":"booked","source":"concierge","specialInstruction":"test
hoppi","outlet":{"id":"46a97c2e-c921-4339-819c-50e17f25d09a","name":"Hoppipolla"},"customer":{"name":"Hoppi","email":"
ho...@xmail.com
","countryCallingCode":"91","phone":"8901234567"}},"eventType":"booked","serverDateTime":"2016-10-06T06:28:25.558+"}

{"booking":{"id":"54093","createdOn":"2016-10-06T06:30:00.000+","bookingDateTime":"2016-10-08T06:46:00.000+","checkInDateTime":null,"checkOutDateTime":null,"tableNumbers":null,"pax":3,"type":"calling","status":"booked","source":"concierge","specialInstruction":"test
hoppi","outlet":{"id":"46a97c2e-c922-4339-819c-50e17f25d09a","name":"Hoppipolla"},"customer":{"name":"Ravi","email":"
r...@xmail.com
","countryCallingCode":"91","phone":"8901234548"}},"eventType":"booked","serverDateTime":"2016-10-06T06:28:25.558+"}


*Input2*


{"feedback":{"dateTime":"2016-10-06T09:24:05.730+","customerName":"mytestdevcog","averageRating":4,"isNegativeByComments":false,"outlet":{"id":"f9e9c21f-2e52-462e-a1f2-012dab216d27","name":"cholan
's Darbar"},"customer":{"name":"mytestdevcog","email":"
mytestdevcog...@gmail.com","countryCallingCode":"91","phone":"7895478745"},"responses":[{"question":"Was
your waiting time too
long?","response":"No","questionType":"yes_no"},{"question":"Service","response":"3","questionType":"rating"},{"question":"desserts","response":"4","questionType":"rating"},{"question":"Comments","response":"good","questionType":"short_answer"},{"question":"How
likely is it that you would recommend us to a friend or
colleague?","response":"5","questionType":"nps"},{"question":"Portion
Size","response":"5","questionType":"rating"},{"question":"Indian
Food","response":"4","questionType":"rating"},{"question":"Desert
spread","response":"4","questionType":"rating"}]},"serverDateTime":"2016-10-06T09:24:27.644+"}

{"feedback":{"dateTime":"2016-10-06T09:24:05.730+","customerName":"mytestdevcog","averageRating":4,"isNegativeByComments":false,"outlet":{"id":"f9e9c21f-2e52-462e-a1f2-012dab216d27","name":"cholan
's Darbar"},"customer":{"name":"mytestdevcog","email":"
mytestdevcog...@gmail.com","countryCallingCode":"91","phone":"7895478745"},"responses":[{"question":"Was
your waiting time too
long?","response":"No","questionType":"yes_no"},{"question":"Service","response":"3","questionType":"rating"},{"question":"desserts","response":"4","questionType":"rating"},{"question":"Comments","response":"good","questionType":"short_answer"},{"question":"How
likely is it that you would recommend us to a friend or
colleague?","response":"5","questionType":"nps"},{"question":"Portion
Size","response":"5","questionType":"rating"},{"question":"Indian
Food","response":"4","questionType":"rating"},{"question":"Desert
spread","response":"4","questionType":"rating"}]},"serverDateTime":"2016-10-06T09:24:27.644+"}


Would require two seperate dataframes for two inputs. Help would be highly
appreciated


Regards,

Abhinaba

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] tar()/untar() argument symmetry

2016-10-18 Thread Roebuck,Paul L
Any reason untar() has an "exdir" argument (the equivalent of "tar -C"),
but tar() does not?

The information contained in this e-mail message may be privileged, 
confidential, and/or protected from disclosure. This e-mail message may contain 
protected health information (PHI); dissemination of PHI should comply with 
applicable federal and state laws. If you are not the intended recipient, or an 
authorized representative of the intended recipient, any further review, 
disclosure, use, dissemination, distribution, or copying of this message or any 
attachment (or the information contained therein) is strictly prohibited. If 
you think that you have received this e-mail message in error, please notify 
the sender by return e-mail and delete all references to it and its contents 
from your systems.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Difficulties with setting working directory

2016-10-18 Thread Roebuck,Paul L
On 10/14/16, 1:52 PM, "R-help on behalf of Anže Dejak" wrote:

>So, the thing with my version of R (I'm using RStudio for R x64 3.3.0 in,
>currently, Windows 7) is, that I'm able to set the working directory
>temporary (through using setwd() function), but once I try to set it
>permanently (through "Session -> Set Working Directory -> Choose
>Directory..."), this error appears: Error in setwd("~/...") : cannot
>change
>working directory.
>
>As I've seen online on certain forums, the problem, supposedly, is that R
>in Windows is unable to recognize the ~ sign. But without it, I'm unable
>to
>set the working directory for more than a session.
>
>I'd hope you have a possible answer to this error.

Two problems:

1) R won't convert "~" to its shell equivalent without using path.expand()
2) There is no "..." directory [only "." (current) or ".." (parent)]

The information contained in this e-mail message may be privileged, 
confidential, and/or protected from disclosure. This e-mail message may contain 
protected health information (PHI); dissemination of PHI should comply with 
applicable federal and state laws. If you are not the intended recipient, or an 
authorized representative of the intended recipient, any further review, 
disclosure, use, dissemination, distribution, or copying of this message or any 
attachment (or the information contained therein) is strictly prohibited. If 
you think that you have received this e-mail message in error, please notify 
the sender by return e-mail and delete all references to it and its contents 
from your systems.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] MDS, line of best fit, and id of variables

2016-10-18 Thread Kirsten Green
Hi,

I have created a dataset that includes 28 rows (burials) and 27 columns
(variables) that are coded binomially. I have gotten metaMDS to run in the
pst but now can't seem to get it run at all.
Error message:
> mortdata.mds <- metaMDS(mortdata)
Error in FUN(X[[i]], ...) :
  only defined on a data frame with all numeric variables
In addition: Warning message:
In Ops.factor(left, right) : ‘<’ not meaningful for factors

I'd like to create a 3D MDS plot and add the line of best fit for the 3
dimensions (3 variables). I am also trying to figure out, or understand,
which variables are causing the variation.

I ran PCA and it told me that with 3 variables approximately 50% of the
data variation is explained. So I assumed that meant that running MDS in 3
dimensions would show me 3 variables causing the variation but I can't get
that to work.

Here is my code so far (i've also attached it to the email):

mortdata<-read.csv("Table5.5.csv", header=TRUE)
mortdata
row.names(mortdata) <- mortdata[,1]
mortdata <- mortdata[,-1]
mortdata

mortdata.mds <- metaMDS(mortdata)
mortdata.mds.alt <- metaMDS(mortdata, distance="euclidean", k=3, trymax=50,
  autotransform=FALSE, noshare=FALSE)


*object = mortdata.mds.alt

names(mortdata.mds.alt)

mortdata.mds.alt
summary(mortdata.mds.alt)

*stress plot
stressplot(mortdata.mds.alt)

x <- mortdata.mds.alt$species
y <- mortdata.mds.alt$points
na.exclude(mortdata.mds.alt)
vScoresScale <- scale(, center = TRUE, scale = TRUE)


plot(mortdata.mds.alt)
plot(mortdata.mds.alt, type="t")

*multiple linear regression model
lm(formula = x ~ y)
abline(lm(x ~ y), col="red")


*scatterplot3D
library(scatterplot3d)
attach(mortdata.mds.alt)
scatterplot3d(mortdata.mds.alt, x="sampleScores", y="variableScores",
main="3D Scatterplot")

Any help would be greatly appreciated. I can also send the dataset if that
helps.

-- 
*Kirsten Green*
kagbo...@gmail.com
916-712-5193
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] tar()/untar() argument symmetry

2016-10-18 Thread Duncan Murdoch

On 18/10/2016 12:38 PM, Roebuck,Paul L wrote:

Any reason untar() has an "exdir" argument (the equivalent of "tar -C"),
but tar() does not?


Because you can specify the source directory in the files argument using 
list.files().  There's no need to duplicate that in tar().


Duncan Murdoch

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] tar()/untar() argument symmetry

2016-10-18 Thread Roebuck,Paul L
On 10/18/16, 12:52 PM, "Duncan Murdoch"  wrote:

>On 18/10/2016 12:38 PM, Roebuck,Paul L wrote:
>> Any reason untar() has an "exdir" argument (the equivalent of "tar -C"),
>> but tar() does not?
>
>Because you can specify the source directory in the files argument using
>list.files().  There's no need to duplicate that in tar().

But that solution introduces (undesired) intermediate directory paths
into the tar archive.


Any other thoughts outside using something like below:

stopifnot(dir.exists(local))
savedir <- ""
tryCatch({
savedir <- setwd(local)
tar(Š)
  },
  finally = setwd(savedir))

The information contained in this e-mail message may be privileged, 
confidential, and/or protected from disclosure. This e-mail message may contain 
protected health information (PHI); dissemination of PHI should comply with 
applicable federal and state laws. If you are not the intended recipient, or an 
authorized representative of the intended recipient, any further review, 
disclosure, use, dissemination, distribution, or copying of this message or any 
attachment (or the information contained therein) is strictly prohibited. If 
you think that you have received this e-mail message in error, please notify 
the sender by return e-mail and delete all references to it and its contents 
from your systems.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] MDS, line of best fit, and id of variables

2016-10-18 Thread David L Carlson
What do you get with str(mortdata)? The error message indicates that at least 
one of the variables is not numeric and the second suggests it is a factor. You 
said the values were coded binomially, but they must be numeric, e.g. 0, 1 and 
not "Present" "Absent" or something like that. If they are all factors, 
something like

mortdata1 <- sapply(mortdata, as.numeric)-1

would convert factor levels of 1 and 2 to 0 and 1.
-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kirsten Green
Sent: Tuesday, October 18, 2016 12:28 PM
To: r-help@r-project.org
Subject: [R] MDS, line of best fit, and id of variables

Hi,

I have created a dataset that includes 28 rows (burials) and 27 columns
(variables) that are coded binomially. I have gotten metaMDS to run in the
pst but now can't seem to get it run at all.
Error message:
> mortdata.mds <- metaMDS(mortdata)
Error in FUN(X[[i]], ...) :
  only defined on a data frame with all numeric variables
In addition: Warning message:
In Ops.factor(left, right) : ‘<’ not meaningful for factors

I'd like to create a 3D MDS plot and add the line of best fit for the 3
dimensions (3 variables). I am also trying to figure out, or understand,
which variables are causing the variation.

I ran PCA and it told me that with 3 variables approximately 50% of the
data variation is explained. So I assumed that meant that running MDS in 3
dimensions would show me 3 variables causing the variation but I can't get
that to work.

Here is my code so far (i've also attached it to the email):

mortdata<-read.csv("Table5.5.csv", header=TRUE)
mortdata
row.names(mortdata) <- mortdata[,1]
mortdata <- mortdata[,-1]
mortdata

mortdata.mds <- metaMDS(mortdata)
mortdata.mds.alt <- metaMDS(mortdata, distance="euclidean", k=3, trymax=50,
  autotransform=FALSE, noshare=FALSE)


*object = mortdata.mds.alt

names(mortdata.mds.alt)

mortdata.mds.alt
summary(mortdata.mds.alt)

*stress plot
stressplot(mortdata.mds.alt)

x <- mortdata.mds.alt$species
y <- mortdata.mds.alt$points
na.exclude(mortdata.mds.alt)
vScoresScale <- scale(, center = TRUE, scale = TRUE)


plot(mortdata.mds.alt)
plot(mortdata.mds.alt, type="t")

*multiple linear regression model
lm(formula = x ~ y)
abline(lm(x ~ y), col="red")


*scatterplot3D
library(scatterplot3d)
attach(mortdata.mds.alt)
scatterplot3d(mortdata.mds.alt, x="sampleScores", y="variableScores",
main="3D Scatterplot")

Any help would be greatly appreciated. I can also send the dataset if that
helps.

-- 
*Kirsten Green*
kagbo...@gmail.com
916-712-5193
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] MDS, line of best fit, and id of variables

2016-10-18 Thread David L Carlson
You do not need to change it to numeric if it is integer. But if you want to 
change it, you need to follow the example I included and use sapply(). 

Here is my effort to replicate your error. Since I'm using random data, it 
fails to converge, but I do not get the error message you are getting. This is 
the best I can do since you have not given us reproducible data. 

> set.seed(42)
> mortdata <- data.frame(matrix(sample(0:1, 28*27, replace=TRUE), 28, 27))
> dim(mortdata)
[1] 28 27
> library(vegan)
Loading required package: permute
Loading required package: lattice
This is vegan 2.4-1
> sapply(mortdata, type)
Error in match.fun(FUN) : object 'type' not found
> sapply(mortdata, class)  # Is everything numeric (which includes integer)?
   X1X2X3X4X5X6X7X8 
   X9 
"integer" "integer" "integer" "integer" "integer" "integer" "integer" "integer" 
"integer" 
  X10   X11   X12   X13   X14   X15   X16   X17 
  X18 
"integer" "integer" "integer" "integer" "integer" "integer" "integer" "integer" 
"integer" 
  X19   X20   X21   X22   X23   X24   X25   X26 
  X27 
"integer" "integer" "integer" "integer" "integer" "integer" "integer" "integer" 
"integer" 
> mortdata.mds <- metaMDS(mortdata)
. . . Many messages 
... New best solution
... Procrustes: rmse 0.07861438  max resid 0.2210256 
Run 18 stress 0.277969 
Run 19 stress 0.2633298 
Run 20 stress 0.2838487 
*** No convergence -- monoMDS stopping criteria:
20: stress ratio > sratmax

-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352




From: Kirsten Green [mailto:kagbo...@gmail.com] 
Sent: Tuesday, October 18, 2016 2:27 PM
To: David L Carlson
Cc: r-help@r-project.org
Subject: Re: [R] MDS, line of best fit, and id of variables

David,

I have run the str() function and all my data is int (integer). So I am trying 
to change it to numeric using:
str(mortdata)
class(mortdata)
is.numeric(mortdata)
mortdata.num <- as.numeric(data.frame(mortdata))

But I keep getting an error: > mortdata.num <- as.numeric(data.frame(mortdata))
Error: (list) object cannot be coerced to type 'double

On Tue, Oct 18, 2016 at 1:23 PM, David L Carlson  wrote:
What do you get with str(mortdata)? The error message indicates that at least 
one of the variables is not numeric and the second suggests it is a factor. You 
said the values were coded binomially, but they must be numeric, e.g. 0, 1 and 
not "Present" "Absent" or something like that. If they are all factors, 
something like

mortdata1 <- sapply(mortdata, as.numeric)-1

would convert factor levels of 1 and 2 to 0 and 1.
-
David L Carlson
Department of Anthropology
Texas A University
College Station, TX 77840-4352

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kirsten Green
Sent: Tuesday, October 18, 2016 12:28 PM
To: r-help@r-project.org
Subject: [R] MDS, line of best fit, and id of variables
Hi,

I have created a dataset that includes 28 rows (burials) and 27 columns
(variables) that are coded binomially. I have gotten metaMDS to run in the
pst but now can't seem to get it run at all.
Error message:
> mortdata.mds <- metaMDS(mortdata)
Error in FUN(X[[i]], ...) :
  only defined on a data frame with all numeric variables
In addition: Warning message:
In Ops.factor(left, right) : ‘<’ not meaningful for factors

I'd like to create a 3D MDS plot and add the line of best fit for the 3
dimensions (3 variables). I am also trying to figure out, or understand,
which variables are causing the variation.

I ran PCA and it told me that with 3 variables approximately 50% of the
data variation is explained. So I assumed that meant that running MDS in 3
dimensions would show me 3 variables causing the variation but I can't get
that to work.

Here is my code so far (i've also attached it to the email):

mortdata<-read.csv("Table5.5.csv", header=TRUE)
mortdata
row.names(mortdata) <- mortdata[,1]
mortdata <- mortdata[,-1]
mortdata

mortdata.mds <- metaMDS(mortdata)
mortdata.mds.alt <- metaMDS(mortdata, distance="euclidean", k=3, trymax=50,
      autotransform=FALSE, noshare=FALSE)


*object = mortdata.mds.alt

names(mortdata.mds.alt)

mortdata.mds.alt
summary(mortdata.mds.alt)

*stress plot
stressplot(mortdata.mds.alt)

x <- mortdata.mds.alt$species
y <- mortdata.mds.alt$points
na.exclude(mortdata.mds.alt)
vScoresScale <- scale(, center = TRUE, scale = TRUE)


plot(mortdata.mds.alt)
plot(mortdata.mds.alt, type="t")

*multiple linear regression model
lm(formula = x ~ y)
abline(lm(x ~ y), col="red")


*scatterplot3D
library(scatterplot3d)
attach(mortdata.mds.alt)
scatterplot3d(mortdata.mds.alt, x="sampleScores", y="variableScores",
main="3D Scatterplot")

Any help would be greatly appreciated. I can also send the dataset if that
helps.

--

Re: [R] MDS, line of best fit, and id of variables

2016-10-18 Thread Kirsten Green
David,

I have run the str() function and all my data is int (integer). So I am
trying to change it to numeric using:
str(mortdata)
class(mortdata)
is.numeric(mortdata)
mortdata.num <- as.numeric(data.frame(mortdata))

But I keep getting an error: > mortdata.num <- as.numeric(data.frame(
mortdata))
Error: (list) object cannot be coerced to type 'double

On Tue, Oct 18, 2016 at 1:23 PM, David L Carlson  wrote:

> What do you get with str(mortdata)? The error message indicates that at
> least one of the variables is not numeric and the second suggests it is a
> factor. You said the values were coded binomially, but they must be
> numeric, e.g. 0, 1 and not "Present" "Absent" or something like that. If
> they are all factors, something like
>
> mortdata1 <- sapply(mortdata, as.numeric)-1
>
> would convert factor levels of 1 and 2 to 0 and 1.
> -
> David L Carlson
> Department of Anthropology
> Texas A University
> College Station, TX 77840-4352
>
> -Original Message-
> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kirsten
> Green
> Sent: Tuesday, October 18, 2016 12:28 PM
> To: r-help@r-project.org
> Subject: [R] MDS, line of best fit, and id of variables
>
> Hi,
>
> I have created a dataset that includes 28 rows (burials) and 27 columns
> (variables) that are coded binomially. I have gotten metaMDS to run in the
> pst but now can't seem to get it run at all.
> Error message:
> > mortdata.mds <- metaMDS(mortdata)
> Error in FUN(X[[i]], ...) :
>   only defined on a data frame with all numeric variables
> In addition: Warning message:
> In Ops.factor(left, right) : ‘<’ not meaningful for factors
>
> I'd like to create a 3D MDS plot and add the line of best fit for the 3
> dimensions (3 variables). I am also trying to figure out, or understand,
> which variables are causing the variation.
>
> I ran PCA and it told me that with 3 variables approximately 50% of the
> data variation is explained. So I assumed that meant that running MDS in 3
> dimensions would show me 3 variables causing the variation but I can't get
> that to work.
>
> Here is my code so far (i've also attached it to the email):
>
> mortdata<-read.csv("Table5.5.csv", header=TRUE)
> mortdata
> row.names(mortdata) <- mortdata[,1]
> mortdata <- mortdata[,-1]
> mortdata
>
> mortdata.mds <- metaMDS(mortdata)
> mortdata.mds.alt <- metaMDS(mortdata, distance="euclidean", k=3, trymax=50,
>   autotransform=FALSE, noshare=FALSE)
>
>
> *object = mortdata.mds.alt
>
> names(mortdata.mds.alt)
>
> mortdata.mds.alt
> summary(mortdata.mds.alt)
>
> *stress plot
> stressplot(mortdata.mds.alt)
>
> x <- mortdata.mds.alt$species
> y <- mortdata.mds.alt$points
> na.exclude(mortdata.mds.alt)
> vScoresScale <- scale(, center = TRUE, scale = TRUE)
>
>
> plot(mortdata.mds.alt)
> plot(mortdata.mds.alt, type="t")
>
> *multiple linear regression model
> lm(formula = x ~ y)
> abline(lm(x ~ y), col="red")
>
>
> *scatterplot3D
> library(scatterplot3d)
> attach(mortdata.mds.alt)
> scatterplot3d(mortdata.mds.alt, x="sampleScores", y="variableScores",
> main="3D Scatterplot")
>
> Any help would be greatly appreciated. I can also send the dataset if that
> helps.
>
> --
> *Kirsten Green*
> kagbo...@gmail.com
> 916-712-5193
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
*Kirsten Green*
kagbo...@gmail.com
916-712-5193

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Re: [R] MDS, line of best fit, and id of variables

2016-10-18 Thread Bert Gunter
You need to spend time with an R tutorial or two. Your error is due to
ignorance of basic R data structures.

Bert

On Oct 18, 2016 10:48 PM, "Kirsten Green"  wrote:

> David,
>
> I have run the str() function and all my data is int (integer). So I am
> trying to change it to numeric using:
> str(mortdata)
> class(mortdata)
> is.numeric(mortdata)
> mortdata.num <- as.numeric(data.frame(mortdata))
>
> But I keep getting an error: > mortdata.num <- as.numeric(data.frame(
> mortdata))
> Error: (list) object cannot be coerced to type 'double
>
> On Tue, Oct 18, 2016 at 1:23 PM, David L Carlson 
> wrote:
>
> > What do you get with str(mortdata)? The error message indicates that at
> > least one of the variables is not numeric and the second suggests it is a
> > factor. You said the values were coded binomially, but they must be
> > numeric, e.g. 0, 1 and not "Present" "Absent" or something like that. If
> > they are all factors, something like
> >
> > mortdata1 <- sapply(mortdata, as.numeric)-1
> >
> > would convert factor levels of 1 and 2 to 0 and 1.
> > -
> > David L Carlson
> > Department of Anthropology
> > Texas A University
> > College Station, TX 77840-4352
> >
> > -Original Message-
> > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Kirsten
> > Green
> > Sent: Tuesday, October 18, 2016 12:28 PM
> > To: r-help@r-project.org
> > Subject: [R] MDS, line of best fit, and id of variables
> >
> > Hi,
> >
> > I have created a dataset that includes 28 rows (burials) and 27 columns
> > (variables) that are coded binomially. I have gotten metaMDS to run in
> the
> > pst but now can't seem to get it run at all.
> > Error message:
> > > mortdata.mds <- metaMDS(mortdata)
> > Error in FUN(X[[i]], ...) :
> >   only defined on a data frame with all numeric variables
> > In addition: Warning message:
> > In Ops.factor(left, right) : ‘<’ not meaningful for factors
> >
> > I'd like to create a 3D MDS plot and add the line of best fit for the 3
> > dimensions (3 variables). I am also trying to figure out, or understand,
> > which variables are causing the variation.
> >
> > I ran PCA and it told me that with 3 variables approximately 50% of the
> > data variation is explained. So I assumed that meant that running MDS in
> 3
> > dimensions would show me 3 variables causing the variation but I can't
> get
> > that to work.
> >
> > Here is my code so far (i've also attached it to the email):
> >
> > mortdata<-read.csv("Table5.5.csv", header=TRUE)
> > mortdata
> > row.names(mortdata) <- mortdata[,1]
> > mortdata <- mortdata[,-1]
> > mortdata
> >
> > mortdata.mds <- metaMDS(mortdata)
> > mortdata.mds.alt <- metaMDS(mortdata, distance="euclidean", k=3,
> trymax=50,
> >   autotransform=FALSE, noshare=FALSE)
> >
> >
> > *object = mortdata.mds.alt
> >
> > names(mortdata.mds.alt)
> >
> > mortdata.mds.alt
> > summary(mortdata.mds.alt)
> >
> > *stress plot
> > stressplot(mortdata.mds.alt)
> >
> > x <- mortdata.mds.alt$species
> > y <- mortdata.mds.alt$points
> > na.exclude(mortdata.mds.alt)
> > vScoresScale <- scale(, center = TRUE, scale = TRUE)
> >
> >
> > plot(mortdata.mds.alt)
> > plot(mortdata.mds.alt, type="t")
> >
> > *multiple linear regression model
> > lm(formula = x ~ y)
> > abline(lm(x ~ y), col="red")
> >
> >
> > *scatterplot3D
> > library(scatterplot3d)
> > attach(mortdata.mds.alt)
> > scatterplot3d(mortdata.mds.alt, x="sampleScores", y="variableScores",
> > main="3D Scatterplot")
> >
> > Any help would be greatly appreciated. I can also send the dataset if
> that
> > helps.
> >
> > --
> > *Kirsten Green*
> > kagbo...@gmail.com
> > 916-712-5193
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/
> > posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>
>
> --
> *Kirsten Green*
> kagbo...@gmail.com
> 916-712-5193
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/
> posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

[R] install R in relative path

2016-10-18 Thread Tom Graves via R-help
Hello everyone,
I am trying to figure out if I can install R in a relative path?  The reason I 
need to do this is to send R along to a Hadoop cluster so that I can use sparkR 
with the R version I shipped. The Hadoop cluster doesn't have R installed and 
the admin won't install it. 
I tried a few things but the things I had tried didn't work. Are there any 
options to configure or PATHs I could use to do this?
Any help is appreciated.
Thanks,Tom
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.