Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8125965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:59:36+00:00 2026-06-06T06:59:36+00:00

this is the sas code which i want to replicate in R, proc fastclus

  • 0

this is the sas code which i want to replicate in R,

proc fastclus data = in.stores_standard
maxclusters = 20
outseed= in.out_seed
maxiter = 1000
converge = 0 
strict=5.0; 
var storesize sales_per_sqft sales_per_visits tothhsinta;
id store_nbr;
run;

my attempt:

library(amap)
set.seed(1)
kmeans_object=Kmeans(stores_standard, 20, iter.max = 1000, nstart = 1, method = c("euclidean"))
p=do.call(rbind, kmeans_object)

What am unable to achieve:
1) run kmeans on these parameters only: storesize,sales_per_sqft,sales_per_visits, tothhsinta

2) id on store_nbr

3) outseed function in R

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:59:38+00:00Added an answer on June 6, 2026 at 6:59 am

    1) is quite easy:

    want <- c("storesize", "sales_per_sqft", "sales_per_visits", "tothhsinta")
    Kmeans(stores_standard[, want], 20, iter.max = 1000, nstart = 1,
           method = c("euclidean"))
    

    For 2)

     ## a 2-dimensional example from ?Kmeans
     x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
                matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
     colnames(x) <- c("x", "y")
     cl <- Kmeans(x, 2)
    

    Now look at cl:

    R> str(cl)
    List of 4
     $ cluster : int [1:100] 2 2 2 2 2 2 2 2 2 2 ...
     $ centers : num [1:2, 1:2] 1.0245 -0.017 1.0346 0.0375
      ..- attr(*, "dimnames")=List of 2
      .. ..$ : chr [1:2] "1" "2"
      .. ..$ : chr [1:2] "x" "y"
     $ withinss: num [1:2] 0.00847 0.22549
     $ size    : int [1:2] 50 50
     - attr(*, "class")= chr "kmeans"
    

    The cluster component of the list contains the assigned cluster ID. These are in the same order as the samples in the input data. If you want to assign the cluster component as a column in the input data we’d then do:

    R> x <- cbind(x, Cluster = cl$cluster)
    R> head(x)
                   x            y Cluster
    [1,] -0.24251497  0.532012889       2
    [2,]  0.10957740  0.225168920       2
    [3,] -0.35563544 -0.428798979       2
    [4,] -0.41251306  0.529953489       2
    [5,] -0.61212001 -0.003443993       2
    [6,]  0.04435213  0.086595025       2
    

    For your data do:

    stores_standard <- cbind(stores_standard, Cluster = kmeans_object$cluster)
    

    As for 3, that doesn’t appear possible with kmeans() in standard R nor Kmeans() in package amap.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my code that I write it but I want to use LINQ
I'm learning SAS and write this macro: %macro firstMacro(mvLO, OLO); %local Count; %local Wordy;
I am beginner to java and was trying out this code puzzle from the
I have two SAS data tables. The first has many millions of records, and
I have a data.frame in R which has been constructed off the Example 1-3
I'm using SAS 9.2 on OpenVMS to connect to an external data source over
We have some code that must access low level windows XP os calls which
This is my jQuery script: $(input[type=radio]:checked).live(click, function() { $(this).attr(checked,false); }); I want to make
i want to write NSString into NSMutableArray.Please look at the following code: NSData *returnData
I have C# .NET code with a DataSet (System.Data.DataSet) containing one table of data,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.